Skip to content

Instantly share code, notes, and snippets.

@naiquevin
naiquevin / acl_ex1.php
Created November 14, 2011 11:39
Code Examples for Acl in Kodelearn http://github.com/kodeplay/kodelearn
<?php
// defining resource-levels as arrays
return array(
'exam' => array(
'levels' => array(
'view',
'create',
'edit',
'delete'
@naiquevin
naiquevin / mysql.py
Created February 5, 2012 15:10
Examples of Mysql programming in Python
#!/usr/bin/env python
## Mysql-Python basic examples.
## All code is taken from [here](http://zetcode.com/databases/mysqlpythontutorial/)
## Gist created only for quick reference purpose
import sys
import _mysql
import MySQLdb as mdb
@naiquevin
naiquevin / mirrors.sh
Created June 16, 2012 08:33
Setting up and maintaining Git repository mirrors
#!/bin/bash
## This shell script will read all names from repos.txt
## which are names of git repositories located at
## git@main-reposerver:/path/to/repos
## if a mirror is not created, it will create
##
## other wise it will try to update the mirror
##
## Main purpose of having mirrors is backup so pushing
@naiquevin
naiquevin / dummy.php
Created June 18, 2012 06:49
Kodemall Cache examples
<?php
class DummyCacheBackend implements CacheBackend {
public function get($key) {
return array();
}
public function set($key, $value) {
return;
@naiquevin
naiquevin / notes.txt
Created August 15, 2012 15:27
Tuple based tree implementation in Erlang (from LYSE) and Python
The no. of lines in erlang implementation is half that in python!
Observe how pattern matching alone gets rid of the selector functions
@naiquevin
naiquevin / multilevelsort.py
Created August 29, 2012 03:49
Multi Level sorting example in Python
#!/usr/bin/env python
## An alternative approach for sorting list of dicts by multiple
## levels of criteria
## Original example: http://sleepythread.blogspot.in/2012/08/sorting-hash-on-more-than-one-key-with.html
import pprint
pp = pprint.PrettyPrinter(indent=4)
@naiquevin
naiquevin / currencies.json
Created September 1, 2012 06:48
Various currencies in json format and code for scraping data and using it in KodeCRM
[
{
"symbol": "Lek",
"code": "ALL",
"uhex": [
"4c",
"65",
"6b"
],
"name": "Albania Lek"
.myKodecrmButton {
display: block;
background: #08C;
color: #fff;
padding: 5px;
}
@naiquevin
naiquevin / middleware.py
Created November 3, 2012 07:01
Examples for i18n using Django middleware blog post
class ChatLocaleMiddleware(object):
def process_request(self, request):
if request.path in ['/jsi18n/']:
return None
match = SHOPPER_CHAT_PATH.match(request.path)
if match is not None:
appid = match.groups()[0]
try:
store = Store.objects.get(appid=appid)
@naiquevin
naiquevin / app.py
Created November 11, 2012 17:49
Dynamic index view for a Flask app
# View for generating a dynamic index page for the Flask app.
# Note: Function name used as title and docstring used as description
# so choose them accordingly
@app.route('/')
def index():
"""Index
"""
def title(r):
return r.endpoint.replace('_', ' ').title()