Skip to content

Instantly share code, notes, and snippets.

@jargnar
jargnar / style.mss
Last active May 4, 2017 03:35
Example carto css
Map {
background-color: #444;
}
#countries {
::outline {
line-color: #aaa;
line-width: 1;
line-join: round;
}
@jargnar
jargnar / BinaryTreeMinDepth.java
Last active March 21, 2017 11:27
Minimum Depth of a Binary Tree
/**
* Created by suhas on 21/03/17.
*/
class BinaryTree<T> {
class Node<T> {
T val;
BinaryTree left;
BinaryTree right;
Node(T val, BinaryTree left, BinaryTree right) {

What I Wish I'd Known About Equity Before Joining A Unicorn

Disclaimer: This piece is written anonymously. The names of a few particular companies are mentioned, but as common examples only.

This is a short write-up on things that I wish I'd known and considered before joining a private company (aka startup, aka unicorn in some cases). I'm not trying to make the case that you should never join a private company, but the power imbalance between founder and employee is extreme, and that potential candidates would

@jargnar
jargnar / webpack.config.js
Created October 23, 2016 10:32
Sample webpack config
var HtmlWebpackPlugin = require('html-webpack-plugin');
var HtmlWebpackPluginConfig = new HtmlWebpackPlugin({
template: __dirname + '/app/index.html',
filename: 'index.html',
inject: 'body'
});
var CopyWebpackPlugin = require('copy-webpack-plugin');
var CopyWebpackPluginConfig = new CopyWebpackPlugin([
{
@jargnar
jargnar / get_state_for_district.py
Created July 16, 2016 16:12
Querying a district_code to state_code lookup service
import json
import requests
def get_state_for_district(district_code):
'''
Queries a hypothetical URL endpoint of the following form:
/lookup?level=district&parent=state&district=<district_code>
and retrieves a state_code for the given district_code
'''
@jargnar
jargnar / topo.html
Created June 4, 2016 08:25
Custom TopoJSON and Leaflet.js
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Custom map</title>
<link rel="stylesheet" href="http://cdn.leafletjs.com/leaflet/v0.7.7/leaflet.css" />
</head>
<body>
<div id="map" style="width: 100%; height: 400px; margin-bottom: 1.5em;"></div>
@jargnar
jargnar / Test.Volume.Dockerfile
Created April 12, 2016 08:27
Example Docker image for testing volume mounts
FROM busybox
MAINTAINER Suhas SG <suhas@suhas.co>
RUN mkdir /var/lib
RUN touch /var/lib/data.txt
VOLUME ["/var/lib"]
@jargnar
jargnar / checkcmd.sh
Last active April 12, 2016 07:31
Check if a command exists in linux
#!/bin/bash
if [ $# -eq 0 ]; then
printf "Please specify the command to check for.\n"
printf "Example:\n"
printf "$ ./checkcmd.sh docker\n"
else
if sudo command -v $1 >/dev/null 2>&1; then
printf "Yay! $1 exists.\n"
else
@jargnar
jargnar / deletestuffast.py
Last active March 20, 2021 16:12
Parse a Python AST and delete stuff from it
import ast
class RemoveMethod(ast.NodeTransformer):
'''
Removes all occurences of a method from the AST
Example:
---
tree = RemoveMethod('bar').visit(tree)
x = foo.bar() => x = foo
@jargnar
jargnar / function_calls_ast.py
Created March 8, 2016 16:53
Lists all function calls in a python file
'''
Get all function calls from a python file
The MIT License (MIT)
Copyright (c) 2016 Suhas S G <jargnar@gmail.com>
'''
import ast
from collections import deque