Skip to content

Instantly share code, notes, and snippets.

@gwjjeff
gwjjeff / .gitignore
Created July 2, 2018 08:32 — forked from chhh/.gitignore
.gitignore file for IDEA, Eclipse, NetBeans
#
# Project specific excludes
#
tomcat
#
# Default excludes
#
@gwjjeff
gwjjeff / cross_compile.sh
Last active August 29, 2015 14:27
交叉编译nodejs v0.10.29 ruby v2.2.2
#!/bin/bash
#GCC_PATH=/opt/gcc-linaro-arm-linux-gnueabihf-4.8-2013.05_linux/bin
#GCC_PATH=/opt/gcc-linaro-arm-linux-gnueabihf-4.7-2013.03-20130313_linux/bin
GCC_PATH=/opt/gcc-linaro-arm-linux-gnueabihf-4.7-2013.04-20130415_linux/bin
#GCC_PATH=/var/www/arm_sysroot/usr/bin
CROSS=${GCC_PATH}/arm-linux-gnueabihf-
#CROSS=${GCC_PATH}/
ARM_MA=armv7l-unknown-linux-gnueabihf
#SYS_ROOT=/var/www/arm_sysroot
@gwjjeff
gwjjeff / post_csrf_form.js
Created October 28, 2014 09:22
Post form with CSRF token in javascript.
// usage: $.redirectPost('/terminals/in_batch_register', {terminal_ids: terminal_ids});
$(function () {
$.extend({
redirectPost: function(location, args) {
var form = '';
$.each(args, function (k, v) {
form += '<input type="hidden" name="' + k +'" value="' + v + '">';
});
// rails way
// form += '<%= hidden_field_tag :authenticity_token, form_authenticity_token %>';
# RSpec 2.0 syntax Cheet Sheet by http://ApproachE.com
# defining spec within a module will automatically pick Player::MovieList as a 'subject' (see below)
module Player
describe MovieList, "with optional description" do
it "is pending example, so that you can write ones quickly"
it "is already working example that we want to suspend from failing temporarily" do
pending("working on another feature that temporarily breaks this one")
@gwjjeff
gwjjeff / pip-cache-install.py
Created November 22, 2012 11:58 — forked from jacobian/pip-cache-install.py
Install a package from your local pip download cache without touching the 'net.
#!/usr/bin/env python
"""
Install a package from your local pip download cache without having to touch
the 'net at all.
You'll need to be using a pip download cache; that is, you'll need the
following in your ~/.pip/pip.cfg:
[install]
@gwjjeff
gwjjeff / 人民币大写
Created January 19, 2012 08:21
杂项内容
壹 贰 叁 肆 伍 陆 柒 捌 玖 拾 佰 仟 万 亿 元 角 分 零 整
例:¥654321
人民币陆拾伍万肆仟叁佰贰拾壹元整
@gwjjeff
gwjjeff / GMTdate.scala
Created January 13, 2012 03:08
scala - sbt
def cvtToGmt( date: Date ) = {
val tz = TimeZone.getDefault()
var ret = new Date( date.getTime() - tz.getRawOffset() )
// if we are now in DST, back off by the delta. Note that we are checking the GMT date, this is the KEY.
if ( tz.inDaylightTime( ret )) {
val dstDate = new Date( ret.getTime() - tz.getDSTSavings() )
// check to make sure we have not crossed back into standard time
// this happens when we are on the cusp of DST (7pm the day before the change for PDT)
@gwjjeff
gwjjeff / def.sh
Created January 5, 2012 14:54
bash: frequently used scripts
# example: mergepath $JAVA_HOME/bin java
mergepath() {
if [[ "${PATH/$1/}" != "$PATH" ]] ; then
echo $2 already in \$PATH
else
export PATH=$1:$PATH
echo add $2 to \$PATH
fi
}
@gwjjeff
gwjjeff / log4j.properties
Last active September 28, 2015 17:27
一些典型的配置文件
log4j.rootLogger=INFO, console, rfile, logfile, errfile
log4j.appender.console=org.apache.log4j.ConsoleAppender
log4j.appender.console.layout=org.apache.log4j.PatternLayout
log4j.appender.console.layout.ConversionPattern=%5p | %m%n
log4j.appender.console.threshold=INFO
log4j.appender.rfile=org.apache.log4j.RollingFileAppender
log4j.appender.rfile.file=${app.base}/log/app.log
log4j.appender.rfile.maxFileSize=1024KB
log4j.appender.rfile.maxBackupIndex=5