Skip to content

Instantly share code, notes, and snippets.

View iamalbert's full-sized avatar

Albert Zhuang iamalbert

View GitHub Profile
@iamalbert
iamalbert / README.md
Last active November 30, 2023 22:39
Git skip LFS on local repo

Because GitKraken and SourceTree are FUCKING SLOW for repo with large LFS objects.

Need to completely skip LFS operation when pull/fetch/checkout/...

Skip downloading when clone

GIT_LFS_SKIP_SMUDGE=1 git clone SERVER-REPOSITORY

Skip downloading when fetch/checkout/pull

@iamalbert
iamalbert / util.vim
Created May 15, 2017 06:04
vim commands
" convert \xHHHH into Unicode character.
:%s#\\x\([0-9a-f]\{4\}\)#\=nr2char(str2nr(submatch(1),16))#g
@iamalbert
iamalbert / util.py
Last active July 5, 2017 06:43
python utilities
# get dir of current file
import os
this_path = os.path.dirname(os.path.realpath(__file__))
import torch
from torch.autograd import Variable as V
import numpy as np
a = V( torch.from_numpy( np.asarray([1.112]) ) ).float()
b = V( torch.rand(1) )
c = a + b
@iamalbert
iamalbert / argparse.py
Last active October 25, 2016 05:57
Python Collection
#!/usr/bin/env python3
import argparse
import json
import sys
import collections
import itertools
def main(args):
pass
@iamalbert
iamalbert / normalizeText.py
Created September 29, 2016 08:43
normalize_text
FULL2HALF = {
r' ' : r' ', # full space and halfspace
r'!' : r'!', r'"' : r'"', r'#' : r'#', r'$' : r'$', r'%' : r'%',
r'&' : r'&', r''' : r"'", r'(' : r'(', r')' : r')', r'*' : r'*',
r'+' : r'+', r',' : r',', r'-' : r'-', r'.' : r'.', r'/' : r'/',
r'0' : r'0', r'1' : r'1', r'2' : r'2', r'3' : r'3', r'4' : r'4',
r'5' : r'5', r'6' : r'6', r'7' : r'7', r'8' : r'8', r'9' : r'9',
r':' : r':', r';' : r';', r'<' : r'<', r'=' : r'=', r'>' : r'>',
r'?' : r'?', r'@' : r'@', r'A' : r'A', r'B' : r'B', r'C' : r'C',
r'D' : r'D', r'E' : r'E', r'F' : r'F', r'G' : r'G', r'H' : r'H',
@iamalbert
iamalbert / test.lua
Created August 31, 2016 09:11
lua coroutine vs plain loop
require 'sys'
local n = 100000
local seq = {}
for i = 1, n do seq[i] = i end
local bs = 405
local plainLoop = function()
local yield = {}
for i = 1, #seq do
-- in global scope
if not ... then
print "main"
else
print "library"
end
[[
$ luajit test.lua
# Json Pretty Print
json.dumps({'4': 5, '6': 7}, sort_keys=True, indent=4)
# Json Print Entities instead of \uXXXX
json.dumps({'4': 5, '6': 7}, sort_keys=True, indent=4, ensure_ascii=True)
@iamalbert
iamalbert / Assert.hpp
Last active June 5, 2022 04:51
C++ SMART ASSERT
#define __ASSERT1__(x) __REPORT__(x).__ASSERT2__
#define __ASSERT2__(x) __REPORT__(x).__ASSERT1__
#define __REPORT__(x) report(#x,(x))
#define ASSERT(cond, msg) if(!(cond)) Assert(#cond,msg,__FILE__,__LINE__).__ASSERT1__
#include <iostream>
struct Assert {
template<class T>