Skip to content

Instantly share code, notes, and snippets.

"""
An updated version of https://gist.github.com/markshannon/da7588db3c883dc2006a727a10e00ca5.
"""
import timeit
import sys
def foo():
for i in range(100_000):
if i == 50_000:
import time
import threading
def set_timeout(delay, callback):
def target():
time.sleep(delay)
callback()
threading.Thread(target=target).start()
#!/use/bin/env perl
use strict;
# Usage:
# ls -l <path> | perl lsbasename.pl
while (<STDIN>) {
chomp;
my $original = $_;
my @chunks = split / /;
@avli
avli / Monoid.json
Last active August 1, 2020 12:58
High contrast theme for iTerm2 that uses the IntelliJ IDEA high contrast theme colors
{
"Ansi 5 Color" : {
"Red Component" : 1,
"Color Space" : "sRGB",
"Blue Component" : 1,
"Alpha Component" : 1,
"Green Component" : 0.58823529411764708
},
"Tags" : [
@avli
avli / calc.py
Created May 2, 2020 14:59
An arithmetic expression evaluator in Python.
"""
An arithmetic expression evaluator in Python.
The language grammar:
prog : expr ;
expr : NUMBER ('+'|'-' NUMBER)* NEWLINE;
NUMBER : '0'..'9'+ ;
NEWLINE : '\n' ;
{
"global": {
"check_for_updates_on_startup": false,
"show_in_menu_bar": true,
"show_profile_name_in_menu_bar": false
},
"profiles": [
{
"complex_modifications": {
"parameters": {
@avli
avli / README.md
Last active July 26, 2018 10:10
Docker Interaction Between Stacks

Docker Interaction Between Stacks

First create an overlay network:

docker network create -d overlay uber-net

Now deploy two stacks:

Python Pip Git Dependencies

To add a Git dependency:

pip install git+https://github.com/account/repo@tag#egg=package_name

or

@avli
avli / ndvi.py
Created December 20, 2017 12:50 — forked from celoyd/ndvi.py
#!/usr/bin/env python
# ndvi.py red.tif nir.tif output-ndvi.tif
# Calculate NDVI (see Wikipedia). Assumes atmospheric correction.
# (Although I use it without all the time for quick experiments.)
import numpy as np
from sys import argv
from osgeo import gdal, gdalconst
@avli
avli / nginxproxy.md
Created October 14, 2017 19:25 — forked from soheilhy/nginxproxy.md
How to proxy web apps using nginx?

Virtual Hosts on nginx (CSC309)

When hosting our web applications, we often have one public IP address (i.e., an IP address visible to the outside world) using which we want to host multiple web apps. For example, one may wants to host three different web apps respectively for example1.com, example2.com, and example1.com/images on the same machine using a single IP address.

How can we do that? Well, the good news is Internet browsers