Skip to content

Instantly share code, notes, and snippets.

Saltuk Alakus saltukalakus

Block or report user

Report or block saltukalakus

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@saltukalakus
saltukalakus / elk_bulk.js
Last active Oct 6, 2015
Elastic search tests for API:1.7
View elk_bulk.js
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 Sep 10, 2015
Object generation patterns.
View with_function.js
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 Sep 10, 2015
Replace a JSON property dynamically in a function call
View replace_json_property.js
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");
View typeof_vs_instanceof.js
/*
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 Feb 6, 2017
Technologies in the scope
View README.md

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 Sep 29, 2015
Structural patterns
View module_pattern.js
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 Sep 17, 2015
Function overloading
View function_overload.js
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 Aug 7, 2016
js, convert array to string with space
View string_to_array
var arr = [1,2,3,4];
var res= arr.join(' ');
@saltukalakus
saltukalakus / npm_view_old
Created Aug 7, 2016
npm view list old versions of a module
View npm_view_old
npm view module_name versions
@saltukalakus
saltukalakus / window.onload
Created Aug 9, 2016
js window on load page refresh trigger
View window.onload
window.onload = function() {
doSomethingElse();
};
You can’t perform that action at this time.