Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am leomao on github.

  • I am leomao (https://keybase.io/leomao) on keybase.

  • I have a public key ASBXeji9z5TAstVXbfROPQ4y4SuIcKis5q9S0vD97VrjWwo

@leomao
leomao / cuda101.patch
Created August 4, 2019 04:00
warp-ctc cuda 10.1 patch
diff --git a/include/contrib/moderngpu/include/device/intrinsics.cuh b/include/contrib/moderngpu/include/device/intrinsics.cuh
index a601443..4be77a8 100644
--- a/include/contrib/moderngpu/include/device/intrinsics.cuh
+++ b/include/contrib/moderngpu/include/device/intrinsics.cuh
@@ -112,7 +112,7 @@ __device__ __forceinline__ float shfl_up(float var,
unsigned int delta, int width = 32) {
#if __CUDA_ARCH__ >= 300
- var = __shfl_up(var, delta, width);
+ var = __shfl_up_sync(0xFFFFFFFF, var, delta, width);
@leomao
leomao / tetris_in_one.cpp
Created November 11, 2017 09:15
Tetris battle in one cpp
///////////////////////////////////////////
// Author: LeoMao
// Filename: tetris.cpp
// Purpose: simulate tetris battle
// encoding: UTF-8
//
// Features:
// => basic tetris battle game control
// => can see next 5 pieces
// => can hold just like tetris battle
@leomao
leomao / pacfzf
Last active September 29, 2017 10:07
Use fzf to filter and select the search result from pacman (or pacaur)
#!/bin/bash
if [[ -z $(command -v fzf) ]]; then
echo "You don't have fzf!!"
exit -1
fi
# collapse pacaur search result into oneline each entry
collapse() {
head=''
@leomao
leomao / watchsync.sh
Last active April 23, 2023 10:21
Watch file changes and sync two directories (to remote via ssh)
#!/bin/bash
#
# Sync local directory to remote directory.
#
# Modified by: Leo Mao
# Modified from: https://gist.github.com/evgenius/6019316
#
# Requires Linux, bash, inotifywait and rsync.
#
# To avoid executing the command multiple times when a sequence of
@leomao
leomao / PKGBUILD
Created March 14, 2017 02:24
Cadivsor PKGBUILD
pkgname=cadvisor
pkgver=0.25.0
pkgrel=1
pkgdesc="Analyzes resource usage and performance characteristics of running containers"
license=('Apache')
arch=('x86_64')
url='https://github.com/google/cadvisor'
makedepends=()
optdepends=()
source_x86_64=(
@leomao
leomao / pm_name.txt
Created March 7, 2017 03:27
Pokemon
中 日 英
妙蛙種子 フシギダネ Bulbasaur
妙蛙草 フシギソウ Ivysaur
妙蛙花 フシギバナ Venusaur
小火龍 ヒトカゲ Charmander
火恐龍 リザード Charmeleon
噴火龍 リザードン Charizard
傑尼龜 ゼニガメ Squirtle
卡咪龜 カメール Wartortle
水箭龜 カメックス Blastoise
@leomao
leomao / client.js
Created March 7, 2017 03:23
socket in node
const net = require('net');
socket = net.createConnection(54321);
socket.on('data', (data) => {
console.log(data.toString().trim());
});
socket.on('end', () => {
console.log('socket end');
socket.end();
});
@leomao
leomao / ansistyle.py
Created January 30, 2017 14:29
ANSI style escape code
# /usr/bin/env python
# Copyright (C) 2017 Leo Mao
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
@leomao
leomao / colsure_compile.py
Created June 27, 2015 03:02
optimize javascript using closure compiler
#! /usr/bin/env python3
import http.client, urllib.parse, sys
# Define the parameters for the POST request and encode them in
# a URL-safe format.
params = urllib.parse.urlencode([
('js_code', sys.argv[1]),
('compilation_level', 'SIMPLE_OPTIMIZATIONS'),