Skip to content

Instantly share code, notes, and snippets.

View tanduong's full-sized avatar

Tan Duong tanduong

View GitHub Profile
DROP TABLE if exists d_date;
CREATE TABLE d_date
(
date_dim_id INT NOT NULL,
date_actual DATE NOT NULL,
epoch BIGINT NOT NULL,
day_suffix VARCHAR(4) NOT NULL,
day_name VARCHAR(9) NOT NULL,
day_of_week INT NOT NULL,
@tanduong
tanduong / odbc_setup_macos.md
Created September 24, 2019 17:15 — forked from arvsrao/odbc_setup_macos.md
Guide to accessing MS SQL Server in Mac OS X via PyODBC

Since I spent essentially two full days figuring out how to access a corporate MS SQL database pythonicly, I figured I should leave some notes, for future reference and to aid other souls looking to do the same.

These instructions and the commands that follow, were executed on a MAC OS 10.8.3 system. Additionally, I found this blog [post][1] especially helpful during the debugging process.

On mac os, there is a default ODBC manager, iODBC. Other Unix based systems tend to use [unixODBC][2]. Look elsewhere for a discussion about the differences between these driver managers. The only feature we care about is being able to connect to SQL databases through [pyodbc][3], and at the time of this writing [pyodbc][3] requires iODBC as its manager.

Start by installing freeTDS libraries. FreeTDS allows unix programs to talk natively with MS SQL and SyBase databases.

brew intsall freetds
@tanduong
tanduong / odbc_setup_macos.md
Created September 24, 2019 17:15 — forked from arvsrao/odbc_setup_macos.md
Guide to accessing MS SQL Server in Mac OS X via PyODBC

Since I spent essentially two full days figuring out how to access a corporate MS SQL database pythonicly, I figured I should leave some notes, for future reference and to aid other souls looking to do the same.

These instructions and the commands that follow, were executed on a MAC OS 10.8.3 system. Additionally, I found this blog [post][1] especially helpful during the debugging process.

On mac os, there is a default ODBC manager, iODBC. Other Unix based systems tend to use [unixODBC][2]. Look elsewhere for a discussion about the differences between these driver managers. The only feature we care about is being able to connect to SQL databases through [pyodbc][3], and at the time of this writing [pyodbc][3] requires iODBC as its manager.

Start by installing freeTDS libraries. FreeTDS allows unix programs to talk natively with MS SQL and SyBase databases.

brew intsall freetds
@tanduong
tanduong / Middleware.js
Created July 3, 2019 10:55 — forked from darrenscerri/Middleware.js
A very minimal Javascript (ES5 & ES6) Middleware Pattern Implementation
var Middleware = function() {};
Middleware.prototype.use = function(fn) {
var self = this;
this.go = (function(stack) {
return function(next) {
stack.call(self, function() {
fn.call(self, next.bind(self));
});
@tanduong
tanduong / jwtRS256.sh
Created May 20, 2019 17:03 — forked from ygotthilf/jwtRS256.sh
How to generate JWT RS256 key
ssh-keygen -t rsa -b 4096 -m PEM -f jwtRS256.key
# Don't add passphrase
openssl rsa -in jwtRS256.key -pubout -outform PEM -out jwtRS256.key.pub
cat jwtRS256.key
cat jwtRS256.key.pub
@tanduong
tanduong / tmux-cheatsheet.markdown
Created June 9, 2018 13:10 — forked from MohamedAlaa/tmux-cheatsheet.markdown
tmux shortcuts & cheatsheet

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
# Raw transaction API example work-through
# Send coins to a 2-of-3 multisig, then spend them.
#
# For this example, I'm using these three keypairs (public/private)
# 0491bba2510912a5bd37da1fb5b1673010e43d2c6d812c514e91bfa9f2eb129e1c183329db55bd868e209aac2fbc02cb33d98fe74bf23f0c235d6126b1d8334f86 / 5JaTXbAUmfPYZFRwrYaALK48fN6sFJp4rHqq2QSXs8ucfpE4yQU
# 04865c40293a680cb9c020e7b1e106d8c1916d3cef99aa431a56d253e69256dac09ef122b1a986818a7cb624532f062c1d1f8722084861c5c3291ccffef4ec6874 / 5Jb7fCeh1Wtm4yBBg3q3XbT6B525i17kVhy3vMC9AqfR6FH2qGk
# 048d2455d2403e08708fc1f556002f1b6cd83f992d085097f9974ab08a28838f07896fbab08f39495e15fa6fad6edbfb1e754e35fa1c7844c41f322a1863d46213 / 5JFjmGo5Fww9p8gvx48qBYDJNAzR9pmH5S389axMtDyPT8ddqmw
# First: combine the three keys into a multisig address:
./bitcoind createmultisig 2 '["0491bba2510912a5bd37da1fb5b1673010e43d2c6d812c514e91bfa9f2eb129e1c183329db55bd868e209aac2fbc02cb33d98fe74bf23f0c235d6126b1d8334f86","04865c40293a680cb9c020e7b1e106d8c1916d3cef99aa431a56d253e69256dac09ef122b1a9
@tanduong
tanduong / signal.py
Created August 14, 2017 17:40 — forked from HugoPresents/signal.py
limit execution time of a function call in Python
from __future__ import with_statement
import signal, time
from contextlib import contextmanager
def long_function_call():
while True:
if time.time() % 1 == 0:
print '*'
class TimeoutException(Exception): pass
@tanduong
tanduong / min-char-rnn.py
Created June 23, 2017 17:25 — forked from karpathy/min-char-rnn.py
Minimal character-level language model with a Vanilla Recurrent Neural Network, in Python/numpy
"""
Minimal character-level Vanilla RNN model. Written by Andrej Karpathy (@karpathy)
BSD License
"""
import numpy as np
# data I/O
data = open('input.txt', 'r').read() # should be simple plain text file
chars = list(set(data))
data_size, vocab_size = len(data), len(chars)
@tanduong
tanduong / automobile.ipynb
Created May 27, 2017 10:36 — forked from martinwicke/automobile.ipynb
Estimator demo using Automobile dataset
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.