Skip to content

Instantly share code, notes, and snippets.

View ermst4r's full-sized avatar

Erwin Nandpersad ermst4r

View GitHub Profile
module.exports.bootstrap = function(cb) {
_.extend(sails.hooks.http.app.locals, sails.config.http.locals);
// add the lines from here
// bootstrapping all the cronjobs in the crontab folder
var schedule = require('node-schedule');
sails.config.crontab.crons().forEach(function(item){
schedule.scheduleJob(item.interval,sails.config.crontab[item.method]);
});
<script>
module.exports.bootstrap = function(cb) {
_.extend(sails.hooks.http.app.locals, sails.config.http.locals);
// add the lines from here
// bootstrapping all the cronjobs in the crontab folder
var schedule = require('node-schedule');
sails.config.crontab.crons().forEach(function(item){
schedule.scheduleJob(item.interval,sails.config.crontab[item.method]);
//
// FirstViewController.swift
// cheapveilingen
//
// Created by Erwin Nandpersad on 17-07-16.
// Copyright © 2016 Cheapveilingen.nl. All rights reserved.
// http://stackoverflow.com/questions/23193087/using-timer-in-a-tableview-re-creates-the-timer-after-any-scroll-or-table-reload
import UIKit
import SwiftyJSON
@ermst4r
ermst4r / CustomCell.swift
Created August 17, 2016 18:09
CustomCell.swift
//
// CustomCell.swift
// cheapveilingen
//
// Created by Erwin Nandpersad on 17-07-16.
// Copyright © 2016 Cheapveilingen.nl. All rights reserved.
//
import UIKit
import SocketIOClientSwift
var page = 1,
lastPage = 5000; // force sync, by incresing this counter
async.whilst(function () {
return page <= lastPage;
},
function (next) {
// BUSINESS LOGIC HERE
// DON'T FORGET TO ADD page++ and next() into a callback
@ermst4r
ermst4r / async_2.js
Created August 31, 2016 13:00
example 2
var fileType = require('file-type');
var fs = require('fs');
var Stream = require('stream').Transform;
var image_dest = sails.config.orangebuddies.settings.image_download_location;
var thumb_dest = sails.config.orangebuddies.settings.image_thumbnail_location;
var max_images_writes = sails.config.orangebuddies.settings.max_write_images;
var product = require('../../services/mongoose_wrapper/product');
var path = require('path');
var request = require('request');
var async = require('async');
parse: function(feed) {
return new Promise(function(resolve, reject) { // wrap into function to return a promise
sails.log.info('downloading feed ' + feed.id );
importcsv_service.parsecsvfeed.downloadfile(feed,csv_dir).then(function(file){
sails.log.info('file '+ feed.id +' downloaded succesfully');
return file;
}).then(function(file) {
console.log("reading" + file);
importcsv_service.parsecsvfeed.convert_line_to_json(file).then(function(data) {
@ermst4r
ermst4r / psuedo_code.js
Created September 2, 2016 07:28
psuodo code
var counter = 0 // count when the foreach is done
retailers.forEach(function(retailer) {
retailer.siteid=siteid;
retailer.month=month;
retailer.year=year;
prim_id =md5(siteid+month+year+retailer.storeid);
retailer.prim_id=prim_id;
//sails.log(retailer);
Retailers.updateOrCreate({prim_id:prim_id},retailer,function createFindCB(error, createdOrFoundRecords){
module.exports = {
run:function()
{
Feed.find({}).then(function(feed) {
@ermst4r
ermst4r / iTasks.php
Created October 5, 2016 15:42
taken
<?php
namespace tasks;
interface iTask {
/**
* Method to enqueue the task. This should take params and values from the class that implements the interface,
* given to the class by the constructor or other methods.
**/