Skip to content

Instantly share code, notes, and snippets.

View mnowakowski's full-sized avatar
🚲

Marcin Nowakowski mnowakowski

🚲
View GitHub Profile
<!DOCTYPE html>
<html>
<head>
<script src="http://documentcloud.github.io/underscore/underscore-min.js"></script>
<script src="http://documentcloud.github.io/backbone/backbone-min.js"></script>
<script src="http://code.jquery.com/jquery.min.js"></script>
<link href="http://getbootstrap.com/dist/css/bootstrap.css" rel="stylesheet" type="text/css" />
<script src="http://getbootstrap.com/dist/js/bootstrap.js"></script>
<meta name="description" content="jsBin template - Backbone, Twitter Bootstrap" />
@mnowakowski
mnowakowski / jQuery validation message
Created January 21, 2011 10:47
Custom message in addMethod for jQuery validation
$j.validator.addMethod("remote_data", function(value, element, params) {
var my_message = "some message";
$j.ajax({
...
});
if (correct){
return true;
} else {
$j.validator.messages.remote_data = my_message;
return false;
@mnowakowski
mnowakowski / update to rails3 and Ruby 1.9 on MacOS Tiger
Created January 11, 2011 21:54
Update to Ruby On Rails 3 and Ruby 1.9 on MacOS 10.4 Tiger (using mac port)
sudo gem update rails
sudo gem update --system
sudo port install ruby19 +nosuffix
$("#my_radio_or_checkbox").attr("checked", "checked"); // check it
$("#my_radio_or_checkbox").removeAttr("checked"); // uncheck it
=> Booting Mongrel
=> Rails 2.3.5 application starting on http://0.0.0.0:3000
/opt/local/lib/ruby/gems/1.8/gems/rails-2.3.5/lib/rails/gem_dependency.rb:119:Warning: Gem::Dependency#version_requirements is deprecated and will be removed on or after August 2010. Use #requirement
/opt/local/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/routing/route_set.rb:142:in `named_helper_module_eval': (eval):3:in `named_helper_module_eval': compile error (SyntaxError)
(eval):1: syntax error, unexpected ':', expecting '\n' or ';'
... def hash_for_username:strings_path(options = nil) ...
^
(eval):3: syntax error, unexpected kEND, expecting $end
end ...
^
@mnowakowski
mnowakowski / rails_template.rb
Created April 6, 2009 12:57
rails-template.rb
# rails-template.rb
# by Marcin Nowakowski (mymanufactory.com)
#-------------------------
# Plugins and Gems
#-------------------------
plugin 'rspec', :git => 'git://github.com/dchelimsky/rspec.git'
plugin 'rspec-rails', :git => 'git://github.com/dchelimsky/rspec-rails.git'
plugin 'exception_notifier', :git => 'git://github.com/rails/exception_notification.git'
@mnowakowski
mnowakowski / gist:43740
Created January 6, 2009 09:19
convert int to hex
// convert some user ID (int) in to special unique hex color
function convertIdToHex(val:int):String{
return '#' + ('00000' + (val * 999999).toString(16).toUpperCase()).substr(-6);
}
trace(convertIdToHex(1))
trace(convertIdToHex(2))
trace(convertIdToHex(3))
trace(convertIdToHex(4))
trace(convertIdToHex(5))