Skip to content

Instantly share code, notes, and snippets.

/**
* Created by Simon on 6/23/14.
*/
// parsable url example parse?limit=2&offset=2&sort=grpId%20DESC&filter={"grpId":{">":"1"}}
// in api/services
exports.parseGetParams = function (params) {
var query = {
limit : 10,
@mmirolim
mmirolim / gist:18323d6ab2fd1f4f4dc3
Created June 30, 2014 18:23
Private channel static for a day
current: function (req, res){
return User.findOne(req.session.user)
.then(function (user) {
if (!user) return {msg:'User not found.'};
var today = new Date();
var hash = user.fullName + today.getDay();
return [{
fullName: user.fullName,
role: user.role,
id: user.id,
@mmirolim
mmirolim / gist:27c2891ddd06ce51dae3
Created June 30, 2014 21:25
Example of pouchDB service in angularjs
app.factory('CacheDB', ['$http', 'API',
function ($http, API) {
var db = new PouchDB('cachedb');
return {
put: function (obj, id) {
db.put(obj, id)
.then(function (r) {
return r;
});
},
// Enter the nodes.
// set different colors for task status
var nodeEnter = node.enter().append("g")
.attr("class", function (d) {
return "node" + " " + d.status;
})
.attr("transform", function(d) {
return "translate(" + d.y + "," + d.x + ")"; });
nodeEnter.append("circle")
@mmirolim
mmirolim / gist:f096eb82a80285653e97
Created July 3, 2014 19:56
Order tasks by createdAt
ng-repeat="task in tasks | orderBy: '-createdAt'"
@mmirolim
mmirolim / gist:9b7f85bf22d944c9d155
Last active August 29, 2015 14:03
Auto focus to popups
/**
* Directive to focus autocomplete popover when it shown
* @author Mirolim Mirzakhmedov mirolim777 at gmail dot com
*/
app.directive('focusPopover', function($timeout) {
return function(scope, element) {
$timeout(function() {
element.focus();
});
}
@mmirolim
mmirolim / services.js
Created July 4, 2014 00:12
Offline Gear
/**
* Caching service via pouchDb
* @link http://pouchdb.com/
* @author Mirolim Mirzakhmedov mirolim777 at gmail.com
* @date 03.07.2014
*/
app.factory('CacheDB', ['$http', 'API',
function ($http, API) {
var db = new PouchDB('cachedb');
@mmirolim
mmirolim / Changes-06-07-14.js
Last active August 29, 2015 14:03
Modifications 06.07.14
// DEFINE cache _ID in one place
// like for update, create, last disconnect and so on
// add children collection to task model
children:{
collection: 'task',
via: 'parentTaskId'
// fix problem with sails crash (waterline) when model send with extra fields
// clean obj before so sails will not crash, should be cleaned in TaskController actions update and create
@mmirolim
mmirolim / anti-iframe
Created July 17, 2014 18:43
Test if in iframe
if ( window.location !== window.parent.location ) {
// The page is in an iframe
} else {
// The page is not in an iframe
}
@mmirolim
mmirolim / balabol.go
Created July 31, 2014 03:06
Simple load producer
package main
import (
"fmt"
"flag"
//"errors"
//"os"
//"strings"
"strconv"
"math/rand"