Skip to content

Instantly share code, notes, and snippets.

View kristw's full-sized avatar

Krist Wongsuphasawat kristw

View GitHub Profile
@kristw
kristw / filters.js
Last active August 29, 2015 13:56
Pattern for defining angularjs filter
define(['angular'], function (ng) {
'use strict';
return ng.module('app.filters', []);
});
@kristw
kristw / getPosition.js
Created May 15, 2014 22:25
Get element position on a screen
function getPosition(element) {
var xPosition = 0;
var yPosition = 0;
var topContainer;
while(element) {
xPosition += (element.offsetLeft - element.scrollLeft + element.clientLeft);
yPosition += (element.offsetTop - element.scrollTop + element.clientTop);
if(!element.offsetParent) topContainer = element;
element = element.offsetParent;
@kristw
kristw / smartDebounce.js
Last active August 29, 2015 14:11
Smart Debounce
// An improved version of the classic "debounce" function.
// var doSomething = debounce(fn);
// doSomething(params); will debounce.
// doSomething.now(params) will execute immediately.
//---------------------------------------------------
// Modified from lodash's debounce
//---------------------------------------------------
/**
@kristw
kristw / .gitignore
Last active August 29, 2015 14:24 — forked from kogakure/.gitignore
.gitignore for latex
*.acn
*.acr
*.alg
*.aux
*.blg
*.dvi
*.fdb_latexmk
*.glg
*.glo
*.gls
'Tweet is coming.',
'When you play the game of tweets, you tweet or you die.',
'I demand a trial by tweeting.',
'Valar Morghutweet. All men must tweet.',
'A Lannister always favorite his tweet.',
'Hear me tweet.',
'The Lannisters tweet their regards.',
'You tweet nothing, Jon Snow.',
'I\'m going to tweet him an offer he can\'t refuse.',
'Toto, I\'ve got to tweet that we\'re not in Kansas anymore.',
@kristw
kristw / loading.html
Created December 13, 2013 02:31
Simple float loading component
<html>
<body>
<!-- Loading -->
<div class="loading-sign-wrap">
<div class="loading-sign">
<div class="loading-title">
loading
</div>
<img src="images/progress_bar.gif" alt="">
<div class="loading-subtitle">
@kristw
kristw / Package Control.sublime-settings
Last active January 3, 2016 07:49
Sublime Settings
{
"installed_packages":
[
"Alignment",
"Apache Pig",
"AutoFileName",
"BracketHighlighter",
"Color Schemes by carlcalderon",
"ColorPicker",
"DashDoc",
@kristw
kristw / thailand-square-gridmap-raw.csv
Last active January 10, 2016 22:38
Data for Thailand Square Tile Grid Map
CRI
PYO
MSN CMI NAN
LPN LPG PRE NKI
UTT
STI PLK LEI NBP UDN SNK NPM
TAK KSN MDH
KPT PCT PNB CPM KKN MKM RET YST ACR
UTI NSN
@kristw
kristw / index.html
Last active January 12, 2016 01:14
Thailand Grid Map
<!DOCTYPE html>
<meta charset="utf-8">
<style>
body{
font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
font-size: 12px;
}
svg{
# Yay! High voltage and arrows!
ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg[red]%}(%{$fg[yellow]%}"
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$fg[red]%}) "
ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[yellow]%}⚡%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_CLEAN=""
PROMPT='%{$fg[green]%}%1~ $(git_prompt_info)%{$fg[green]%}>>%{$reset_color%} '