Skip to content

Instantly share code, notes, and snippets.

@suntong
suntong / main.go
Last active August 29, 2015 14:01
// http://play.golang.org/p/FOe85j-O-n
package main
import (
"fmt"
"os"
"time"
)
@suntong
suntong / README.md
Last active December 18, 2015 22:32 — forked from huyng/matplotlibrc
my default matplotlib settings

Source

This is a custom config based on huyng's gist: https://gist.github.com/816622 which implements a nicer color scheme for matplotlib, along with some other styling tweaks.

Problem statement (Aka Goal)

  • The gist was created on Feb 8, 2011. That's old and things have changed
  • Focus on the color scheme tweaking for matplotlib, for the rest use the latest default as much as possible
  • Incorporate all good changes from the following forks:
@suntong
suntong / useful_pandas_snippets.py
Last active July 6, 2016 14:25 — forked from bsweger/useful_pandas_snippets.md
Useful Pandas Snippets
#List unique values in a DataFrame column
pd.unique(df.column_name.ravel())
#Convert Series datatype to numeric, getting rid of any non-numeric values
df['col'] = df['col'].astype(str).convert_objects(convert_numeric=True)
#Grab DataFrame rows where column has certain values
valuelist = ['value1', 'value2', 'value3']
df = df[df.column.isin(value_list)]
@suntong
suntong / udp-port-scanning.txt
Created July 9, 2016 19:55 — forked from benhosmer/udp-port-scanning.txt
UDP Port Troubleshooting using netcat
Using the nc command you can scan a port or a range of ports to verify whether a UDP port is open and able to receive traffic.
This first command will scan all of the UDP ports from 1 to 65535 and add the results to a text file:
$ nc -vnzu server.ip.address.here 1-65535 > udp-scan-results.txt
This merely tells you that the UDP ports are open and receive traffic.
Perhaps a more revealing test would be to actually transfer a file using UDP.
@suntong
suntong / 0_reuse_code.js
Created January 18, 2017 18:23
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@suntong
suntong / simplest.js
Last active February 11, 2018 04:37 — forked from anonymous/simplest.js
gopherjs bare bone js code base
"use strict";
(function() {
Error.stackTraceLimit = Infinity;
var $global, $module;
if (typeof window !== "undefined") { /* web page */
$global = window;
} else if (typeof self !== "undefined") { /* web worker */
$global = self;
@suntong
suntong / foo.go
Created June 7, 2019 23:27 — forked from Merovius/foo.go
////////////////////////////////////////////////////////////////////////////
// Program: dbab-svr
// Purpose: Pixel Server in Go
// Authors: Tong Sun (c) 2019, All rights reserved
////////////////////////////////////////////////////////////////////////////
package main
import (
"bufio"
@suntong
suntong / http.go
Created June 7, 2019 23:37 — forked from AngerM/http.go
High Performance Golang HTTP Client
package utils
import (
"context"
"io"
"io/ioutil"
"net"
"net/http"
"strings"
"time"
@suntong
suntong / git-prompt-color.sh
Last active July 17, 2019 13:28 — forked from goldie-lin/git-bash.awk
git-prompt.sh re-implemented with gawk. >100x faster under git-win (requires git version >= 2.11.0)
#!/usr/bin/env bash
git rev-parse 2>/dev/null && \
git status --porcelain=v2 -b --ignored | gawk '
/^# branch\.head / { head = $0; sub(/# branch\.head /, "", head); next; }
/^# branch\.ab / { match($0, /^# branch\.ab \+([0-9]+) -([0-9]+)$/, ab); ahead = ab[1]; behind = ab[2]; next; }
/^! / { next; } /* ignored */
/^[12] [^.]. / { staged++; next; }
/^[12] \.[MD] / { changed++; next; }