Skip to content

Instantly share code, notes, and snippets.

View karlkori's full-sized avatar
:octocat:

Serhii Drahunov karlkori

:octocat:
View GitHub Profile
@karlkori
karlkori / README.md
Created January 25, 2016 15:00 — forked from magnetikonline/README.md
Shell redirection cheatsheet.
@karlkori
karlkori / optional-arguments.js
Last active November 26, 2015 16:23 — forked from klovadis/gist:2549131
How to use optional arguments in node.js
// example function where arguments 2 and 3 are optional
function example( err, optionalA, optionalB, callback ) {
// retrieve arguments as array
var args = [];
for (var i = 0; i < arguments.length; i++) {
args.push(arguments[i]);
}
// first argument is the error object
@karlkori
karlkori / resource.js
Last active August 29, 2015 14:14 — forked from vladikoff/resource.js
angular.module('itemServices', ['ngResource'])
.factory('Item', ['$resource',
function ($resource) {
return $resource('items/:id',
{id: '@id'},
{
query: {
isArray: true,
method: 'GET',
params: {},
// Node.js CheatSheet.
// Download the Node.js source code or a pre-built installer for your platform, and start developing today.
// Download: http://nodejs.org/download/
// More: http://nodejs.org/api/all.html
// 0. Synopsis.
// http://nodejs.org/api/synopsis.html
@karlkori
karlkori / gist:d536dfab9a006b7f7305
Last active August 29, 2015 14:10 — forked from Mithrandir0x/gist:3639232
Diference beetwen angular service, factory, provider
// Source: https://groups.google.com/forum/#!topic/angular/hVrkvaHGOfc
// jsFiddle: http://jsfiddle.net/pkozlowski_opensource/PxdSP/14/
// author: Pawel Kozlowski
var myApp = angular.module('myApp', []);
//service style, probably the simplest one
myApp.service('helloWorldFromService', function() {
this.sayHello = function() {
return "Hello, World!"
@karlkori
karlkori / pub_sub.js
Created October 21, 2013 10:55 — forked from s0ber/pub_sub.js
var mediator = (function(){
var subscribe = function(channel, fn){
if (!mediator.channels[channel]) mediator.channels[channel] = [];
mediator.channels[channel].push({ context: this, callback: fn });
return this;
},
publish = function(channel){
if (!mediator.channels[channel]) return false;