Skip to content

Instantly share code, notes, and snippets.

Thanasis Polychronakis thanpolas

Block or report user

Report or block thanpolas

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
thanpolas / singleton-class.js
Created Sep 16, 2016
ES6 Singleton Pattern
View singleton-class.js
* @fileOverview Singleton pattern on ES6.
import logger from './logger.midd';
* The class statement.
thanpolas / hidden-iframe.js
Last active Aug 8, 2018
In the absence of CORS support the Hidden Iframe technique is the only way to submit a big amount of data (over 2kb that jsonp can handle).
View hidden-iframe.js
* @fileOverview Hidden iFrame implementation for browsers without CORS.
* Usage:
* var iframe = new Iframe();
* iframe.submit(url, {data: yourData}, function(err) {});
* The server will get a POST request on the defined URL with the data
* JSON encoded in the body attribute named "data".
thanpolas / jquery-debounce.js
Created May 20, 2015
Angular window resize service
View jquery-debounce.js
// debouncing function from John Hann
var debounce = function (func, threshold, execAsap) {
var timeout;
return function debounced () {
var obj = this, args = arguments;
thanpolas / hack-lusca.js
Created Jun 14, 2014
Hack lusca CSRF store
View hack-lusca.js
* @fileOverview A CSRF Implementation for WebSocket calls.
var Promise = require('bluebird');
var config = require('config');
var lusca = require('lusca');
var Middleware = require('./middleware');
thanpolas / index.js
Created Jun 10, 2014
requirebin sketch
View index.js
// example using the raf module from npm. try changing some values!
var requestAnimationFrame = require("raf")
var canvas = document.createElement("canvas")
canvas.width = 500
canvas.height = 500
var context = canvas.getContext("2d")
thanpolas /
Last active Aug 29, 2015
Heroku Environment mass export

Exporting sensitive data to Heroku's Environment

This script is ment to work with the node-config package, it will export whatever configuration data you set on the herokuOverride Object, as a JSON serialized string, onto the NODE_CONFIG environment variable on Heroku.

This results in the config package to use those values instead, thus enabling you to keep sensitive data out of your tracked files.


  • Add env.js to your .gitignore file
  • Edit it as per your needs
thanpolas /
Created Mar 6, 2014
Setup Heroku sensitive configs
thanpolas / list-mantri.js
Created Feb 18, 2014
List required files by Mantri
View list-mantri.js
var mantri = require('mantri');
var mantriCompile = require('mantri/lib/mantri-build-compile');
jsRoot: './js',
src: './js/app.js',
gmockDir: mantri.helpers.getPath('closure-mock'),
}, function(status, results) {
console.log('Status should be true:', status);
thanpolas / test.js
Created Feb 13, 2014
How to test a promise returning async method using Mocha
View test.js
test('test case', function(done) {
promise.method(function(result) {
assert.equal(, 'mocha');
}).then(done, done);
View apitest.js
var apitest = module.exports = {};
* Have a Cooldown period between tests.
* @param {number} seconds cooldown in seconds.
* @return {Function} use is beforeEach().
apitest.cooldown = function(seconds) {
return function(done) {
You can’t perform that action at this time.