Skip to content

Instantly share code, notes, and snippets.

View jackey's full-sized avatar
🏠
Working from home

jackey

🏠
Working from home
  • A programer
  • Changde, Hunan, China
View GitHub Profile
@jackey
jackey / AjaxForm
Created May 19, 2011 08:44
small event driver programe
/**
* @description Ajax Form object. Depend on the jQuery and jquery.form.js
* @param
*/
function AjaxForm(settings) {
this.settings = settings;
this.action = {};
this.__load(settings.url, settings.form_id);
};
@jackey
jackey / bones error
Created June 14, 2011 11:04
bones error
node index.js
node.js:116
throw e; // process.nextTick error, or 'error' event on first tick
^
TypeError: object is not a function
at Object.CALL_NON_FUNCTION_AS_CONSTRUCTOR (native)
at Object.<anonymous> (/home/jackey/workspace/bones/servers/Route.bones:13:13)
at Module._compile (module.js:380:26)
at Object..bones (/home/jackey/workspace/bones/server/plugin.js:32:12)
@jackey
jackey / gist:1026639
Created June 15, 2011 07:25
optimization array read
$array = array(
'field_item_1' => array(
'field_sub_item_11' => array('field' => TRUE, 'title' => 'sub field item 1'),
'field_sub_item_12' => array('field' => FALSE, 'title' => 'sub field item 2'),
),
'field_item_2' => array(
'field_sub_item_21' => array('field' => TRUE, 'title' => 'sub field item 21'),
),
);
@jackey
jackey / gist:1414846
Created December 1, 2011 08:06
process.nextTick
var MyConstructor = function() {
...
process.nextTick(function() {
self._continue();
});
};
MyConstructor.prototype.__proto__ = EventEmitter.prototype;
MyConstructor.prototype._continue = function() {
@jackey
jackey / gist:1505400
Created December 21, 2011 09:40
events binding missed!
router:
App.bones
```javascript
router = Backbone.Router.extend({
routes: {
'front': 'front'
},
front: function () {
this.send(views.Front);
@jackey
jackey / gist:1891370
Created February 23, 2012 07:46
create instance as soon as required module
//File class.js
class = module.exports = function () {
}
class.prototype.add = function () {console.log('hello')};
//File index.js
var class = new require('./class')();
@jackey
jackey / connection.js
Created March 23, 2012 09:46
Bones Attachment Model And Document Model
var _ = Bones._;
var sync = Document.prototype.sync;
Document.prototype.sync = function (method, model, options) {
var self = this;
var properties = this.getSchema().getProperty('properties');
var names = properties.getPropertyNames();
_.each(names, function(name, index) {
var property = properties.getProperty(name);
// Maybe I should use function instead of directly access value;
<HTML><HEAD><style type="text/css">
<!--
a:link {
color: #000000;
text-decoration: none;
}
a:visited {
color: #000000;
text-decoration: none;
}
@jackey
jackey / gist:2557021
Created April 30, 2012 10:15
PHP 字符 截取
//来自 phpcms:
/**
* 字符截取 支持UTF8/GBK
* @param $string
* @param $length
* @param $dot
*/
function str_cut($string, $length, $dot = '...') {
$strlen = strlen($string);
@jackey
jackey / gist:2707285
Created May 16, 2012 04:07
Mysql draft
CREATE TABLE `table_name` (
`id` INT AUTO_INCREMENT,
`center` POINT,
`radius` INT
)
SELECT (GLength(LineStringFromWKB(LineString(pt,GeomFromText(center))))) AS rradius
FROM `table_name` t