This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class="frm-item" jsselect="$this"> | |
<label jscontent="$this"></label><br /> | |
<input type="text" jsvalues="value:$item[$this]"><br /> | |
</div> | |
<script> | |
jq("a.item-result").live('click', function() { | |
var itemid = jq(this).attr('itemid'); | |
var baseurl = 'proxy.php?url=http://localhost:9999/item'; | |
jq.getJSON(baseurl + '/' + itemid, function(json) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class QBuilderCondition { | |
protected $conjunction = 'AND'; | |
protected $wheres = array(); | |
public function __construct($conjunction = 'AND') { | |
$this->conjunction = $conjunction; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function modulename_theme($existing, $type, $theme, $path) { | |
return array( | |
'formtemplate_horizontal' => array( | |
'arguments' => array('form' => NULL), | |
), | |
); | |
} | |
function theme_formtemplate_horizontal($form) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
from optparse import OptionParser | |
from os.path import join, dirname, abspath | |
from string import Template | |
import os, sys | |
parser = OptionParser() | |
parser.add_option("-a", "--address", default="127.0.0.1", help="Server address to listen") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import redis | |
class KVStore: | |
def __init__(self, prefix, host='localhost', port=6379, **params): | |
self._prefix = prefix | |
self._db = redis.Redis(host=host, port=port) | |
def _get_prefix(self, key): | |
return '%s:%s' % (self._prefix, key) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from flask import Flask, request, session | |
from sqlalchemy import create_engine, Table, MetaData | |
from sqlalchemy.orm import mapper, relationship, sessionmaker, scoped_session | |
from sqlalchemy.sql import select | |
app = Flask(__name__) | |
engine = create_engine('postgresql+psycopg2://kamal@localhost/clinic_dev') | |
metadata = MetaData(bind=engine) | |
DBSession = scoped_session(sessionmaker(bind=engine)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def transact(func): | |
""" | |
Usage: | |
@transaction.commit_manually | |
@transact | |
def some_function(a, b): | |
do_something() | |
""" | |
def decorated(*args, **kwargs): | |
try: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Django in single file with model and admin. Based on:- | |
http://fahhem.com/blog/2011/10/django-models-without-apps-or-everything-django-truly-in-a-single-file/ | |
""" | |
import sys | |
from os import path as osp | |
def rel_path(*p): return osp.normpath(osp.join(rel_path.path, *p)) | |
rel_path.path = osp.abspath(osp.dirname(__file__)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
This use mini_django.py, sort of micro framework based on django. | |
""" | |
import mini_django | |
mini_django.configure() | |
from django.db import models | |
from django.contrib import admin | |
from django.http import HttpResponse |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.db import transaction | |
def transaction_commit_manually_wrapper(func): | |
"""Wrapper to transaction.commit_manually so that we can reraise any | |
uncaught exception instead of getting TransactionManagementError. | |
Ref - https://code.djangoproject.com/ticket/6623 | |
""" | |
@transaction.commit_manually | |
def func_wrapper(*args, **kwargs): |
OlderNewer