Skip to content

Instantly share code, notes, and snippets.

@toctan
toctan / youtube-dl.sh
Last active December 17, 2015 11:39
Download 3 videos concurrently using youtube-dl.
#!/bin/bash
i=0
while read LINE
do
(youtube-dl $LINE -o "%(title)s.%(ext)s") &
let i++
if (( $i % 3 == 0 )); then
wait # Limit to 3 concurrent subshells
@toctan
toctan / yasnippet_cleanup.sh
Created May 29, 2013 01:57
A shell script to clean up textmate imported yasnippets.
UNIMPLEMENTED=$(grep -nr 'yas-unimplemented' $1 | cut -d: -f 1 | uniq)
while read -r LINE; do
if [[ "$LINE" != *yas-setup.el* ]]; then
rm "$LINE"
fi
done <<< "$UNIMPLEMENTED"
@toctan
toctan / backup.sh
Created May 31, 2013 05:39
Full system backup with rsync.
#!/bin/sh
if [ $# -lt 1 ]; then
echo "No destination defined. Usage: $0 destination" >&2
exit 1
elif [ $# -gt 1 ]; then
echo "Too many arguments. Usage: $0 destination" >&2
exit 1
fi
casper = require('casper').create()
casper.start 'http://v2ex.com/signin'
casper.then ->
@fill 'form[action=\"/signin\"]',
'u': 'username'
'p': 'password'
, true
@toctan
toctan / js2coffee.sh
Last active December 20, 2015 22:59
Convert existing js project to CoffeeScript.
find . -name '*.js' -not -path './node_modules/*' -exec sh -c 'js2coffee {} > {}.coffee && rm {}' \;
var list = document.getElementById("list");
for (var i = 1; i <= 5; i++) {
var item = document.createElement("LI");
item.appendChild(document.createTextNode("Item " + i));
item.onclick = function (ev) {
alert("Item " + i + " is clicked.");
};
list.appendChild(item);
require 'delegate'
class Bar < SimpleDelegator
def initialize(obj)
super(obj)
end
end
class Foo
end
@toctan
toctan / emacsclient.desktop
Last active December 23, 2015 02:49
Use emacsclient to open TextMate URL On Linux
[Desktop Entry]
Name=Emacs Client
GenericName=Text Editor
Comment=Edit text
MimeType=x-scheme-handler/txmt;x-scheme-handler/emacs
Exec=/bin/emacsclient.rb %u
Icon=emacs
Type=Application
Terminal=false
Categories=Development;TextEditor;
@toctan
toctan / rgl.sh
Created September 17, 2013 11:39
#!/bin/bash
# Remove Gnome launcher from Applications view
# ./rgl.sh qt4 avahi jdk
while read -r LINE; do
echo "NoDisplay=true" >> $LINE
done < <(pacman -Ql $@ | grep \.desktop$ | cut -d' ' -f2)
var jq = document.createElement('script');
jq.src = "//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js";
document.getElementsByTagName('head')[0].appendChild(jq);
jQuery.noConflict();
$('.WB_feed_type.SW_fun.type_intimate.S_line2').each(function(){
$.post("https://api.weibo.com/2/statuses/destroy.json",
{ id: $(this).attr('mid'),
access_token: 'access_token' });
});