Skip to content

Instantly share code, notes, and snippets.

View charlax's full-sized avatar

Charles-Axel Dein charlax

View GitHub Profile
-- ResetPrototype
--
-- Copyright (c) 2011, Charles-Axel Dein
-- All rights reserved.
--
-- Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
--
-- Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
-- Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
@charlax
charlax / supervisord.conf
Created September 13, 2011 02:49
To save in /etc/init/supervisord.conf
description "supervisord"
start on runlevel [2345]
stop on runlevel [!2345]
respawn
exec /usr/local/bin/supervisord --nodaemon --configuration /etc/supervisord.conf
@charlax
charlax / pgrouting-mac-os-x.patch
Created October 7, 2011 20:40
Patch to install pgrouting on Mac Os X
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 1d6612c..852fd1b 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -64,7 +64,9 @@ OPTION(WITH_DD "Build Driving distance library" OFF)
IF(UNIX)
SET(LIBRARY_INSTALL_PATH ${LIB_DIR})
- SET(SQL_INSTALL_PATH /usr/share/postlbs)
+ if(NOT SQL_INSTALL_PATH)
@charlax
charlax / gaul-mac-os-x.patch
Created October 7, 2011 20:59
Patch to install gaul on Mac Os X
diff --git a/util/gaul/gaul_util.h b/util/gaul/gaul_util.h
index d81df51..74511d9 100755
--- a/util/gaul/gaul_util.h
+++ b/util/gaul/gaul_util.h
@@ -175,6 +175,7 @@ typedef short _Bool;
#if HAVE__BOOL != 1
typedef short _Bool;
#endif
+typedef short _Bool;
#!/usr/bin/env python
#
# Copyright 2007 Google Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
@charlax
charlax / myapp.model.__init__.py
Created September 7, 2012 08:35
Transaction and scopedsession (SQLAlchemy & Pyramid)
from sqlalchemy.orm import sessionmaker, scoped_session
...
Session = scoped_session(sessionmaker())
# When using scoped_session, Session and Session() expose the same .commit() .query() .add() etc. methods.
...
@charlax
charlax / transaction.py
Created December 18, 2012 17:20
Keeping deletion atomic in spite of model method calling `commit()`.
from sqlalchemy import Column, Integer, Unicode
from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker, scoped_session
from sqlalchemy.ext.declarative import declarative_base
Base = declarative_base()
Session = scoped_session(sessionmaker())
class User(Base):
@charlax
charlax / chord_poc.py
Last active February 9, 2023 19:49
Getting results from a chord's header
import time
from celery import chord
from celery.utils import uuid
from my_app.celery import celery
class ProgressChord(chord):
@charlax
charlax / progresschord.py
Created March 20, 2013 23:19
chord returning the header's task group
class ProgressChord(chord):
"""
Chord that returns both the callback's AsyncResult and the group's
AsyncResult.
"""
# See:
# http://stackoverflow.com/questions/15441101/how-to-track-the-progress-of-individual-tasks-inside-a-group-which-forms-the-hea
# https://groups.google.com/forum/?fromgroups=#!topic/celery-users/xSdxI-Z08Cw
from alembic.script import ScriptDirectory
from alembic.config import Config
from alembic.migration import MigrationContext
from sqlalchemy import create_engine
# current head
config = Config()
config.set_main_option("script_location", "myapp:migrations")
script = ScriptDirectory.from_config(config)
head_revision = script.get_current_head()