This file contains hidden or 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
module Rack | |
class Request | |
def subdomains(tld_len=1) # we set tld_len to 1, use 2 for co.uk or similar | |
# cache the result so we only compute it once. | |
@env['rack.env.subdomains'] ||= lambda { | |
# check if the current host is an IP address, if so return an empty array | |
return [] if (host.nil? || | |
/\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/.match(host)) | |
host.split('.')[0...(1 - tld_len - 2)] # pull everything except the TLD | |
}.call |
This file contains hidden or 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
puts "hello joe" |
This file contains hidden or 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
def self.tree(path = nil) | |
Rails.cache.fetch("folder-tree-#{path}", expires_in: 0) do | |
folders = Folder.where('path LIKE ?', "#{path}%").all | |
path_parts = path.to_s.count('/') | |
local_root = root | |
local_first_tier = [] | |
folders.each do |folder| | |
folder.children = folders.select { |f| f.parent_id == folder.id }.sort { |a, b| a.position <=> b.position } | |
local_root = folder if path == folder.path |
This file contains hidden or 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
# Orignal | |
module ActionController | |
class Responder | |
def to_format | |
if get? || !has_errors? || response_overridden? | |
default_render | |
else | |
display_errors | |
end |
This file contains hidden or 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
class Foo | |
public def my_public_method | |
1 + 2 | |
end | |
protected def my_protected_method | |
3 + 4 | |
end | |
def my_private_method |
This file contains hidden or 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
NoMethodError (super: no superclass method `request_parameters'): | |
gems/gems/actionpack-3.2.13/lib/action_dispatch/http/request.rb:237:in `POST' | |
gems/gems/actionpack-3.2.13/lib/action_dispatch/http/parameters.rb:10:in `parameters' |
This file contains hidden or 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
module Couchbase | |
class AsyncCallback | |
include Java::NetSpyMemcachedInternal::OperationCompletionListener | |
def initialize(callback) | |
@callback = callback | |
end | |
def onComplete(future) |
This file contains hidden or 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
$ sudo dpkg -i couchbase-server-enterprise_2.2.0_x86_64.deb | |
Selecting previously unselected package couchbase-server. | |
(Reading database ... 70796 files and directories currently installed.) | |
Unpacking couchbase-server (from couchbase-server-enterprise_2.2.0_x86_64.deb) ... | |
libssl1* is installed. Continue installing | |
Minimum RAM required : 4 GB | |
System RAM configured : 3145728 kB | |
Minimum number of processors required : 4 cores | |
Number of processors on the system : 32 cores | |
Setting up couchbase-server (2.2.0) ... |
This file contains hidden or 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
# A | |
100.times do |i| | |
case [i % 3 == 0, i % 5 == 0] | |
when [true, true] then puts 'Fizz Buzz' | |
when [true, false] then puts 'Fizz' | |
when [false, true] then puts 'Buzz' | |
else | |
puts i | |
end | |
end |
This file contains hidden or 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
$ ping github.com | |
PING github.com (192.30.252.131): 56 data bytes | |
64 bytes from 192.30.252.131: icmp_seq=0 ttl=248 time=88.360 ms | |
Request timeout for icmp_seq 1 | |
64 bytes from 192.30.252.131: icmp_seq=2 ttl=248 time=91.491 ms | |
64 bytes from 192.30.252.131: icmp_seq=3 ttl=248 time=91.730 ms | |
64 bytes from 192.30.252.131: icmp_seq=4 ttl=248 time=86.243 ms | |
64 bytes from 192.30.252.131: icmp_seq=5 ttl=248 time=89.297 ms | |
Request timeout for icmp_seq 6 | |
Request timeout for icmp_seq 7 |
OlderNewer