Skip to content

Instantly share code, notes, and snippets.

View ehabkost's full-sized avatar

Eduardo Habkost ehabkost

View GitHub Profile
@ehabkost
ehabkost / gist:8716439
Created January 30, 2014 19:07
CPU model probing through QMP
https://github.com/ehabkost/qemu/tree/work/cpu-model-classes
You can run it as:
$ qemu-system-x86_64 -enable-kvm -machine none -monitor stdio -qmp unix:/tmp/qmp,server,nowait -nographic
Then:
$ ./scripts/qmp/qmp-shell /tmp/qmp
[...]
import re, sys
fieldre = re.compile(r'^ *\.([a-z0-9_]+) *= *(.*?),? *([^,]*?)\n', re.M)
def fixmachine(m):
print >>sys.stderr,"whole: %r" % (m.group(0))
name = m.group(2)
if name.endswith('_machine'):
name = name[:-len('_machine')]
fields = m.group(4)
print >>sys.stderr,"fields: %r" % (fields)
#!/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.
#
. /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 / .gitconfig
Created September 13, 2010 14:27
my .gitconfig
[rerere]
enabled = true
[format]
numbered = auto
[sendemail]
chainreplyto = 0
suppressfrom = 1
suppresscc = all
#/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 / 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 = []
@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 / 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 / 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