This is an excerpt from an interview that I had recently.
Just wanted to share.
Volkan
Since how long do you develop for the web ? Front-end or Back-end?
| // This... | |
| exports.find = function(queue, query, callback) { | |
| switch(queue) { | |
| case 'today': | |
| return callback(null, { | |
| query: query, | |
| realm: 'today', | |
| goals: privates.getTodayGoals(query) | |
| }); |
| var methods = ['log', 'warn'], i, len, old; | |
| for (i = 0, len = methods.length; i < len; i++){ | |
| old = console[methods[i]]; | |
| console[methods[i]] = function() { | |
| var stack = (new Error()).stack.split(/\n/); | |
| if (stack[0].indexOf('Error') === 0) {stack = stack.slice(1);} | |
| function maybe(obj, path, defaultValue) { | |
| if (obj == null) {return undefined;} | |
| var reduced = path.split('.').reduce(function(memo, attr) { | |
| if (memo == null) {return undefined;} | |
| return memo[attr]; | |
| }, obj); | |
| return reduced === undefined ? defaultValue : reduced; |
| var app = require('express')(), | |
| server = require('http').Server(app), | |
| io = require('engine.io').attach(server); | |
| // Use this middleware to workaround "Access-Control-Allow-Origin" errors on the client. | |
| app.use(function (req, res, next) { | |
| res.setHeader('Access-Control-Allow-Origin', "http://theWebsiteThatOpensSocketConnection.com"); | |
| res.setHeader('Access-Control-Allow-Methods', 'GET, POST, OPTIONS, PUT, PATCH, DELETE'); | |
| res.setHeader('Access-Control-Allow-Headers', 'X-Requested-With,content-type'); | |
| res.setHeader('Access-Control-Allow-Credentials', 'true'); |
This is an excerpt from an interview that I had recently.
Just wanted to share.
Volkan
Since how long do you develop for the web ? Front-end or Back-end?
| " ----------------------------------------------------------------------------- | |
| " Almost 99% Based on gruvbox.vim | |
| " Description: Retro groove color scheme for Vim | |
| " Author: morhetz <morhetz@gmail.com> | |
| " Source: https://github.com/morhetz/gruvbox | |
| " ----------------------------------------------------------------------------- | |
| " Supporting code ------------------------------------------------------------- | |
| " Initialisation: {{{ |
| // ---------------------------------------------------------------------------- | |
| // File: PROJECT_ROOT/ ... / servers/app1/app.js | |
| // Define this **before** all the `require`s. | |
| function initRekuire(baseDir, appDir) { | |
| var base = baseDir || '.', | |
| app == appDir || '.'; | |
| global.rekuire = function(name) { | |
| return require( |
| // ## Every console needs a WTF prompt. | |
| // Method: | |
| console.wtf = function() { | |
| console.warn.apply(console, | |
| ['(W)hat a (T)errible (F)ailure »» '].concat( | |
| Array.prototoype.slice.call(arguments) | |
| ) | |
| ); | |
| }; |
| // ## Every console needs a WTF prompt. | |
| // | |
| // Usage: | |
| //console.wtf('This should not have happened AT ALL!', param1, param2); | |
| // Check if `console.wtf` is natively supported. | |
| if (!console.wtf) { | |
| console.wtf = function() { | |
| console.warn.apply(console, |
| set nocompatible " be iMproved, required | |
| filetype off " required | |
| " set the runtime path to include Vundle and initialize | |
| set rtp+=~/.vim/bundle/Vundle.vim | |
| call vundle#begin() | |
| " alternatively, pass a path where Vundle should install plugins | |
| "call vundle#begin('~/some/path/here') | |
| " let Vundle manage Vundle, required |