Skip to content

Instantly share code, notes, and snippets.

View jasonlai's full-sized avatar

Jason Lai jasonlai

  • San Francisco Bay Area, CA
View GitHub Profile
@jasonlai
jasonlai / telnet-backend.sh
Last active March 27, 2018 20:18
Poor man's telnet server in Bash
# Session 3
sudo setsid bash -l < /var/run/my-telnet > /var/run/my-telnet 2>&1 # Bash expects itself as a session leader
#!/sbin/sysctl -p
kernel.grsecurity.chroot_caps = 0
kernel.grsecurity.chroot_deny_mount = 0
@jasonlai
jasonlai / BUILD
Created June 16, 2017 10:22
Adhoc Mesos Executor
python_library(
name='executor',
sources=rglobs('*.py'),
dependencies=[
'3rdparty/python:mesos.executor',
'3rdparty/python:mesos.interface',
'3rdparty/python:pex',
'3rdparty/python:protobuf',
],
provides=setup_py(
@jasonlai
jasonlai / mesos-agent-task-run-call-graph.rs
Last active January 6, 2019 01:28
Mesos Agent task run call graph
Slave::run(FrameworkInfo&, ExecutorInfo, Option<TaskInfo>, Option<TaskGroupInfo>, UPID&);
|-> Slave::unschedule(path: string&) -> Future<bool>; // path = paths::getFrameworkPath(work_dir: string&, SlaveID&, FrameworkID&) -> string;
|-> Slave::unschedule(path: string&) -> Future<bool>; // path = paths::getFrameworkPath(metaDir: string&, SlaveID&, FrameworkID&) -> string;
|-> Slave::unschedule(path: string&) -> Future<bool>; // path = paths::getExecutorPath(work_dir: string&, SlaveID&, FrameworkID&, ExecutorID&) -> string;
|-> Slave::unschedule(path: string&) -> Future<bool>; // path = paths::getExecutorPath(metaDir: string&, SlaveID&, FrameworkID&, ExecutorID&) -> string;
\-> Slave::_run(Future<bool>&, FrameworkInfo&, ExecutorInfo&, Option<TaskInfo>&, Option<TaskGroupInfo>&);
|-> Slave::authorizeTask(TaskInfo&, FrameworkInfo&) -> Future<bool>;
\-> Slave::__run(Future<list<bool>>&, FrameworkInfo&, ExecutorInfo&, Option<TaskInfo>&, Option<TaskGroupInfo>&);
|-> Slave::launchExecutor(Option<Future<
@jasonlai
jasonlai / build-mesos.sh
Created April 8, 2017 20:21
Mesos build scripts with Docker
echo 'deb http://httpredir.debian.org/debian jessie-backports main contrib non-free' >> /etc/apt/sources.list
apt-get update
apt-get install -y apt-transport-https ca-certificates
apt-get install -y linux-image-4.7.0-0.bpo.1-amd64 linux-headers-4.7.0-0.bpo.1-amd64 linux-base=4.3~bpo8+1
apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 58118E89F3A912897C070ADBF76221572C52609D
echo 'deb https://apt.dockerproject.org/repo debian-jessie main' > /etc/apt/sources.list.d/docker.list
apt-get update
apt-get install -y docker-engine
@jasonlai
jasonlai / erb-render.rb
Created December 31, 2014 07:12
Utility Ruby script to render ERB templates, loading a JSON file as source for instance variables (useful when you need to debug Puppet templates)
#!/usr/bin/env ruby
require 'erb'
require 'json'
require 'optparse'
require 'ostruct'
class ERBContext
def initialize(hash)
raise ArgumentError, 'hash must be a Hash object' unless hash.is_a?(::Hash)
@jasonlai
jasonlai / tax_change_graph.py
Created April 26, 2011 07:32
Taxes Calculator
#!/usr/bin/env python
# This snippet generates a chart showing tax changes after China's 2011 Individual Income Tax Adjustment Draft.
# Both NumPy & PyLab are required here. Please make sure you have these libs installed.
import sys
from pylab import arange, array, frompyfunc, plot, show
from taxes import NEW_THRESHOLD, NEW_TAX_LEVELS, OLD_THRESHOLD, OLD_TAX_LEVELS, income_tax