This file contains hidden or 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 | |
| def busy_sleep(n): | |
| while n > 0: | |
| n -= 1 | |
| N = 99999999 | |
| t1 = Thread(target=busy_sleep, args=(N, )) |
This file contains hidden or 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 tornado.httpserver | |
| import tornado.ioloop | |
| import tornado.options | |
| import tornado.web | |
| class BaseHandler(tornado.web.RequestHandler): | |
| pass | |
| class HandlerMixin(object): | |
| listeners = [] |
This file contains hidden or 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 Gist is for my post: http://www.andretw.com/2013/10/What-you-should-know-before-using-DataTables.html |
This file contains hidden or 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 collections import namedtuple | |
| from pymongo import MongoClient | |
| from flask import request | |
| from core.web.site import app | |
| from core.web.site.views_master import * | |
| import json | |
| ''' | |
| $('#companies').dataTable( { | |
| "bProcessing": true, |
This file contains hidden or 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
| #Newbie programmer | |
| def factorial(x): | |
| if x == 0: | |
| return 1 | |
| else: | |
| return x * factorial(x - 1) | |
| print factorial(6) | |
| #First year programmer, studied Pascal |
This file contains hidden or 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 BaseRequestHandler(tornado.web.RequestHandler): | |
| '''An non-blocking process | |
| Example usage: | |
| class MainHandler(srmlib.BaseRequestHandler): | |
| @tornado.web.asynchronous | |
| def get(self): | |
| self.call_subprocess('sleep 5; cat /var/run/syslog.pid', self.async_callback(self.on_response)) |
This file contains hidden or 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 os | |
| import string | |
| import time | |
| import logging | |
| from datetime import datetime | |
| import tornado.httpserver | |
| import tornado.ioloop | |
| import tornado.options | |
| import tornado.web |
This file contains hidden or 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
| #!/bin/bash | |
| set -e | |
| # Clean out /var/cache/apt/archives | |
| apt-get clean | |
| # Fill it with all the .debs we need | |
| apt-get --reinstall -dy install $(dpkg --get-selections | grep '[[:space:]]install' | cut -f1) | |
| DIR=$(mktemp -d -t info-XXXXXX) | |
| for deb in /var/cache/apt/archives/*.deb |
This file contains hidden or 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 BetterMap(object): | |
| def __init__(self,n=100): | |
| self.maps=[] | |
| for i in range(n): | |
| self.maps.append(LinearMap()) | |
| def find_map(self,k): | |
| index=hash(k)%len(self.maps) | |
| return self.maps[index] | |
This file contains hidden or 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> | |
| main() | |
| { | |
| struct A { | |
| int a; | |
| char b; | |
| short c; | |
| }; |