Skip to content

Instantly share code, notes, and snippets.

View wmakeev's full-sized avatar
💭
💻

Makeev Vitaliy wmakeev

💭
💻
View GitHub Profile
@wmakeev
wmakeev / http-post.json
Created November 5, 2014 13:38
Google Script HTTP POST
{
"queryString": "param1=value11¶m1=value12¶m2=value2",
"postData": {
"contents": "{ \"key1\": \"value1\", \"key2\": \"value2\" }",
"type": "application/javascript",
"name": "postData",
"length": 38
},
"parameter": {
"param1": "value11",
@wmakeev
wmakeev / http-get.json
Created November 5, 2014 13:39
Google Script HTTP GET
{
"queryString": "param1=value11¶m1=value12¶m2=value2",
"parameter": {
"param1": "value11",
"param2": "value2"
},
"contextPath": "",
"parameters": {
"param1": [
"value11",
@wmakeev
wmakeev / checkType.js
Last active August 29, 2015 14:09
Check type
checkType = function(type, val, name) {
if (typeof val !== type) {
return "" + name + " has to be a " + type;
}
};
err = checkType("string", id, "module ID") || checkType("function", creator, "creator") || checkType("object", options, "option parameter");
if (err) {
this.log.error("could not register module '" + id + "': " + err);
@wmakeev
wmakeev / array_split.js
Created December 28, 2014 05:47
Split the array into parts
var codeGroups = [];
for (var i = 0, len = productCodes.length; i < len; i += groupSize) {
codeGroups.push(_.first(_.last(productCodes, len - i), groupSize));
}
@wmakeev
wmakeev / encode_base64.js
Created January 10, 2015 09:31
Base64 encode (from jaydata.js)
var encodeBase64 = function (val) {
var b64array = "ABCDEFGHIJKLMNOP" +
"QRSTUVWXYZabcdef" +
"ghijklmnopqrstuv" +
"wxyz0123456789+/" +
"=";
var input = val;
var base64 = "";
var hex = "";
@wmakeev
wmakeev / index.js
Created January 13, 2015 03:33
requirebin sketch
var _ = require('lodash');
module.export = function () {
console.log(_.max([1,2,3]));
}
// Simple, tiny, dumb module definitions for Browser JavaScript.
//
// What it does:
//
// * Tiny enough to include anywhere. Intended as a shim for delivering
// browser builds of your library to folks who don't want to use script loaders.
// * Exports modules to `__modules__`, a namespace on the global object.
// This is an improvement over typical browser code, which pollutes the
// global object.
// * Prettier and more robust than the
@wmakeev
wmakeev / env_test.js
Created January 16, 2015 11:42
Environment test (from uRequire)
var __isAMD = !!(typeof define === 'function' && define.amd),
__isNode = (typeof exports === 'object'),
__isWeb = !__isNode;
var javaScriptStr = JSON.stringify(obj)
.replace('\u2028', '\\u2028')
.replace('\u2029', '\\u2029');
@wmakeev
wmakeev / some.js
Last active August 29, 2015 14:14
Async-Await (some thoughts)
sb.send('dom/watch', '.b-pump-title-panel', function (err, changes) {
// some stuff with el
});
var changes = await sb.send('dom/watch', '.b-pump-title-panel');