Skip to content

Instantly share code, notes, and snippets.

@Reder
Reder / gist:145556
Last active September 5, 2016 22:51
Javascript to gt client width and height.
function getClient(e)
{
var h, w, de;
if (e) {
w = e.clientWidth;
h = e.clientHeight;
} else {
de = document.documentElement;
w = window.innerWidth || self.innerWidth
|| (de&&de.clientWidth) || document.body.clientWidth;
@Reder
Reder / gist:553902
Created August 27, 2010 18:24 — forked from anonymous/gist:553899
Modified from [Make.text](http://homepage.mac.com/tjim/).
javascript:(function(){/**%20Make.text%201.5.%20Trevor%20Jim.%20License:%20GPL%20v2%20(www.fsf.org/copyleft/gpl.html).%20**/%20var%20logging%20=%20false;%20var%20logString%20=%20'';%20var%20unhandled%20=%20{};%20%20function%20log(exn,msg)%20{%20if%20(!logging)%20return;%20logString%20+=%20msg%20+%20':%20'%20+%20exn%20+%20'%5cn';%20}%20var%20w%20=%20window.open('');%20%20var%20d%20=%20w.document;%20var%20last%20=%20null;%20function%20addText(s)%20{%20if%20(last%20!=%20null)%20d.write(last);%20last%20=%20s;%20}%20function%20llapLast(s)%20{%20if%20(last)%20last%20=%20last.replace(/%20%20%20%20$/,s);%20}%20function%20finishOutput()%20{%20addText(%22%22);%20}%20var%20links%20=%20new%20Array(window.location);%20%20var%20rlinks%20=%20{};%20rlinks[window.location]%20=%200;%20var%20linkTitles%20=%20new%20Array();%20var%20atP%20=%20true;%20var%20atLeft%20=%20true;%20var%20atNoWS%20=%20true;%20%20var%20left%20=%20'%5cn';%20function%20pushLeft(s)%20{%20var%20oldLeft%20=%20left;%20left%20+=%20s;%20if%20(atP)%20addText(s);
@Reder
Reder / gist:1238974
Created September 24, 2011 04:40
GroovyScript for checking link between Notational Velocity Data
def nvDir = '/Users/mac/Documents/Notational Data'
def files = new File(nvDir).list() as List
def result = new ArrayList(files)
new File(nvDir).eachFile {
def text = it.text
files.each {
def name = it.replaceAll('\\.txt$|\\.markdown$', '')
if (text.contains("[[${name}]]")){
result.remove(it)
@Reder
Reder / .vimrc
Last active June 8, 2017 18:47
.vimrc
" Reder's vimrc
" Reder Tseng <reder.tseng@gmail.com>
" Ref:
" 1. <https://github.com/vgod/vimrc>
" 2. <https://github.com/gmarik/vimfiles>
"
" Usage:
" 1. Download .vimrc
" 2. Setup vundle:
" git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim
@Reder
Reder / gist:2403113
Created April 17, 2012 03:08
Preferences.sublime-settings
{
"auto_match_enabled": false,
"color_scheme": "Packages/Color Scheme - Default/Monokai Bright.tmTheme",
"font_face": "Monaco",
"font_size": 16.0,
"highlight_line": true,
"open_files_in_new_window": true
}
@Reder
Reder / gist:2435132
Created April 21, 2012 07:09
jsp-config
<jsp-config>
<jsp-property-group>
<url-pattern>*.jsp</url-pattern>
<el-ignored>false</el-ignored>
<page-encoding>UTF-8</page-encoding>
<scripting-invalid>true</scripting-invalid>
<include-prelude>/jsp/taglib.jsp</include-prelude>
</jsp-property-group>
</jsp-config>
[{ "keys": ["alt+m"], "command": "markdown_preview", "args": {"target": "browser"} }
]
@Reder
Reder / .bash_profile
Created April 28, 2012 17:57
.bash_profile
PS1='\[\033[G\]\w \$ '
export EDITOR=vim
alias mongod='mongod run --config /usr/local/Cellar/mongodb/2.0.4-x86_64/mongod.conf'
@Reder
Reder / utils.clj
Created March 16, 2013 18:32
In order to get a resource from the standalone jar and run directly when development, I have to use following code to get the true file path. I wonder if there is some better way…
(ns my.utils
(:gen-class)
(:use clojure.tools.logging
clj-logging-config.log4j)
(:use [clojure.string :only (split)])
(import (java.util.zip ZipFile))
(import (java.io File
FileInputStream
FileOutputStream
BufferedInputStream
@Reder
Reder / get-key-from-map
Created March 22, 2013 21:42
A way to get the key by a value in a Map. Though it makes more sense to use BiMap, but it should be a harder implementation.
(defn get-key-from-map [v m]
(key (first (filter #(-> % val (= v)) m))))