Skip to content

Instantly share code, notes, and snippets.

View slightair's full-sized avatar
🍄
Hello

Tomohiro Moro slightair

🍄
Hello
View GitHub Profile
require "faraday"
conn = Faraday::Connection.new(url: 'https://api.parse.com') do |builder|
builder.request :url_encoded
builder.adapter :net_http
end
response = conn.get do |request|
request.url '/1/classes/Foo'
request.headers = {
@slightair
slightair / gist:2949580
Created June 18, 2012 17:35
sample for kue issue #110
var kue = require('kue');
var jobs = kue.createQueue();
jobs.process('job', function(job, done){
var progressMax = 3;
var next = function(i){
console.log("job-%d-%s [%d/%d] #%d", job.data.id, job.data.title, i, progressMax, job.id);
job.progress(i, progressMax);
if (i == progressMax) {
package cc.clv
object InverseFizzBuzz extends App {
case object FizzBuzz
case object Fizz
case object Buzz
def fizzbuzzSequence(limit: Int) = Range(1, limit).collect {
case x if x % 15 == 0 => (x, FizzBuzz)
case x if x % 3 == 0 => (x, Fizz)
val Width = 129
val Height = 48
val MaxTrial = 200
def recurrence(pxn: Double, pyn: Double, a: Double, b: Double, trial:Int):Int = trial match {
case MaxTrial => MaxTrial
case _ => {
val xn = pxn * pxn - pyn * pyn + a
val yn = 2 * pxn * pyn + b
@slightair
slightair / gist:2509557
Created April 27, 2012 14:07
sample CoderwallAPIClient
[[CoderwallAPIClient sharedClient] profileForUsername:@"slightair"
completion:^(CoderwallUserProfile *profile){
// success
}
failure:^(NSError *error){
// failure
}];
@slightair
slightair / CoderwallAPIClientTest.m
Created April 27, 2012 13:58
CoderwallAPIClientTest uses NLTHTTPStubServer
//
// CoderwallAPIClientTest.m
// CoderwallAPIClientExample
//
// Created by slightair on 12/04/23.
// Copyright (c) 2012 slightair. All rights reserved.
//
#define kStubServerPort 12345
@slightair
slightair / ca1d.clj
Created April 15, 2012 17:15
one-dimensional cellular automaton
(def trials 32)
(def rule 90)
(def initial-state (concat (repeat 32 0) '(1) (repeat 32 0)))
(defn show-cells [cells]
(println (apply str (map #(cond (= % 0) " "
(= % 1) "*") cells))))
(defn neighbors [state]
(concat