Skip to content

Instantly share code, notes, and snippets.

View saltukalakus's full-sized avatar
💭

Saltuk Alakus saltukalakus

💭
View GitHub Profile
@saltukalakus
saltukalakus / elk_bulk.js
Last active October 6, 2015 17:08
Elastic search tests for API:1.7
var elasticsearch = require('elasticsearch');
var client = elasticsearch.Client({
hosts: [
'localhost:9200'
]
});
var tk = {
_bulkArray: function(idx, type, data) {
@saltukalakus
saltukalakus / with_function.js
Last active September 10, 2015 19:54
Object generation patterns.
function Apple (type) {
this.type = type;
this.color = "red";
}
Apple.prototype.getInfo = function() {
return this.color + ' ' + this.type + ' apple';
};
var apple = new Apple('macintosh');
@saltukalakus
saltukalakus / replace_json_property.js
Created September 10, 2015 11:23
Replace a JSON property dynamically in a function call
var test = function(key, value) {
a = {foo:{bar:{baz:"placeholder"}}};
a.foo.bar.baz = {}; //creating a new object as `baz` value then assign
a.foo.bar.baz[key] = value;
console.log(JSON.stringify(a));
};
test("Jon", "Dough");
@saltukalakus
saltukalakus / typeof_vs_instanceof.js
Last active September 10, 2015 12:26
typeof vs instanceof
/*
typeof is a construct that "returns" the primitive type of whatever you pass it.
instanceof tests to see if the right operand appears anywhere in the prototype chain of the left.
*/
var test = require('tape');
test('typeof vs instanceof tests', function (t) {
t.plan(13);
@saltukalakus
saltukalakus / README.md
Last active February 6, 2017 20:03
Technologies in the scope

List of things I am interested in web technologies. Not inclusive.

Database

  • MongoDB
  • ElasticSearch
  • Redis

Backend Libraries

  • ExpressJs
  • Mongoose
@saltukalakus
saltukalakus / module_pattern.js
Last active September 29, 2015 13:36
Structural patterns
test = require('tape');
// Basic module with closure
var Module = (function () {
var my = {},
privateVariable = 1;
function setPrivateMethod(val) {
privateVariable = val;
@saltukalakus
saltukalakus / function_overload.js
Last active September 17, 2015 11:18
Function overloading
test = require("tape");
function addMethod(object, name, fn){
object._store = object._store || {};
object._store[name] = object._store[name] || {};
object._store[name][fn.length] = fn;
object[name] = function() {
if(this._store[name][arguments.length])
return this._store[name][arguments.length].apply(this, arguments);
};
@saltukalakus
saltukalakus / string_to_array
Created August 7, 2016 10:33
js, convert array to string with space
var arr = [1,2,3,4];
var res= arr.join(' ');
@saltukalakus
saltukalakus / npm_view_old
Created August 7, 2016 15:14
npm view list old versions of a module
npm view module_name versions
@saltukalakus
saltukalakus / window.onload
Created August 9, 2016 14:10
js window on load page refresh trigger
window.onload = function() {
doSomethingElse();
};