Skip to content

Instantly share code, notes, and snippets.

Tan Duong tanduong

Block or report user

Report or block tanduong

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View creating_a_date_dimension_table_in_postgresql.sql
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 Sep 24, 2019 — forked from arvsrao/odbc_setup_macos.md
Guide to accessing MS SQL Server in Mac OS X via PyODBC
View odbc_setup_macos.md

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 Sep 24, 2019 — forked from arvsrao/odbc_setup_macos.md
Guide to accessing MS SQL Server in Mac OS X via PyODBC
View odbc_setup_macos.md

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 Jul 3, 2019 — forked from darrenscerri/Middleware.js
A very minimal Javascript (ES5 & ES6) Middleware Pattern Implementation
View Middleware.js
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 — forked from ygotthilf/jwtRS256.sh
How to generate JWT RS256 key
View jwtRS256.sh
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
View Pull many repos as once
find . -type d -depth 1 -exec git --git-dir={}/.git --work-tree=\$PWD/{} pull \;
@tanduong
tanduong / proxy-graphql.js
Created Nov 5, 2018
proxy and edit graphql response
View proxy-graphql.js
const express = require('express');
const bodyParser = require('body-parser');
const axios = require('axios');
const app = express();
const cors = require('cors');
app.use(cors());
app.use(bodyParser.json());
const backend = 'https://marketplace-api.qa.kamereo.vn/graphql';
@tanduong
tanduong / graphql-get-schema.js
Created Nov 5, 2018
Get & write out graphql schema
View graphql-get-schema.js
const fs = require('fs');
require('isomorphic-fetch');
const {introspectionQuery, buildClientSchema, printSchema} = require('graphql');
function introspectionProvider(introspectionQuery) {
console.log(JSON.stringify({query: introspectionQuery}));
return fetch('https://marketplace-api.qa.kamereo.vn/graphql', {
method: 'post',
headers: {
Accept: 'application/json',
@tanduong
tanduong / db.rake
Created Jul 27, 2018
Pulling heroku db to local
View db.rake
namespace :db do
desc "Backs up heroku database and restores it locally."
task import_from_heroku: [ :environment, :create ] do
HEROKU_APP_NAME = nil # Change this if app name is not picked up by `heroku` git remote.
c = Rails.configuration.database_configuration[Rails.env]
heroku_app_flag = HEROKU_APP_NAME ? " --app #{HEROKU_APP_NAME}" : nil
Bundler.with_clean_env do
puts "[1/4] Capturing backup on Heroku"
`heroku pg:backups capture DATABASE_URL#{heroku_app_flag}`
You can’t perform that action at this time.