Skip to content

Instantly share code, notes, and snippets.

View imWildCat's full-sized avatar

Mike Chong imWildCat

  • True North
  • 12:50 (UTC -07:00)
View GitHub Profile
@imWildCat
imWildCat / gist:9482017
Created March 11, 2014 09:03
~/.bash_profile in my Macbook Air
MAVEN_HOME=/usr/share/java/apache-maven-3.0.5
JAVA_HOME=/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home
PATH=$MAVEN_HOME/bin:$PATH
PATH=$JAVA_HOME/bin:$PATH
PATH=/System/Library/Frameworks/Python.framework/Versions/2.7/bin:$PATH
PATH=/usr/local/mongodb/bin:$PATH
PYTHONPATH=/System/Library/Frameworks/Python.framework/Versions/2.7/bin
PYTHON=$PYTHONPATH/python
require('dotq');
function demoCallback(cb){
setImmediate(cb('test'));
}
var test = demoCallback.promise().then(function(str){
return str;
});
@imWildCat
imWildCat / gist:971ec15462757e8029ad
Last active August 29, 2015 14:01
Express Regx Param
// 如下,想限制匹配长度等于24的字符串,因为ID是mongodb的id
// Sample in Expressjs.com
router.param(function(name, fn){
if (fn instanceof RegExp) {
return function(req, res, next, val){
var captures;
if (captures = fn.exec(String(val))) {
req.params[name] = captures;
next();
@imWildCat
imWildCat / gist:9b3bb1b3d7a1698a21ad
Last active August 29, 2015 14:03
Navigation Bar on Android of Xamarin.Forms to be solid color
<?xml version="1.0" encoding="UTF-8" ?>
<resources>
<style name="KitKatTheme" parent="android:Theme.Holo.Light">
<item name="android:windowBackground">@color/green</item> <!--This works as background color on Android-->
<item name="android:actionBarStyle">@style/ActionBar.Solid.KitKat</item>
</style>
<!--<style name="ActionBar.Solid.KitKat" parent="@android:style/Widget.Holo.Light.ActionBar.Solid">-->
<!-- <item name="android:background">@color/xamarinblue</item>-->
<!--</style>-->
var mongoose = require('mongoose');
var config = require('../config');
var db = mongoose.createConnection();
var options = {
db: { native_parser: true },
server: {
poolSize: 5,
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@imWildCat
imWildCat / gist:17f47926c453a1ff7a62
Last active August 29, 2015 14:07
in RNFrostedSideBar
vImageBoxConvolve_ARGB8888(&effectInBuffer, &effectOutBuffer, NULL, 0, 0, (uint32_t)radius, (uint32_t)radius, 0, kvImageEdgeExtend);
vImageBoxConvolve_ARGB8888(&effectOutBuffer, &effectInBuffer, NULL, 0, 0, (uint32_t)radius, (uint32_t)radius, 0, kvImageEdgeExtend);
vImageBoxConvolve_ARGB8888(&effectInBuffer, &effectOutBuffer, NULL, 0, 0, (uint32_t)radius, (uint32_t)radius, 0, kvImageEdgeExtend);
@imWildCat
imWildCat / api_only
Last active August 29, 2015 14:07
Gemfile provided by Good man~
source 'https://rubygems.org'
gem 'rails', '4.2.0.beta2'
gem 'rails-api'
gem 'spring', :group => :development
gem 'pg'
@imWildCat
imWildCat / md
Created April 20, 2016 02:00
React Native: Parsing/Crawling HTML
# React Native: Parsing/Crawling HTML
## Ugly Way
[xmldom](https://www.npmjs.com/package/xmldom) + [xpath](https://www.npmjs.com/package/xpath)
## Much Better Way
[cheerio][https://www.npmjs.com/package/cheerio].
Note: You MUST also install `buffer`, `events` and `stream` to avoid dependency errors.
In the past, cheerio uses `fs` so that it is not possible to use it in the environment of react native. But now it works fine.
@imWildCat
imWildCat / new_vps.sh
Last active March 28, 2017 13:42
Set up new VPS
curl -sSL https://get.docker.com/ | sh
curl -L "https://github.com/docker/compose/releases/download/1.8.1/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose
echo 'docker installed, cheers!'
# apt-get install -y zsh
# zsh
# sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"