Skip to content

Instantly share code, notes, and snippets.

View wmakeev's full-sized avatar
💭
💻

Makeev Vitaliy wmakeev

💭
💻
View GitHub Profile
@CrabDude
CrabDude / gist:1597914
Created January 12, 2012 01:33
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);
@mjackson
mjackson / color-conversion-algorithms.js
Last active July 24, 2024 13:28
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 / 01-csp-api.js
Last active December 29, 2015 09:09
Moysklad Client interface
import moysklad from 'moysklad'
import csp from 'js-csp'
import { take } from 'js-csp-async'
let client = moysklad.createCspClient()
let { customerOrder, CustomerOrder } = client
async function orders () {
let order, orders, orderPositions
@lttlrck
lttlrck / gist:9628955
Created March 18, 2014 20:34
rename git branch locally and remotely
git branch -m old_branch new_branch # Rename branch locally
git push origin :old_branch # Delete the old branch
git push --set-upstream origin new_branch # Push the new branch, set local branch to track the new remote
@staltz
staltz / introrx.md
Last active July 22, 2024 09:31
The introduction to Reactive Programming you've been missing
@asheb
asheb / mocha-source-map-reporter.coffee
Created July 20, 2014 09:39
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
@tonymtz
tonymtz / gist:d75101d9bdf764c890ef
Last active May 7, 2024 13:07
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*
@fxposter
fxposter / group_by.clj
Last active October 7, 2015 03:07
group-by as a transducer
(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))
@tracker1
tracker1 / .eslintrc
Created March 24, 2015 00:43
ES6 Testing With Mocha and BabelJS
{
"ecmaFeatures": {
"arrowFunctions": true,
"binaryLiterals": false,
"blockBindings": true,
"classes": true,
"defaultParams": true,
"destructuring": true,
"forOf": true,
"generators": true,
@ericelliott
ericelliott / react-reusable-component.md
Last active December 26, 2022 07:05
React - Complete Reusable Component

React Reusable Component Factory

'use strict';

const ENTER_KEY = 13;

const emailFactory = function ({
  React,
  setEmail,