Skip to content

Instantly share code, notes, and snippets.

def reportToInstanceService(arg)
instance_service_url = JSON.parse(arg)['atmosphere']['instance_service_url'] token = JSON.parse(arg)['atmosphere']['token']
userid = JSON.parse(arg)['atmosphere']['userid']
uri = URI.parse(instance_service_url)
data = {'token'=> token, 'userid'=>userid,'vminfo'=>$instance_info_json}
if uri.scheme == "https"
http = Net::HTTP.new(uri.host,uri.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
path = uri.path
@seungjin
seungjin / hash2param.rb
Created January 8, 2011 17:09
ruby hash to url param
def do_it(params)
params.collect do |key,val|
"#{CGI.escape(key.to_s)}=#{CGI.escape(val)}"
end.join('&')
end
"./lib/"+(a = Dir.entries('./lib')).each_index{ |i| if a[i].split(".").last != "jar" then a.delete_at(i) end}.join(";./lib/")
"./lib/"+(a = Dir.entries('./lib')).find_all{|item| item =~ /[(.jar)]$/}.join(";./lib/")
#!/usr/bin/env python
import urllib2, re
processed_list = []
cond = [('w','m'),('u','n'),('p','d'),('g','b'),('b','q')]
for word in filter(lambda x: x != None, map(lambda x: len(x.rstrip().lstrip().lower()) > 0 and x.rstrip().lstrip().lower() or None , urllib2.urlopen('http://www.u.arizona.edu:80/~echan3/539/english-vocab.txt').read().split('\r\n'))):
if re.match('^[xolswmunpdbgqz]*$',word) :
w = list(word)
for i in range(0,len(w)):
for j in cond:
import java.net.*;
import java.io.*;
import java.io.File;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
@seungjin
seungjin / webserver.py
Created March 2, 2011 03:53
post debugger
import string,cgi,time
from os import curdir, sep
from BaseHTTPServer import BaseHTTPRequestHandler, HTTPServer
#import pri
class MyHandler(BaseHTTPRequestHandler):
def do_GET(self):
print "do_GET"
self.send_response(200)
self.send_header('Content-type', 'text/html')
@seungjin
seungjin / PostMethodExample.java
Created March 2, 2011 03:54
Post Method Example
import java.net.*;
import java.io.*;
public class PostMethodExample {
public static void main(String args[]) {
try {
// Construct data
#!/usr/bin/python
import httplib
import urllib
from urlparse import urlparse
import string
import datetime
import getpass
import json
import sys
import os
import asyncore
import pyinotify
class EventHandler(pyinotify.ProcessEvent):
def process_IN_CREATE(self, event):
#print "Creating:", event.pathname
#I will use boto to connect amazon / euca2ool or irod??
os.system('scp "%s" "%s:%s"' % (event.pathname, 'seungjin@localhost', '/home/seungjin/mydropbox') )