Skip to content

Instantly share code, notes, and snippets.

@yiboyang
yiboyang / pandas_help.ipynb
Created January 11, 2024 07:07
Code snippets to remind myself how pandas works
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@yiboyang
yiboyang / active_set_for_convex_qp.py
Created June 26, 2019 20:56
Algorithm demos for Numerical Optimization by Nocedal and Wright.
# active_set_for_convex_qp.py
# Yibo Yang
# 04/16/2019
# Algorithm 16.3 (active-set method for convex QP) in Numerical Optimization
import numpy as np
from numpy.linalg import solve, lstsq
printing_count_from_1 = 1 # set to 1 to match textbook numbering; 0 to use python numbering
@yiboyang
yiboyang / git_bash_here.ahk
Last active March 3, 2024 08:44
Git bash here in Windows Explorer with Ctrl + Alt + T
;
; AutoHotkey Version: 1.1
; Language: English
; Platform: Win9x/NT
; Author: Yibo
;
; Script Function:
; Define the shortcut Ctrl + Alt + T for launching Git bash in current folder in Windows Explorer
;
@yiboyang
yiboyang / cmd_in_current_dir.ahk
Created December 3, 2016 18:33
Win + T to open cmd in current directory
;
; AutoHotkey Version: 1.1
; Language: English
; Platform: Win9x/NT
; Author: Yibo, from Internet
;
; Script Function:
; Define the shortcut Win + T for launching cmd in current folder in Windows Explorer
;
@yiboyang
yiboyang / remap_win_desktop_switcher.ahk
Created July 19, 2016 01:57
Remap Windows10's virtual desktop switcher key combo to Unity's "Ctrl + Alt + Left/Right"
;
; AutoHotkey Version: 1.1
; Language: English
; Platform: Win9x/NT
; Author: Yibo Yang
;
; Script Function:
; Remap Windows10's virtual desktop switcher keyboard shortcut from the default "Ctrl + Win + Left/Right" to Unity's "Ctrl + Alt + Left/Right"
; Put into the startup folder so that it will run every time your computer starts (http://superuser.com/questions/948616/windows-10-change-shortcut-keys-to-switch-between-desktops)
@yiboyang
yiboyang / helloworld.py
Created February 21, 2016 19:03
My fancy hello world app on Google App Engine
import webapp2
mainForm="""
<form method='post' action='#'>
<label>What world do you come from?
<br>
<input name='world' value='%(world)s' placeholder='Minecraft World'>
</label>
<label>What's your name?
@yiboyang
yiboyang / UnionFind.js
Last active February 9, 2016 00:54
Lightweight union find/disjoint set data structure with path compression
// Construct a UnionFind object for integer elements 0... n-1
function UnionFind(n) {
this.s = []; // Underlying array
this.numSets = n;
for (var i = 0; i < n; i++) // initial representatives are -1
this.s[i] = -1
};
// Search for element y and return the index of the root of the tree containing y;
// does path compression on each find
@yiboyang
yiboyang / xclip aliases for startup scripts
Last active May 11, 2024 03:31
A few xclip aliases to simplify copying/pasting
# to simplify life, install xclip and append the following lines to your .bashrc
alias "c=xclip" # copy to X clipboard (register *)
alias "cs=xclip -selection clipboard" # copy to system wide clipboard (register +)
alias "v=xclip -o" # output copied content (paste)
alias "vs=xclip -o -selection clipboard" # paste from system wide clipboard (equivalent to `v -selection clipboard`)
# examples:
# copy to X:
# go to the same directory in terminal 2 as in terminal 1
# Terminal 1: