Skip to content

Instantly share code, notes, and snippets.

@lrvick
lrvick / jQuery.EmbedPicasaGallery.js
Created January 3, 2012 05:51 — forked from mwolfetech/jQuery.EmbedPicasaGallery.js
Adjustment to EmbedPicasaGallery to pass album description, photo count, and title back to user provided callback functions.
/**************************************************************************
* Name: EmbedPicasaGallery
* Author: Tobias Oetiker <[email protected]>
* Demo: http://tobi.oetiker.ch/photo/
* $Id: jquery.EmbedPicasaGallery.js 474 2011-06-16 09:02:45Z oetiker $
**************************************************************************
Description:
[elided]
@lrvick
lrvick / craigmailer.php
Created January 7, 2012 09:15
Script to email all Craigslist posts from given categories to you from the authors emails, so you can simply reply to the ones that interest you.
<?php // CraigMailer
$to_email = '[email protected]'; // the email all postings should be sent to
$sqlite_file = 'craigmailer.sqlite'; // sqlite file location
$city = 'orlando'; // city to watch (as per cl subdomain)
$topics = array('cpg','sad','web','sof','eng'); // topics (three char topics as used in cl urls)
$handle = sqlite_open($sqlite_file, 0666, $sqlite_error) or die("Could not open database");
$query = sqlite_query($handle,"SELECT name FROM sqlite_master WHERE type='table'");
if (!sqlite_fetch_array($query)){
sqlite_query($handle,"CREATE TABLE posts (id INTEGER(15) PRIMARY KEY NOT NULL,timestamp DATETIME NOT NULL,topic CHAR(4) NOT NULL, subject CHAR(255) NOT NULL, email CHAR(255) NOT NULL, body TEXT, mail_sent INTEGER(1) DEFAULT 0 NOT NULL);")
@lrvick
lrvick / whitepagecarriers.sh
Created January 7, 2012 09:19
Bash script to harvest all public cell-phone number -> carrier mappings from whitepages.com
#!/bin/bash
for NPA in {201..989}; do
NXXX=2000
while [ ${NXXX} -lt 9999 ]; do
NXXX1=$[$NXXX+1]
NXXX2=$[$NXXX+2]
NXXX3=$[$NXXX+3]
echo "Checking ${NPA}${NXXX}XXX, ${NPA}${NXXX1}XXX,
${NPA}${NXXX2}XXX, ${NPA}${NXXX3}XXX..."
URL="http://www.whitepages.com/carrier_lookup?carrier=alltel&name;_0=&number;_0=${NPA}${NXXX}000&name;_1=&number;_1=${NPA}${NXXX1}000&name;_2=&number;_2=${NPA}${NXXX2}000&name;_3=&number;_3=${NPA}${NXXX3}000&localtime;=survey"
@lrvick
lrvick / hnscrape.py
Created March 1, 2012 03:54
Scrapy spider to output hackernews titles
from scrapy.http import Request
from scrapy.spider import BaseSpider
from scrapy.selector import HtmlXPathSelector
class HackernewsSpider(BaseSpider):
name = 'hackernews'
allowed_domains = []
start_urls = ['http://news.ycombinator.com']
def parse(self, response):
if 'news.ycombinator.com' in response.url:
@lrvick
lrvick / bitcolor.js
Created March 18, 2012 20:02
Javascript functions for doing fast binary/hex/RGB color conversions using bitwise operations.
// convert 0..255 R,G,B values to binary string
RGBToBin = function(r,g,b){
var bin = r << 16 | g << 8 | b;
return (function(h){
return new Array(25-h.length).join("0")+h
})(bin.toString(2))
}
// convert 0..255 R,G,B values to a hexidecimal color string
RGBToHex = function(r,g,b){
@lrvick
lrvick / loadtest.py
Created March 27, 2012 07:31
Simple 1000 thread web server load test using eventlet
import eventlet
from eventlet.green import urllib2
def request():
urllib2.urlopen("http://yourtarget.com").read()
print "%s request sent"
pool = eventlet.GreenPool(size=1000)
while True:
@lrvick
lrvick / baez.js
Created March 29, 2012 11:16
Naive Bayes sentiment classifer attempt in javascript
var baez = (function(){
var stopwords = ['i','in','and','to','are','the','but','my','they','those','them','you','a']
function tokenize(sample){
var tokens = []
sample.split(' ').forEach(function(token){
if (baez.stopwords.indexOf(token) & /^[a-zA-Z0-9]+$/.test(token)){
@lrvick
lrvick / github_flask.py
Created April 26, 2012 06:47
Github API access with Flask and rauth
from flask import Flask, request, redirect, url_for
from rauth.service import OAuth1Service, OAuth2Service
github = OAuth2Service(
name='github',
consumer_key='GITHUB_CONSUMER_KEY',
consumer_secret='GITHUB_CONSUMER_SECRET',
access_token_url='https://github.com/login/oauth/access_token',
authorize_url='https://github.com/login/oauth/authorize',
)
@lrvick
lrvick / init.sh
Created May 8, 2012 03:00
Chrooted Arch Linux environment setup script for Android
USER='lrvick'
cd /data/local/arch
if ! mountpoint -q dev; then
mount -t proc /proc proc
mount -o bind /dev dev
mount -o bind /dev/pts dev/pts
fi
@lrvick
lrvick / q3lcd.py
Created July 7, 2012 11:35
Quake3 logger for the raspberry pi that outputs to an attached HD44780 LCD using my library for it
from hd44780 import HD44780
from os import stat
from time import sleep
lcd = HD44780()
lcd.message(" Quake3 Logger\nCommence killing...")
logfile_name = 'game.log'