Skip to content

Instantly share code, notes, and snippets.

View wmakeev's full-sized avatar
💭
💻

Makeev Vitaliy wmakeev

💭
💻
View GitHub Profile
ec.order = ec.order || {};
ec.order.extraFields = ec.order.extraFields || {};
// A text input that asks a buyer how to sign the package
ec.order.extraFields.wrapping_box_signature = {
'title': 'How should we sign the package?',
'textPlaceholder': 'Package sign',
'type': 'text',
'tip': 'We will put a label on a box so the recipient knows who it is from',
'required': false,
@wmakeev
wmakeev / color-conversion-algorithms.js
Created April 12, 2020 08:20 — forked from mjackson/color-conversion-algorithms.js
RGB, HSV, and HSL color conversion algorithms in JavaScript
/**
* Converts an RGB color value to HSL. Conversion formula
* adapted from http://en.wikipedia.org/wiki/HSL_color_space.
* Assumes r, g, and b are contained in the set [0, 255] and
* returns h, s, and l in the set [0, 1].
*
* @param Number r The red color value
* @param Number g The green color value
* @param Number b The blue color value
* @return Array The HSL representation
@wmakeev
wmakeev / token-generator.js
Created April 1, 2018 14:58 — forked from ziluvatar/token-generator.js
Example of refreshing tokens with jwt
/**
* Example to refresh tokens using https://github.com/auth0/node-jsonwebtoken
* It was requested to be introduced at as part of the jsonwebtoken library,
* since we feel it does not add too much value but it will add code to mantain
* we won't include it.
*
* I create this gist just to help those who want to auto-refresh JWTs.
*/
const jwt = require('jwt');
@wmakeev
wmakeev / README.md
Created April 23, 2017 18:27 — forked from PeterHancock/README.md
Running a node script on your $PATH with --harmony flag

Running a node script on your $PATH but with the --harmony flag

Some npm packaged scripts are written as frameworks that dynamically require user node scripts, e.g. the gulp CLI script requires the user provided Gulpfile.js (by default).

To write .js using ES6 syntax is problematic; if the $PATH script for a framework x looks like

#!/usr/bin/env node
var x = require('x');

...
@wmakeev
wmakeev / TL.d.ts
Created November 20, 2016 07:51 — forked from richard1122/TL.d.ts
telegram typings #telegram #typings
// A typings definition of some telegram data structure
// author: Richard He<richard9372@gmail.com>
// https://gist.github.com/richard1122/1eb54cd4e422aeb707718ab307decd34
// see more detail: https://core.telegram.org/bots/api
declare namespace TL {
export interface IResponse<T> {
ok:boolean
result:T
}
@wmakeev
wmakeev / gist:e21625ff31a125d8530eca19847acae1
Created October 15, 2016 10:30 — forked from tonymtz/gist:d75101d9bdf764c890ef
Uninstall nodejs from OSX Yosemite
# first:
lsbom -f -l -s -pf /var/db/receipts/org.nodejs.pkg.bom | while read f; do sudo rm /usr/local/${f}; done
sudo rm -rf /usr/local/lib/node /usr/local/lib/node_modules /var/db/receipts/org.nodejs.*
# To recap, the best way (I've found) to completely uninstall node + npm is to do the following:
# go to /usr/local/lib and delete any node and node_modules
cd /usr/local/lib
sudo rm -rf node*
@wmakeev
wmakeev / gist:dc2c362f6491b7bdf50b
Last active August 29, 2015 14:26 — forked from CrabDude/gist:1597914
JS Sandboxing via Harmony Proxies and with()
// in new iframe
var whitelist = {
// add whitelisted globals
};
var handler = {
// Fundamental traps
getOwnPropertyDescriptor: function(name) {
var desc = Object.getOwnPropertyDescriptor(whitelist, name);
@wmakeev
wmakeev / mocha-source-map-reporter.coffee
Last active August 29, 2015 14:25 — forked from asheb/mocha-source-map-reporter.coffee
Dirty hack to make 'source-map-support' work with mocha in PhantomJS
sourceMapper = require 'source-map-support'
Dot = require '../../../node_modules/grunt-mocha/node_modules/mocha/lib/reporters/dot.js'
module.exports = Dot
##
parseLine = (line) ->
[_, file, row] = line.match /file:\/\/\/(.*):(\d*)/
frame =
getFileName: -> file
@wmakeev
wmakeev / .eslintrc
Last active August 29, 2015 14:25 — forked from tracker1/.eslintrc
ES6 Testing With Mocha and BabelJS
{
"ecmaFeatures": {
"arrowFunctions": true,
"binaryLiterals": false,
"blockBindings": true,
"classes": true,
"defaultParams": true,
"destructuring": true,
"forOf": true,
"generators": true,
(defn group-by [f]
(fn [rf]
(let [groupped-value (volatile! (transient {}))]
(fn
([] (rf))
([result]
(rf (rf result (persistent! @groupped-value))))
([result input]
(let [key (f input)]
(vswap! groupped-value assoc! key (conj (get @groupped-value key []) input))