Skip to content

Instantly share code, notes, and snippets.

htc htchaan

View GitHub Profile
View InputMethodService.java
/*
* Copyright (C) 2007-2008 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
View join-gopro-clips.sh
#!/bin/sh
# example usage:
# . join-gopro-clips.sh /f/DCIM/111GOPRO/*574*MP4
# this will generate and execute a ffmpeg command:
# /cygdrive/c/ProgramData/chocolatey/bin/ffmpeg -i 'F:\DCIM\111GOPRO\GOPR0574.MP4' -filter_complex '[0:v]scale=-1:720[v0];[v0][0:a]concat=n=1:v=1:a=1[v][a]' -r 18 -pix_fmt yuv420p -map '[v]' -map '[a]' -vcodec libx264 -preset veryslow 'C:\Temp\GOPR0574.MP4'
#function join-gopro-clips() {
i=0
c=$(which ffmpeg)
View Base64Binary.js
/*
Copyright (c) 2011, Daniel Guerrero
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
View react-component-lifecycle.md
First render Props change State change Force update Unmount
getDefaultProps
getInitialState
componentWillMount
componentWillReceiveProps
shouldComponentUpdate
componentWillUpdate
render
componentDidMount
@htchaan
htchaan / gcoa.sh
Created Nov 4, 2015
Git checkout all remote branches
View gcoa.sh
#!/bin/bash
function gcoa() {(
UPSTREAM=${1:=origin}
IFS=$'\n'
for BRANCH in $(git branch -r); do
BRANCH=${BRANCH# }
[[ "$BRANCH" != $UPSTREAM* ]] && continue
BRANCH=${BRANCH#$UPSTREAM/}
[ "${BRANCH:0:4}" = 'HEAD' ] && continue
@htchaan
htchaan / de.sh
Created Oct 31, 2015
Shorthand to docker exec
View de.sh
#!/bin/bash
function de() {
ssh -t -i "$DOCKER_CERT_PATH/id_rsa" -p 22 \
-l $(jq -r '.Driver.SSHUser' "$DOCKER_CERT_PATH/config.json") \
$(jq -r '.Driver.IPAddress' "$DOCKER_CERT_PATH/config.json") \
"docker exec $@"
}
@htchaan
htchaan / fixBrewFailedToUpdateTap.sh
Created Oct 21, 2015
Failed to update tap: caskroom/cask
View fixBrewFailedToUpdateTap.sh
brew untap caskroom/cask && brew update && brew cleanup --force -s && rm -rf "$(brew --cache)"' && brew tap caskroom/cask
@htchaan
htchaan / returnExports.coffee
Created Oct 17, 2014
Uses Node, AMD or browser globals to create a module.
View returnExports.coffee
# https://github.com/umdjs/umd/blob/master/returnExportsGlobal.js
# Uses Node, AMD or browser globals to create a module.
# If you want something that will work in other stricter CommonJS environments,
# or if you need to create a circular dependency, see commonJsStrict.js
# Defines a module "returnExports" that depends another module called "b".
# Note that the name of the module is implied by the file name. It is best
# if the file name and the exported global have matching names.
@htchaan
htchaan / toType.js
Created Feb 5, 2014
An improved version of the typeOf operator.
View toType.js
var toType = function(obj) {
return ({}).toString.call(obj).match(/\s([a-zA-Z]+)/)[1].toLowerCase()
}
/**
* http://javascriptweblog.wordpress.com/2011/08/08/fixing-the-javascript-typeof-operator/
* toType({a: 4}); //"object"
* toType([1, 2, 3]); //"array"
* (function() {console.log(toType(arguments))})(); //arguments
* toType(new ReferenceError); //"error"
You can’t perform that action at this time.