Skip to content

Instantly share code, notes, and snippets.

View ehabkost's full-sized avatar

Eduardo Habkost ehabkost

View GitHub Profile
echo inc.sh:
if [ "${#BASH_SOURCE[@]}" -le 1 ];then
echo I am the main script file.
else
echo I am being called from another file.
fi
func1()
{
echo env on func1 called from $1:
set
int a;
@ehabkost
ehabkost / NSDictionary+QueryStringBuilder.h
Created October 12, 2011 16:19 — forked from mramsden/NSDictionary+QueryStringBuilder.h
Creating a query string from an NSDictionary.
#import <Foundation/Foundation.h>
@interface NSDictionary (QueryStringBuilder)
- (NSString *)queryString;
@end
@ehabkost
ehabkost / challenge.py
Created September 26, 2011 22:47
Challenge: make this code *worse*
try:
datetime.datetime(year+2000 if year < 1000 else year, month, day)
print "%i-%i-%i" % (year+2000 if year < 1000 else year, month, day)
except ValueError:
try:
datetime.datetime(year+2000 if year < 1000 else year, day, month)
print "%i-%i-%i" % (year+2000 if year < 1000 else year, day, month)
except ValueError:
try:
datetime.datetime(month+2000 if month < 1000 else month, day, year)
@ehabkost
ehabkost / main.cf
Created July 27, 2011 16:37
My postfix auth config
relayhost = [smtp.gmail.com]:587
smtp_tls_policy_maps = hash:/etc/postfix/tls_policy
smtp_tls_CAfile = /etc/pki/tls/cert.pem
sender_dependent_relayhost_maps = hash:/etc/postfix/sender_relayhost
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/smtp_pass
smtp_sasl_security_options =
@ehabkost
ehabkost / emu-cpudef-flags-compare.py
Created June 2, 2011 17:45
Simmple script to compare sets of flags on Qemu cpudef config files
#!/usr/bin/env python
# simple script to compare sets of flags on Qemu cpudef config files
# Author: Eduardo Habkost <ehabkost@redhat.com>
import sys
import ConfigParser
files = sys.argv[1:]
setlists = []
#/usr/bin/env python
# Game of Death
# quick and dirty implemenation of http://spikedmath.com/299.html
# Copyright (c) 2010 Eduardo Habkost <ehabkost@raisama.net>
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
@ehabkost
ehabkost / .gitconfig
Created September 13, 2010 14:27
my .gitconfig
[rerere]
enabled = true
[format]
numbered = auto
[sendemail]
chainreplyto = 0
suppressfrom = 1
suppresscc = all
. /mnt/common/sys/scripts/git-completion.bash
export GIT_PS1_SHOWDIRTYSTATE=true
export GIT_PS1_SHOWUNTRACKEDFILES=true
_git_cur_branch()
{
__git_ps1
return
@ehabkost
ehabkost / make-bridge-for-libvirt.sh
Created May 7, 2010 15:08
Very small qemu-ifup script
#!/bin/bash
# make-bridge-for-libvirt.sh
#
# This scripts follows blindly the instructions from:
# http://wiki.libvirt.org/page/Networking#Fedora.2FRHEL_Bridging
#
# It tries to copy the existing physical network config
# to the bridge. It may not work if you have a non-trivial
# network setup on ifcfg-eth0.
#