Skip to content

Instantly share code, notes, and snippets.

@suntong
suntong / Sql.rl
Created August 7, 2021 16:14 — forked from umjasnik/Sql.rl
simple SQL parser using ragel - get all tables that are referenced in a SQL statement
package de.uwefleischer.statemachines;
import java.util.Set;
import java.util.TreeSet;
public class Sql {
private static Set<String> tables;
%%{
@suntong
suntong / newGoAPI.sh
Created April 17, 2021 16:35 — forked from buildingwatsize/newGoAPI.sh
[v0.1.0] Golang + Fiber Boilerplate with a single command `./newGoAPI.sh` | Note: maybe you have to run `chmod a+x newGoAPI.sh` first
#!/bin/sh
echo "=================================="
echo "Welcome to Golang + Fiber Project Creator v0.1.0"
echo "=================================="
echo "For this script, The user have to input the project name (this will use to be the go module name and the project name."
echo ""
read -n 1 -s -r -p "Press any key to continue"
echo "\n"
@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; }
@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 / 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 / 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 / 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 / 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 / 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)]