Skip to content

Instantly share code, notes, and snippets.

View williamcspace's full-sized avatar

William Chan williamcspace

  • Shanghai Xinyue Information Technology Ltd.
  • Shanghai
View GitHub Profile
@williamcspace
williamcspace / Open-in-Sublime
Created September 24, 2013 18:14
This is the OSX Bash Shell Script for opening folder in sublime text. Automator, pass input as argument
/Applications/Sublime\ Text.app/Contents/SharedSupport/bin/subl -n $@
@williamcspace
williamcspace / open-subl-in-term
Created September 24, 2013 18:15
Simply make a symbolic link to open sublime text in terminal
sudo ln -s "/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl" /bin/subl
@williamcspace
williamcspace / apacheMemUsage
Created October 8, 2013 09:20
Average Apache Process Memory Usage
ps aux | grep apache2 | grep -v pts | awk '{ tot += $6; procs += 1; print $2,$6,$11 } END { print "TOTAL: ",tot,"/",procs,"=",tot/procs }'

tmux cheatsheet

As configured in my dotfiles.

start new:

tmux

start new with session name:

import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
public abstract class EndlessRecyclerOnScrollListener extends RecyclerView.OnScrollListener {
public static String TAG = EndlessRecyclerOnScrollListener.class.getSimpleName();
private int previousTotal = 0; // The total number of items in the dataset after the last load
private boolean loading = true; // True if we are still waiting for the last set of data to load.
private int visibleThreshold = 5; // The minimum amount of items to have below your current scroll position before loading more.
int firstVisibleItem, visibleItemCount, totalItemCount;
public abstract class HeaderFooterRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
private static final int VIEW_TYPE_MAX_COUNT = 1000;
private static final int HEADER_VIEW_TYPE_OFFSET = 0;
private static final int FOOTER_VIEW_TYPE_OFFSET = HEADER_VIEW_TYPE_OFFSET + VIEW_TYPE_MAX_COUNT;
private static final int CONTENT_VIEW_TYPE_OFFSET = FOOTER_VIEW_TYPE_OFFSET + VIEW_TYPE_MAX_COUNT;
private int headerItemCount;
private int contentItemCount;
private int footerItemCount;
@williamcspace
williamcspace / gulpfile.js
Created November 3, 2015 06:56
Angularjs build script
var gulp = require('gulp');
var concat = require('gulp-concat');
var uglify = require('gulp-uglify');
var ngAnnotate = require('gulp-ng-annotate');
var sourcemaps = require('gulp-sourcemaps');
var exec = require('child_process').exec;
var livereload = require('gulp-livereload');
gulp.task('livereload', function() {
livereload.reload();
@williamcspace
williamcspace / head.html
Last active November 6, 2015 04:09
HTML5 tag shim for HTML4 browser
<!--[if lt IE 9]>
<script>
document.createElement("header" );
document.createElement("footer" );
document.createElement("section");
document.createElement("aside" );
document.createElement("nav" );
document.createElement("article");
document.createElement("hgroup" );
document.createElement("time" );
@williamcspace
williamcspace / promise.js
Created November 17, 2015 05:55
ES6 Promise Example
var p1 = function (value) {
return new Promise(function (resolve, reject) {
resolve(value + 111);
});
};
var p2 = function (value) {
return new Promise(function (resolve, reject) {
resolve(value + 111);
@williamcspace
williamcspace / FontUtils.java
Last active January 15, 2016 08:42
[Android] Custom Fonts with reflect
package common.utils;
import android.content.Context;
import android.graphics.Typeface;
import java.lang.reflect.Field;
public class FontUtils {
public static final String DEFAULT = "DEFAULT";
public static final String DEFAULT_BOLD = "DEFAULT_BOLD";