Skip to content

Instantly share code, notes, and snippets.

View dsully's full-sized avatar

Dan Sully dsully

View GitHub Profile
@Schnouki
Schnouki / popcorntime-vpn.sh
Last active November 12, 2024 00:33
OpenVPN for a single application using network namespaces -- helper scripts
#!/usr/bin/env zsh
# Initialize VPN
sudo vpnns up
sudo vpnns start_vpn
# Popcorn time!
sudo ip netns exec frootvpn sudo -u $USER popcorntime
# Cleanup
@voidfiles
voidfiles / secmatics_to_json_schema.py
Created November 8, 2014 00:11
Schematics to JSONSchema
import json
from schematics.types.base import (BaseType, NumberType, IntType, LongType, FloatType,
DecimalType, BooleanType)
from schematics.types.compound import ModelType, ListType
__version__ = '1.0'
SCHEMATIC_TYPE_TO_JSON_TYPE = {
@Zearin
Zearin / python_decorator_guide.md
Last active August 25, 2025 07:22
The best explanation of Python decorators I’ve ever seen. (An archived answer from StackOverflow.)

NOTE: This is a question I found on StackOverflow which I’ve archived here, because the answer is so effing phenomenal.


Q: How can I make a chain of function decorators in Python?


If you are not into long explanations, see [Paolo Bergantino’s answer][2].

@agronholm
agronholm / gist:84e4e31621e07b9e12f3
Last active August 29, 2015 14:01
A minimal replacement for Flask-SQLAlchemy
from sqlalchemy.engine import create_engine
from sqlalchemy.orm.scoping import scoped_session
from sqlalchemy.orm.session import sessionmaker
class SQLAlchemy:
def __init__(self, app=None):
if app is not None:
self.init_app(app)
@L422Y
L422Y / osx_automount_nfs.md
Last active September 6, 2025 03:43
Automounting NFS share in OS X into /Volumes

I have spent quite a bit of time figuring out automounts of NFS shares in OS X...

Somewhere along the line, Apple decided allowing mounts directly into /Volumes should not be possible:

/etc/auto_master (see last line):

#
# Automounter master map
#

+auto_master # Use directory service

On the relative value of startup stock

How do you compare the potential value of different stage companies? And as a company progresses what is the appropriate amount of stock to give new employees?

Using data from Crunchbase and Yahoo Finance we can calculate the average value created per company broken down by how much money they have raised. From this we can then compute relative returns at the different stages, e.g. $1M raised, $10M, $100M, etc.

tl;dr

For this exercise we'll calibrate relative to expected return from a company that's raised $1M.

require 'rubygems'
require 'mechanize'
FIRST_NAME = 'FIRST_NAME'
LAST_NAME = 'LAST_NAME'
PHONE = 'PHONE'
EMAIL = '[email protected]'
PARTY_SIZE = 2
SCHEDULE_RANGE = { :start_time => '19:00', :end_time => '20:30' }
import collections
import json
import redis
import threading
from tornado import gen
from tornado import ioloop
from tornado import web
from tornado.options import define
from tornado.options import options
import tornadoredis
#pragma comment (lib, "libuv.lib")
#pragma comment (lib, "ws2_32.lib")
#pragma comment(lib, "psapi.lib")
#pragma comment(lib, "Iphlpapi.lib")
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include "../../lib/libuv/include/uv.h"
#include "http_parser.h"
class TrapLoop
trap('TERM') { stop! }
trap('INT') { stop! }
trap('SIGTERM') { stop! }
def self.stop!
@loop = false
end
def self.safe_exit_point!