4
"model": "main.oneliner",
7
"explanation": "When you watch a flash video like youtube in a browser, the video file is saved on your harddisk at a temporary location. And, if you watch a video and then another video in the same window, the first one will be deleted.",
8
"summary": "Find Flash videos stored by browsers on a Mac",
9
"created_dt": "2011-08-05 18:57:10",
11
"line": "find /private/ 2>/dev/null | grep /Flash",
17
"model": "main.oneliner",
19
"limitations": "- Won't work if there are spaces in a filename.",
20
"explanation": "- {{<(cmd)}} is the filename of a named pipe (FIFO), where the named pipe is filled by the output of {{cmd}}\r\n- {{paste}} puts together the named pipes to form two columns: first column with the original filenames, second column with the lowercased filenames\r\n- {{... | tr abc ABC}} transforms stdin by replacing any characters that appear in the first set of letters to the second set of letters\r\n- {{while read old new; do ...; done}} for each line it reads the first column into {{$old}} and the second column into {{$new}}",
21
"summary": "An elegant way to rename all files in a directory to lowercase names",
22
"created_dt": "2011-08-05 18:57:10",
24
"line": "paste <(ls) <(ls | tr A-Z a-z) | while read old new; do echo mv -v $old $new; done\r\n",
30
"model": "main.oneliner",
32
"limitations": "- The author information will get lost in the process.\r\n",
33
"explanation": "- The commit history in repo1 will be copied to repo2.\r\n- The temporary Bazaar repository (proj1) will have the full history of changes.",
34
"summary": "Mirror a Subversion repository from one Subversion repository to another Subversion repository",
35
"created_dt": "2011-08-05 18:57:10",
37
"line": "bzr co https://repo1/proj1/trunk proj1 && cd proj1 && bzr push https://repo2/vendor/proj1/trunk\r\ncd proj1 && bzr up && bzr push",
43
"model": "main.oneliner",
46
"explanation": "Replace {{/dev/sdd1}} with whatever your USB stick is mounted on.",
47
"summary": "Change the label of a USB drive in Linux without a gui",
48
"created_dt": "2011-08-05 18:57:10",
50
"line": "sudo mlabel -i /dev/sdd1 ::NewLabel",
56
"model": "main.oneliner",
59
"explanation": "In Ubuntu the first user (created during installation) has special privileges. The privileges come from the fact that the user was automatically added to various system groups. To make another user have the same privileges, all you need to do is add the user to the same groups.\r\n\r\n- {{grep :boss /etc/group}} gets the group records where the user {{boss}} is the first member. \r\n- {{cut -f1 -d:}} gets the first column, where \":\" is the column separator.\r\n- {{for i in ...; do ... ; done}} for each group it adds the user to the group.",
60
"summary": "Make another user superuser in Ubuntu",
61
"created_dt": "2011-08-05 18:57:10",
63
"line": "for i in $(grep :boss /etc/group | cut -f1 -d:); do adduser wife $i; done",
69
"model": "main.oneliner",
72
"explanation": "todo",
73
"summary": "todo - smartctl",
74
"created_dt": "2011-08-05 18:57:10",
76
"line": "smartctl -t long /dev/sda\r\nsmartctl -a /dev/sda",
82
"model": "main.oneliner",
85
"explanation": "todo",
86
"summary": "todo - cpio",
87
"created_dt": "2011-08-05 18:57:10",
89
"line": "find . -xdev -print0 | cpio -oa0V | gzip > path_to_save.cpio.gz\r\ngzip -cd path_to_save.cpio.gz | cpio -imV",
95
"model": "main.oneliner",
99
"summary": "Create an encrypted tar file with openssl",
100
"created_dt": "2011-08-08 23:30:33",
102
"line": "tar c paths_to_files_and_dirs | gzip -c | openssl des3 > encrypted.tar.gz\r\nopenssl des3 -d < encrypted.tar.gz | tar zx",
108
"model": "main.oneliner",
112
"summary": "Change to the previous directory, a shortcut for \"cd $OLDPWD\"",
113
"created_dt": "2011-08-08 23:31:34",
121
"model": "main.oneliner",
124
"explanation": "- {{echo 1 > /proc/sys/kernel/sysrq}} enable the sysrq interface\r\n- {{echo o > /proc/sysrq-trigger}} halts\r\n- {{echo b > /proc/sysrq-trigger}} reboots",
125
"summary": "Halt the system in Linux without the halt command or gui",
126
"created_dt": "2011-08-09 19:55:50",
128
"line": "echo 1 > /proc/sys/kernel/sysrq\r\necho o > /proc/sysrq-trigger",
134
"model": "main.oneliner",
138
"summary": "Convert all flac files in the current directory to mp3 format using \"lame\"",
139
"created_dt": "2011-08-09 19:57:06",
141
"line": "for i in *.flac; do flac -c -d \"$i\" | lame -m j -b 192 -s 44.1 - \"${i%.flac}.mp3\"; done",
147
"model": "main.oneliner",
150
"explanation": "Useful if you have a directory full of data to burn to DVD without using a GUI. ",
151
"summary": "Burn the contents of a directory to dvd without a gui",
152
"created_dt": "2011-08-14 19:35:52",
154
"line": "sudo apt-get install dvd+rw-tools\r\ngrowisofs -dvd-compat -Z /dev/scd0 -R -J -pad path_to_dir",
160
"model": "main.oneliner",
163
"explanation": "When downloading web pages with wget, some websites try to be smart and detect your preferred language based on geographical location of your IP address. This can be a problem if for example you are in Japan but you want to download a page in English.",
164
"summary": "Force the preferred language when downloading a web page with wget",
165
"created_dt": "2011-08-21 11:40:12",
167
"line": "wget -\u2013header=\u2019Accept-Language: en-us\u2019 http://www.timeanddate.com/calendar/index.html?year=2008&country=26 -O calendar.html",
173
"model": "main.oneliner",
176
"explanation": "Recent versions of the flash plugin hide the temporary file by marking it deleted. Practically the video stream is downloaded to a \"deleted file\". However, even when a file is deleted, if the file is opened by a process then you can find its file descriptor and consequently the file contents. \r\n\r\nThis simple script prints out the file descriptors of opened Flash videos:\r\n\r\n {{file /proc/*/fd/* 2>/dev/null | grep Flash | cut -f1 -d:}}\r\n\r\nAnd, you probably want to create a regular file from the file descriptor, for example:\r\n\r\n {{cp $(file /proc/*/fd/* 2>/dev/null | grep Flash | cut -f1 -d: | head -n 1) video.avi}}\r\n\r\nOtherwise the file descriptor is not very convenient (remember, it's a deleted file!)\r\n\r\nThe method should work regardless of your browser.\r\n",
177
"summary": "Find video files cached by the flash plugin in browsers",
178
"created_dt": "2011-08-27 11:46:46",
180
"line": "file /proc/*/fd/* 2>/dev/null | grep Flash | cut -f1 -d:",
186
"model": "main.oneliner",
189
"explanation": "With screen you can have multiple shells in the same window. You don't need to open new windows for a second connection to the same remote server, you can simply press {{C-a c}} inside the screen session. And if your computer crashes, you screen session on the remote server survives, you can re-attach to a previous screen session with {{screen -R}}. ",
190
"summary": "The first command you should run after you login to a remote server",
191
"created_dt": "2011-09-15 20:24:43",
199
"model": "main.oneliner",
201
"limitations": "The :bufdo command might not be there in old versions of vim.",
202
"explanation": "- The inner grep will search recursively in specified directory and print the filenames that contain the pattern.\r\n- All files will be opened in vim, one buffer per file.\r\n- The :bufdo command in vim will perform the replacement in all buffers, and save all buffers.",
203
"summary": "Replace a regexp pattern in many files at once easily",
204
"created_dt": "2011-09-15 21:50:50",
206
"line": "vim $(grep -rl pattern dirpath)\r\n:bufdo %s/pattern/replacement/g | update",
212
"model": "main.oneliner",
215
"explanation": "- {{find path_to_dir -type d}} finds all the subdirectories\r\n- {{tail -r}} reverses the order. This is important to make \"leaf\" directories come first! \r\n- {{target=...}} stuff constructs the new name, removing spaces from the leaf component and keeping everything before that the same\r\n- {{echo mv ...}} for safety you should run with \"echo\" first, if the output looks good then remove the \"echo\" to really perform the rename",
216
"summary": "Remove spaces recursively from all subdirectories of a directory",
217
"created_dt": "2011-09-20 14:52:07",
219
"line": "find path_to_dir -type d | tail -r | while read line; do target=$(dirname \"$line\")/$(basename \"$line\" | tr -d ' '); echo mv \"$line\" \"$target\"; done\r\n",
225
"model": "main.oneliner",
228
"explanation": "alias: allows you to define a shortcut to a longer command. In this case 'ls' with the flags set for long listing, human readable no group and in color, not displaying the group, appending a slash to directories and color coding the output.",
229
"summary": "aliases the ls command to display the way I like it",
230
"created_dt": "2011-09-21 22:25:03",
232
"line": "alias ls='ls -lhGpt --color=always'",