Skip to content

Instantly share code, notes, and snippets.

View vangie's full-sized avatar

Vangie Du vangie

View GitHub Profile
@vangie
vangie / gist:2592085
Created May 4, 2012 04:43
how to implement this._super in js function
// tests if we can get super in .toString()
fnTest = /xyz/.test(function() {
xyz;
}) ? /\b_super\b/ : /.*/,
// overwrites an object with methods, sets up _super
// newProps - new properties
// oldProps - where the old properties might be
// addTo - what we are adding to
inheritProps = function( newProps, oldProps, addTo ) {
@vangie
vangie / extending-the-defaults-of-a-model-superclass-in-backbone-js
Created June 23, 2012 18:06
Extending the defaults of a Model superclass in Backbone.js
var ExtendedInventory = Inventory.extend({
defaults: {
rabit:25
}
});
_.extend(ExtendedInventory.prototype.defaults, Inventory.prototype.defaults);
// or
@vangie
vangie / gist:3087862
Created July 11, 2012 03:44
text-overflow
white-space:nowrap;
overflow:hidden;
text-overflow: clip | ellipsis | ellipsis-word;
@vangie
vangie / gist:3174886
Created July 25, 2012 07:16
使用Spring初始化一个自己实例化的Bean
private View applyLifecycleMethods(String viewName, AbstractView view) {
return (View) getApplicationContext().getAutowireCapableBeanFactory().initializeBean(view, viewName);
}
//参考 UrlBasedViewResolver
@vangie
vangie / FileExt.java
Last active October 10, 2015 14:07
java:获得文件扩展名
import org.apache.commons.io.FilenameUtils;
String extension = FilenameUtils.getExtension(fileName);
@vangie
vangie / bash_default_value.sh
Last active October 10, 2015 15:07
bash:变量默认值
#!/bin/bash
#直观当繁琐的写法
if [ ! $1 ]; then
$1='default'
fi
#当变量a为null时则var=b
var=${a-b}
@vangie
vangie / toolbar-view.coffee
Last active December 11, 2015 16:58
coffeescript define function in loop
val = (x, ctx, args) =>
if _.isFunction x
x.apply ctx or this, args or []
else
x
[
openWith
replaceWith
closeWith
repaceHolder
@vangie
vangie / pptpd.sh
Created March 2, 2014 12:00
PPTPD一键安装 For CentOS 5 32bits/64bits
yum remove -y pptpd ppp
iptables --flush POSTROUTING --table nat
iptables --flush FORWARD
rm -rf /etc/pptpd.conf
rm -rf /etc/ppp
wget http://www.diahosting.com/dload/dkms-2.0.17.5-1.noarch.rpm
wget http://www.diahosting.com/dload/kernel_ppp_mppe-1.0.2-3dkms.noarch.rpm
wget http://www.diahosting.com/dload/pptpd-1.3.4-1.rhel5.1.i386.rpm
wget http://www.diahosting.com/dload/ppp-2.4.4-9.0.rhel5.i386.rpm
@vangie
vangie / rmb.coffee
Created March 2, 2014 12:04
人民币小写转换为大写
#! /usr/bin/env coffee
# convert amount from figures to words
# @author vangie.du
# @url http://codelife.me/blog/2013/03/09/convert-amount-from-figures-to-words-by-coffeescript/
# @version 1.1
# @since 2013-03-09
if process.argv.length >= 3
n = parseFloat(process.argv[2]).toFixed(2)
@vangie
vangie / install-vagex-ubuntu.sh
Last active July 28, 2020 08:03
install and run Vagex on Koding
sudo apt-get install php5-curl
wget https://gist.githubusercontent.com/horsley/12a14498e02c994e0664/raw/a6e0dc785f2a17353860b02b163b5386a3823efa/VagexRobot.AllInOne.php
sed -i "s/240907/$1/" VagexRobot.AllInOne.php
screen -S vagex -d -m php VagexRobot.AllInOne.php