Skip to content

Instantly share code, notes, and snippets.

console.lol = function () {
var args = Array.prototype.slice.call(arguments);
args.unshift('such-log!');
console.log.apply(console, args);
};
@gergelyke
gergelyke / Gruntfile.js
Last active August 29, 2015 13:56
Gruntfile to concat & uglify
'use strict';
module.exports = function(grunt) {
// Project configuration.
grunt.initConfig({
concat: {
dist: {
src: ['main.js', 'ctrl1.js'], //source files goes here
@gergelyke
gergelyke / Gruntfile.js
Last active March 27, 2017 09:47
Uploading to S3, Cloudfront invalidation, HipChat notification
'use strict';
module.exports = function(grunt) {
// Project configuration.
grunt.initConfig({
s3: {
options: {
region: 'us-east-1',
endpoint: 's3.amazonaws.com',
'use strict';
module.exports = function(grunt) {
// Project configuration.
grunt.initConfig({
concat: {
dist: {
src: ['main.js', 'ctrl1.js'], //source files goes here
dest: 'build/lib.js' //concatenated file goes here
@gergelyke
gergelyke / server.js
Created March 4, 2014 16:26
Restify routes
server.get('/', [
restify.bodyParser(),
function (req, res, next) {
console.log('done')
res.send('okay ' + req.whatever)
return next()
}
]);
@gergelyke
gergelyke / 01.js
Last active August 29, 2015 14:00
Generators
function* naturalNumbers(){
var n = 1;
while (true){
yield n++;
}
}
var numbers = naturalNumbers();
console.log (numbers.next());
@gergelyke
gergelyke / app.js
Last active August 29, 2015 14:01
Koa middlewares
var koa = require('koa');
var app = koa();
app.use(function *responseTime(next){
var start = new Date;
yield next;
var ms = new Date - start;
this.set('X-Response-Time', ms + 'ms');
});
{
"username": "XXX",
"key": "XXX",
"test_path": "test/angular/protractor.conf.js",
"test_framework": "mocha",
"browsers": [
{
"browser": "firefox",
"browser_version": "latest",
"os": "OS X",
@gergelyke
gergelyke / PROJECT_NAME.conf
Created July 11, 2014 05:57
Minimal Node.js supervisor conf
[program:PROJECT_NAME]
command=/home/risingstack/.nvm/v0.10.29/bin/node /home/risingstack/PROJECT_NAME/app.js
autostart=true
autorestart=true
environment=NODE_ENV=production
stderr_logfile=/var/log/PROJECT_NAME.err.log
stdout_logfile=/var/log/PROJECT_NAME.out.log
@gergelyke
gergelyke / Very.js
Last active August 29, 2015 14:06
Such javascript, very unicredit
// not written by me, found at unicredit's spectranet :)
// now I feel a lot safer
function parseBug(m){
if (m == '08') return '8';
if (m == '09') return '9';
return m
}
var dp_y=parseInt(parseBug(v.substring(0,4)));