This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// I was in a hurry, so I didn't look for it on internet... thought I would share it :P | |
function toggleMsg(callback) { | |
$("#my_block").fadeToggle( | |
'slow', function() { | |
toggleMsg(callback) | |
}); | |
} | |
toggleMsg(toggleMsg); //It's infinite! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Current solution | |
var Vatican = require("vatican"); | |
var app = new Vatican(); | |
app.preprocessor(function(req, res, next) { | |
if(req.url.indexOf("/auth/unregister") != -1) { | |
//do the checks | |
if(error) next(error) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function getScreenshots(urls) { | |
console.log("Getting screenshots for: " + urls.length + " files") | |
var client = knox.createClient({ | |
key: config.s3.key, | |
secret: config.s3.secret, | |
bucket: config.s3.bucket | |
}); | |
return function(callback) { | |
async.mapSeries(urls, function(url, cb) { | |
console.log("Getting: " + url) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const request = require("request"), | |
fibonacci = require("fibonacci"), | |
fs = require("fs"); | |
process.nextTick(() => { | |
process.stdout.write("NT #1\n"); | |
}); | |
fs.readFile("./index.js", (err, data) => { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const { Worker, isMainThread, workerData } = require('worker_threads'); | |
let currentVal = 0; | |
let intervals = [100,1000, 500] | |
function counter(id, i){ | |
console.log("[", id, "]", i) | |
return i; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const { Worker, isMainThread, parentPort, workerData } = require('worker_threads'); | |
const request = require("request"); | |
if(isMainThread) { | |
console.log("This is the main thread") | |
let w = new Worker(__filename, {workerData: null}); | |
w.on('message', (msg) => { //A message from the worker! | |
console.log("First value is: ", msg.val); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports = { | |
firstValue: null, | |
sort: function(list) { | |
let sorted = list.sort(); | |
this.firstValue = sorted[0] | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const { Worker, isMainThread, parentPort, workerData } = require('worker_threads'); | |
const request = require("request"); | |
function startWorker(path, cb) { | |
let w = new Worker(path, {workerData: null}); | |
w.on('message', (msg) => { | |
cb(null, msg) | |
}) | |
w.on('error', cb); | |
w.on('exit', (code) => { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const { parentPort } = require('worker_threads'); | |
function random(min, max) { | |
return Math.random() * (max - min) + min | |
} | |
const sorter = require("./test2-worker"); | |
const start = Date.now() | |
let bigList = Array(1000000).fill().map( (_) => random(1,10000)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const PusherServer = require('pusher'); | |
const PusherClient = require('pusher-js'); | |
const express = require('express'); | |
const router = express.Router(); | |
const config = require("config"); | |
const pusherServer = new PusherServer(config.get('pusher.config')); | |
const pusherClient = new PusherClient(config.get('pusher.config.key'), { | |
cluster: config.get('pusher.config.cluster') |
OlderNewer