Skip to content

Instantly share code, notes, and snippets.

View katio's full-sized avatar

Johann Echavarria katio

  • Medellín, Colombia
View GitHub Profile
@tanaikech
tanaikech / submit.md
Last active April 23, 2024 22:31
Multipart-POST Request Using Node.js

Multipart-POST Request Using Node.js

Here, I introduce 2 scripts for uploading files to Slack using Node.js as samples. These 2 sample scripts are for uploading files to Slack.

Sample script 1:

  • You can upload the zip file by converting byte array as follows.
    • At first, it builds form-data.
    • Adds the zip file converted to byte array and boundary using Buffer.concat().
    • This is used as body in request.
transaction = new DOMTransaction(function (container, articleList) {
var childCount = container.childNodes.length;
for (let article of articleList)
container.append(article);
// No DOM mutation is made until this function exits.
console.assert(childCount == container.childNodes.length);
});
transaction.commit(element, articles);
@katio
katio / polyfill.js
Last active November 4, 2021 15:02
Collection of JavaScript polyfills of MDN (Mozilla Developer Network) https://developer.mozilla.org. Polyfill definition in MDN (https://developer.mozilla.org/en-US/docs/Web/Guide/Terminology) "A polyfill is a piece of code that implements a common API that isn't natively supported by a browser". This file can be used in XPages SSJS (Server Side…
"use strict";
/*Start of developer.mozilla.org Polyfill*/
/*WARNING FOR SERVER SIDE JAVASCRIPT IN XPAGES: http://xomino.com/2014/03/02/prototypal-inheritance-of-ssjs-across-the-whole-server-in-xpages/ http://stackoverflow.com/questions/26695434/how-to-clean-ssjs-in-domino-server-after-someone-used-javascript-*/
/*
* Polyfill:
Array.isArray
Array.prototype.indexOf
Array.prototype.lastIndexOf
Array.prototype.forEach
Array.prototype.some
@katio
katio / resig-netflix-inheritance.js
Last active April 23, 2018 22:45
From @dylanthehuman's article: (http://techblog.netflix.com/2014/05/improving-performance-of-our-javascript.html) about Netflix's improved version of John Resig's "simple-javascript-inheritance" (http://ejohn.org/blog/simple-javascript-inheritance/)
/* Simple JavaScript Inheritance with NFE's
* MIT Licensed.
*/
// Inspired by base2 and Prototype and John Resig's class system
(function(){
var initializing = false;
// The base Class implementation (does nothing)
this.Class = function(){};
@ssp
ssp / elag-couchdb.text
Created May 28, 2013 21:08
Notes for CouchDB Bootcamp at ELAG 2013.
+ Part I: Getting to know CouchDB (10:00-12:30)
+ Hello
+ me = ssp@SUB
- https://github.com/ssp/
- http://www.sub.uni-goettingen.de/
- who are you?
- what are you doing?
- how do you think CouchDB could be interesting for you?
+ What is CouchDB?
- http://couchdb.apache.org
@liamcurry
liamcurry / gist:2597326
Created May 4, 2012 19:56
Vanilla JS vs jQuery

Moving from jQuery

Events

// jQuery
$(document).ready(function() {
  // code
})
@dhm116
dhm116 / ie.shims.js
Created February 10, 2012 15:14
IE7/8 Javascript method shims
'use strict';
// Add ECMA262-5 method binding if not supported natively
//
if (!('bind' in Function.prototype)) {
Function.prototype.bind= function(owner) {
var that= this;
if (arguments.length<=1) {
return function() {
return that.apply(owner, arguments);
@lpar
lpar / weeknum.ls
Created June 17, 2011 18:28
ISO 8601 week number calculation in LotusScript
Function WeekNumber(t As NotesDateTime) As String
' Wrapper to work out week numbers of NotesDateTime objects in the
' current time zone
Dim lst As Variant
lst = t.LSLocalTime
WeekNumber = LSWeekNumber(lst)
End Function
Function LSWeekNumber(t As Variant) As String
' Returns the week number of a NotesDateTime object
@robrighter
robrighter / gist:897565
Created April 1, 2011 00:59
Walk a JSON/Javascript tree to grab all values for a given key
function traverse(obj,func, parent) {
for (i in obj){
func.apply(this,[i,obj[i],parent]);
if (obj[i] instanceof Object && !(obj[i] instanceof Array)) {
traverse(obj[i],func, i);
}
}
}
function getPropertyRecursive(obj, property){