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 'net/http' | |
require 'openssl' | |
content = ARGF.read | |
def create_vuash(message) | |
url = "https://vua.sh" | |
uri = URI(url) |
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
run lambda { |env| [200, { "Content-Type" => "text/plain" }, ["Hello World"]] } |
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
# code/something.rb | |
class Something | |
def nothing | |
p caller | |
end | |
end | |
Something.new.nothing | |
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
# Reverse words | |
# Small and Large solution | |
# | |
data = File.read(ARGV[0] || 'in.txt').split("\n") | |
def pluck(data) | |
data.shift.to_i | |
end | |
times = pluck(data) |
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
# Store Credit | |
# | |
# SMALL solution | |
data = File.read(ARGV[0] || 'in.txt').split | |
def pluck(data) | |
data.shift.to_i | |
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 'bundler/capistrano' | |
set :application, "net" | |
set :repository, "git@githost.com:net.git" | |
set :scm, :git | |
set :default_environment, { | |
'PATH' => "$HOME/.rbenv/shims:$HOME/.rbenv/bin:$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
# Enhance rails test with lib directory | |
# | |
# http://www.seanbehan.com/how-to-add-additional-sub-directories-to-the-default-rails-testunit-file-structure | |
namespace :test do | |
Rake::TestTask.new(:lib) do |t| | |
t.libs << "test" | |
t.pattern = 'test/lib/**/*_test.rb' | |
t.verbose = true | |
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
# Reference: http://ridingtheclutch.com/post/71345006944/how-to-add-directories-to-rake-stats | |
task :stats => "omakase:stats" | |
namespace :omakase do | |
task :stats do | |
require 'rails/code_statistics' | |
::STATS_DIRECTORIES << ["Services", "app/services"] | |
::STATS_DIRECTORIES << ["Services Tests", "test/services"] | |
CodeStatistics::TEST_TYPES << 'Services Tests' |
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/sessions_controller.rb | |
class SessionsController < ApplicationController | |
def create | |
authenticate! | |
render :json => {:status => "200", :message => "You have successfully logged in"} | |
end | |
private | |
def warden | |
request.env['warden'] |
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
# Install pg on mavericks | |
# Using Postgres app | |
export PATH="~/bin:/usr/local/bin:/usr/local/sbin:/Applications/Postgres93.app/Contents/MacOS/bin:$PATH" | |
gem install pg -v='0.14.0' | |
# Import pg dump to rails app | |
rake db:create:all | |
pg_restore -d app_development file.dump |