Skip to content

Instantly share code, notes, and snippets.

View sandro's full-sized avatar
☀️
Sharing Goodness

Sandro Turriate sandro

☀️
Sharing Goodness
View GitHub Profile
@sandro
sandro / .slate
Last active October 7, 2015 10:37
My slate config
config defaultToCurrentScreen true
config nudgePercentOf screenSize
config resizePercentOf screenSize
bind g:ctrl;shift grid padding:5 0:4,2 1:6,2
# Resize Bindings
bind right:alt;ctrl resize +10% +0
bind left:alt;ctrl resize -10% +0
bind up:alt;ctrl resize +0 -10%
onerror = function(m, f, l) {console.log('begin');console.log(m); console.log(f); console.log(l); console.log('end'); return false;}
y = function() { $.getScript('http://turriate.com/notthere.js') }
y()
@sandro
sandro / ios_autofocus.html
Created May 23, 2012 00:44
playground for testing ios web autofocus
<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
</head>
<body>
<a href="">link</a>
<input type="text" id="in"/>
<button>hi</button>
<script type="text/javascript">
EphemeralResponse.mock('google.com') do |domain|
domain.on('get') do |request|
if query = request.query[:q]
puts "searching for #{query}"
Net::HTTPSuccess.new
else
nil # pass through, raise ExternalRequest or whatever normally happens
end
end
end
@sandro
sandro / c.rb
Created April 9, 2012 15:41
ssl socket tunneling proxy; performs an ssl handshake on behalf of another socket.
require 'net/http'
s = TCPSocket.open('localhost', 44567)
ss = OpenSSL::SSL::SSLSocket.new s
ss.sync_close = true
puts 'connecting...'
p ss.connect
puts 'done'
@sandro
sandro / proxy.rb
Created April 6, 2012 04:46
http proxy
require 'socket'
require 'uri'
require 'net/http'
require 'openssl'
# module Net
# OHTTP = remove_const(:HTTP)
# class HTTP < OHTTP
# include OHTTP::ProxyDelta
# @is_proxy_class = true
@sandro
sandro / pass.rb
Created February 21, 2012 20:26
Preforking spec runner - like spork.
#!/usr/bin/env ruby
# Description
# Starts the rails environment in a long running process that forks a test
# runner. The test begins running immediately as the rails environment
# has already been loaded. Useful when running a single spec over and over.
# The program will exit when a change is detected
# in the Gemfile, or the db, config, lib and vendor directories.
#
@sandro
sandro / gist:1838363
Created February 15, 2012 19:31
Forced asset compiling mixed with some specjour internals
def default_after_load
lambda do
if rails_with_ar?
if Rails.application.assets
%w(application.js application.css).each do |primary_asset|
Rails.application.assets.find_asset(primary_asset)
end
end
ActiveRecord::Base.remove_connection
end
@sandro
sandro / async-rack.rb
Created September 8, 2011 08:52
Imagining async rack-test
require 'rubygems'
require 'bundler'
Bundler.setup
require 'rack'
require 'rack/test'
require 'benchmark'
class Foo
def self.call(env)
sleep 1
@sandro
sandro / client_example
Created September 4, 2011 09:09
Ruby select socket server. An example of a single-threaded, event-driven (select) server.
$ irb -r ./select_server
>> client.puts "hi"
=> nil
>> client.puts "bye"
=> nil
>> client.close
=> nil
>> exit