Skip to content

Instantly share code, notes, and snippets.

View thanpolas's full-sized avatar

Thanos Polychronakis thanpolas

View GitHub Profile
@thanpolas
thanpolas / apitest.js
Created February 7, 2014 17:09
Mocha Cooldown
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) {
@thanpolas
thanpolas / test.js
Created February 13, 2014 13:52
How to test a promise returning async method using Mocha
View test.js
test('test case', function(done) {
promise.method(function(result) {
assert.equal(result.name, 'mocha');
}).then(done, done);
});
@thanpolas
thanpolas / list-mantri.js
Created February 18, 2014 13:49
List required files by Mantri
View list-mantri.js
var mantri = require('mantri');
var mantriCompile = require('mantri/lib/mantri-build-compile');
mantriCompile.getDepsFiles({
jsRoot: './js',
src: './js/app.js',
gmockDir: mantri.helpers.getPath('closure-mock'),
}, function(status, results) {
console.log('Status should be true:', status);
@thanpolas
thanpolas / README.md
Created March 6, 2014 22:43
Setup Heroku sensitive configs
View README.md
@thanpolas
thanpolas / README.md
Last active August 29, 2015 14:02
Heroku Environment mass export
View README.md

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.

Usage

  • Add env.js to your .gitignore file
  • Edit it as per your needs
@thanpolas
thanpolas / index.js
Created June 10, 2014 13:28
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
document.body.appendChild(canvas)
var context = canvas.getContext("2d")
@thanpolas
thanpolas / hack-lusca.js
Created June 14, 2014 16:31
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
thanpolas / jquery-debounce.js
Created May 20, 2015 12:22
Angular window resize service
View jquery-debounce.js
// http://www.paulirish.com/2009/throttled-smartresize-jquery-event-handler/
//
// debouncing function from John Hann
// http://unscriptable.com/index.php/2009/03/20/debouncing-javascript-methods/
var debounce = function (func, threshold, execAsap) {
var timeout;
return function debounced () {
var obj = this, args = arguments;
@thanpolas
thanpolas / MySublimeCheatsheat.md
Created July 3, 2012 14:49
Packages to install, configs, hints & tips
View MySublimeCheatsheat.md

My Sublime cheatsheet

Packages to install

  • Package Control website
  • SublimeLinter Git Site
  • Git support git repo - package control: git
  • sublime-jsdocs git repo - package control: DocBlockr
  • Alignment website - package control:alignment ctrl+alt+a or Cmd+ctrl+a
  • JsFormat Git Site - Package Control: JsFormat Ctrl+Alt+f
@thanpolas
thanpolas / string2path
Created September 17, 2012 19:07
string2path by Ben Alman
View string2path
/*
* grunt
* http://gruntjs.com/
*
* Copyright (c) 2012 "Cowboy" Ben Alman
* Licensed under the MIT license.
* http://benalman.com/about/license/
*/
(function(exports) {