Skip to content

Instantly share code, notes, and snippets.

View timendum's full-sized avatar

Timendum timendum

  • Italy
View GitHub Profile
@timendum
timendum / find-smtp.sh
Created July 27, 2011 10:04
Find SMTP server [ bash dns ]
dig +nocmd $DOMAIN MX +noall +answer | awk '{print $5 " " $6}' | sort -n | awk '{print substr($2,1,length($2)-1) " " $1 }'
@timendum
timendum / gist:1109073
Created July 27, 2011 10:11
Check if a page is in a frame
if (top != self) {
//framed
} else {
// stand-alone
}
@timendum
timendum / BirthAge.java
Created July 27, 2011 10:13
Calculate the age from birth date
/**
* Calculate the age from birth date
* @param birth the birth date
* @return the age
*/
public static int getAge(Calendar birth) {
Calendar today = Calendar.getInstance();
int age = today.get(Calendar.YEAR) - birth.get(GregorianCalendar.YEAR);
if (
today.get(Calendar.MONTH) < birth.get(GregorianCalendar.MONTH) ||
@timendum
timendum / UTIL_COSTANTS.sql
Created July 27, 2011 10:00
Create constants in SQL
CREATE VIEW V_UTIL_CONSTANTS AS
SELECT 1 AS ONE, 2 AS TWO, 3 AS THREE
SELECT ONE FROM V_UTIL_CONSTANTS
@timendum
timendum / epoch.sh
Created July 27, 2011 10:00
From epoch to date [ bash ]
date -d @1208941833 +"%Y-%m-%d %H:%M:%S"
# 2008-04-23 11:10:33
date +%s
# 1208941833
@timendum
timendum / string-hash.js
Created July 27, 2011 10:04
Javascript String hash
function stringHash(s) {
var hash = 0,
i = 0,
char;
if (s.length === 0) {
return hash;
}
for (i = 0; i < s.length; i++) {
char = s.charCodeAt(i);
hash = 31*hash+char;
@timendum
timendum / gist:1109052
Created July 27, 2011 10:03
Telnet SMTP mail
telnet server.com 25
telnet-ssl server.com 465
HELO server.com
MAIL FROM: <me@mine.com>
RCPT TO: <you@your.com>
RCPT TO: <he@your.com>
DATA
From: me@mine.com
To: you@your.com
@timendum
timendum / sleep.bat
Created July 27, 2011 10:10
Sleep in Windows shell [ trick ]
ping 1.1.1 -w 10 >/null
@timendum
timendum / CfDate.java
Created July 27, 2011 10:12
Calculate the birth date form CodiceFiscale
public static GregorianCalendar getDateFromCF(String cf) {
GregorianCalendar date = new GregorianCalendar();
int anno = Integer.parseInt("19" + cf.substring(6, 8));
date.set(GregorianCalendar.YEAR, anno);
int month = 0;
switch (Character.toUpperCase(cf.charAt(8))) {
case 'A':
month = GregorianCalendar.JANUARY;
break;
@timendum
timendum / check-hosting.sh
Created July 27, 2011 10:08
Check hosting [ bash dns ]
# one line response
whois `host $DOMAIN | grep "has address" | head -n 1 | sed 's/.* address //'` | grep desc | head -n 1 | sed 's/.*: *//'
# detail
whois `host $DOMAIN | grep "has address" | head -n 1 | sed 's/.* address //'` | grep desc | sed 's/.*: *//'
# full detail
whois `host $DOMAIN | grep "has address" | head -n 1 | sed 's/.* address //'`
#ps: check for mirrors:
host $DOMAIN | grep "has address"