Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env ruby
require 'net/http'
require 'openssl'
content = ARGF.read
def create_vuash(message)
url = "https://vua.sh"
uri = URI(url)
@jonduarte
jonduarte / config.ru
Created April 25, 2014 14:00
minimum rack
run lambda { |env| [200, { "Content-Type" => "text/plain" }, ["Hello World"]] }
# code/something.rb
class Something
def nothing
p caller
end
end
Something.new.nothing
# 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)
# Store Credit
#
# SMALL solution
data = File.read(ARGV[0] || 'in.txt').split
def pluck(data)
data.shift.to_i
end
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"
}
@jonduarte
jonduarte / gist:8476862
Created January 17, 2014 16:52
Add custom folders to rake test
# 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
@jonduarte
jonduarte / gist:8476817
Created January 17, 2014 16:49
How to add directories to `rake stats`
# 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'
# 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']
# 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