Skip to content

Instantly share code, notes, and snippets.

View v0lkan's full-sized avatar
🎸
totally rocking it 🚀.

Volkan Özçelik v0lkan

🎸
totally rocking it 🚀.
View GitHub Profile
// This...
exports.find = function(queue, query, callback) {
switch(queue) {
case 'today':
return callback(null, {
query: query,
realm: 'today',
goals: privates.getTodayGoals(query)
});
@v0lkan
v0lkan / consolefix.js
Created June 11, 2014 23:11
makes console.log display method and line info.
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);}
@v0lkan
v0lkan / maybe.js
Last active August 29, 2015 14:02
A quick namespace resolver.
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');
@v0lkan
v0lkan / frameworks.md
Last active August 29, 2015 14:05
Do You Rely On Any Frameworks?

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?

@v0lkan
v0lkan / gruvbox-terminal.vim
Created August 18, 2014 23:13
My current color scheme.
" -----------------------------------------------------------------------------
" 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: {{{
@v0lkan
v0lkan / app.js
Last active August 29, 2015 14:06
#nodejs #tip Tame your dependencies with a `rekuire` function ;)
// ----------------------------------------------------------------------------
// 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)
)
);
};
@v0lkan
v0lkan / console.extend.wtf.js
Last active August 29, 2015 14:07 — forked from anonymous/console.extend.wtf.js
A shim for the console.wtf functionality (hoping that somebody natively implements that feature in the future ;))
// ## 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,
@v0lkan
v0lkan / vimrc
Last active September 15, 2015 15:15
vimrc
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