This file contains hidden or 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
(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 |
This file contains hidden or 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
// | |
// CoderwallAPIClientTest.m | |
// CoderwallAPIClientExample | |
// | |
// Created by slightair on 12/04/23. | |
// Copyright (c) 2012 slightair. All rights reserved. | |
// | |
#define kStubServerPort 12345 |
This file contains hidden or 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
[[CoderwallAPIClient sharedClient] profileForUsername:@"slightair" | |
completion:^(CoderwallUserProfile *profile){ | |
// success | |
} | |
failure:^(NSError *error){ | |
// failure | |
}]; |
This file contains hidden or 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
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 | |
This file contains hidden or 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
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) |
This file contains hidden or 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 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) { |
This file contains hidden or 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 "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 = { |
This file contains hidden or 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
>> puts "ひろし".unpack("b*")[0].scan(/../).map{|x|%w(ヴ ィ ム …)[x.to_i(2)]}.join("") | |
…ヴィ…ムヴヴィィヴ…ィ…ヴィ…ィヴヴィム…ヴィ…ヴィ…ムヴヴィ…ムムィ | |
=> nil | |
>> puts ["…ヴィ…ムヴヴィィヴ…ィ…ヴィ…ィヴヴィム…ヴィ…ヴィ…ムヴヴィ…ムムィ".scan(/ヴ|ィ|ム|…/).map{|c|%w(ヴ ィ ム …).index(c)}.map{|i|"%02b"%i}.join("")].pack("b*") | |
ひろし | |
=> nil |
This file contains hidden or 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 <Foundation/Foundation.h> | |
#import <dispatch/dispatch.h> | |
int main (int argc, char const *argv[]) | |
{ | |
int i; | |
dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0); | |
dispatch_semaphore_t semaphore = dispatch_semaphore_create(1); | |
for(i = 0; i < 10; i++) { |
This file contains hidden or 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
[1] pry(main)> RUBY_VERSION | |
=> "2.0.0" | |
[2] pry(main)> require 'active_support/time' | |
=> true | |
[3] pry(main)> Time.new(2013, 4, 1).end_of_day | |
=> 2013-04-01 23:59:59 +0900 | |
[4] pry(main)> Time.new(2013, 4, 1).end_of_day.to_f | |
=> 1364828400.0 | |
[5] pry(main)> Time.at(1364828400.0) | |
=> 2013-04-02 00:00:00 +0900 |
OlderNewer