Skip to content

Instantly share code, notes, and snippets.

vim
:args `ls`
:argdo %s#SEARCH#REPLACE#gec |update
First character afer %s is used as separator
git ls-files
@yifanz
yifanz / population.html
Created May 20, 2017 21:08
US Population 2015
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script>
</head>
<script>
$(document).ready(function() {
jQuery.support.cors = true;
var states = ["01", "02", "04", "05", "06", "08", "09", "10", "11", "12", "13", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31", "32", "33", "34", "35", "36", "37", "38", "39", "40", "41", "42", "44", "45", "46", "47", "48", "49", "50", "51", "53", "54", "55", "56", "72"];
var api_key = '5e562d947f0fb77549cb73938cf1bec320ebe37e';
var url = "https://api.census.gov/data/2015/pep/population";
@yifanz
yifanz / palindrome.html
Created May 20, 2017 21:06
Palindrome Highlighter
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<meta name="author" content="Yi-Fan Zhang" />
<title>Palindromes</title>
<style>
@yifanz
yifanz / find-deps.sh
Created July 18, 2016 17:40
macOS script: Transitively list all dynamic library dependencies
#!/bin/bash
deps=""
find_deps()
{
bin=$1
while read lib; do
lib=${lib%%\(*\)}
lib=${lib%%[[:space:]]}
# https://communities.vmware.com/docs/DOC-8970
config.vm.provider "vmware_fusion" do |v|
# Enable hardware virtualization in vmware fusion
v.vmx["vhv.enable"] = "TRUE"
# Maybe needed for KVM
v.vmx["vcpu.hotadd"] = "FALSE"
end
@yifanz
yifanz / Makefile
Last active August 13, 2018 08:17
Generic Makefile
http://stackoverflow.com/questions/7004702/how-can-i-create-a-makefile-for-c-projects-with-src-obj-and-bin-subdirectories
# ------------------------------------------------
# Generic Makefile
#
# Author: yanick.rochon@gmail.com
# Date : 2011-08-10
#
# Changelog :
# 2010-11-05 - first version
@yifanz
yifanz / show_hidden.sh
Last active October 11, 2015 05:57
Show hidden files in OSX
defaults write com.apple.Finder AppleShowAllFiles TRUE
killall Finder
@yifanz
yifanz / weird.js
Created September 2, 2012 21:21
Weird Javascript
// Somehow this evaluates to true ...
",,," == new Array(4);
@yifanz
yifanz / git_notes.txt
Created September 2, 2012 06:30
Notes on common git operations
# Undo last commit and put changes into staging
git reset --soft HEAD^
# Change the last commit
git commit --amend -m "Oops, forgot to add this to last commit"
# Totally undo the last commit
git reset --hard HEAD^
# Undo local changes to a file
@yifanz
yifanz / .bash_profile
Last active November 17, 2015 22:52
Basic setup for bash
# bash.profile
# .bash_profile is executed for login shells
# .bashrc is executed for non-login shells
# However, Mac OS X’s Terminal.app runs a login shell by default for each
# new terminal window, calling .bash_profile instead of .bashrc
if [ -f ~/.bashrc ]; then
source ~/.bashrc
fi