Skip to content

Instantly share code, notes, and snippets.

View graffic's full-sized avatar

Javier Gonel graffic

View GitHub Profile
@graffic
graffic / maze.py
Created January 27, 2017 03:12
bkkhack tournament
maze = """XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXX.XXXXX XXXXX XXXXXXXXXXX
XXX XXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXX XXXXXXXXXXX
XXX XX XXXXXXXX XXX XXXX XXXXX XXXX
XXX XX XXXXXXXXXXXXXX XXXXXXXX XXX XXXX XXXXX XXXX
XXX XX XXXXXXXXXXXXXX XX X XXX XXX XXXX XXXXX XXXX
XXX XX XXX XXXXXX XX X XXX XXX XXXX XXXXX XXXX
XXX XX XXX XXX XXXXXX XX X XXX XXX XXXX XXXXX XXXX
XXX XX XXX XXX XXXXXX XX X XXX XXXXXXXXXX XXXXX XXXX
XXX XX XXX XXXXXX XX X XXX XXXXX XXXXX XXXX
@graffic
graffic / async.py
Created September 9, 2015 16:41
Async demo python 3.5
import aiohttp
import asyncio
async def get(index):
response = await aiohttp.get('http://httpbin.org/delay/%d' % index)
print(index, "Done")
response.close()
async def doMany():
coros = []

Keybase proof

I hereby claim:

  • I am graffic on github.
  • I am graffic (https://keybase.io/graffic) on keybase.
  • I have a public key whose fingerprint is D44E 1E92 061C 54D4 964F 4470 D075 45BC 53D6 9D57

To claim this, I am signing this object:

@graffic
graffic / gist:6c15f8c2b4f0f208939e
Created May 11, 2014 19:49
Uncle bob "Framework Whipped" original post

Framework Whipped

Uncle Bob 11 May 2014 Craftsmanship Frameworks are powerful tools. We'd be lost without them. But there's a cost to using them.

The relationship between a programmer and a framework is similar to the relationship between an executive and an administrative assistant. The framework takes care of all the necessary details, so that the executive can focus on high level decisions.

Think of Rails, or Spring, or JSF, or Hibernate. Think about what writing a web system would be like without these frameworks to help you. The idea is disheartening. There'd be so many little piddling details to deal with. It'd be like endeavoring to construct a mnemonic memory circuit using stone knives and bearskins[1].

And so we gleefully use those glittering frameworks. We joyously intermingle our code with the frameworks' in anticipation of all the benefits they promise. We make the mistake that so many executives have made before us. We marry our secretary.

@graffic
graffic / zodb.py
Last active December 30, 2015 02:59
Simple ZODB support in Flask. Works with ZODB4
"""
ZODB support in flask
Usage: `DB = FlaskZODB(APP)`
In your views use `DB.root` to get the database root dictionary.
"""
from flask import _app_ctx_stack as stack
import transaction
import zodburi
@graffic
graffic / gist:6577063
Created September 16, 2013 05:46
Pyramid bootstrap setting a base_url for the request.
def bootstrap(config_uri, options=None):
"""
Bootstraps a pyramid environment
Differences with the default pyramid bootstrap:
- It handles tasks.base_url
"""
app = get_app(config_uri, options=options)
registry = global_registries.last
base_url = registry.settings.get('tasks.base_url', None)
@graffic
graffic / fastcgi.sh
Created July 23, 2012 07:08
Django on fastcgi and nginx featuring transifex.
#! /bin/sh
### BEGIN INIT INFO
# Provides: FastCGI servers for Django
# Required-Start: $network
# Required-Stop: $network
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start FastCGI servers with Django.
# Description: Django, in order to operate with FastCGI, must be started
# in a very specific way with manage.py. This must be done
@graffic
graffic / nginx.conf
Created July 16, 2012 11:10
Nginx maintenance snippet
server {
...
# This is a copy&paste snippet to put your server in maintenance mode
error_page 503 @maintenance;
location @maintenance {
rewrite ^(.*)$ /maint.html break;
}
return 503;
@graffic
graffic / gist:1404782
Created November 29, 2011 13:18
Dictionaries to Map in MessagePack for .NET
if (type.IsMap())
{
Label work = il.DefineLabel();
Label getNext = il.DefineLabel();
Label end = il.DefineLabel();
il.EmitLd(arg_writer);
// 1. Get length of the dictionary
il.EmitLd(arg_obj);
@graffic
graffic / console.py
Created October 18, 2011 11:15
Dummy Flights web services tester
#!/usr/bin/python
import httplib, time
from flights_pb2 import SearchRequest
class FlightsService(object):
"""Basic Flights service implementation with common methods"""
def __init__(self,host="10.0.0.210",port=80):
self.__ws = httplib.HTTPConnection(host,port)