Created after reading Learning the vi and vim editors seventh editor. O`Reilly, 2008
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# Copyright (C) 2014 Vitaliy Elengaupt <[email protected]> | |
# 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 |
Created after reading Pro Git - Scott Chacon, 2010
Note: add git
at the beginning of each command below (except those that begins with $
or :
)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
################################################################################ | |
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/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" |
Create db dump:
mysqldump -u user -p db_name > db_name.sql
Restore db dump:
mysql -u user -p db_name < db_name.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$$$ | |
crystal | |
crystal run | |
crystal build | |
crystal version |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
OlderNewer