Skip to content

Instantly share code, notes, and snippets.

View hoffrocket's full-sized avatar
👋

Jon Hoffman hoffrocket

👋
  • Anomaly
  • New York, NY
View GitHub Profile
import commands
import pymongo
import time
from pymongo import Connection
from boto.ec2.connection import EC2Connection
host = '127.0.0.1'
timestamp = time.strftime("%Y-%m-%d-%H-%M")
#! /usr/bin/python
from subprocess import Popen
import sys, os, urllib2
try:
import json
except ImportError:
import simplejson as json
Dear  Hoffman,
I am Barr. Chris Jacobs, an Attorney at law, and the personal lawyer/friend to late Engineer M.A. Hoffman, a foreigner who used to work with Shell International, Lome, Republic of Togo, herein, after shall be referred to as my late client/friend. I have contacted the white and yellow pages in search of his relatives but unfortunately did not succeed. As it may interest you to know, I got your contact through the internet professional Data Base by divine inspiration as I was going through some directories. I decided to contact you in order to champion a business of this magnitude without any problem.
On the 21st of April 2005, my client, his wife and their two children were involved in a car accident along Kara-Sokode Expressway while arriving from a holiday to Lome. All occupants of the vehicle unfortunately lost their lives. Since then, I have made several inquiries to their embassy to locate any of their extended relatives and this has also proved unsuccessful. I am contacting you to assist
// Copyright 2011 Foursquare Labs Inc. All Rights Reserved.
package com.foursquare.snippet
import com.foursquare.lib._
import net.liftweb.common._
import net.liftweb.http._
import net.liftweb.util._
import net.liftweb.util.Helpers._
import scala.xml._
@hoffrocket
hoffrocket / jquery-emoji.js
Created January 29, 2011 04:12
query plugin to replace emoji utf-8 characters with the iPhone glyphs.
/**
* jquery plugin to replace emoji utf-8 characters with the iPhone glyphs.
* code adapted from here: https://github.com/konstantinov/jQuery.emoji
*
* Get your glyphs here:
* wget http://pukupi.com/post/1964/ -O - | perl -ne '/(e\d{3}.png)/ && print "http://pukupi.com/media/emoji/$1\n"' | xargs wget
*
* someone (Apple?) probably has copyright on the glyphs, not sure about reuse rules.
*/
$.fn.emoji = function() {
@hoffrocket
hoffrocket / Flickr.scala
Created January 4, 2011 05:57
flickr api utility
import _root_.net.liftweb.util._
import _root_.net.liftweb.json._
import _root_.net.liftweb.common._
import _root_.java.net.{HttpURLConnection, URL, URLEncoder}
import JsonAST._
import JsonDSL._
import JsonParser._
import Helpers._
//flickr uses some proprietary authentication mechanism instead of oauth
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;
import java.io.UnsupportedEncodingException;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLEncoder;
public class FS {
import _root_.net.liftweb.mapper._
trait HasCreatedMetaMapper[T <: HasCreated[T]] {
self: T with LongKeyedMetaMapper[T] =>
import java.util.Date
def findByCreated(startDate:Date, endDate:Date) = findAll(By_>(created_at, startDate), By_<(created_at, endDate))
def findByCreatedSince(startDate: Date) = findAll(By_>(created_at, startDate))
}
trait HasCreated [T <: HasCreated[T]] extends KeyedMapper[Long, T] {
trait ScriptFilter extends JsCmd {
def content:NodeSeq
override def fixHtml(uid: String, content: NodeSeq): String = {
def xform(in: NodeSeq): NodeSeq = in flatMap {
case e: Elem if e.label == "script" => NodeSeq.Empty
case e: Elem => Elem(e.prefix, e.label, e.attributes, e.scope, xform(e.child) :_*)
case g: Group => xform(g.child)
case x => x
case class MySetHtml(uid:String, xhtml:NodeSeq) extends JsCmd {
def filterScripts(xhtml:NodeSeq):(String, NodeSeq) = {
def xform(in: NodeSeq): NodeSeq = in flatMap {
case e: Elem if e.label == "script" => NodeSeq.Empty
case e: Elem => Elem(e.prefix, e.label, e.attributes, e.scope, xform(e.child) :_*)
case g: Group => xform(g.child)
case x => x
}