Skip to content

Instantly share code, notes, and snippets.

@bhaskar-c
bhaskar-c / Makefile
Created September 16, 2020 15:52 — forked from isaacs/Makefile
# Hello, and welcome to makefile basics.
#
# You will learn why `make` is so great, and why, despite its "weird" syntax,
# it is actually a highly expressive, efficient, and powerful way to build
# programs.
#
# Once you're done here, go to
# http://www.gnu.org/software/make/manual/make.html
# to learn SOOOO much more.
@bhaskar-c
bhaskar-c / gist:a567acd868a01d31fd632bb3c9c7de55
Created December 22, 2018 17:03 — forked from paales/gist:6682242
rsync a Magento installation
rsync -chavzP --exclude='path/to/installation/var/cache' --exclude='path/to/installation/.git' --exclude='path/to/installation/media/catalog/product/cache' --exclude='path/to/installation/var/tmp' --exclude='path/to/installation/var/session' --exclude='kiboots/var/report' --stats username@host:path/to/installation /destination/path
from tkinter import *
import asyncio
from functools import wraps
import websockets
def runloop(func):
'''
This decorator converts a coroutine into a function which, when called,
runs the underlying coroutine to completion in the asyncio event loop.
'''
"""
This is a batched LSTM forward and backward pass
"""
import numpy as np
import code
class LSTM:
@staticmethod
def init(input_size, hidden_size, fancy_forget_bias_init = 3):
@bhaskar-c
bhaskar-c / setup.py
Created January 29, 2016 17:47
Flask app's cx_freeze's setup.py file.
from cx_Freeze import setup, Executable
include_files = [ 'app/templates/',
'app/static/',]
# Note: without 'jinja2.ext' in this list, we won't get the templates working.
include = [ 'jinja2', 'jinja2.ext',]
flaskapp = Executable(script="run.py",
base="Win32GUI",
@bhaskar-c
bhaskar-c / tornado-flash-message-mixin.py
Created December 3, 2015 07:47 — forked from pplante/tornado-flash-message-mixin.py
Store a message between requests which the user needs to see. Similar to the functionality available in Django/Rails.
# Copyright (c) 2011 Phil Plante <unhappyrobot AT gmail DOT com>
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
@bhaskar-c
bhaskar-c / gist:01f8bb4ce6ae58d0a712
Created November 15, 2015 06:46 — forked from kaizhu256/gist:4482069
javascript - very fast and simple uuid4 generator benchmarked on http://jsperf.com/uuid4/8
/*jslint bitwise: true, indent: 2, nomen: true, regexp: true, stupid: true*/
(function () {
'use strict';
var exports = {};
exports.uuid4 = function () {
//// return uuid of form xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx
var uuid = '', ii;
for (ii = 0; ii < 32; ii += 1) {
@bhaskar-c
bhaskar-c / tornado-long-polling.py
Created November 10, 2015 06:41 — forked from stevepeak/tornado-long-polling.py
Tornado Long-Polling Example
from time import sleep
from tornado.httpserver import HTTPServer
from tornado.ioloop import IOLoop
from tornado.web import Application, asynchronous, RequestHandler
from multiprocessing.pool import ThreadPool
_workers = ThreadPool(10)
def run_background(func, callback, args=(), kwds={}):
def _callback(result):
@bhaskar-c
bhaskar-c / nginx.conf
Created October 4, 2015 16:50 — forked from neara/nginx.conf
nginx configuration file for example, including web sockets supports
user nginx;
worker_processes 1;
error_log /var/log/nginx/error.log;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
use epoll;
}
# install sysbench
$ apt-get install sysbench
# CPU benchmark, 1 thread
$ sysbench --test=cpu --cpu-max-prime=20000 run
# CPU benchmark, 64 threads
$ sysbench --test=cpu --cpu-max-prime=20000 --num-threads=64 run
# Disk benchmark, random read. See .fio files in this gist