Skip to content

Instantly share code, notes, and snippets.

@yenliangl
yenliangl / mintty.bat
Created December 29, 2021 05:41
Start Mintty with tabbar
C:\cygwin64\bin\mintty.exe -i /Cygwin-Terminal.ico --tabbar -o "SessionGeomSync=4" -o "TabForegroundColour=white" -o "TabBackgroundColour=black" /bin/bash -l -c "ssh -X host"
@yenliangl
yenliangl / git-pushing-multiple.rst
Created September 12, 2021 03:44 — forked from rvl/git-pushing-multiple.rst
How to push to multiple git remotes at once. Useful if you keep mirrors of your repo.

Pushing to Multiple Git Repos

If a project has to have multiple git repos (e.g. Bitbucket and Github) then it's better that they remain in sync.

Usually this would involve pushing each branch to each repo in turn, but actually Git allows pushing to multiple repos in one go.

If in doubt about what git is doing when you run these commands, just

@yenliangl
yenliangl / zigzag-encoding.README
Created August 7, 2018 07:53 — forked from mfuerstenau/zigzag-encoding.README
ZigZag encoding/decoding explained
ZigZag-Encoding
---------------
Maps negative values to positive values while going back and
forth (0 = 0, -1 = 1, 1 = 2, -2 = 3, 2 = 4, -3 = 5, 3 = 6 ...)
(i >> bitlength-1) ^ (i << 1)
with "i" being the number to be encoded, "^" being
XOR-operation and ">>" would be arithemtic shifting-operation
@yenliangl
yenliangl / stacktrace.cxx
Created December 20, 2017 16:33 — forked from fmela/stacktrace.cxx
A C++ function that produces a stack backtrace with demangled function & method names.
/*
* Copyright (c) 2009-2017, Farooq Mela
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
@yenliangl
yenliangl / zigzag_encoding32.cc
Last active August 29, 2015 14:24
zigzag encoding (32bits)
#include <cstdio>
#include <iostream>
#include <bitset>
#include <cstring>
#include <limits>
int main(int argc, char** argv)
{
const int n = atoi(argv[1]);
@yenliangl
yenliangl / gist:2dca5efbaa3a065a88b8
Created March 12, 2015 03:45
Reverse page order of PDF using PDFTK
# Assume in.pdf has 100 pages
pdftk in.pdf cat 100-1 output out.pdf
@yenliangl
yenliangl / gist:4d42e4a18369ae5b71a4
Created January 10, 2015 08:22
How to use repo to smart switch different branch
Use repo to intitalize different branches
$ mkdir /repos/aosp-1.6_r1
$ cd /repos/aosp-1.6_r1
$ repo init -b android-1.6_r1 -u https://android.googlesource.com/platform/manifest --reference=/repos/aosp-main
$ repo sync
Switch to another branch
$ mkdir /repos/aosp-1.6_r2
android {
signingConfigs {
release
}
buildTypes {
release {
signingConfig signingConfigs.release
}
package your_package;
import android.animation.AnimatorSet;
import android.animation.ObjectAnimator;
import android.app.Activity;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
@yenliangl
yenliangl / create_mavericks_install_falsh_drive.sh
Created February 15, 2014 17:15
Create install flash drive for MacOSX Mavericks
sudo /Applications/Install\ OS\ X\ Mavericks.app/Contents/Resources/createinstallmedia --volume /Volumes/Untitled --applicationpath /Applications/Install\ OS\ X\ Mavericks.app --nointeraction