Skip to content

Instantly share code, notes, and snippets.

@kof
kof / defer 1
Created January 21, 2011 14:48
deffered function execution
(function(global){
var $ = global.jQuery || global,
D = Date,
now = D.now || function() {
return (new D).getTime();
};
// if once is true, fn will be executed only once if called more then one times during the time in delay.
// if once is not defined or false, fn will be executed periodically, period is delay.
require('./schema');
var m = require('mongoose');
var Model = m.model('mymodel');
var model = new Model({
name: 'test',
elements: [{
@kof
kof / inherits.js
Created March 24, 2011 13:10
nodejs like utility method for inheritance
/**
* Inherit prototype properties
* @param {Function} ctor
* @param {Function} superCtor
*/
_.mixin({
inherits: (function(){
function noop(){}
function ecma3(ctor, superCtor) {
@kof
kof / bootstrap.js
Created March 30, 2011 22:52
bootstrap file for mongoose models
var fs = require('fs'),
m = require('mongoose');
fs.readdirSync(__dirname).forEach(function(filename) {
var schamaName = filename.replace(/\.js$/, ''),
Schema = require('./' + schemaName);
m.model(schemaName, Schema);
});
var m = require('mongoose'),
fs = require('fs'),
http = require('http');
m.connect('mongodb://localhost/test');
var ObjectId = m.Types.ObjectId;
var UserModel = m.model('user', require('./userSchema', {strict: false}));
var data = { "birthday" : Date("1981-09-21T00:00:00Z"), "email" : "aaaaa@bbbbbb.com", "firstName" : "Hannes", "lastIpAddr" : "138.188.103.139", "lastName" : "Gassert", "likedSkim" : true, "locale" : "en_US", "nick" : "Hannes", "relationshipStatus" : "In a Relationship", "urlName" : "han", "coins" : 550, "marketValue" : 63, "currentLocale" : "en-us", "sports" : [ ], "schools" : [ { "id" : "109924452370813", "name" : "Gymnasium Leonhard", "_id" : ObjectId("517fc1e66d19040200004fb7") }, { "id" : "107967209224731", "name" : "University of Fribourg", "_id" : ObjectId("517fc1e66d19040200004fb6") }, { "id" : "109414082410185", "name" : "National University of Ireland, Galway", "_id" : ObjectId("517fc1e66d19040200004fb5") } ], "jobs" : [ { "id" : "1602115006654
/******************************************************************************
* Screens DPI
* @see
* http://developer.android.com/guide/webapps/overview.html
* http://developer.android.com/guide/practices/screens_support.html
*****************************************************************************/
/*mdpi*/
@media (-webkit-min-device-pixel-ratio : 1) and (min-width: 320px), (min-device-pixel-ratio : 1) and (min-width: 320px) {
body {zoom: 0.5 !important;}
@kof
kof / famous-scrollview.js
Created May 19, 2014 21:06
famous scrollview
/* globals define */
define(function(require, exports, module) {
'use strict';
// import dependencies
var Engine = require('famous/core/Engine');
var Modifier = require('famous/core/Modifier');
var Transform = require('famous/core/Transform');
var Scrollview = require("famous/views/Scrollview");
var View = require('famous/core/View');
var Surface = require('famous/core/Surface');
@kof
kof / structure.md
Last active August 29, 2015 14:01
Project structure

app

  1. lib (app unspecific, installed from bower, npm or component) - lib1
  2. src (app specific) - screens (take components and build screens)
    • screen1
      • models
        • Model1.js
      • views
  • View1.js
@kof
kof / SomeView.js
Last active August 29, 2015 14:03
RenderController
SomeView.prototype.show = function() {
var prevAnimation = {
transition: {},
transform: {}
}
var thisAnimation = {
transition: {},
transform: {}
}
@kof
kof / app.js
Created June 25, 2014 23:05
Famo.us app init
exports.ready = new Promise(function(fulfill, reject) {
var isResized, isDomReady
var isDeviceReady = !window.cordova
context.on('resize', function() {
isResized = true
resolve()
})
domready(function() {