i = 1000
i.toExponential();
// 1e+3
This file contains hidden or 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
CarrierWave.configure do |config| | |
config.asset_host = proc do |file| | |
'http://www.domain.com' | |
end | |
end |
my_hash = {}
@objects.each { |obj| my_hash[obj.id] = obj }
my_array.collect{ |id| my_hash[id] }
Install tcpkill
yum -y install dsniff --enablerepo=epel
View connections
netstat -tnpa | grep ESTABLISHED.*sshd.
Block with ip tables
iptables -A INPUT -s IP-ADDRESS -j DROP
Kill connection
Convert a ruby hash to dotted path
def hash_to_dotted_path(hash, path = "")
hash.each_with_object({}) do |(k, v), ret|
key = path + k.to_s
if v.is_a? Hash
ret.merge! hash_to_dotted_path(v, key.to_s + ".")
else
Convert a dotted path to hash
def dotted_path_to_hash(hash)
hash.map do |pkey, pvalue|
pkey.to_s.split(".").reverse.inject(pvalue) do |value, key|
{key.to_sym => value}
end
end.inject(&:deep_merge)
end
Check for existing swap files
swapon -s
Create swap file with 1024k size
sudo dd if=/dev/zero of=/swapfile bs=1M count=1024
sudo mkswap /swapfile
NewerOlder