Skip to content

Instantly share code, notes, and snippets.

Avatar
:octocat:
It's 5.50 a.m.... Do you know where your stack pointer is?

Rodrigo Delduca skhaz

:octocat:
It's 5.50 a.m.... Do you know where your stack pointer is?
View GitHub Profile
View gist:815661
class Size
{
public:
Size();
Size(uint width, uint height);
const Size& setWidth(uint width);
const Size& setHeight(uint height);
uint width() const;
uint height() const;
private:
View gist:1022136
std::map<std::string, std::string> result;
std::string str("foo=bar&color=red&zoom=22.5&alpha=3,4,2,1222.8");
sregex pair = ( (s1= +_w) >> "=" >> (s2= +(set[alnum | '_' | '.' | ',']) ))
[ ref(result)[s1] = s2];
sregex rx = pair >> *('&' >> *(pair));
if(regex_match(str, rx)) {
View gist:1096448
"""
https://github.com/coffin/coffin/blob/master/coffin/template/defaulttags.py
"""
class SpacelessExtension(Extension):
"""Removes whitespace between HTML tags, including tab and
newline characters.
Works exactly like Django's own tag.
"""
View gist:1099818
import os
import sys
import pyttsx
def main():
engine = pyttsx.init()
for root, dirs, filenames in os.walk('.'):
for filename in filenames:
basename, extension = os.path.splitext(filename)
fullpath = os.path.abspath(os.path.join(root, filename))
@skhaz
skhaz / gist:2172956
Created Mar 23, 2012
Example of the MonoState pattern
View gist:2172956
#include <iostream>
#include <boost/shared_ptr.hpp>
class VideoManagerPrivate {
private:
friend class VideoManager;
VideoManagerPrivate() { }
bool init(int _width, int _height, short _bpp, bool _fullscreen) {
@skhaz
skhaz / hack.sh
Created Apr 2, 2012 — forked from erikh/hack.sh
OSX For Hackers
View hack.sh
#!/usr/bin/env sh
##
# This is script with usefull tips taken from:
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
#
# install it:
# curl -sL https://raw.github.com/gist/2108403/hack.sh | sh
#
View gist:2783188
QString atom(
"declare namespace atom = \"http://www.w3.org/2005/Atom\";\n"
"declare namespace media = \"http://search.yahoo.com/mrss/\";\n"
"doc($result)//atom:entry/media:group/media:player/@url/string()\n"
);
QXmlQuery query;
query.bindVariable("result", &buffer);
query.setQuery(atom);
@skhaz
skhaz / gist:3350974
Created Aug 14, 2012
A tribute to XKCD: the light comes on when I compile!
View gist:3350974
/*
* Based on this picture
* http://imgur.com/ZZxFy
*/
#include <cstdio>
#include <stdio.h>
#include <windows.h>
#include <tlhelp32.h>
View gist:3439187
QFile *file = new QFile(filename);
QFileInfo info(*file);
QDir dir = info.dir();
QString filepath = dir.absolutePath();
if (!dir.mkpath(filepath)) {
qWarning("Error while creating the subdirectory %s", qPrintable(filepath));
}
View gist:3741040
# -*- coding: utf-8 -*-
"""
Based upon www.splinter.com.au/converting-hsv-to-rgb-colour-using-c/
"""
from math import floor
def HSVtoRGB(h, s, v):
r, g ,b = 0, 0, 0