Skip to content

Instantly share code, notes, and snippets.

View slawosz's full-sized avatar

Sławosz Sławiński slawosz

View GitHub Profile
@dcparker
dcparker / sample_ruby_webserver.rb
Created August 11, 2009 17:19
Mini Ruby web server example!
require 'socket'
socket = TCPServer.new('0.0.0.0', '8080')
socket.setsockopt(Socket::SOL_SOCKET, Socket::SO_REUSEADDR, 1)
loop do
client = socket.accept
data = ''
loop do
event = select([client],nil,nil,0.5)
if client.eof? # Socket's been closed by the client
# Hi! I'am rack middleware!
# I was born for show right way to you JavaScript
# My author's name was Aleksandr Koss. Mail him at kossnocorp@gmail.com
# Nice to MIT you!
require(File.dirname(__FILE__) + '/../config/environment') unless defined?(Rails)
class RoutesJs
def initialize app, options = {}
#This file is for drying end easy maintain template for creating rails application with devise, mongoid and #haml
#Gemfile
apply "http://gist.github.com/raw/406147/edge-template-Gemfile.rb"
# Bundle
run 'bundle install --relock'
# Initialize testing suite
run 'script/rails g rspec:install'
# In your test_helper.rb
class ActiveRecord::Base
mattr_accessor :shared_connection
@@shared_connection = nil
def self.connection
@@shared_connection || retrieve_connection
end
end
@slawosz
slawosz / module_instead_alias.rb
Created January 7, 2011 12:05
use module hierarchy!
# people write such a code
class Person
def say(word)
puts word
end
end
class Person
alias_method :old_say, :say
@paulsmith
paulsmith / echo.go
Created January 12, 2011 06:09
A simple echo server testing a few interesting Go language features, goroutines and channels.
// $ 6g echo.go && 6l -o echo echo.6
// $ ./echo
//
// ~ in another terminal ~
//
// $ nc localhost 3540
package main
import (
@slawosz
slawosz / symbol_expressions.rb
Created May 25, 2011 11:36 — forked from pjb3/symbol_expressions.rb
Symbol Expressions Simplified
class Symbol
def |(*args)
@args = args
self
end
def to_proc
Proc.new { |obj|
obj.send *[self] + (@args || [])
}
@dx7
dx7 / gist:1333785
Created November 2, 2011 14:33
Installing ruby-debug with ruby-1.9.3-p0
### UPDATE: ruby-debuy19 is no longer maintained, use https://github.com/cldwalker/debugger
# Install with:
# bash < <(curl -L https://raw.github.com/gist/1333785)
#
# Reference: http://blog.wyeworks.com/2011/11/1/ruby-1-9-3-and-ruby-debug
echo "Installing ruby-debug with ruby-1.9.3-p0 ..."
curl -OL http://rubyforge.org/frs/download.php/75414/linecache19-0.5.13.gem
@slawosz
slawosz / application.js.coffee
Created December 17, 2011 16:59 — forked from ddemaree/application.js.coffee
Simple Google Maps API v3 integration in CoffeeScript, with non-JS Static Maps fallback
#= require jquery
#= require jquery_ujs
#= require lib/modernizr
#= require lib/jquery.lettering
#= require_tree .
$ ->
$('*[data-googlemap]').googleMap()
true
@slawosz
slawosz / 0-readme.md
Created February 1, 2012 07:49 — forked from burke/0-readme.md
ruby-1.9.3-p0 cumulative performance patch.

Patched ruby 1.9.3-p0 for 30% faster rails boot

What is?

This script installs a patched version of ruby 1.9.3-p0 with patches to make ruby-debug work again (#47) and boot-time performance improvements (#66 and #68), and runtime performance improvements (#83 and #84).

Huge thanks to funny-falcon for the performance patches.