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 sqlite3 as lite | |
from random import randint | |
def real_random(total): | |
result = [] | |
while True: | |
new_value = randint(1, 10000) | |
if new_value not in result: | |
result.append(new_value) |
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
%timeit [0, 1, 2, 3, 4, 5] | |
10000000 loops, best of 3: 113 ns per loop | |
%timeit (0, 1, 2, 3, 4, 5) | |
100000000 loops, best of 3: 17.4 ns per loop | |
%timeit {0:0, 1:1, 2:2, 3:3, 4:4, 5:5} | |
1000000 loops, best of 3: 410 ns per loop | |
lista = [0, 1, 2, 3, 4, 5] |
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
class middleware_mongodb(object): | |
def __init__(self, db=None): | |
self.db = db | |
def __getattr__(self, attr): | |
if attr in dir(self.db): | |
return getattr(self.db, attr) | |
return middleware_mongodb(self.db.__getattr__(attr)) | |
# rewrite methods |
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
#check python https://gist.github.com/kianxineki/aa10199ba96d0d4009c6 | |
def append_values(new_value,a=[]) | |
a.push(new_value) | |
return a | |
end | |
append_values("n1") # result ['n1'] | |
rlist = append_values("n2") # result ['n2'] | |
rlist.push("n3") | |
print rlist # result ['n2', 'n3'] |
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
#default values in ruby https://gist.github.com/kianxineki/8b13ebc8816623f4a650 | |
def append_values(new_value, a=[]): | |
a.append(new_value) | |
return a | |
append_values("n1") # result ['n1'] | |
rlist = append_values("n2") # result ['n1', 'n2'] | |
rlist.append("n3") | |
print(rlist) # result ['n1', 'n2', 'n3'] | |
append_values("n4") # result ['n1', 'n2', 'n3', 'n4'] |
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 | |
# -*- coding: utf-8 -*- | |
import sys | |
from bottle import run, get | |
@get('/test') | |
def test(): | |
return "test" |
NewerOlder