Skip to content

Instantly share code, notes, and snippets.

View icco's full-sized avatar
🏠
Working from home

Nat Welch icco

🏠
Working from home
View GitHub Profile
#!/bin/bash
echo min_power > /sys/class/scsi_host/host0/link_power_management_policy
echo 5 > /proc/sys/vm/laptop_mode
echo 1500 > /proc/sys/vm/dirty_writeback_centisecs
@icco
icco / gist:115279
Created May 21, 2009 04:41
Word count a web page with python
#!/usr/bin/python
import httplib
import httplibfrom operator import itemgetter
import re
def get_webpage(site,page):
conn = httplib.HTTPConnection(site)
conn.request("GET", page)
rd = conn.getresponse()
print rd.status, rd.reason
@icco
icco / countlocsvn.sh
Created June 1, 2009 06:11
LOC Counter by Hyperlisk
#!/bin/bash
START=`pwd`;
script=$START"/hyperliskLOC.php";
cd /tmp/;
svn co http://wiki.csc.calpoly.edu/blugoo/svn/trunk/
cd trunk;
for i in $(seq 820 972);
do
svn up -r $i > /dev/null;
@icco
icco / gist:193865
Created September 25, 2009 21:36 — forked from dominiek/gist:193517
One line bash twitter bot
curl -d 'track=one line' http://stream.twitter.com/track.json -uonelinebot:one.onelinebot > tweets.json 2> /dev/null & tail -f tweets.json | \
while read tweet; do echo $tweet | \
grep -E -o '"screen_name":"[[:alnum:]]+"' | cut -d '"' -f 4 | while read screen_name; do \
echo "following: $screen_name"; curl -d '' http://twitter.com/friendships/create/$screen_name.json?follow=true -uonelinebot:one.onelinebot; \
done ; \
done
@icco
icco / user_history.sql
Created November 17, 2009 08:03
Some sql examples for peter
DROP TABLE IF EXISTS `user_history`;
CREATE TABLE `user_history` (
`historyid` int(10) unsigned NOT NULL auto_increment,
`userid` int(10) unsigned NOT NULL,
`delta` int(11) NOT NULL,
`rewarded` int(11) NOT NULL,
`date` int(11) NOT NULL,
`doctype` enum('wiki_revisions','guide_translation_revisions','guide_step_revisions','user_success','comments','posts','user_badges','user_votes','users') default NULL,
`docid` int(10) unsigned default NULL,
`event` varchar(255) default 'default',
@icco
icco / .htaccess
Created December 21, 2009 08:04 — forked from henrik/.htaccess
pseudoweb.net .htaccess
RewriteEngine On
# Map / to /_site.
RewriteRule ^$ /_site/ [L]
# Map /x to /_site/x
RewriteCond %{REQUEST_URI} !^/_site/
RewriteRule ^(.*)$ /_site/$1
# Add trailing slash to directories without them so DirectoryIndex works.
@icco
icco / gist:261504
Created December 22, 2009 04:49
twitter regex parsing
<?php
/**
* Regex's a twitter message to make it have links like all the cool kids.
*
* ex.
* @username = http://twitter.com/username
* #hashtag = http://twitter.com/search?q=%23hashtag
* http://something = <a href....
*
* @author Nat Welch
@icco
icco / mountiso.sh
Created December 23, 2009 04:22
used to mount isos
# Mounts an iso to a folder
# usage ./mountiso.sh temp.iso mountpoint/
if [ $# -ne 2 ]; then
echo "Mounts an iso to a folder";
echo "Usage: $0 <iso> <mountpoint>";
else
echo "running mount -o loop -t iso9660 $1 $2";
mount -o loop -t iso9660 $1 $2;
fi
[Thu Dec 24 03:24 PM]
[nat@arclight ~/Projects/erasmus]$ rake --trace
(in /home/nat/Projects/erasmus)
** Invoke default (first_time)
** Invoke test (first_time)
** Invoke check_dependencies (first_time)
** Execute check_dependencies
All dependencies seem to be installed.
** Execute test
/usr/bin/ruby -Ilib:lib:test "/usr/lib/ruby/1.9.1/rake/rake_test_loader.rb" "test/erasmus_test.rb"
-------------------------------------------------------------------------
USEFUL ONE-LINE SCRIPTS FOR SED (Unix stream editor) Dec. 29, 2005
Compiled by Eric Pement - pemente[at]northpark[dot]edu version 5.5
Latest version of this file (in English) is usually at:
http://sed.sourceforge.net/sed1line.txt
http://www.pement.org/sed/sed1line.txt
This file will also available in other languages:
Chinese - http://sed.sourceforge.net/sed1line_zh-CN.html