This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
num=$(grep -n \# $1 | awk -F: '{print $1}') | |
file=$(grep -n \# $1 | awk -F: '{print $2}' | awk '{print $2}') | |
if [ -n "$num" ] ; then | |
sed "${num}d" $1 > $2 | |
sed -i "${num} a | |
" $2 | |
sed -i "${num}r $file" $2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
echo "<html><head>" > page.html | |
echo "<script type=\"text/javascript\" src=\"https://apis.google.com/js/plusone.js\"></script>" >> page.html | |
echo "</head><body>" >> page.html | |
grep -o http[^\"\)\']* $1 | xargs -I{} echo "<g:plusone href=\"{}\"></g:plusone>" >> page.html | |
echo "</body></html>" >> page.html |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
symbols | |
surface downsect | |
message activated | |
thing ghosttel1 | |
thing ghosttel2 | |
thing player local | |
surface upsuf1 | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Problem 1 | |
fact = lambda n: reduce(lambda x,y: x*y, range(1, n+1), 1) | |
convert = lambda n: sum(map(int,str(n))) | |
def p1gen(): | |
i = 0 | |
while True: | |
yield (i,convert(fact(i))) | |
i+=1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# requires git alias | |
# s = status -s -uno | |
for i in `find ~/ -type d -name .git` ; do echo $i ; builtin cd $i/../ ; git s ; builtin cd ~/ ; done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# remove a file or directory | |
set -e | |
EXPECTED_ARGS=1 | |
E_BADARGS=65 | |
if [ $# -lt $EXPECTED_ARGS ] | |
then | |
echo "Usage: `basename $0` [directory]" | |
exit $E_BADARGS | |
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Lists directories in the given path | |
list_t ls_d(string path) { | |
list_t output; | |
DIR* dirp = opendir(path.c_str()); | |
struct dirent *file; | |
if(dirp==NULL) | |
return list_t(); | |
while ((file = readdir(dirp)) != NULL) { | |
string name(file->d_name); | |
if(!name.compare(".") || !name.compare("..")) continue; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# prepossess: remove newlines, add newlines after end of sentences, trim whitespace, and remove short lines | |
man /usr/share/man/man1/git.1.gz | tr '\n' ' ' | sed 's/\./\.\n/g' | sed -e 's/^[ \t]*//' | sed '/.\{3\}/!d' |
NewerOlder