Skip to content

Instantly share code, notes, and snippets.

View Fonsan's full-sized avatar

Erik Fonselius Fonsan

View GitHub Profile
@Fonsan
Fonsan / keybase.md
Created March 8, 2014 14:46
keybase.md

Keybase proof

I hereby claim:

  • I am Fonsan on github.
  • I am Fonsan (https://keybase.io/Fonsan) on keybase.
  • I have a public key whose fingerprint is CA01 210C 0B82 03F4 D398 E46A B39E DC79 D3A5 A0CF

To claim this, I am signing this object:

parallel_fetch(ServerPid, FirstKey, SecondKey, ThirdKey) ->
FirstRequestId = make_ref(),
SecondRequestId = make_ref(),
ThirdRequestId = make_ref(),
ServerPid ! {self(), FirstRequestId, FirstKey},
ServerPid ! {self(), SecondRequestId, SecondKey},
ServerPid ! {self(), ThirdRequestId, Thirdkey},
FirstValue = receive
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")
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")
link_to raw("We" + image_tag('heart.png') + " Feedback")
# generates
# <a class="footer_link" href="/feedback">We&lt;img alt="Heart" src="/images/heart.png?1297276993" /&gt; Feedback</a>
#include <CoreServices/CoreServices.h>
static void callback(ConstFSEventStreamRef streamRef,
void *clientCallBackInfo,
size_t numEvents,
void *eventPaths,
const FSEventStreamEventFlags eventFlags[],
const FSEventStreamEventId eventIds[]) {
exit(0);
}
@Fonsan
Fonsan / router.rb
Created March 13, 2011 17:09
Ugly non threadsafe way of routing a subdomain to a controller
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]
@Fonsan
Fonsan / Debugger.rb
Created May 13, 2011 08:57
Has many through 3.1 beta
(rdb:1) pp o
#<Arel::Nodes::SelectCore:0x000001056b0638
@groups=[],
@having=nil,
@projections=
[#<struct Arel::Attributes::Attribute
relation=
#<Arel::Table:0x000001056aea68
@aliases=[],
@columns=nil,
module MetaSearch
module Helpers
module UrlHelper
def order_indicator_for(order)
if order == 'asc'
'&#9650;' # replace this with a string or nil
elsif order == 'desc'
'&#9660;' # replace this with a string or nil
else
@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]]