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 / 0 - Readme.md
Last active July 4, 2023 09:34
移除 macOS 健保卡元件

檔案說明

  • removeNHIICC.sh : 移除健保卡元件與相關設定,須以 root (sudo) 權限執行。
  • postinstall.sh : 官方「MAC 元件移除安裝檔」的 script 內容(2020)
@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 / 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 / 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
"""
#!/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 / locale_fallback.cpp
Created January 20, 2015 08:58
Fallback to minimal locale ("C" locale)
/* modified from https://github.com/bitcoin/bitcoin/issues/4147#issuecomment-42493883 */
try {
std::locale("");
} catch (const std::runtime_error& e) {
setenv("LC_ALL", "C", 1);
}
@wancw
wancw / conversion.cpp
Created January 12, 2015 12:50
Implicit conversion failure under Clang
class To{};
#include <utility>
class From{
public:
/* This will cause compilation error under Clang (3.5) with c++11 standard */
operator const To() { return To(); }
@wancw
wancw / stack_trace
Last active August 29, 2015 14:12
Dump stack traces
A helper function to dump backtrace in more accurate information
with helper script to translate dumped address to source code line.
@wancw
wancw / libnice.rb.patch
Created December 23, 2014 14:36
Install libnice by Homebrew without gstreamer dependencies
diff --git a/Library/Formula/libnice.rb b/Library/Formula/libnice.rb
index 3964b17..89a1f34 100644
--- a/Library/Formula/libnice.rb
+++ b/Library/Formula/libnice.rb
@@ -5,6 +5,8 @@ class Libnice < Formula
url "http://nice.freedesktop.org/releases/libnice-0.1.7.tar.gz"
sha1 "94d459fc409da9cf5e4ac30d680ee6c0ded2cb64"
+ option "without-gstreamer"
+