Run it with:
curl -fsSL https://gist.github.com/shime/6129865/raw/try_it.sh | bash -e
if Rails.env.production? | |
slow_logfile = File.open(Rails.root.join("log", "slow.log"), 'a') | |
slow_log = Logger.new(slow_logfile) | |
slow_log.level = Logger::INFO | |
ActiveSupport::Notifications.subscribe "process_action.action_controller" do |name, start, finish, id, payload| | |
duration = (finish - start) * 1000 | |
StatHat::API.ez_post_value("rails request duration", "info@stathat.com", duration) | |
view_time = 0 | |
db_time = 0 |
test "the Ember.RSVP.Promise works", -> | |
promise = new Ember.RSVP.Promise((resolve, reject) -> | |
Ember.run(null, resolve, "value") | |
) | |
Ember.run => | |
promise.then (actual) -> | |
equal(actual, 'value', 'promise resolved with "hello"') |
Run it with:
curl -fsSL https://gist.github.com/shime/6129865/raw/try_it.sh | bash -e
source 'https://rubygems.org' | |
gem "minitest" |
def solution(a) | |
counter = [0] * a.length | |
a.each do |element| | |
if ! (1 <= element && element <= a.length) | |
return 0 | |
else | |
if counter[element-1] != 0 | |
return 0 | |
else | |
counter[element-1] = 1 |
{ | |
"artists": [ | |
"parov stelar", | |
"proleter", | |
"goldfish", | |
"tape five", | |
"movits", | |
"odjbox" | |
] | |
} |
var express = require('express') | |
, app = express() | |
, http = require('http') | |
, server = http.createServer(app) | |
, io = require('socket.io').listen(server); | |
server.listen(4000); | |
app.get('/', function(request, response){ | |
response.sendfile(__dirname + "/index.html"); |
vendor/ | |
.bundle/ | |
node_modules/ | |
Gemfile.lock |
require "sinatra" | |
get "/oauth/github" do | |
OAuthingWithGithub.start(self) | |
end | |
get "/oauth/github/callback" do | |
OAuthingWithGithub.finish(self) | |
end |