Skip to content

Instantly share code, notes, and snippets.

View charroch's full-sized avatar
🏠
Working from home

Carl-Gustaf Harroch charroch

🏠
Working from home
View GitHub Profile
@charroch
charroch / Main.java
Created July 15, 2009 08:07
OAuth access to jaiku
import net.oauth.OAuthAccessor;
import net.oauth.OAuthConsumer;
import net.oauth.OAuthServiceProvider;
import net.oauth.client.OAuthClient;
import net.oauth.client.httpclient4.HttpClient4;
public class Main {
public static void main(String[] args) throws Exception {
String consumerKey = "<KEY>";
/*
* Copyright 2010, Novoda ltd
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@charroch
charroch / gist:781300
Created January 15, 2011 21:50
Mixin solutions...
package novoda.mixin;
public class TestMixin extends Mixable implements WithTest {
/**
* @param args
*/
public static void main(String[] args) {
TestMixin mixin = new TestMixin();
mixin.sayHello("test");
}
sequential ^
"""Given the following json {"test": "value"}""" ! c1.getJson^
"""When applying jsonpath test"""! c1.getQuery^
"""Then I should get value"""! c1.checkResutl^
end
...
"""Given the following json {"test": [2]}"""
"""When applying jsonpath test"""
"""And applying jsonpath [#]"""
import java.text.SimpleDateFormat
import java.util.Date
class RichHumanDate(d:Long) {
def toHumanString() = {
val sdf = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss.SSS");
val dt = new Date(d);
sdf.format(dt);
}
}
import java.text.SimpleDateFormat
import java.util.Date
class RichHumanDate(d:Long) {
def toHumanString() = {
val sdf = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss.SSS");
val dt = new Date(d);
sdf.format(dt);
}
}
trait AndroidDeviceAction
case class Install extends AndroidDeviceAction
case class Instrument(options:InstrumentOptions) extends AndroidDeviceAction
case class Monkey extends AndroidDeviceAction
case class MoneyScript(script:Script) extends AndroidDeviceAction
class AndroidDevice extends Actor with IDevice {
def receive = {
case Install => // install app
case Instrument =>
#!/usr/bin/ruby
require 'rubygems'
require 'git'
g = Git.open(".")
log = g.log(10000)
c = log.collect {|l| l.date.yday}
(commit_count = {}).default = 0
c.each {|e| commit_count[e] += 1}
@charroch
charroch / gist:1988640
Created March 6, 2012 19:56
HelloWorld on dalvik
package com.hello
import java.lang.String
import android.net.Uri
import com.android.dx.dex.DexOptions
import com.android.dx.dex.file.DexFile
import dalvik.system.DexClassLoader
import java.io.{PrintWriter, FileInputStream, FileOutputStream, File}
import com.android.dx.dex.cf.{CfOptions, CfTranslator}
@charroch
charroch / SpecInstrumentationRunner
Created April 17, 2012 10:39
SpecInstrumentationRunner on android
package org.scalatest.tools
import org.scalatest._
import dalvik.system.DexFile
import java.io.File
import android.os.{Looper, Bundle}
import android.test.{AndroidTestCase, InstrumentationTestCase}
import scala.collection.JavaConversions._
import android.app.{Activity, Instrumentation}