This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'java' | |
require File.dirname(__FILE__) + '/commons-codec-1.3.jar' | |
require File.dirname(__FILE__) + '/commons-httpclient-3.1.jar' | |
require 'cgi' | |
module JRestClient | |
include_package 'org.apache.commons.httpclient' | |
include_package 'org.apache.commons.httpclient.methods' | |
include_package 'org.apache.commons.httpclient.params' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Corresponding table: | |
CREATE TABLE `users` ( | |
`id` int(11) NOT NULL auto_increment, | |
`name` varchar(255) default NULL, | |
`admin` tinyint(1) default '0', | |
PRIMARY KEY (`id`) | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
JDO Persistence Manager in Scala using blocks | |
Sample below works with Google App Engine | |
Sample usage: | |
Persistence.manage { (pm) => | |
val message = new Message("message body here") | |
pm.makePersistent(message) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var anchors = document.getElementsByTagName("a"); | |
for(var i = 0; i < anchors.length; i++) { | |
var a = anchors[i]; | |
var href = a.getAttribute("href"); | |
// for some reason the HREF in this onClick is always bound to the last element in anchors[]. WHY?! | |
a.onclick = function(el) { | |
//console.log(href); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.mortbay.jetty.Server | |
import org.mortbay.jetty.servlet.Context | |
import org.mortbay.jetty.servlet.ServletHolder; | |
object Main { | |
def main(args: Array[String]) { | |
var server = new Server(8080) | |
println("Starting world server") | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private byte[] getByteArrayFromInputStream(InputStream stream) throws IOException { | |
byte[] bytes; | |
int len; | |
byte[] buffer = new byte[8192]; | |
ByteArrayOutputStream output = new ByteArrayOutputStream(); | |
try { | |
while ((len = stream.read(buffer, 0, buffer.length)) != -1) output.write(buffer, 0, len); | |
bytes = output.toByteArray(); | |
} finally { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function longFunction() { | |
var x = 1; | |
x = 0; | |
x = 1; | |
x = 2; | |
x = 3; | |
x = 4; | |
x = 5; | |
x = 6; | |
x = 7; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.ByteArrayOutputStream; | |
import java.io.File; | |
import java.io.FileNotFoundException; | |
import java.io.FileOutputStream; | |
import java.io.IOException; | |
import java.io.InputStream; | |
import java.net.MalformedURLException; | |
import java.net.URL; | |
import java.net.URLConnection; | |
import java.security.MessageDigest; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
buildscript { | |
repositories { | |
maven { | |
url 'http://repo1.maven.org/maven2' | |
} | |
} | |
dependencies { | |
classpath 'com.android.tools.build:gradle:0.4' | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
import httplib2 | |
import os | |
import sys | |
from apiclient.discovery import build | |
from oauth2client.file import Storage | |
from oauth2client.client import flow_from_clientsecrets | |
from oauth2client.tools import run |
OlderNewer