Skip to content

Instantly share code, notes, and snippets.

View runemadsen's full-sized avatar

Rune Skjoldborg Madsen runemadsen

View GitHub Profile
@runemadsen
runemadsen / High Five Ruby App
Created October 24, 2011 19:00 — forked from lilyszajn/High Five Ruby App
High Five Ruby app with jquery
require 'rubygems'
require 'sinatra'
require 'open-uri'
get "/highFive.jsonp" do
content_type :jsonp
open("http://www.itpcakemix.com/project/HI5SON!!").read
end
get "/" do
var date = new Date(data.rows[i].doc.created_at);
date.setHours(date.getHours()+4);
<html>
<head>
<title></title>
<script src="http://code.jquery.com/jquery-1.4.2.min.js" ></script>
<script>
$(window).load(function()
{
$.ajax({
url: "http://www.itpcakemix.com/project/HI5SON!!",
dataType: 'jsonp',
@runemadsen
runemadsen / auth.rb
Created October 29, 2011 22:03
Simple Github OAuth authorization Sinatra
require 'oauth2'
get '/' do
require_user
erb :index
end
get '/oauth' do
session[:access_token] = github_client.token(params[:code])
redirect '/'
@runemadsen
runemadsen / httparty.rb
Created October 30, 2011 01:45
Creating a repo via the Github API and HTTParty
class Github
include HTTParty
base_uri 'https://api.github.com'
end
Github.post("/user/repos", :query => {
:access_token => @token
},
:body => {
:name => name,
@runemadsen
runemadsen / customgem.sh
Created October 30, 2011 04:37
Custom Gem Procedure
# create the gem
bundle gem crazygem
# move into folder
cd crazygem
# now develop the gem
# to use gem from disk in a project, do this in Gemfile
gem 'crazygem', :path => '/Users/rune/Projects/gems/crazygem'
@runemadsen
runemadsen / converter.java
Created October 31, 2011 20:45
Processing 8-bit pixel converter
PImage img;
int pixelSize = 5;
void setup()
{
noStroke();
img = loadImage("subway.jpg");
@runemadsen
runemadsen / datamapper_caching.rb
Created November 9, 2011 16:00
Simple example of caching I would love in ORM's
# In your datamapper class you can define caching per environment
class Post
include DataMapper::Resource
enable_caching :production
property :id, Serial
property :title, String
property :body, Text
property :created_at, DateTime
end
function test(anotherfunction)
{
anotherfunction();
}
test(function() {
console.log("This is called in the test function");
});
@runemadsen
runemadsen / TemplateTest.html
Created November 16, 2011 14:56 — forked from anonymous/TemplateTest.html
Template Testing
<!DOCTYPE html>
<html>
<head>
<title>Untitled Document</title>
<link href="statusBoard.css" rel="stylesheet" type="text/css" />
<script type="text/x-jquery-tmpl" id="testBuildTemplate">
<tr><td data-bind="id: statusClass"></td><td data-bind="text: name"></td></tr>
</script>