Skip to content

Instantly share code, notes, and snippets.

@infinex
infinex / tmux.conf
Last active July 21, 2020 02:04
tmux.conf
# force a reload of the config file
unbind r
bind r source-file ~/.tmux.conf
set -g history-limit 5000
set -g default-terminal "screen-256color"
set -g status-left-length 24
# remap prefix from 'C-b' to 'C-a'
CREATE TEMP FUNCTION
cleanup(text
STRING
)
RETURNS
STRUCT <
key string,
value string>
LANGUAGE js AS """
return JSON.parse(text);
# Install ucu4c via Brew
brew install icu4c
# Create relative symlinks for icu4c
brew link --force icu4c
# Install pyicu via pip
# Make sure ICU_VERSION matches the one you just installed
sudo ICU_VERSION=60.2 pip install pyicu
@infinex
infinex / 1.sql
Last active March 12, 2018 16:36
big query rolling average ARPU
WITH
mydate AS(
SELECT
day
FROM
UNNEST( GENERATE_DATE_ARRAY( DATE_TRUNC(DATE_SUB(CURRENT_DATE,INTERVAL 1 YEAR),MONTH), CURRENT_DATE(), INTERVAL 1 DAY) ) AS day ),
randomdata AS(
SELECT
t1.*,
ROUND(t1.revenue*rand()) AS user
#standard sql
SELECT "Current Month" as type,cast(TIMESTAMP_TRUNC(CURRENT_TIMESTAMP(), MONTH) as date)
UNION ALL
SELECT "Week ending",DATE_ADD(cast(TIMESTAMP_TRUNC(CURRENT_TIMESTAMP(), WEEK) as date),interval 7 DAY)
UNION ALL
SELECT "Current Month",DATE_TRUNC(CURRENT_DATE,MONTH)
UNION ALL
SELECT "First day of last Month",DATE_TRUNC(DATE_SUB(CURRENT_DATE,INTERVAL 1 MONTH),MONTH)
UNION ALL
@infinex
infinex / gist:88de4b0659cf10b88518c91a2c37c29c
Last active March 12, 2018 16:21
big query date generator
#standard sql
#https://stackoverflow.com/questions/38929121/duplicating-records-to-fill-gap-between-dates-in-google-bigquery
SELECT day
FROM UNNEST(
GENERATE_DATE_ARRAY(
DATE_TRUNC(DATE_SUB(CURRENT_DATE,INTERVAL 1 YEAR),MONTH)
, CURRENT_DATE(), INTERVAL 1 DAY)
) AS day
@infinex
infinex / siamese_twin.py
Created February 18, 2018 16:55
Siamese Twin Eager Mode Tensorflow Bidirectional LSTM
#BiDirectional LSTM
#Training Data
# Embedding1,Embedding2,Labels
# 1 Jurong,Jurng,1
# 2 Jurong,Jrung,1
# 3 Jurong,Bishan,0
# Purpose: To create measure to determine how similar sequences of inputs are to each other.
import os
import random
@infinex
infinex / LSTM.py
Last active February 6, 2019 16:15
Simple LSTM with tensorflow eager mode on MNIST
import numpy as np
import tensorflow as tf
import tensorflow.contrib.eager as tfe
tfe.enable_eager_execution()
from tensorflow.examples.tutorials.mnist import input_data
mnist = input_data.read_data_sets("/tmp/data/", one_hot=True)
# Training Parameters
learning_rate = 0.001
@infinex
infinex / gist:66d82da824ebbaef99ea
Created March 13, 2016 13:14
Neo4J Visualization of airport connectivities
LOAD CSV FROM ‘https://raw.githubusercontent.com/jpatokal/openflights/master/data/airports.dat' AS line
CREATE (:Airport { myid:toInt(line[0]),name: line[1], lat: line[6],lon: line[7]})
CREATE INDEX ON :Airport(myid)
LOAD CSV FROM ‘https://raw.githubusercontent.com/jpatokal/openflights/master/data/routes.dat' AS line
MATCH (from:Airport {myid: toInt(line[3])})
MATCH (to:Airport {myid: toInt(line[5])})
MERGE (from)-[r:route]->(to)
ON MATCH SET r.count = r.count + 1 ON CREATE SET r.count = 1
@infinex
infinex / airport.r
Created March 13, 2016 13:13
Visualisation of airport connectivities in R using ggmap/ggplot/igraph
library(ggmap)
airports <- read.csv(“https://raw.githubusercontent.com/jpatokal/openflights/master/data/airports.dat", header = FALSE)
names(airports) <- c(“id”, “name”, “city”, “country”, “code”,
“icao”, “lat”, “lon”, “altitude”, “timezone”,
“dst”,”tz”)
location <- c( 115,0 )
location
map <- get_map(location, zoom=3,maptype=’toner-lite’)
p <- ggmap(map)
p