Skip to content

Instantly share code, notes, and snippets.

@nhatbui
nhatbui / arboretum-all-stars.tsv
Last active April 20, 2021 07:06
Text version of UC Davis's Arboretum All-Stars (https://arboretum.ucdavis.edu/plant-database).
Common Name Latin Name Description
Snowy River wattle Acacia boormanii Fragrant yellow flowers add color to the winter garden; very adaptable and hardy, grows best in well-drained soils; heat and drought tolerant.
pineapple guava Acca sellowiana (Feijoa sellowiana) Attractive spring flowers are edible and sweet; large green berries have a pineapple-like flavor; can be used as hedging or as a screen; attracts hummingbirds.
island pink yarrow Achillea millefolium 'Island Pink' California native plant; colorful pink flowers in spring, summer, and fall make good cut flowers; ferny green foliage will spread; flowers attract butterflies and beneficial insects.
serpentine columbine Aquilegia eximia California native plant; larger and showier than most columbines; attractive delicate foliage in basal mound; attracts hummingbirds.
Marina madrone Arbutus 'Marina' Shiny evergreen leaves and large drooping clusters of pink flowers are followed by red berries that last into late winter; attractive smooth coppery bark; t
@nhatbui
nhatbui / heartbeat.go
Last active October 21, 2017 17:04
A toy heartbeat server in Go. Each client, upon loading, registers itself and thereafter, sends heartbeats every X seconds. The server checks every Y seconds if a heartbeat has been received.
package main
import (
"fmt"
"log"
"net/http"
"sync"
"time"
)
@nhatbui
nhatbui / list.c
Created September 25, 2017 06:31
Linked List implementation in C. Iteration in only one direction. Optimized for appending. (nothing special, just for copy pasta)
// One element of the list
// You should replace the "data" field
// with a type of your choice.
struct Node
{
struct Node * next;
/* Replace this with the data of your choice */
char * data;
};
COMPILER=clang++
CPP_FLAGS=-D ASIO_STANDALONE -std=c++11 -stdlib=libc++
INCLUDES=-I/path/to/asio-1.10.6/include
all: client server
client: chat_client.cpp
$(COMPILER) $(CPP_FLAGS) $(INCLUDES) -o $@ $<
server: chat_server.cpp
@nhatbui
nhatbui / get_all_tweets.py
Last active September 25, 2016 20:25
Get all historical Tweets from user(s) starting from now.
import argparse
import datetime
from TwitterAPI import TwitterAPI, TwitterOAuth, TwitterRequestError
twitter_handles = ['Twitter']
# The seed_set is a queue containing API requests to be performed.
seed_set = []
api_endpoint = 'statuses/user_timeline'
for handle in twitter_handles:

Keybase proof

I hereby claim:

  • I am nhatbui on github.
  • I am nbui (https://keybase.io/nbui) on keybase.
  • I have a public key ASA_K8kZ1CUaGNhVEsHepSJ5_P7HW3GYD_tSkgJjPAw5gQo

To claim this, I am signing this object:

@nhatbui
nhatbui / filter_punc.py
Last active June 2, 2016 10:34
Filters rows based on exactly one punctuation occurance or none.
#!/usr/bin/python
import sys
import csv
import re
# The data in at least one of the fields (the body field) can include newline
# characters, and all the fields are enclosed in double quotes. Therefore, we
# will need to process the data file in a way other than using split(","). To do this,
# we have provided sample code for using the csv module of Python. Each 'line'
# will be a list that contains each field in sequential order.
@nhatbui
nhatbui / top10.py
Last active June 2, 2016 10:41
finds top 10 longest line[4]'s using quickselect
#!/usr/bin/python
import sys
import csv
import random
# Finds top 10 longest line[4]'s using quickselect sorted in ascending order
def partition(a, l, r, p, key=None):
pivot_value = key(a[p])
temp = a[p]
@nhatbui
nhatbui / nba-teams.txt
Last active January 9, 2016 09:33 — forked from haldun/nba-teams.txt
NBA team list in plain text
Atlanta Hawks
Boston Celtics
Brooklyn Nets
Charlotte Hornets
Chicago Bulls
Cleveland Cavaliers
Dallas Mavericks
Denver Nuggets
Detroit Pistons
Golden State Warriors
@nhatbui
nhatbui / hierarchy.py
Created November 24, 2015 09:55
Pointer-Based n-ary Tree to Graph
class Hierarchy:
def __init__(self):
self.hierarchy = {}
def add_node(self, id):
self.hierarchy[id] = { "children": [], "parent": None }
def add_edge(self, from_id, to_id):
if from_id not in self.hierarchy:
self.add_node(from_id)