Skip to content

Instantly share code, notes, and snippets.

@imhu
imhu / migration_integer_limit_option
Created September 11, 2018 07:12 — forked from stream7/migration_integer_limit_option
Rails migrations integer :limit option
literally always have to look up the meaning of :limit in migrations when it comes to integer values. Here's an overview. Now let's memorise it (oh, this works for MySQL, other databases may work differently):
:limit Numeric Type Column Size Max value
1 tinyint 1 byte 127
2 smallint 2 bytes 32767
3 mediumint 3 byte 8388607
nil, 4, 11 int(11) 4 byte 2147483647
5..8 bigint 8 byte 9223372036854775807
Note: by default MySQL uses signed integers and Rails has no way (that I know of) to change this behaviour. Subsequently, the max. values noted are for signed integers.
git config --global https.proxy http://127.0.0.1:1080
git config --global https.proxy https://127.0.0.1:1080
git config --global --unset http.proxy
git config --global --unset https.proxy
npm config delete proxy
@imhu
imhu / wxcrypto.js
Created November 15, 2017 07:15 — forked from longbill/wxcrypto.js
微信公众号消息加密解密nodejs模块
'use strict';
var crypto = require('crypto');
/**
* 微信公众号消息加密解密
* by Chunlong (http://jszen.com)
*
* var WXCrypto = require('this module');
* var wx = new WXCrypto(token, aesKey, appid);
@imhu
imhu / dom-to-json.js
Created September 29, 2016 05:42 — forked from sstur/dom-to-json.js
Stringify DOM nodes using JSON (and revive again)
function toJSON(node) {
node = node || this;
var obj = {
nodeType: node.nodeType
};
if (node.tagName) {
obj.tagName = node.tagName.toLowerCase();
} else
if (node.nodeName) {
obj.nodeName = node.nodeName;
@imhu
imhu / Apache Tomcat 8 Start stop script init.d script
Created May 23, 2016 08:50 — forked from miglen/Apache Tomcat 8 Start stop script init.d script
Apache Tomcat init script (or startup/controll script). Works fine for version 7/8. Read the comments for release history. Feel free to modify, copy and give suggestions. (c) GNU General Public License
#!/bin/bash
#
# description: Apache Tomcat init script
# processname: tomcat
# chkconfig: 234 20 80
#
#
# Copyright (C) 2014 Miglen Evlogiev
#
# This program is free software: you can redistribute it and/or modify it under
@imhu
imhu / swipeFunc.js
Last active August 29, 2015 14:20 — forked from localpcguy/swipeFunc.js
var swipeFunc = {
touches : {
"touchstart": {"x":-1, "y":-1},
"touchmove" : {"x":-1, "y":-1},
"touchend" : false,
"direction" : "undetermined"
},
touchHandler: function(event) {
var touch;
if (typeof event !== 'undefined'){