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
# app/controllers/posts_controller.rb | |
class PostsController < ApplicationController | |
def index | |
@posts.all_cached # Retrive only at once by every 5 minutes | |
expires_in 5.minutes, :private => false, :public => true | |
end | |
end | |
# app/models/post.rb | |
Class Post |
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 'pp' | |
require 'net/http' | |
require 'net/https' | |
require 'rubygems' | |
require 'json' | |
def bssid_to_api(bssidstr) | |
bssidstr.gsub(':', '-').gsub(/(\-|\A)(\d)(\-|\Z)/) {|match| "#{match[0]}0#{match[1]}#{match[2]}"} | |
end |
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 'HTTP' | |
require 'UV' | |
module Sinachiku | |
@routes = { 'GET' => [], 'POST' => [] } | |
def self.route(method, path, opts, &block) | |
@routes[method] << [path, opts, block] | |
end | |
def self.do(r) | |
@routes[r.method].each {|path| |
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
#include <SPI.h> | |
#include <Dhcp.h> | |
#include <Dns.h> | |
#include <Ethernet.h> | |
#include <EthernetClient.h> | |
#include <EthernetServer.h> | |
#include <EthernetUdp.h> | |
#include <util.h> | |
// color swirl! connect an RGB LED to the PWM pins as indicated |
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 'formula' | |
class Libstemmer < Formula | |
# upstream is constantly changing the tarball, | |
# so doing checksum verification here would require | |
# constant, rapid updates to this formula. | |
head 'http://snowball.tartarus.org/dist/libstemmer_c.tgz' | |
homepage 'http://snowball.tartarus.org/' | |
end |
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
user jessed staff; | |
worker_processes 2; | |
events { | |
worker_connections 1024; | |
} | |
http { | |
include mime.types; |
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/env ruby | |
require 'ftools' | |
require 'fileutils' | |
require 'rubygems' | |
require 'RMagick' | |
include Magick | |
require 'open3' | |
def merge( files = [] ) |
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 EmberApp = require('ember-cli/lib/broccoli/ember-app'); | |
var pickFiles = require('broccoli-static-compiler'); | |
var mergeTrees = require('broccoli-merge-trees'); | |
var vulcanize = require('broccoli-vulcanize'); | |
var app = new EmberApp(); | |
var polymerVulcanize = vulcanize('app', { | |
input: 'elements.html', | |
output: 'assets/vulcanized.html', |
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/env ruby | |
# giftube – Generates an animated gif from a YouTube url. | |
# | |
# Usage: | |
# | |
# giftube [youtube url] [minute:second] [duration] | |
# | |
# ex. | |
# |
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 'json' | |
my_json = { :array => [1, 2, 3, { :sample => "hash"} ], :foo => "bar" } | |
puts JSON.pretty_generate(my_json) | |
Which gets you... | |
{ | |
"array": [ | |
1, | |
2, | |
3, |
OlderNewer