Skip to content

Instantly share code, notes, and snippets.

@wancw
wancw / enable-press-to-repeat.zsh
Last active December 27, 2023 10:22
One-liner to enable "press to repeat" on macOS for all JetBrains IDEs
# ripgrep is required
codesign -dr - ~/Applications/*.app 2>&1 \
| rg --pcre2 -o '(?<=identifier ")com.jetbrains[^"]+(?=")' \
| xargs -L 1 -I _ defaults read _ ApplePressAndHoldEnabled
@wancw
wancw / y-combinator.go
Last active September 19, 2023 20:22
Y combinator in Go, runable example: http://play.golang.org/p/xVHw0zoaWX
package main
import "fmt"
type (
tF func(int) int
tRF func(tF) tF
tX func(tX) tF
)
@wancw
wancw / 0 - Readme.md
Last active July 4, 2023 09:34
移除 macOS 健保卡元件

檔案說明

  • removeNHIICC.sh : 移除健保卡元件與相關設定,須以 root (sudo) 權限執行。
  • postinstall.sh : 官方「MAC 元件移除安裝檔」的 script 內容(2020)
@wancw
wancw / dl_and_gen_doc.bash
Last active November 21, 2019 07:45
Download WebRTC Java source code to generate Javadoc and Dash Docset
#!/usr/bin/env bash
WEBRTC_REPO=http://webrtc.googlecode.com/svn/trunk
WEBRTC_REV=7217
svn checkout ${WEBRTC_REPO}/talk/app/webrtc/java@r${WEBRTC_REV} peer_connection
svn checkout ${WEBRTC_REPO}/webrtc/modules/audio_device/android/java@r${WEBRTC_REV} audio_device
svn checkout ${WEBRTC_REPO}/webrtc/modules/video_capture/android/java@r${WEBRTC_REV} video_capture
svn checkout ${WEBRTC_REPO}/webrtc/modules/video_render/android/java@r${WEBRTC_REV} video_render
#!/usr/bin/env zsh
# Copied from https://github.com/paulirish/dotfiles/commit/6743b907ff586c28cd36e08d1e1c634e2968893e
function strip_diff_leading_symbols(){
color_code_regex=$'(\x1B\\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K])'
# simplify the unified patch diff header
sed -E "s/^($color_code_regex)diff --git .*$//g" | \
sed -E "s/^($color_code_regex)index .*$/\
\1$(rule)/g" | \
@wancw
wancw / aws-get-credentials.js
Created July 9, 2016 15:52 — forked from pahud/aws-get-credentials.js
AWS CredentialProviderChain example in aws-sdk of NodeJS
var AWS = require('aws-sdk');
var chain = new AWS.CredentialProviderChain();
var credentials
AWS.CredentialProviderChain.defaultProviders = [
function () { return new AWS.EnvironmentCredentials('AWS'); },
function () { return new AWS.EnvironmentCredentials('AMAZON'); },
function () { return new AWS.SharedIniFileCredentials({profile: 'my_profile_name'}); },
function () { return new AWS.EC2MetadataCredentials(); }
]
@wancw
wancw / git-sync-track.zsh
Created June 19, 2017 08:06
Update all tracking Git branches
#!/usr/bin/env zsh
ORIG_BRANCH="$(git rev-parse --abbrev-ref HEAD)"
if [[ "$ORIG_BRANCH" == "HEAD" ]] {
ORIG_BRANCH="$(git rev-parse --short HEAD)"
}
for b in $(git branch --track | grep -v 'detached' | sed 's/*//')
do
git checkout "${b}"
@wancw
wancw / ls-migrations-then-checkout
Last active December 16, 2016 18:55
列出切換 branch 前需要 rollback 的 South migration。
#!/usr/bin/env zsh
if [[ $# != 1 ]]; then
cat - << USAGE
Usage: `basename $0` <branch>
USAGE
return 1
fi
local old_branch=$(git rev-parse --abbrev-ref HEAD)
@wancw
wancw / fbfeed2csv.py
Created May 6, 2016 11:26 — forked from pofeng/fbfeed2csv.py
fbfeed2csv: a tool to download all posts from a user/group/page's facebook feed to a csv file
"""
modified for Python 2.7 and unicode
get your goup id at https://lookup-id.com/
get your acess token at https://developers.facebook.com/tools/explorer/
fork from
fbfeed2csv: a tool to download all posts from a user/group/page's facebook feed to a csv file
yuzawa-san
https://github.com/yuzawa-san
"""
import urllib, urllib2, json
'''
The ``FacebookTestUserManager`` module
======================================
Author: Weizhong Yang <zonble at gmail dot com>
A tool which helps to create and delete test account for Facebook.