Skip to content

Instantly share code, notes, and snippets.

View srolel's full-sized avatar

Sharon (Sean) Rolel srolel

View GitHub Profile
const robot = require('robot-js');
const { Keyboard, Mouse } = robot;
const keymap = {
I: [0, -1],
J: [-1, 0],
L: [1, 0],
K: [0, 1],
E: [0, -1],
S: [-1, 0],
ranks = [1,1,1,1]
links = [[1], [0], [0,3], [2]]
damping = 1
iterations = 100
for _ in range(0, iterations):
contributions = [0,0,0,0]
for i, page_links in enumerate(links):
for link in page_links:
@srolel
srolel / kubeshortcuts
Created May 27, 2018 01:15
kubectl shortcuts
kubepods() {
kubectl get pods --all-namespaces | grep $1 | awk '{print "--namespace="$1 " " $2}'
}
kubepod() {
kubepods $1 | head -1
}
kubebash() {
kubectl exec -ti $(kubepod $1) bash
@srolel
srolel / buildWhenAffected.sh
Created December 15, 2017 13:20 — forked from naesheim/buildWhenAffected.sh
CircleCi - only build features that has changed
##################
### config.yml ###
##################
version: 2
jobs:
build:
docker:
- image: circleci/python:3.6
steps:
import * as Knex from 'knex';
declare module "knex" {
export const raw: (x: any) => void;
}
const knex = Knex({});
knex.raw("blah"); // from instance. defined in @types/knex
Knex.raw("blah"); // from 'constructor'. missing. What I am trying to augment
const applyMapFn = (fn, {value}, thisArg) => fn.apply(null, value.reverse());
const generators = {
*filter([map, iteratee, thisArg]) {
const iterator = map.entries();
let nextItem = iterator.next();
while (!nextItem.done) {
const {value} = nextItem;
const result = iteratee.call(thisArg, value[1], value[0], map);
if (result) {
@srolel
srolel / gist:9def16b61893809eee25
Created June 3, 2015 23:52
angular depth-first scope traverse from `Scope.$digest`
let next, current = root, target = root
do {
console.log(current.$$watchers)
if (!(next = ((current.$$watchers.length && current.$$childHead) ||
(current !== target && current.$$nextSibling)))) {
while (current !== target && !(next = current.$$nextSibling)) {
current = current.$parent;
}
}
} while ((current = next));
@srolel
srolel / 1 Topics.md
Last active August 29, 2015 14:19
April Javascript Room Meeting

This document will list the subjects for the upcoming room meeting, scheduled for 2015-04-25.

Feel free to suggest topics in the comment section.

Topic List

  1. subscription to javascript tag on codereview.stackexchange.com
  2. Assigning people to execute room meeting (or other) conclusions.
  3. Contributors to room rules.
  4. Rss feeds.
/**
* A doubly linked list-based Least Recently Used (LRU) cache. Will keep most
* recently used items while discarding least recently used items when its limit
* is reached.
*
* Licensed under MIT. Copyright (c) 2010 Rasmus Andersson <http://hunch.se/>
* See README.md for details.
*
* Illustration of the design:
*
@srolel
srolel / gist:9593751
Created March 17, 2014 03:57
jison example
%lex
%%
\s+ /* skip whitespace */
[0-9]+("."[0-9]+)?\b return 'NUMBER'
true|false return 'BOOLEAN'
(\$|[a-z])([a-z0-9_$])* return 'IDENTIFIER'
(\'|\")(\\.|[^\"])*(\'|\") return 'STRING'
"*" return '*'
"/" return '/'