Skip to content

Instantly share code, notes, and snippets.

@arnaudbreton
arnaudbreton / async-process-jasmine.Spec.js
Last active August 29, 2015 14:00
The 5 best front-end developer tools blogpost: testing with Mocha and Jasmine
AsyncProcess = require('./async-process').AsyncProcess
describe('AsyncProcess', function() {
var asyncProcess;
beforeEach(function() {
asyncProcess = new AsyncProcess();
});
it('should process 42', function() {
anonymous
anonymous / gist:2bd1676ca95281a42d37
Created August 11, 2014 06:38
realtime rsync
#!/usr/bin/python
#-*-coding:utf8-*-
import pyinotify,os,subprocess
sourcePath = '/home/yjiang/foo/'
targetPath = 'yjiang@test:/home/yjiang/sync_test/'
wm = pyinotify.WatchManager()
class rsync():
@jmoiron
jmoiron / jsontest.py
Created November 2, 2011 02:00
json speed test
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""Which json is the best json."""
import json
import simplejson as sjson
import ujson
import cjson
import bson
@cguldogan
cguldogan / ExcelOperations.cs
Last active March 29, 2016 13:06
Read Excel in C#
public class ExcelOperations
{
public List<List<string>> Read(string filePath)
{
OleDbConnection conn = new OleDbConnection("Provider = Microsoft.ACE.OLEDB.12.0; Data Source = " + filePath + "; Extended Properties = 'Excel 8.0; HDR=NO'");
OleDbCommand cmd = new OleDbCommand("select * from [Sheet1$]", conn);
conn.Open();
OleDbDataReader dr = cmd.ExecuteReader();
@pepijndevos
pepijndevos / repyl.py
Last active July 28, 2016 06:51
A Redis-based interactive Python shell.
from __future__ import print_function
import threading
import code
import sys
import contextlib
from time import sleep
try:
from StringIO import StringIO
except ImportError:
from io import StringIO
@jdowning
jdowning / Puppetfile
Created August 26, 2013 18:24
PostgreSQL Cluster for Vagrant
forge "http://forge.puppetlabs.com"
mod "puppetlabs/apt"
mod "puppetlabs/ntp"
mod "puppetlabs/stdlib"
mod "puppetlabs/postgresql"
@typehorror
typehorror / README.md
Last active December 11, 2016 15:16
Celery task bug in a SQLAlchemy event

Celery Bug

When running a celery task, in a SQLAlchemy event, in a unit-test the connection get destroyed somehow.

I attached the requirement to reproduce the bug:

git clone https://gist.github.com/5762792fc1d628843697.git
cd 5762792fc1d628843697
virtualenv venv

. venv/bin/activate

@jvanasco
jvanasco / app-models-__init__.py
Created January 3, 2012 20:21
Reflecting in Pyramid/SqlAlchemy
import logging
log = logging.getLogger(__name__)
from sqlalchemy import Table
from sqlalchemy import MetaData
from sqlalchemy.orm import mapper
from sqlalchemy.orm import scoped_session
from sqlalchemy.orm import sessionmaker
from zope.sqlalchemy import ZopeTransactionExtension
@lentil
lentil / patch.py
Created April 18, 2011 21:09
Control monkey-patch scope with a context manager
from __future__ import with_statement
from types import ClassType, MethodType, TypeType
class Patch(object):
class Missing:
pass
def __init__(self, obj, **kwargs):
@AndreKR
AndreKR / draw_text.go
Created March 14, 2017 09:03
Three ways of drawing text in go
// Initialize an empty image
dest := image.NewRGBA(image.Rect(0, 0, 800, 300))
// Draw a white background
draw.Draw(dest, dest.Bounds(), &image.Uniform{color.White}, image.ZP, draw.Src)
// Read the font
fontBytes, err := ioutil.ReadFile(exeDir + "/DejaVuSans.ttf")
if err != nil {