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" |
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
#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
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
%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
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
#include <stdio.h> | |
#include <pthread.h> | |
void* calculate() | |
{ | |
int i = 0; | |
int b = 0; | |
for(i=0; i<100000000; i++){ | |
b = i+b; | |
} |
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
#include <Python.h> | |
#include <stdio.h> | |
#include <string.h> | |
typedef struct { | |
PyObject_HEAD | |
char* trans; | |
int len_letters; | |
char* letters; | |
int repeat; |
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 threading import Thread | |
import sys | |
import socket | |
host, port = sys.argv[1], int(sys.argv[2]) | |
connect_per_thread = int(sys.argv[4]) | |
def many_connection(): | |
while True: | |
sockets = [] |
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 tornado.httpserver import HTTPServer | |
import tornado.ioloop | |
import tornado.web | |
import uuid | |
from tornado.concurrent import run_on_executor | |
from concurrent.futures import ThreadPoolExecutor | |
@tornado.web.stream_request_body | |
class MainHandler(tornado.web.RequestHandler): | |
executor = ThreadPoolExecutor(max_workers=400) |
OlderNewer