Skip to content

Instantly share code, notes, and snippets.

@suntong
suntong / git-prompt-color.sh
Last active Jul 17, 2019 — 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)
View git-prompt-color.sh
#!/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; }
@suntong
suntong / http.go
Created Jun 7, 2019 — forked from AngerM/http.go
High Performance Golang HTTP Client
View http.go
package utils
import (
"context"
"io"
"io/ioutil"
"net"
"net/http"
"strings"
"time"
View foo.go
////////////////////////////////////////////////////////////////////////////
// Program: dbab-svr
// Purpose: Pixel Server in Go
// Authors: Tong Sun (c) 2019, All rights reserved
////////////////////////////////////////////////////////////////////////////
package main
import (
"bufio"
@suntong
suntong / simplest.js
Last active Feb 11, 2018 — forked from anonymous/simplest.js
gopherjs bare bone js code base
View simplest.js
"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 / 0_reuse_code.js
Created Jan 18, 2017
Here are some things you can do with Gists in GistBox.
View 0_reuse_code.js
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@suntong
suntong / udp-port-scanning.txt
Created Jul 9, 2016 — forked from benhosmer/udp-port-scanning.txt
UDP Port Troubleshooting using netcat
View udp-port-scanning.txt
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.
View useful_pandas_snippets.py
#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 / README.md
Last active Dec 18, 2015 — forked from huyng/matplotlibrc
my default matplotlib settings
View README.md

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:
View main.go
// http://play.golang.org/p/FOe85j-O-n
package main
import (
"fmt"
"os"
"time"
)
You can’t perform that action at this time.