Created after reading Pro Git - Scott Chacon, 2010
Note: add git
at the beginning of each command below (except those that begins with $
or :
)
from optparse import OptionParser | |
from subprocess import call | |
from subprocess import check_output | |
import urllib | |
import re | |
import os | |
import sys | |
import shutil | |
def getUrlCode(url): |
################################################################################ | |
p 10.itself # 10 | |
p "1".itself # "1" | |
p :sym.itself # :sym | |
p true.itself # true | |
p nil.itself # nil | |
p [1, 2].itself # [1, 2] | |
p ({"1" => "2"} of String => String).itself # {"1" => "2"} | |
p /1/.itself # /1/ |
require "benchmark" | |
puts ">> Array#[] vs Array#[]?" | |
arr = Array.new(1000, 1) | |
Benchmark.ips do |x| | |
x.report("Array#[]" ) { arr[500] } | |
x.report("Array#[]?") { arr[500]? } | |
end | |
puts ">> Interpolation vs Int32#to_s" |
Created after reading Pro Git - Scott Chacon, 2010
Note: add git
at the beginning of each command below (except those that begins with $
or :
)
Create db dump:
mysqldump -u user -p db_name > db_name.sql
Restore db dump:
mysql -u user -p db_name < db_name.sql
# create dump of the database on remote server | |
$ mongodump --host remote_host --db database_name | |
# import into database on localhost | |
$ mongorestore --host localhost --dir dump/database_name/ --db database_name --drop |
class String | |
def leftpad(len : Int, char = ' ') | |
char, len = char.to_s, len - self.size | |
raise ArgumentError.new if char.size != 1 | |
len > 0 ? (char * len + self) : self | |
end | |
end |
#!/bin/sh | |
# Copyright (C) 2014 Vitaliy Elengaupt <velenhaupt@gmail.com> | |
# This program is free software: you can redistribute it and/or modify | |
# it under the terms of the GNU General Public License as published by | |
# the Free Software Foundation, either version 3 of the License, or | |
# (at your option) any later version. | |
# This program is distributed in the hope that it will be useful, | |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
sudo killall -HUP mDNSResponder |