Skip to content

Instantly share code, notes, and snippets.

View tuchangwei's full-sized avatar

Changwei tuchangwei

View GitHub Profile
@prologic
prologic / LearnGoIn5mins.md
Last active April 30, 2024 15:10
Learn Go in ~5mins
@fawda123
fawda123 / gist:5ecb73e1304e7faee83eb05b922937e7
Created August 31, 2017 20:09
save git log to csv with header
echo sha, contributor, date, message > log.csv
git log --date=local --pretty=format:'%h, %an, %ad, "%s"' >> log.csv
@jamischarles
jamischarles / npm_install_autocomplete_zsh
Last active July 4, 2016 07:23
npm install autocompletion for bash & zsh. Provides content of `~/.npm` as autocomplete options for `npm install` ✨ https://medium.com/@jamischarles/adding-autocomplete-to-npm-install-5efd3c424067#.8w0jzkh3w
#!/usr/bin/env zsh #adding this to force silly gist highlighting. REMOVE THIS
# ZSH standalone npm install autocompletion. Add this to ~/.zshrc file.
_npm_install_completion() {
local si=$IFS
# if 'install' or 'i ' is one of the subcommands, then...
if [[ ${words} =~ 'install' ]] || [[ ${words} =~ 'i ' ]]; then
# add the result of `ls ~/.npm` (npm cache) as completion options
@ZacSweers
ZacSweers / ExponentialBackoff
Last active April 14, 2020 06:51 — forked from jerrellmardis/ExponentialBackoff
Exponential Backoff using Rx.retryWhen() I DON'T KNOW WHY THIS HAS HIGH SEO I JUST FORKED IT TO SAVE A COPY
// retries up to 3 times while exponentially backing off with each retry
.retryWhen(errors ->
errors
.zipWith(
Observable.range(1, MAX_RETRIES), (n, i) -> i
)
.flatMap(
retryCount -> Observable.timer((long) Math.pow(4, retryCount), TimeUnit.SECONDS)
)
)
//
// UILabel+JumpingDots.swift
// JumpingDots
//
// Copyright (c) 2016 Arkadiusz Holko. All rights reserved.
//
import UIKit
import ObjectiveC
@rnystrom
rnystrom / iOS @3x assets script
Created November 26, 2014 01:52
Save this shell script to generate @2x and 1x PNG assets for your apps. Requires Imagemagick (http://www.imagemagick.org/). These will probably look shitty and blurred.
#!/bin/sh
# Example usage
# cd into directory that has @3x images
# ./whatever-you-name-this.sh
# Remember to chmod +x the script
resize () {
ls *@3x.png | awk '{print("convert "$1" -filter box -resize '$1' "$1)}' | sed 's/@3x/'$2'/2' | /bin/sh
}
@irace
irace / gist:927f843cb0f683a7f2c2
Created August 13, 2014 20:03
New iOS 8 APIs don't allow you to use a custom presentation controller for compact devices, in conjunction with a popover on "normal" size class devices
//
// ViewController.m
// PopoverPresentationControllerExample
//
// Created by Bryan Irace on 8/8/14.
// Copyright (c) 2014 Bryan Irace. All rights reserved.
//
#import "CustomCompactPresentationController.h"
#import "ViewController.h"
@staltz
staltz / introrx.md
Last active May 3, 2024 13:00
The introduction to Reactive Programming you've been missing
@m1entus
m1entus / build-ffmpeg.sh
Last active June 11, 2023 06:42
Installing ffmpeg ios libraries armv7, armv7s, i386
#!/bin/bash
###########################################################################
# Choose your ffmpeg version and your currently-installed iOS SDK version:
#
VERSION="2.0.2"
SDKVERSION="7.0"
ARCHS="armv7 armv7s i386"
#
#
@lmullen
lmullen / post-commit
Created July 27, 2013 17:41
A script to log commits from a Git hook
#!/usr/bin/env ruby
# Write git commit messages to a log file
#
# Lincoln A. Mullen | lincoln@lincolnmullen.com | http://lincolnmullen.com
# MIT License <http://lmullen.mit-license.org/>
#
# You will have to install the git gem for this to work:
# gem install git
#