tips-computer-incantations

Difference between revision 26 and current revision

No diff available.

:w !sudo tee % Save a file you edited in vim without the needed permissions

--- cat ~/.ssh/id_rsa.pub

---
ssh user@server "cat >> .ssh/authorized_keys"

in 'screen', to save a copy of the scrollback buffer:

ctrl-a ctrl-+ to get to command mode, then

hardcopy -h <filename>

btw why do i use screen rather than tmux? tmux had problems with using the middle button to paste, over ssh


screen -X -S [session # you want to kill] kill


sudo ln -s /etc/resolvconf/run/resolv.conf


make any website editable

javascript:document.body.contentEditable='true'; document.designMode='on'; void 0


rotate and play a video:

mplayer -vf rotate=2 /tmp/p8253012.avi -vo x11 -ao none -framedrop -nobps -ni -forceidx -mc 0 -vfm ffmpeg -lavdopts fast:skiploopfilter=all

--- strip audio from a video:

ffmpeg -i -an -vcodec copy /tmp/MVI_0047.AVI avconv -i MVI_0047.AVI -an -c:v copy /tmp/MVI_0047.AVI


how to increase brightness, hue on videos? the following works but is too big and can't be played on xine

mencoder -o /tmp/test.avi -oac copy -ovc raw -vf eq2=1:1:-0.06:1.20 clouds/090802/p8021536.avi


to test and then deploy djangoappengine projects:

./manage.py runserver ./manage.py deploy


GET http://google.com


When changing email addresses, use mairix, mutt, and a standing emacs session to quickly, semiautomatedly send email to some people who have emailed my old address in the last six months:

put in .mairixrc:


  base=~/Mail
  maildir=...
  mfolder=~/mairixResults
  database=~/Mail/mairix_database

initialize mairix database:

  mairix

create a search folder containing every message sent to my old email address by someone other than myself in the last six months:

  mairix d:6m- t:old_email@inet.org f:~my_own_email@inet.org

(replace old_email@inet.org and my_own_email@inet.org with real addresses)

put in .muttrc:

  macro index <F12> "<reply>^M^Unew email: new_email@inet.org^Mny"

(replace new_email@inet.org with the real address)

also, make sure that your sent mail is being saved in .muttrc, with something like:

  set record= =sent-mail

in emacs, type something like this into any buffer, then kill it (and yank it, if you want):


Hi,

My current email address is now

  new_email@inet.org

You are receiving this automated email because you have recently sent an email to my old email address, old_email@inet.org, which will stop working soon -- please update your address book. Thanks, bayle


restart mutt. change to folder ~/Mail/mairixResults. go down the list until you find someone to whom you'd like to send an update, making sure their message is highlighted. hit F12. this starts a reply to the highlighted message with the subject heading as in the F12 macro definition above. now you land in emacs to type the body of the message. press F3 (begin macro definition). Yank the text of the message. Kill the buffer. You return to mutt, and the mutt macro completes execution by automatically sending the message.

Go down the list until you find someone else you wish to notify. This time, in emacs, just press F4 twice. The first press ends the macro defn, the second press executes the macro (which now includes yanking the text and closing the buffer).

For subsequent notifications, just press F4 (sometimes that didn't work for me and i had to press it twice for some reason).

Be careful not to highlight or copy or kill any text while you're doing this, or emacs might start yanking that into your outgoing message body rather than the text that you want. i'd check your sent-mail after sending the first message to make sure it went out OK (or even send the first one to yourself by sending yourself a test message, highlighting it in Mutt when your receive it, and pressing F12). I'd check sent-mail again when you are done to make sure the rest went out ok.


  1. cp -ax / /l/backup/sda/date sudo rsync -ax / /l/backup/sda/date

--- sudo rsync -ax --exclude=/l2/backup /media/l2 /media/l3/backup/l2/date sudo rsync -ax --exclude=/l/backup --exclude=/l/autobackup /media/l /media/l3/backup/l/date

---

http://www.google.com/trends/viz?q=mercurial,+git&date=all&geo=all&graph=weekly_img&sort=0&sa=N

links:

http://www.commandlinefu.com/commands/browse/sort-by-votes


ruby debugging

require 'ruby-debug'

debugger

SOME_VARIABLE.public_methods - Object.public_methods


screen -X hardcopy -h /tmp/t

---

to kill an unresponsive ssh session:

enter, ~, .

---

if you accidentally hit ctrl-S, things might freeze, use ctrl-Q to unfreeze

-- nearlyfreespeech commandline incremental awstats

wc /home/logs/access_log ulimit -t 300 maxlines=10000 startline=0 n=$startline; while true; do echo starting at $n; tail -n +$n /home/logs/access_log

head -n $maxlines perl /usr/local/www/awstats/cgi-bin/awstats.pl -config=nfsn -update -LogFile?=-; n=$(($n + $maxlines)); done
  1. todo break when no more records perl /usr/local/www/awstats/cgi-bin/awstats.pl -config=nfsn -update

if it doesn't say anything for more than five minutes, kill it and reduce maxlines. Supposedly awstats is already already flushing every 20000 lines but i don't see that happening.

--

sync heroku and github: http://stackoverflow.com/a/3373611/171761

multiple accounts on heroku: http://stackoverflow.com/a/13518904/171761

--

to get a later version of nodejs on ubuntu:

https://github.com/mishoo/UglifyJS/issues/479

sudo add-apt-repository ppa:chris-lea/node.js sudo apt-get update sudo apt-get install nodejs

---

to quickly view an HTML file from github: use rawgithub.com: just click 'raw' in github, then edit the URL to remove the first dot in raw.github.com

--

https://raw.github.com/rakudo/rakudo/nom/docs/architecture.html

---

first, use firefox to go to http://www.pinterest.com/bayleshanks/pins/ . Hold down Page Down to scroll all the way to the bottom to get everything to load. File->Save Page As.

cat 'Bayle Shanks on Pinterest.html'

perl -lane 'if (/"(http:\/\/www.pinterest.com\/pin\/[\d]+\/)"/) {print $1;}' > pin_urls.txt

wget -p -i pin_urls.txt -H -D pinimg.com

or, for secret boards, go to each board in Firefox and save it as above, then filter the file to create a list of URLs as above, install the Export Cookies extension in Firefox, then restart Firefox and Tools->Export Cookies, then do:

wget --load-cookies /tmp/cookies.txt -p -i pin_urls.txt -H -D pinimg.com

---

to sum a column of numbers (thanks http://stackoverflow.com/questions/450799/shell-command-to-sum-integers-one-per-line ):

awk '{s+=$1} END {print s}' mydatafile

--

to use xz to compress things which aren't already .xz compressed:

  1. find /l3/bshanks-salk-cp -not -name \*.xz
find /l3/bshanks-salk-cp -not -name \*.xz -print0
xargs -n1 xz
xargs -0 xz
  1. find /l3/bshanks-salk-cp -not -name \*.xz -exec xz \{\} \;

--

when an ssh connection freezes, here's how to kill it: type enter, then ~, then .

for a listing of other ssh escape commands, type enter, then ~, then ?

--