terminal

Pipe to my program as a log rotator

依然范特西╮ 提交于 2019-12-13 01:18:35
问题 I'm trying to implement my own log rotator (create new log file whenever filesize reaches 10 MB). The part that reads the standard input and writes it to the file is this: fstream file("log.txt", ios::out | ios::app); while (std::cin >> lineInput) { file << lineInput; } But the problem is that piped data gets ruined. Tabs and new lines are always lost. So for example if my program's name is LogRotator , then the command: ls | ./LogRotator Just concatenates all the file names together, like

RVM default is 2.1.1 but 2.1.2 is loaded initially

喜夏-厌秋 提交于 2019-12-13 00:16:32
问题 When I run rvm list I get the following: rvm rubies ruby-1.9.2-p318 [ x86_64 ] ruby-1.9.3-head [ x86_64 ] ruby-1.9.3-p125 [ x86_64 ] ruby-1.9.3-p484 [ x86_64 ] ruby-2.0.0-p353 [ x86_64 ] =* ruby-2.1.1 [ x86_64 ] Which would make me think that 2.1.1 is my default ruby version. However, when I open a new terminal window and run ruby -v I get ruby 2.1.2p95 (2014-05-08 revision 45877) [x86_64-darwin13.0] My .bash_profile doesn't do anything besides setting $PATH and a few other variables so I

Hadoop preinstalled example Jars

陌路散爱 提交于 2019-12-13 00:14:48
问题 I just successfully set up Hadoop on my local machines. I am following one of the examples in a popular book I just bought. I am trying to get a list of all hadoop examples that comes with installation. I type the following command to do so: bin/hadoop jar hadoop-*-examples.jar Once I enter this I am supposed to get a list of Hadoop examples right? However all I see is this error message: Not a valid JAR: /home/user/hadoop/hadoop-*-examples.jar How do I solve this problem? Is it just a simple

Changing Python path under Mac OS for applications other than the terminal

笑着哭i 提交于 2019-12-13 00:07:53
问题 I have a Python script that I'd like to be able to run with a minimum of fuss from the Finder or Quicksilver. Unfortunately, any way of running the script that doesn't use the terminal can't find my libraries. For example, running do shell script "~/anaconda/bin/python -c 'import sys; print len(sys.path)'" from Applescript gives a value of 13, but running ~/anaconda/bin/python -c 'import sys; print len(sys.path)' from the terminal gives 15. This makes me think that .bash_profile may not be

montage does not label images with list of strings represented in text file

给你一囗甜甜゛ 提交于 2019-12-12 23:04:40
问题 I have a directory ( ./img/ ) with a large number of images in it. I want to montage them with specific label for each file. I have a text file ( label.txt ) which has list of labels: label1 label2 label3 label4 ... I use this command: montage -label @label.txt -size 512x512 "./img/*.*[120x90]" -geometry +5+5 photo.png But in result, all images are labeled by all lines of label.txt ! How I can separate them, so each image will be labeled by relevant line of label.txt ? 回答1: ImageMagick works

pip command issue - Command “python setup.py egg_info” failed with error code 1 in /private/tmp/pip-build-7n_jim1n/mysql-python/

只谈情不闲聊 提交于 2019-12-12 19:36:27
问题 I am using MACos Terminal, and unable to install mysql on python. pip3 install mysql-python The directory '/Users/aligrdas/Library/Caches/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag. The directory '/Users/aligrdas/Library/Caches/pip' or its parent directory is not owned by the current user and caching wheels has been disabled

Unable to run rails server: `require': cannot load such file — net/ssh (LoadError)

谁说胖子不能爱 提交于 2019-12-12 18:53:33
问题 I am trying to learn ruby on rails using the michael hartl guide. In the past, I was able to get through the setup of a new rails webapp. Now, when I try to run the server, I am getting this error: /home/ss/.rvm/gems/ruby-2.2.2/gems/fog-1.26.0/lib/fog/joyent/compute.rb:3:in `require': cannot load such file -- net/ssh (LoadError) from /home/ss/.rvm/gems/ruby-2.2.2/gems/fog-1.26.0/lib/fog/joyent/compute.rb:3:in `<top (required)>' from /home/ss/.rvm/gems/ruby-2.2.2/gems/fog-1.26.0/lib/fog/joyent

Remove all lines from file with duplicate value in field, including the first occurrence

痴心易碎 提交于 2019-12-12 18:33:36
问题 I would like to remove all the lines in my data file that contain a value in column 2 that is repeated in column 2 in other lines. I've sorted by the value in column 2, but can't figure out how to use uniq for just the values in one field as the values are not necessarily of the same length. Alternately, I can remove lines with the duplicate using an awk one-liner like awk -F"[,]" '!_[$2]++' but this retains the line with the first incidence of the repeated value in col 2. As an example, if

ws_xpixel and ws_ypixel

半世苍凉 提交于 2019-12-12 18:17:22
问题 Here is the code I am using to print the resolution in pixels of the current terminal. #include <sys/ioctl.h> #include <stdio.h> #include <unistd.h> int main (int argc, char *argv[]) { struct winsize ww; ioctl(STDOUT_FILENO, TIOCGWINSZ, &ww); printf ("x-pixels %d\n", ww.ws_xpixel); printf ("y-pixels %d\n", ww.ws_ypixel); return 0; } I used this as winsize reference. But the code prints only zeros. If I use ws_col or ws_row it works fine. Please help, thanks ! 回答1: If you look at the source

Fastlane “nokogiri requires Ruby version >= 2.3.0.” Error

試著忘記壹切 提交于 2019-12-12 18:13:32
问题 I finished this tutorial on medium in order to integrate my Xcode project with sonarQube to have some metrics. Setup SonarQube - Swift. I was able to make it through the last step that is: running "fastlane metrics" on the terminal while being in the root of the project directory. But i get this error on step "slather" nokogiri requires Ruby version >= 2.3.0., fastlane finished with errors: I have also found that someone had a similar question here, but no answers: Similar Question If i run: