Skip to content

Instantly share code, notes, and snippets.

View rusintez's full-sized avatar
💭
🍝

vlspopov rusintez

💭
🍝
View GitHub Profile
@rusintez
rusintez / emitter.ts
Last active April 9, 2024 05:43
Typescript Event Emitter
/**
* Strongly typed event emitter
*
* @usage
*
* const emitter = createEmitter<{
* signature: [{ publicKey: number[]; signature: number[] }];
* }>();
*
* emitter.on("signature", ({ publicKey, signature }) => {
@rusintez
rusintez / sort-by.js
Last active May 30, 2019 09:11
sort array by multiple values
/**
* sort array (of objects) by multiple values
*/
function sort (order) {
return function by (head, ...tail) {
return function comparator (a, b) {
if (!head) return 0;
if (a[head] > b[head]) return order;
if (a[head] < b[head]) return -order;
@rusintez
rusintez / ffffound.js
Created April 17, 2017 11:25
ffffound is shutting down
const fs = require('fs');
const hyperquest = require('hyperquest');
const pump = require('pump');
const xray = require('x-ray');
const parse = require('json-parse-stream');
const through = require('through2').obj;
const x = xray().throttle(1, 300); // be considerate
const schema = [{
@rusintez
rusintez / svgtooltip.js
Last active July 15, 2016 08:00
svg tooltip
/**
* Print SVG that will render a rectangular tooltip with a tip at the bottom
*/
setTimeout(function() {
console.log(
'<svg version="1.1" xmlns="http://www.w3.org/2000/svg"><path d="' +
getTooltipPath(10, 10, 200, 80, 4, 10, 2, 'top').toString() +
'" fill="#777777"/></svg>'
);
@rusintez
rusintez / gist:7b2c5c35bdb571afed58
Created February 19, 2016 13:08
check docker containers memory consumption
for line in `docker ps | awk '{print $1}' | grep -v CONTAINER`; do docker ps | grep $line | awk '{printf $NF" "}' && echo $(( `cat /sys/fs/cgroup/memory/docker/$line*/memory.usage_in_bytes` / 1024 / 1024 ))MB ; done
@rusintez
rusintez / .zshrc
Created September 17, 2015 09:19
change envs on the fly
# USAGE:
# production node -e 'console.log(process.env.HELLO)'
# staging node -e 'console.log(process.env.HELLO)'
#
production() {
NODE_ENV=production \
HELLO=world \
FOO=bar \
$*
@rusintez
rusintez / data.csv
Created August 11, 2015 19:30
data! from editdata.org!
title content cover createdAt
Hello World -123- 10-10-2012
var vm = require('vm'),
code = 'var square = n * n;',
fn = new Function('n', code),
script = vm.createScript(code),
sandbox;
n = 5;
sandbox = { n: n };
benchmark = function(title, funk) {
@rusintez
rusintez / coupons
Created May 22, 2012 07:39 — forked from JamieS/coupons
Load Groupon Codes into Shopify Discounts
# http://forums.shopify.com/categories/6/posts/42926
# This is a fairly simple mechanize script to create a few hundred or so shopify discounts from a CSV of groupon codes.
# You'll want to change all of the "changeme" values to your own.
# The script expects there to be a groupon_codes.csv in the same directory.
#
# The groupons_code.csv should look like this:
# 8m7677
# 8m6749
# 8m5398
# 8m7699