Skip to content

Instantly share code, notes, and snippets.

View saltukalakus's full-sized avatar
🐢
Rust & Cryptography

saltukalakus

🐢
Rust & Cryptography
View GitHub Profile
@saltukalakus
saltukalakus / typeof_vs_instanceof.js
Last active June 2, 2025 20:40
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 / 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 / with_function.js
Last active June 2, 2025 20:40
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 / elk_bulk.js
Last active June 2, 2025 20:40
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) {