Skip to content

Instantly share code, notes, and snippets.

Avatar

Bastien Sevajol buxx

View GitHub Profile
View sqla_copy_data.py
src = create_engine('mysql+oursql://username:password@127.0.0.1:3306/dbname')
dst = create_engine('postgresql://username:password@localhost:5432/dbname')
tables = Base.metadata.tables;
for tbl in tables:
data = src.execute(tables[tbl].select()).fetchall()
for a in data: print(a)
if data:
print (tables[tbl].insert())
dst.execute( tables[tbl].insert(), data)
@buxx
buxx / keybase.md
Created Sep 16, 2019
For keybase auth
View keybase.md

Keybase proof

I hereby claim:

  • I am buxx on github.
  • I am buxx (https://keybase.io/buxx) on keybase.
  • I have a public key ASBiqrMvEzxYFEjTpnHrAOeKpNL3Yt3VYArT-iJ2sFbZ8go

To claim this, I am signing this object:

@buxx
buxx / aiopoc.py
Created Jul 24, 2018
aiohttp stream response example
View aiopoc.py
from aiohttp import web
async def handle(request):
response = web.StreamResponse(
status=200,
reason='OK',
headers={'Content-Type': 'text/plain'},
)
await response.prepare(request)
View testing_transparency.py
from pyglet.gl import *
# glEnable(GL_TEXTURE_2D)
# glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST)
desert_img = pyglet.image.load('assets/desert.png')
data = desert_img.data
data = b'\x00' * 200000 + data[200000:]
desert_img.data = data
@buxx
buxx / .sh
Last active Jul 4, 2017
bash aliases
View .sh
alias uuid="python -c 'import uuid; print(uuid.uuid4())'"
alias gen="python -c 'import uuid; print(str(uuid.uuid4()).replace(\"-\", \"\"))'"
alias freezelist="python -c \"import pip; print(list(sorted(['{}{}'.format(d.project_name, '=={}'.format(getattr(d, 'version')) if getattr(d, 'version') else '') for d in pip.get_installed_distributions(local_only=True)], key=lambda s: s.lower())))\""
alias prettyjson='python -m json.tool'
@buxx
buxx / gist:b85420dd10c67f0cb3ca8b939b5feb8c
Created Mar 2, 2017
Add utf8 info usage at beginning of python file given as 1rst arg
View gist:b85420dd10c67f0cb3ca8b939b5feb8c
#!/bin/bash
line=$(head -n 1 $1)
# need to be fixed below
if ! [ $line="# coding: utf-8" ]; then
printf '%s\n' "# coding: utf-8" | cat - $1 > $1.n && mv $1.n $1
fi;
# use like:
# find -iname '*.py' ! -path "./venv3.5/*" -exec ./u.sh {} \;
@buxx
buxx / ModelTestCase.php
Created Jun 11, 2012 — forked from wowo/ModelTestCase.php
Model Test Case, which loads fixtures and builds database before each test
View ModelTestCase.php
<?php
/*
* Adapt to your AppKernel.php path
*/
require_once(__DIR__ . "../../../../../../app/AppKernel.php");
/**
* @see http://haulynjason.net/weblog/2012/01/fully-isolated-tests-in-symfony2/
*/