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 'socket' | |
puts "Please enter host:" | |
hostname = STDIN.gets.chop # Read host and remove the newline | |
port = 80 | |
s = TCPSocket.open(hostname, port) | |
s.write("HEAD / HTTP/1.0\n") |
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 'socket' | |
puts "Please enter host:" | |
hostname = STDIN.gets.chop # Read host and remove the newline | |
port = 80 | |
s = TCPSocket.open(hostname, port) | |
s.write("HEAD / HTTP/1.0\n") |
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
link_to raw("We" + image_tag('heart.png') + " Feedback") | |
# generates | |
# <a class="footer_link" href="/feedback">We<img alt="Heart" src="/images/heart.png?1297276993" /> Feedback</a> |
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
#include <CoreServices/CoreServices.h> | |
static void callback(ConstFSEventStreamRef streamRef, | |
void *clientCallBackInfo, | |
size_t numEvents, | |
void *eventPaths, | |
const FSEventStreamEventFlags eventFlags[], | |
const FSEventStreamEventId eventIds[]) { | |
exit(0); | |
} |
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
class SupportSubdomain | |
def self.subdomain | |
@@request.subdomain.to_sym rescue :not_found | |
end | |
def self.matches?(request) | |
@@request = request | |
request.path_parameters[:controller] = request.subdomain | |
Rails.logger.info request.path_parameters[:controller] |
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
(rdb:1) pp o | |
#<Arel::Nodes::SelectCore:0x000001056b0638 | |
@groups=[], | |
@having=nil, | |
@projections= | |
[#<struct Arel::Attributes::Attribute | |
relation= | |
#<Arel::Table:0x000001056aea68 | |
@aliases=[], | |
@columns=nil, |
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
module MetaSearch | |
module Helpers | |
module UrlHelper | |
def order_indicator_for(order) | |
if order == 'asc' | |
'▲' # replace this with a string or nil | |
elsif order == 'desc' | |
'▼' # replace this with a string or nil | |
else |
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
@samples = 10.times.map do rand(10) end | |
result = @samples.inject( Hash.new(0) ) do |hash,element| | |
hash[element] += 1 | |
hash | |
end.to_a # => [[6, 3], [3, 1], [1, 1], [9, 2], [4, 2], [8, 1]] | |
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
Form.count | |
(0.4ms) SELECT forms.id, forms.name, forms.created, forms.user_id, forms.category_id, forms.active_status, forms.read_only, forms.example_interview_id, COUNT(*) FROM `forms` | |
=> 1 | |
> Form.unscoped.count | |
(0.2ms) SELECT COUNT(*) FROM `forms` | |
=> 4 | |
> Form.unscoped.select("name").count | |
(0.3ms) SELECT COUNT(`forms`.`name`) FROM `forms` | |
=> 4 |
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
source 'http://rubygems.org' | |
gem 'sinatra' | |
gem 'erubis' | |
gem 'shotgun' |
OlderNewer