I hereby claim:
- I am burlesona on github.
- I am burlesona (https://keybase.io/burlesona) on keybase.
- I have a public key whose fingerprint is 11DB FA34 1EF9 CF16 2955 D274 E038 68E9 30CF 7D68
To claim this, I am signing this object:
# Not that this is an impressive demo, but it makes the point that Ruby | |
# does in fact have the ability to create "pure" functions and pass them | |
# as arguments to higher order functions. People get hung up on the syntax | |
# but it's not really that complicated. | |
make_adder = method def make_adder(num) | |
->(input){ input + num } | |
end | |
make_add_twice = method def make_add_twice(adder, num) |
#!/usr/bin/env ruby | |
require 'rubygems' | |
require 'bundler/setup' | |
require_relative 'environment' | |
require 'models' | |
require 'helpers' | |
require 'pry' | |
Pry.start self |
#user nobody; | |
worker_processes 1; | |
#error_log logs/error.log; | |
#error_log logs/error.log notice; | |
#error_log logs/error.log info; | |
#pid logs/nginx.pid; |
require 'resolv' | |
filename = ARGV[0] | |
batch_size = ARGV[1].to_i | |
outfile = File.open('ip-addresses.txt','w+') | |
domains = File.readlines(filename) | |
groups = domains.each_slice(batch_size) | |
threads = [] | |
results = [] | |
groups.each_with_index do |group,index| |
I hereby claim:
To claim this, I am signing this object:
# BEFORE RUBY 2.0 | |
def method(argument,hash) | |
end | |
method 1, :foo => "bar", :baz => "qux" | |
method 1, {:foo => "bar", :baz => "qux"} #identical | |
method(1, {:foo => "bar", :baz => "qux"}) #identical |
# Use like so: | |
# @key_i_need = @event.seek :coordinator, :api_license, :key | |
class Hash | |
def seek(*_keys_) | |
last_level = self | |
sought_value = nil | |
_keys_.each_with_index do |_key_, _idx_| | |
if last_level.is_a?(Hash) && last_level.has_key?(_key_) | |
if _idx_ + 1 == _keys_.length |
require 'minitest_helper' | |
require 'helpers/application_helper' | |
describe ApplicationHelper do | |
before :all do | |
@helper = Struct.new(:request).new #Create an empty request method so it can be stubbed | |
@helper.extend(ApplicationHelper) | |
end |
# 1. Excerpt of Photo and User model | |
# Photos can belong to Cities and Districts, and users can browse Cities and | |
# Districts to see the photos in them. When a user uploads a photo I really want | |
# them to tell me where the photo came from. | |
# Also, Users can be from a City and District. This is not currently used for very | |
# much, but gives me a path to add location-enhanced results for other stuff in the | |
# future. |
class PhotosController < ApplicationController | |
before_filter :authenticate_user!, :except => [:index, :show] | |
impressionist :actions=>[:show] | |
respond_to :html, :json | |
def index | |
@search = Photo.search(params[:search]) | |
@search.meta_sort ||= 'created_at.desc' | |
@photos = @search.page(params[:page]).per(20) | |
respond_with @photos |