Skip to content

Instantly share code, notes, and snippets.

View attilagyorffy's full-sized avatar
🦜
A UDP packet bar walks a into...

Attila Györffy attilagyorffy

🦜
A UDP packet bar walks a into...
View GitHub Profile
# Free RESTful interface for your Ruby objects with Rackable
# http://github.com/madx/rackable/tree/master
#
# + Free HTTP caching with rack-cache
# http://github.com/rtomayko/rack-cache/tree/master
require 'rackable'
require 'rack/cache'
APP_ROOT = File.dirname(__FILE__)
#!/usr/bin/env ruby
def usage
puts "./pair [name] [name]: pair two people (set the user in git)"
puts "./pair reset: revert to default settings"
exit
end
if ARGV.size == 2
pair = [ARGV[0], ARGV[1]]
/* Ismael Celis 2010
Simplified WebSocket events dispatcher (no channels, no users)
var socket = new ServerEventsDispatcher();
// bind to server events
socket.bind('some_event', function(data){
alert(data.name + ' says: ' + data.message)
});
@attilagyorffy
attilagyorffy / sections.rb
Created March 8, 2011 10:26
Sections implementation (ala Cucumber) for Steak
module SectionHelpers
def selector_of_section(section_name)
case section_name
when 'recent podcasts'
[:css, 'ul.podcasts']
when /^the row containing "[\"+]"$/
[:xpath, "//*[.='#{$1}']/ancestor::tr"]
else
raise "Can't find mapping from \"#{section_name}\" to a section."
end
@attilagyorffy
attilagyorffy / ba-ghettotmpl.js
Created June 11, 2011 18:45 — forked from cowboy/ba-ghettotmpl.js
Ghetto fabulous templating system. More ghetto than fabulous.
// Ghetto fabulous template system for replacing values in strings. If {{.foo}}
// or {{.bar[0].baz}} is encountered (leading . or ( or [ char), attempt to
// access properties of data object like `data.foo` or `data.bar[0].baz`.
// Alternately, if {{foo}} or {{bar("baz")}} is encountered (no leading dot),
// simply evaluate `foo` or `bar("baz")`. If an error occurs, return empty
// string. Oh yeah, you have to pass the result of ghettoTmpl to eval. :)
function ghettoTmpl(data, str) {
ghettoTmpl._data = data;
ghettoTmpl._str = str;
@attilagyorffy
attilagyorffy / gist:1064775
Created July 5, 2011 12:46
Convert non UTF-8 files to UTF8
find . -exec iconv -t UTF-8 {} \;
@attilagyorffy
attilagyorffy / jquery.support.cssproperty.js
Created July 28, 2011 14:06 — forked from jackfuchs/jquery.support.cssproperty.js
Extends the jQuery.support object to CSS Properties
/**
* jQuery.support.cssProperty
* To verify that a CSS property is supported (or any of its browser-specific implementations)
*
* @param string p - css property name
* [@param] bool rp - optional, if set to true, the css property name will be returned, instead of a boolean support indicator
*
* @Author: Axel Jack Fuchs (Cologne, Germany)
* @Date: 08-29-2010 18:43
*
@attilagyorffy
attilagyorffy / css_colour_validator.rb
Created October 29, 2011 12:27
CSS colour validation in Rails 3
# Put this file under Rails.root /lib
class CssColourValidator < ActiveModel::EachValidator
def validate_each(record, attribute, value)
return false unless value
record.errors[attribute] << (options[:message] || 'is not a valid CSS colour') unless ::HexadecimalColourValidator.matches?(value) or ::WebSafeColourValidator.matches?(value)
end
end
@attilagyorffy
attilagyorffy / gist:1351966
Created November 9, 2011 16:24 — forked from attaboy/gist:1346280
Destroy the localStorage copy of less.js client-side-generated CSS
// Destroys the localStorage copy of CSS that less.js creates
function destroyLessCache(pathToCss) { // e.g. '/css/' or '/stylesheets/'
if (!window.localStorage || !less || less.env !== 'development') {
return;
}
var host = window.location.host;
var protocol = window.location.protocol;
var keyPrefix = protocol + '//' + host + pathToCss;
@attilagyorffy
attilagyorffy / acceptance_helper.rb
Created November 29, 2011 14:53
Capybara, with Selenium and Firebug
Capybara.register_driver :selenium do |app|
Capybara::Selenium::Driver # this line ensures that the top level Selenium module is loaded
profile = Selenium::WebDriver::Firefox::Profile.new
profile.add_extension File.expand_path "spec/support/vendor/firebug-1.8.4-fx.xpi"
profile.add_extension File.expand_path "spec/support/vendor/fireStarter-0.1a6.xpi"
profile.add_extension File.expand_path "spec/support/vendor/netExport-0.8b20.xpi"
# Configures Firebug - look at http://getfirebug.com/developer/api/firebug1.6/symbols/src/defaults_preferences_firebug.js.html
profile['extensions.firebug.currentVersion'] = "1.8.4" # avoid 'first run' tab
profile["extensions.firebug.previousPlacement"] = 1