Skip to content

Instantly share code, notes, and snippets.

Spine = require('spine')
Milk = require('milk/milk')
$ = Spine.$
class Payforms extends Spine.Controller
constructor: ->
super
@current = null
# include view is here!!!!
Spine = require('spine')
Milk = require('milk/milk')
$ = Spine.$
Ticket = require('models/ticket')
class Payforms extends Spine.Controller
constructor: ->
super
@current = null
data = [1,2,3,4,5]
# take x if not divided to 2
result = [ x for x in data if x % 2 ]
# take x * 2 if result not divided 3
result = [ x * 2 for x in result if (x * 2) % 3 ]
@sakal
sakal / freeze
Created February 24, 2012 12:22
BeautifulSoup==3.2.1
Chameleon==2.7.3
CherryPy==3.2.2
Django==1.3.1
Jinja2==2.6
Mako==0.6.2
MarkupSafe==0.15
Paste==1.7.5.1
PasteDeploy==1.5.0
PasteScript==1.7.4.2
class A():
def __init__(self):
self._label()
def _label(self):
self.show("A::_label")
def show(self, msg):
print msg
>>> t =json.dumps({'k1':1, 'k2':[1,2,3], 'k3':'blah', 'k4': None})
>>> t
'{"k3": "blah", "k2": [1, 2, 3], "k1": 1, "k4": null}'
>>> json.loads(t)
{u'k3': u'blah', u'k2': [1, 2, 3], u'k1': 1, u'k4': None}
>>> con.hmset("test:hm", {'t':t})
True
>>> v=con.hmget("test:hm", 't')
>>> v
['{"k3": "blah", "k2": [1, 2, 3], "k1": 1, "k4": null}']
@sakal
sakal / gist:2293824
Created April 3, 2012 17:18
Gen pass on python
from random import choice
import string
def genpass(length=16, chars=string.letters+string.digits):
return ''.join(choice(chars) for i in xrange(length))
if '__main__' == __name__:
print genpass()
import subprocess
cmd = ["notify-send", "--hint=int:transient:1", '"Hello"', "-i", "/home/roman/multimedia/img/avatar_100x100_lj.jpg"]
subprocess.call(cmd)
@sakal
sakal / class_a.cpp
Created May 16, 2012 14:37
Use object as param for class method in cpp
#include <stdio.h>
#include "class_a.h"
A::A(void) {
}
A::~A(void) {
}
src = [{"id":1, "value":2}, {"id":3, "value":4}]
tmp_list = []
for item in src:
tmp_list.append({"id": item["id"], "value": item["value"]})
result = tuple(tmp_list)