Skip to content

Instantly share code, notes, and snippets.

View aenon's full-sized avatar

Xilin Sun aenon

  • Nvidia
  • San Jose, CA
  • 03:06 (UTC -07:00)
View GitHub Profile

Docker Cheat Sheet

Why Docker

"With Docker, developers can build any app in any language using any toolchain. “Dockerized” apps are completely portable and can run anywhere - colleagues’ OS X and Windows laptops, QA servers running Ubuntu in the cloud, and production data center VMs running Red Hat.

Developers can get going quickly by starting with one of the 13,000+ apps available on Docker Hub. Docker manages and tracks changes and dependencies, making it easier for sysadmins to understand how the apps that developers build work. And with Docker Hub, developers can automate their build pipeline and share artifacts with collaborators through public or private repositories.

Docker helps developers build and ship higher-quality applications, faster." -- What is Docker

@aenon
aenon / server.py
Last active September 8, 2019 19:37 — forked from dragermrb/server.py
Python 3 HTTP Server with Basic Authentication
import http.server
import cgi
import base64
import json
from urllib.parse import urlparse, parse_qs
class CustomServerHandler(http.server.BaseHTTPRequestHandler):
def do_HEAD(self):
@aenon
aenon / TreeNode.md
Last active February 17, 2018 21:44
Tree Node in JavaScript

Tree Node in JavaScript

Implementation

const TreeNode = val => {
    let value = val
    let children = []
    const getValue = () => value
    const getChildren = () => children
    const setValue = newVal => {value = newVal}
 const addChild = childNode => {children.push(childNode)}
@aenon
aenon / createSinglyLinkedList.js
Created February 16, 2018 10:52
Linked List in JavaScript
var createSLL = () => {
let head = null
const getHead = () => head
const push = value => {
let node = {value, next: null}
if (!head) {
head = node
}
@aenon
aenon / defaultObj.md
Created February 15, 2018 22:08
defaultObj - JavaScript implementation of Python collections.defaultdict

defaultObj - JavaScript implementation of Python collections.defaultdict

Implementation

const defaultObj = (defaultValue = undefined) => {
    const defaultObj = {}
    const set = (key, value) => {
        defaultObj[key] = value
    }
    const get = key => {
 if (key in defaultObj) {
# bz2
import bz2
with bz2.BZ2File("myfile.txt.bz2") as f:
line_list = f.readlines()
@aenon
aenon / watchman_xenial.sh
Last active October 19, 2017 20:22
Install Watchman (https://facebook.github.io/watchman) on Ubuntu 16.04 LTS
#!/bin/bash
# watchman_xenial.sh
# installs watchman on Ubuntu 16.04
# working directory
WD="${HOME}/Applications"
# watchman branch to get and install
WATCHMAN_BRANCH="v4.9.0"
@aenon
aenon / Problem "HHT against HTT" (R)
Last active August 29, 2015 13:58
Problem "HHT against HTT" (R)
# This programme tests the "HHT and HTT" probability problem
# by Xilin SUN
NumberofCases <- 50000
cat("Doing a test with ", NumberofCases, " cases.","\n")
CaseHHT <- 0
CaseHTT <- 1
for(i in 1:NumberofCases){
Digit1 <- sample(0:1, 1)
@aenon
aenon / Problem "HHT against HTT" (Python)
Last active August 29, 2015 13:58
Problem "HHT against HTT" (Python)
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# This programme tests the "HHT and HTT" probability problem
# by Xilin SUN
# Problem: A fair coin is tossed consecutively. Once the sequence
# "HHT" appears, person A wins and the game is terminated. Once the
# sequence "HTT" appears, person B wins and the game is also terminated.
# Find the probability that person A wins.