Skip to content

Instantly share code, notes, and snippets.

View jms's full-sized avatar

Jeronimo Martinez Sanchez jms

View GitHub Profile
@jms
jms / grep remove comments
Created May 17, 2012 21:39
remove comment in configuration files
grep -v '^#' file | grep '\w' > new.file
@jms
jms / hashlib md5
Created May 17, 2012 21:42
Python hashlib md5 from text
import hashlib
hashlib.md5(textToHash).hexdigest()
# get a random password from console using tr, dc, urandom
tr -dc a-zA-Z0-9 < /dev/urandom | head -c 10 ; echo -en "\n"
@jms
jms / cron template
Created November 1, 2013 04:53
cron template
# .---------------- minute (0 - 59)
# | .------------- hour (0 - 23)
# | | .---------- day of month (1 - 31)
# | | | .------- month (1 - 12) OR jan,feb,mar,apr ...
# | | | | .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat
# | | | | |
# * * * * * command to be executed
* * * * * command --arg1 --arg2 file1 file2 2>&1
@jms
jms / wipe out disk o flash memory
Created November 1, 2013 04:54
wipe out disk o flash memory
dd count=1 bs=512 if=/dev/zero of=/dev/sdb && sync
@jms
jms / iconv utf8 to iso
Created November 1, 2013 04:59
convert file utf8 to iso(latin) encoding
iconv --verbose -f UTF-8 -t ISO-8859-1 input.txt > output.txt
command line
---------------------------------
padrino g project achiever -d none -t rspec -s none -e erb -c none -m none -b
padrino g controller Admin get:index get:new post:create
padrino start #defaults, non daemonized
padrino start -d -p 3000 -e development #daemonized, port 3000, specified env
padrino
padrino rake spec
padrino rake routes
@jms
jms / mail-function
Created January 27, 2014 21:24
send test email using PHP mail function
<?php
$to = "[email protected]";
$subject = "test";
$body = "Body of your message here you can use HTML too. e.g. <br> <b> Bold </b>";
$headers = "From: Peter\r\n";
$headers .= "Reply-To: [email protected]\r\n";
$headers .= "Return-Path: [email protected]\r\n";
# flush queue
sendmail -q -v
find /var/spool/mqueue/* -type f -exec grep -irl “domainname.com” {} \; -exec rm -vf {} \;
# check queue
mailq
@jms
jms / gist:4bb857cfae3689d48320
Created May 22, 2014 16:21
cfengine 3 community missing link
ln -s /usr/sbin/cf-serverd /var/cfengine/bin/cf-serverd
ln -s /usr/sbin/cf-monitord /var/cfengine/bin/cf-monitord