Skip to content

Instantly share code, notes, and snippets.

View carlopires's full-sized avatar

Carlo Pires carlopires

  • Aldeia Global
  • Goiânia/Brazil
View GitHub Profile
# Config for Nginx to act as a front-end for Riak
# The main goal is to proxy all GETs directly to Riak, and disallow anything else (POST, PUT, etc)
# Also, disallow use of the map/reduce query links (i.e. /riak/bucket/key/_,_,_)
# Config is in /etc/nginx/sites-available/default or somewhere like that
# Set up load-balancing to send requests to all nodes in the Riak cluster
# Replace these IPs/ports with the locations of your Riak nodes
upstream riak_hosts {
server 127.0.0.1:8098;
application: filehangar
version: live
runtime: python
api_version: 1
handlers:
- url: /remote_api
script: $PYTHON_LIB/google/appengine/ext/remote_api/handler.py
login: admin
'''
redis_search.py
Written by Josiah Carlson July 3, 2010
Released into the public domain.
This module implements a simple TF/IDF indexing and search algorithm using
Redis as a datastore server. The particular algorithm implemented uses the
@teepark
teepark / btree.py
Created September 9, 2010 22:45
a pure-python B tree and B+ tree implementation
import bisect
import itertools
import operator
class _BNode(object):
__slots__ = ["tree", "contents", "children"]
def __init__(self, tree, contents=None, children=None):
self.tree = tree
@mdornseif
mdornseif / replication.py
Created May 1, 2011 20:35
Replication of AppEngine & Minimal implementation for generating zipfiles. See also http://mdornseif.github.com/2011/05/01/writing-zipfiles-to-blobstore.html
#!/usr/bin/env python
# encoding: utf-8
"""
replication.py - extport data to external systems
Created by Maximillian Dornseif on 2011-05-01.
Copyright (c) 2011 HUDORA. All rights reserved.
"""
from __future__ import with_statement
@mdornseif
mdornseif / zib_datastore.py
Created May 1, 2011 20:44
This is shows how to generate ZIP files in the blobstore.
def store_pdfs_in_zip():
docs = Dokument.all().order('updated_at')
file_name = files.blobstore.create(mime_type='application/zip',
_blobinfo_uploaded_filename='test.zip')
with files.open(file_name, 'w') as f:
z = blobstoreZipFile(f)
for doc in docs.fetch(75):
pdf = doc.data
fname = "%s-%s.pdf" % (doc.designator, doc.updated_at)
fname = fname.encode('ascii', 'replace')
@carlopires
carlopires / easy_daemon.py
Created October 24, 2011 17:57
Easy python daemon
# -*- coding: utf-8 -*-
"""
Created on 23/10/2011
@author: Carlo Pires <carlopires@gmail.com>
"""
import sys
import time
from daemon import DaemonContext
from daemon.runner import make_pidlockfile, is_pidfile_stale
@mklabs
mklabs / bootstrap-plugins.txt
Created December 2, 2011 11:23
h5bp + twitter bootstrap integration
bootstrap-tooltip.js
bootstrap-popover.js
bootstrap-alert.js
bootstrap-button.js
bootstrap-carousel.js
bootstrap-collapse.js
bootstrap-dropdown.js
bootstrap-modal.js
bootstrap-scrollspy.js
bootstrap-tab.js
@alper
alper / pullsink.py
Created August 10, 2012 11:23
Simplified zeromq PUSH/PULL example
import sys
import time
import zmq
context = zmq.Context()
# Socket to receive messages on
receiver = context.socket(zmq.PULL)
receiver.bind("tcp://*:5558")
@koblas
koblas / echo.cxx
Created August 15, 2012 22:46
libev c++ echo server
#include <unistd.h>
#include <fcntl.h>
#include <string.h>
#include <stdlib.h>
#include <ev++.h>
#include <netinet/in.h>
#include <sys/socket.h>
#include <resolv.h>
#include <errno.h>
#include <list>