Skip to content

Instantly share code, notes, and snippets.

View haiy's full-sized avatar

hai haiy

View GitHub Profile
@haiy
haiy / cloudflare-worker-proxy.js
Created December 17, 2023 11:19 — forked from noobnooc/cloudflare-worker-proxy.js
cloudflare-worker-proxy
// Website you intended to retrieve for users.
const upstream = 'api.openai.com'
// Custom pathname for the upstream website.
const upstream_path = '/'
// Website you intended to retrieve for users using mobile devices.
const upstream_mobile = upstream
// Countries and regions where you wish to suspend your service.
@haiy
haiy / min-char-rnn.py
Created November 12, 2017 14:54 — 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)
@haiy
haiy / jupyter
Created October 14, 2016 18:16 — forked from jmtatsch/jupyter
A service (init.d) script for jupyter
#! /bin/sh
### BEGIN INIT INFO
# Provides: jupyter
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start jupyter
# Description: This file should be used to construct scripts to be
# placed in /etc/init.d.
@haiy
haiy / tmux.md
Created July 23, 2016 13:28 — forked from andreyvit/tmux.md
tmux cheatsheet

tmux cheat sheet

(C-x means ctrl+x, M-x means alt+x)

Prefix key

The default prefix is C-b. If you (or your muscle memory) prefer C-a, you need to add this to ~/.tmux.conf:

remap prefix to Control + a

@haiy
haiy / vim_cheatsheet.md
Created July 23, 2016 13:25 — forked from awidegreen/vim_cheatsheet.md
Vim shortcuts

Introduction

  • C-a == Ctrl-a
  • M-a == Alt-a

General

:q        close
:w        write/saves
:wa[!]    write/save all windows [force]
:wq       write/save and close
time mysqlimport --use-threads 10 --fields-terminated-by , -uroot -proot --local kaggle events.csv
@haiy
haiy / gist:e1ef2c74276a0be8b4dd498873d0ec98
Last active July 15, 2016 09:33
mysql database bench
dz-h@dzh-H:~/Desktop/kaggle_test/csv_data$ time mysqlimport --use-threads 10 --fields-terminated-by , -uroot -proot --local kaggle app_events.csv
mysqlimport: [Warning] Using a password on the command line interface can be insecure.
kaggle.app_events: Records: 32473068 Deleted: 0 Skipped: 0 Warnings: 3
real 2m28.837s
user 0m0.084s
sys 0m0.568s
@haiy
haiy / clone_hbase_table.sh
Created May 27, 2015 03:31
clone hbase table
#!/bin/bash
#author: haiy
#date: Mon Mar 30 17:01:00 CST 2015
src=$1
dst=$2
tmp=$dst"_tmp"
red=$'\e[31m'
reset=$'\e[0m'
if [[ $# -lt 2 ]]; then
echo "Usage: clone_table source_table_name target_table_name"
@haiy
haiy / json.scala
Last active August 29, 2015 14:21
json scala simple
import java.util
import org.scalatest.FunSuite
import scala.util.parsing.json._
import org.json.JSONObject
import scala.collection.JavaConverters._
/**
* Created by haiy on 5/21/15.
*/
@haiy
haiy / scala map merge
Created January 7, 2015 10:17
scala map merge
def merge(m1: Map[String, Int], m2: Map[String, Int]): Map[String, Int] =
m1 ++ m2.map { case (k, v) => k -> (v + m1.getOrElse(k, 0)) }