Skip to content

Instantly share code, notes, and snippets.

View tc's full-sized avatar
💭
🚢

Tommy Chheng tc

💭
🚢
View GitHub Profile
var i;
for (i=0; i<5; i+=1){
setTimeout(
function(){ console.log(i); },
100
);
}
@tc
tc / vimrc.after
Created March 26, 2018 02:54
vimrc.after
" Fast saving
nmap <leader>w :w!<cr>
vnoremap <silent> gv :call VisualSearch('gv')<CR>
map <leader>g :vimgrep // **/*<left><left><left><left><left><left><left>
function! GoogleSearch()
let searchterm = getreg("g")
silent! exec "silent! !open \"http://google.com/search?q=" . searchterm . "\" &"
endfunction
@tc
tc / CounterView.java
Last active June 24, 2016 19:44 — forked from edisonw/gist:a5d64c0402696f525a76
CounterView to support localization of grouping character.
/*
* Copyright (C) 2014 Twitter Inc.
*
* 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
@tc
tc / upload-cropper-example.html
Created June 25, 2015 21:34
Example of using https://github.com/fengyuanchen/cropper to crop an image and upload it to a server.
<html>
<head>
<title>Cropper example</title>
<script src="https://code.jquery.com/jquery-2.1.4.min.js"></script>
<link href="https://cdnjs.cloudflare.com/ajax/libs/cropper/0.9.1/cropper.min.css" rel="stylesheet">
<script src="https://cdnjs.cloudflare.com/ajax/libs/cropper/0.9.1/cropper.min.js"></script>
</head>
<body>
<div class="container">
@tc
tc / react-slideshow-demo.html
Created March 18, 2015 21:34
React slideshow demo
<html>
<head>
<title>React slideshow test</title>
<script src="http://fb.me/react-with-addons-0.13.1.js"></script>
<script src="http://fb.me/JSXTransformer-0.13.1.js"></script>
<style>
* {
box-sizing: border-box;
padding: 0;
margin: 0;
var BusBoy = require('busboy'),
fs = require('fs'),
path = require('path');
var RE_MIME = /^(?:multipart\/.+)|(?:application\/x-www-form-urlencoded)$/i;
// options will have limit and uploadDir.
exports = module.exports = function(options){
options = options || {};
var five, board, servo, blink;
five = require("johnny-five");
board = new five.Board();
board.on("ready", function() {
servo = new five.Servo(10);
@tc
tc / EncodeAndMuxTest.java
Created September 5, 2013 21:26
OpenGL to video on Android, 4.3 API 18
/*
* Copyright 2013 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
@tc
tc / using-ruby-1.9.3-p392.md
Last active December 15, 2015 06:38 — forked from juno/using-ruby-1.9.3-p327.md
update to reflect ruby 1.9.3-p392

Using ruby-1.9.3-p392 with ruby-env and ruby-build

Prerequisite

  • Mac OS X Mountain Lion (10.8.2)
  • Homebrew
  • readline
  • rbenv

Install or update ruby-build

@tc
tc / gist:2363185
Created April 11, 2012 22:26
facebook timeline page not parsable with jsoup
<!DOCTYPE html>
<html lang="en" id="facebook" class="no_js">
<head><meta charset="utf-8" /><script>function envFlush(a){function b(c){for(var d in a)c[d]=a[d];}if(window.requireLazy){requireLazy(['Env'],b);}else{Env=window.Env||{};b(Env);}}
envFlush({"user":"0","locale":"en_US","method":"GET","svn_rev":539342,"vip":"69.171.247.80","static_base":"http:\/\/static.ak.fbcdn.net\/","www_base":"http:\/\/www.facebook.com\/","rep_lag":2,"fb_dtsg":"AQDM19gw","ajaxpipe_token":"AXjcQXC0BvABCfxF","lhsh":"JAQEQyaoL","tracking_domain":"http:\/\/pixel.facebook.com","retry_ajax_on_network_error":"1","html5_audio":"1","fbid_emoticons":"1"});</script><script>envFlush({"eagleEyeConfig":{"seed":"3NbA"}});CavalryLogger=false;window._script_path = "\/profile_page_timeline.php";</script><noscript> <meta http-equiv="refresh" content="0; URL=/SHOandCO?_fb_noscript=1" /> </noscript>
<meta name="robots" content="noodp, noydir" /><meta name="description" content=" Facebook is a social utility that connects people with friends and other