Skip to content

Instantly share code, notes, and snippets.

View MBO's full-sized avatar

Mirosław Boruta MBO

  • Lędziny, Poland
View GitHub Profile
##
## Zapisz jako /etc/apt/sources.list
##
#
# deb cdrom:[Kubuntu 8.10 _Intrepid Ibex_ - Release i386 (20081028)]/ intrepid main restricted
# deb cdrom:[Kubuntu 8.10 _Intrepid Ibex_ - Release i386 (20081028)]/ intrepid main restricted
# See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to
# newer versions of the distribution.
sortedDefault:
==============
a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z, ó, ö, ą, ć, ę, ě, ł, ń, ś, ź, ż
sortedDefaultWithCollator:
==========================
a, ą, b, c, ć, d, e, ě, ę, f, g, h, i, j, k, l, m, n, ń, o, ó, ö, p, q, r, s, ś, t, u, v, w, x, y, z, ź, ż, ł
# Distance between two dates in days
now.yday - back.yday + (back.year...now.year).reduce(0) do |acc,el|
acc + Time.mktime(el, 12, 31).yday # last day of year = number of days in year
end
/*
* How to build a Google Map and bind a SearchControl to it and put markers
* on the map for each result we receive.
*/
// First, we have to load the APIs.
google.load('maps' , '2');
google.load('search' , '1');
// Global variables we will set in OnLoad
This example shows how to setup an environment running Rails 3 beta under 1.9.1 with a 'rails3' gem set.
∴ rvm update --head
# ((Open a new shell)) or do 'rvm reload'
# If you do not already have the ruby interpreter installed, install it:
∴ rvm install 1.9.1
# Switch to 1.9.1 and gemset rails3, create if it doesn't exist.
∴ rvm --create use 1.9.1@rails3
namespace :delayed_job do
desc "*HACK* Restart the delayed_job process"
task :restart do
stop
enforce_stop_delayed_job
start
end
# Send SIGTERM to delayed_job associated with current logfile and then
# wait for every delayed_job to finish
mirko@akagi.pts/7 ~/Code/rolldice
23:02:57 % ./rdp 1d6 2d6 3d6
1d6
1d6+0
min: 1, max: 6, avg: 3.5
| # | cnt | cumulative distribution | probability mass |
+===+=====+==========================================+==========================================+
| 1 | 1 | ###### | ###### |
| 2 | 1 | ############# | ###### |
| 3 | 1 | #################### | ###### |
@MBO
MBO / README
Created June 1, 2011 11:38
How to convert params for nested attributes and _destroy
Convert params in form:
"product_suppliers_attributes"=>{
"0"=>{"id"=>"2", "_destroy"=>"false", "supplier_id"=>"1"},
"1"=>{"id"=>"3", "_destroy"=>"false", "supplier_id"=>"3"}
}
to form:
"product_suppliers_attributes"=>[
@MBO
MBO / with_http_router.rb
Created November 28, 2012 21:43
Cramp example with Journey instead of HttpRouter
require "bundler"
Bundler.setup(:default)
require "cramp"
require "http_router"
require "thin"
class HomeController < Cramp::Action
def before_start
if params[:password] != "foo"
@MBO
MBO / robot.js
Created December 5, 2012 10:39
mbo
//FightCode can only understand your robot
//if its class is called Robot
var Robot = function(robot) {
};
Robot.prototype.onIdle = function(ev) {
var robot = ev.robot;