Skip to content

Instantly share code, notes, and snippets.

View hfaran's full-sized avatar

Hamza Faran hfaran

View GitHub Profile
@didip
didip / supervisord-example.conf
Created January 30, 2011 05:10
Example configuration file for supervisord.conf
[unix_http_server]
file=/tmp/supervisor.sock ; path to your socket file
[supervisord]
logfile=/var/log/supervisord/supervisord.log ; supervisord log file
logfile_maxbytes=50MB ; maximum size of logfile before rotation
logfile_backups=10 ; number of backed up logfiles
loglevel=error ; info, debug, warn, trace
pidfile=/var/run/supervisord.pid ; pidfile location
nodaemon=false ; run supervisord as a daemon
@hrldcpr
hrldcpr / tree.md
Last active March 27, 2024 14:40
one-line tree in python

One-line Tree in Python

Using Python's built-in defaultdict we can easily define a tree data structure:

def tree(): return defaultdict(tree)

That's it!

@hellerbarde
hellerbarde / latency.markdown
Created May 31, 2012 13:16 — forked from jboner/latency.txt
Latency numbers every programmer should know

Latency numbers every programmer should know

L1 cache reference ......................... 0.5 ns
Branch mispredict ............................ 5 ns
L2 cache reference ........................... 7 ns
Mutex lock/unlock ........................... 25 ns
Main memory reference ...................... 100 ns             
Compress 1K bytes with Zippy ............. 3,000 ns  =   3 µs
Send 2K bytes over 1 Gbps network ....... 20,000 ns  =  20 µs
SSD random read ........................ 150,000 ns  = 150 µs

Read 1 MB sequentially from memory ..... 250,000 ns = 250 µs

@jlewin
jlewin / countTabs.js
Last active March 7, 2023 17:21
Count of open tabs in Chrome
chrome.windows.getAll({populate: true}, function(allWindows)
{
console.log(allWindows);
});
@willurd
willurd / web-servers.md
Last active March 26, 2024 18:11
Big list of http static server one-liners

Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.

Discussion on reddit.

Python 2.x

$ python -m SimpleHTTPServer 8000
@Neal
Neal / putiodl
Created July 17, 2013 02:53
put.io cli downloader
#!/bin/bash
#
# putiodl - put.io cli downloader
#
# Copyright (C) 2013 Neal <neal@ineal.me>
#
# Dependencies: jq, curl, wget
#
# Make sure ~/.putiodl exists and contains your put.io OAuth token.
#
@vdavez
vdavez / docx2md.md
Last active August 6, 2023 08:58
Convert a Word Document into MD

Converting a Word Document to Markdown in Two Moves

The Problem

A lot of important government documents are created and saved in Microsoft Word (*.docx). But Microsoft Word is a proprietary format, and it's not really useful for presenting documents on the web. So, I wanted to find a way to convert a .docx file into markdown.

The Solution

As it turns out, there are several open-source tools that allow for conversion between file types. Pandoc is one of them, and it's powerful. In fact, pandoc's website says "If you need to convert files from one markup format into another, pandoc is your swiss-army knife." But, although pandoc can convert from markdown into .docx, it doesn't work in the other direction.

@mrkline
mrkline / c_sharp_for_python.md
Last active March 9, 2024 20:09
An intro to C# for a Python developer. Made for one of my coworkers.

C# For Python Programmers

Syntax and core concepts

Basic Syntax

  • Single-line comments are started with //. Multi-line comments are started with /* and ended with */.

  • C# uses braces ({ and }) instead of indentation to organize code into blocks. If a block is a single line, the braces can be omitted. For example,

@jegger
jegger / Kivy_on_Mac_10.9.2
Last active November 9, 2020 22:58
Install kivy into a virtualenv on Mac 10.9 Mavericks
# Inspired by:
# - https://gist.github.com/goldsmith/7262122
# - https://gist.github.com/brousch/6589386
#### Some hints ####
# Currently kivy apps only work on monitor 1 (multiple monitor setup)
# You have to place the terminal which runs kivy on the monitor 1 or make the app fullscreen.
# Make sure you have the "command line tools" for mavericks installed!
# (xcode-select --install)
@CamDavidsonPilon
CamDavidsonPilon / 538.json
Last active November 28, 2021 07:37
Use the two files below to mimic graphs on 538. www.dataorigami.net/blogs/fivethirtyeight-mpl
{
"lines.linewidth": 2.0,
"examples.download": true,
"patch.linewidth": 0.5,
"legend.fancybox": true,
"axes.color_cycle": [
"#30a2da",
"#fc4f30",
"#e5ae38",
"#6d904f",