Skip to content

Instantly share code, notes, and snippets.

#! /usr/bin/env python
import sys, os
import httplib # JSON Retrieval
import simplejson # JSON Parsing
class Story(object):
"""
Class to represent a single Reddit story.
#!/usr/bin/env bash
cd GGR && git pull && cd ..
cd GGRServices && git pull && cd ..
cd KVHx && git pull && cd ..
cd KVHxServices && git pull && cd ..
[alias]
up = !sh -c 'git checkout master && git pull && git merge $0 && git push && git checkout $0'
down = !sh -c 'git checkout master && git pull && git checkout $0 && git merge master'
// ==UserScript==
// @name replace star by profile icon
// @namespace http://ss-o.net/
// @description replace star by profile icon (for Firefox3)
// @include http://*.hatena.ne.jp/*
// @version 1.3
// ==/UserScript==
location.href = 'javascript:(' + function(){
var COLOR = true;
@jmesnil
jmesnil / ScriptTest.java
Created July 25, 2008 12:07
How to execute JavaScript code from a Java class
public class JavaScriptTest {
public static void main(String[] args) throws Exception {
ScriptEngineManager factory = new ScriptEngineManager();
ScriptEngine engine = factory.getEngineByName("JavaScript");
engine.eval("print('hello, world!')");
}
}
public class AppleScriptTest {
public static void main(String[] args) throws Exception {
ScriptEngineManager factory = new ScriptEngineManager();
ScriptEngine engine = factory.getEngineByName("AppleScript");
engine.eval("tell application \"Finder\"\n display dialog \"Who cares?\"\n end tell");
}
}
@brainopia
brainopia / gist:2431
Created July 25, 2008 12:32
unexpected behavior of background method (_why fixed this already)
Shoes.app :width => 600, :height => 400 do
flow :width => 400, :height => 400, :margin => 20 do
fill '#dfd'
stroke '#ddd'
rect 0, 0, 200, 200
background white
end
background black
class Person
def greet
"how are you?"
end
end
en = Person.new
it = Person.new # but we wish an italian greeting
fr = Person.new # french
ar = Person.new # argentinian
Object.class_eval do
def deep_clone
Marshal::load(Marshal.dump(self))
end
end
Array.class_eval do
def sum
self.inject(0) { |sum, element| sum += element }
end
namespace :mod_rails do
desc <<-DESC
Restart the application altering tmp/restart.txt for mod_rails.
DESC
task :restart, :roles => :app do
run "touch #{release_path}/tmp/restart.txt"
end
end
namespace :deploy do