Skip to content

Instantly share code, notes, and snippets.

View hartym's full-sized avatar
👽
Crafting great software

Romain Dorgueil hartym

👽
Crafting great software
View GitHub Profile
@hartym
hartym / pynatra.py
Created September 24, 2011 14:50
I want to cheat too ... Here is pynatra !
import subprocess
from flask import Flask
from hamlpy import hamlpy
def sass(source):
proc = subprocess.Popen(['/var/lib/gems/1.8/gems/sass-3.1.7/bin/sass'], stdin=subprocess.PIPE, stdout=subprocess.PIPE)
return proc.communicate(source)[0]
def scss(source):
proc = subprocess.Popen(['/var/lib/gems/1.8/gems/sass-3.1.7/bin/scss'], stdin=subprocess.PIPE, stdout=subprocess.PIPE)
<?php
class toto
{
public function __construct()
{
$this->method = function () {
echo 'it works';
};
}
@hartym
hartym / __init__.py
Created February 16, 2012 13:12
namespace package declaration
# this is a namespace package
try:
import pkg_resources
pkg_resources.declare_namespace(__name__)
except ImportError:
import pkgutil
__path__ = pkgutil.extend_path(__path__, __name__)
@hartym
hartym / git-stash-grep
Created May 3, 2012 09:45 — forked from netshade/gist:1125810
git stash grep (bash)
stashgrep() {
for i in `git stash list | awk -F ':' '{print $1}'`; do
git stash show -p $i | grep -H --label="$i" "$1"
done
}
"""Utilities for managing database sessions."""
from __future__ import with_statement
import contextlib
import functools
@contextlib.contextmanager
def temp_session(session_cls, **kwargs):
"""Quick and dirty context manager that provides a temporary Session object
to the nested block. The session is always closed at the end of the block.
[alias]
co = checkout
ci = commit
br = branch
lg = log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit
st = status
[color]
branch = auto
diff = auto
interactive = auto
python -c 'import random; print(random.randint(pow(10,3),int(2*pow(10,8)/365)))' 'Gare du Nord'
# Orignal version taken from http://www.djangosnippets.org/snippets/186/
# Original author: udfalkso
# Modified by: Shwagroo Team and Gun.io
import sys
import os
import re
import hotshot, hotshot.stats
import tempfile
import StringIO
@hartym
hartym / designer.html
Created August 24, 2014 20:03
designer
<link rel="import" href="../core-drawer-panel/core-drawer-panel.html">
<link rel="import" href="../core-menu/core-submenu.html">
<link rel="import" href="../core-item/core-item.html">
<link rel="import" href="../topeka-elements/category-icons.html">
<link rel="import" href="../core-icon/core-icon.html">
<polymer-element name="my-element">
<template>
<style>
@hartym
hartym / extract.py
Last active March 25, 2017 10:26
Bonobo - Step 1 - Extract the data
def my_extract():
yield 1
yield 2
yield 3