Skip to content

Instantly share code, notes, and snippets.

View l0gicpath's full-sized avatar

Hady Mahmoud l0gicpath

View GitHub Profile
@l0gicpath
l0gicpath / gist:210909
Created October 15, 2009 12:02
Rails template test
# Some cleaning up ;)
run "rm public/index.html"
# Installing required plugins
plugin 'Authentasaurus', :git => 'git://github.com/logicpath/Authentasaurus.git'
plugin 'flash_message_conductor', :git => 'git://github.com/planetargon/flash-message-conductor.git'
plugin 'acts_as_taggable_on_steroids', :git => 'git://github.com/jviney/acts_as_taggable_on_steroids.git'
plugin 'paperclip', :git => 'git://github.com/thoughtbot/paperclip.git'
plugin 'rspec', :git => 'git://github.com/dchelimsky/rspec.git'
config.gem "webrat", :lib => false, :version => "0.5.3"
config.gem "cucumber", :lib => false, :version => "0.3.98"
config.gem "thoughtbot-factory_girl", :lib => 'factory_girl', :source => 'http://gems.github.com', :version => "1.2.1"
@l0gicpath
l0gicpath / mash_app_template
Created October 19, 2009 13:05
Mash's Minimalist Rails app Template
run "rm public/index.html"
run "rm public/images/rails.png"
plugin 'flash_message_conductor', :git => 'git://github.com/planetargon/flash-message-conductor.git'
plugin 'acts_as_taggable_on_steroids', :git => 'git://github.com/jviney/acts_as_taggable_on_steroids.git'
plugin 'paperclip', :git => 'git://github.com/thoughtbot/paperclip.git'
plugin 'rspec', :git => 'git://github.com/dchelimsky/rspec.git'
plugin 'rspec-rails', :git => 'git://github.com/dchelimsky/rspec-rails.git'
/* Ismael Celis 2010
Simplified WebSocket events dispatcher (no channels, no users)
var socket = new FancyWebSocket();
// bind to server events
socket.bind('some_event', function(data){
alert(data.name + ' says: ' + data.message)
});
@l0gicpath
l0gicpath / dnsd.rb
Created December 9, 2011 05:14 — forked from peterc/dnsd.rb
Simple, scrappy UDP DNS server in Ruby (with protocol annotations)
# Simple, scrappy UDP DNS server in Ruby (with protocol annotations)
# By Peter Cooper
#
# MIT license
#
# * Not advised to use in your production environment! ;-)
# * Requires Ruby 1.9
# * Supports A and CNAME records
# * See http://www.ietf.org/rfc/rfc1035.txt for protocol guidance
# * All records get the same TTL
@l0gicpath
l0gicpath / rails_bootstrap_delete_confirmation_modal.md
Created September 21, 2012 03:36 — forked from postpostmodern/rails_bootstrap_delete_confirmation_modal.md
A nice delete confirmation modal in Rails courtesy of Bootstrap

Here's what you get.

Some CoffeeScript (verbosely commented for clarity)

# Override Rails handling of confirmation

$.rails.allowAction = (element) ->
  # The message is something like "Are you sure?"
  message = element.data('confirm')
@l0gicpath
l0gicpath / accepts_new_nested_associations.rb
Created November 5, 2012 04:26 — forked from Zequez/accepts_new_nested_associations.rb
Allow existing associations in accepts_nested_attributes_for
module ActiveRecord::NestedAttributes
module ClassMethods
def accepts_nested_attributes_for(*attr_names)
options = { :allow_destroy => false, :update_only => false }
options.update(attr_names.extract_options!)
# Modified stuff
#options.assert_valid_keys(:allow_destroy, :reject_if, :limit, :update_only)
options.assert_valid_keys(:allow_destroy, :reject_if, :limit, :update_only, :allow_existing)
# This is an incomplete implementation.
module MongoMapper
module NestedAttributes
def self.included(base)
base.extend(ClassMethods)
base.send :include, InstanceMethods
end
module ClassMethods
def accepts_nested_attributes_for(*attr_names)
/* Abstract event binding
Example:
var MyEventEmitter = function(){};
MyEventEmitter.prototype = new AbstractEventsDispatcher;
var emitter = new MyEventEmitter();
// Bind to single event
emitter.bind('foo_event', function(data){ alert(data)} );
var wireio = new WireIO({app_key: "yourappkey"});
wireio.on('wireio/connected', function() {
console.log("Connected");
});
wireio.on('chatter-entered', {nick: 'awesomechatter'});