Skip to content

Instantly share code, notes, and snippets.

View icsaas's full-sized avatar
🎯
saasing

iac icsaas

🎯
saasing
View GitHub Profile
@icsaas
icsaas / par.py
Created February 14, 2014 06:33 — forked from lbolla/par.py
from threading import Thread
def busy_sleep(n):
while n > 0:
n -= 1
N = 99999999
t1 = Thread(target=busy_sleep, args=(N, ))
import tornado.httpserver
import tornado.ioloop
import tornado.options
import tornado.web
class BaseHandler(tornado.web.RequestHandler):
pass
class HandlerMixin(object):
listeners = []
This Gist is for my post: http://www.andretw.com/2013/10/What-you-should-know-before-using-DataTables.html
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,
#Newbie programmer
def factorial(x):
if x == 0:
return 1
else:
return x * factorial(x - 1)
print factorial(6)
#First year programmer, studied Pascal
@icsaas
icsaas / processhandler.py
Created March 18, 2014 06:47
nonblocking process in tornado
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))
@icsaas
icsaas / app.py
Last active August 29, 2015 13:57
long polling in tornado
import os
import string
import time
import logging
from datetime import datetime
import tornado.httpserver
import tornado.ioloop
import tornado.options
import tornado.web
@icsaas
icsaas / fix.sh
Created March 31, 2014 01:35
dpkg: warning: files list file for package `*****' missing, assuming package has no files currently installed
#!/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
@icsaas
icsaas / BetterMap.py
Last active August 29, 2015 13:59
HashTable implemented by python
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]
#include <stdio.h>
main()
{
struct A {
int a;
char b;
short c;
};