Skip to content

Instantly share code, notes, and snippets.

View zlargon's full-sized avatar
:electron:
Focusing

Leon Huang zlargon

:electron:
Focusing
  • Boston, MA
View GitHub Profile
@zlargon
zlargon / [Swift] using swift command line.md
Last active August 29, 2015 14:12
Using Swift command line
@zlargon
zlargon / [C] Pointer Tutorial.c
Created April 30, 2015 03:02
C 指標基本觀念,function 總是 pass by value
#include "stdio.h"
void setNumberTo10(int n) {
printf("\n%s:\n", __func__);
printf("n 記憶體位址 = %p, n 記憶體位址 size = %zu\n", &n, sizeof(&n));
printf("n 記憶體空間的值 = %d, n 記憶體空間的 size = %zu\n", n, sizeof(n));
n = 10;
printf("n = %d\n\n", n);
}
@zlargon
zlargon / remove_malware.sh
Last active February 15, 2017 15:08
Remove unwanted adware that displays pop-up ads and graphics on your Mac. https://support.apple.com/en-us/HT203987
#!/bin/bash
echo "Remove unwanted adware that displays pop-up ads and graphics on your Mac"
echo "https://support.apple.com/en-us/HT203987"
echo ""
# 1. Downlite, VSearch, Conduit, Trovi, MyBrand, Search Protect, Buca Apps
echo "1. Remove Downlite, VSearch, Conduit, Trovi, MyBrand, Search Protect, Buca Apps"
echo ""
malware[0]="/System/Library/Frameworks/v.framework"
malware[1]="/System/Library/Frameworks/VSearch.framework"
@zlargon
zlargon / update_xcode_plugin_compat.sh
Last active August 29, 2015 14:24
When Xcode is upgrade, Xcode Plugin will not work at all. Use this script to update all your Xcode plugin's compatibility.
#!/bin/bash
# When Xcode is upgrade, Xcode Plugin will not work at all.
# Use this script to update all your Xcode plugin's compatibility.
# https://github.com/supermarin/Alcatraz/issues/213#issuecomment-91288935
# show Xcode version and UUID
xcodebuild -version
uuid=$(defaults read /Applications/Xcode.app/Contents/Info DVTPlugInCompatibilityUUID)
echo "UUID $uuid"
echo ""
@zlargon
zlargon / show-file.sh
Last active August 29, 2015 14:25
[MAC OSX] Show/Hide the hidden files in Finder.
# [MAC OSX] Show/Hide the hidden files in Finder.
# add this function to '~/.bash_profile' and reopen terminal.
# Usage: show-file -> show
# show-file 0 / off / hide / false -> hide
show-file () {
opt=$(echo $1 | tr '[:upper:]' '[:lower:]') # transfer into lowercase
# Hide Files
if [ "$opt" = "off" ] || [ "$opt" = "0" ] || [ "$opt" = "false" ] || [ "$opt" = "hide" ] ; then
@zlargon
zlargon / karabiner_fn_cmd_to_left_click.xml
Created October 5, 2015 06:52
Karabiner private.xml: Fn + Cmd to LeftClick
<?xml version="1.0"?>
<root>
<item>
<name>Fn + Cmd to LeftClick</name>
<identifier>private.fn2leftclick</identifier>
<autogen>__KeyToPointingButton__ KeyCode::FN, ModifierFlag::COMMAND_L, PointingButton::LEFT</autogen>
</item>
</root>
@zlargon
zlargon / [bash] replace.sh
Last active October 5, 2015 09:24
replace "line_number" line to "repace_string" in "file_name"
#!/bin/bash
# function replace (file_name, line_number, replace_string)
replace () {
file=$1
number=$2
string=$3
n=1
cat $file | while read line
import fs from 'fs'
var output = fs.readFileSync('input.txt', 'utf8')
.trim() // remove end of line
.split('\n')
.map(line => line.split('\t'))
.reduce((customers, [ user, name, price, quality ]) => {
customers[user] = customers[user] || [];
customers[user].push({ name, price, quality });
return customers;
@zlargon
zlargon / flexbox.css
Created November 21, 2015 08:50
CSS Flexbox
.container {
display: flex; /* or inline-flex */
/* Flexbox is a single-direction layout concept */
flex-direction: row | row-reverse | column | column-reverse;
flex-wrap: nowrap | wrap | wrap-reverse;
flex-flow: <‘flex-direction’> || <‘flex-wrap’>;
/* main axis */
justify-content: flex-start | flex-end | center | space-between | space-around;
@zlargon
zlargon / karabiner_arrow_symbol_shortcuts.xml
Created January 25, 2016 07:24
Karabiner private.xml: arrow symbol shortcuts
<!-- https://pqrs.org/osx/karabiner/faq.html.en#unicode-hex-input -->
<?xml version="1.0"?>
<root>
<item>
<name>Use right option as unicode hex input modifier</name>
<appendix>- right option + ← = ← (U+2190)</appendix>
<appendix>- right option + ↑ = ↑ (U+2191)</appendix>
<appendix>- right option + → = → (U+2192)</appendix>
<appendix>- right option + ↓ = ↓ (U+2193)</appendix>
<identifier>private.unicode_hex_input_modifier</identifier>