Skip to content

Instantly share code, notes, and snippets.

View junosuarez's full-sized avatar
💭
hi hello

juno suárez junosuarez

💭
hi hello
View GitHub Profile
@junosuarez
junosuarez / index.js
Last active June 27, 2017 21:34
saludx
#!/usr/bin/env node
console.log((new Date().getHours()) < 12 ? 'buenos!' : 'buenas!')
@junosuarez
junosuarez / pre-commit
Created May 10, 2017 22:14
prettier git hooks
#!/bin/sh
# Redirect output to stderr.
exec 1>&2
changed=$(git diff --cached --name-only)
if echo $changed | grep '.js$'; then
prettier --list-different --no-semi --single-quote --trailing-comma=none --print-width=80 $changed || echo you cant go out looking like this! 💅 ; exit 1
fi
@junosuarez
junosuarez / foo.js
Last active December 16, 2016 03:13
This should type check
// @flow
export type Locale =
| 'EN-us'
| 'ES-us'
export default class Foo {
name: string
constructor (name: string) {
@junosuarez
junosuarez / notes.md
Created September 16, 2016 02:18
debugging graphql-ruby
  1. traverse each top-level thing, depth-first. for fragments, build a stack of "spread" references to be executed later 1a. so first it gets the query operation, then the F0, F1, etc 1b. each top-level object (operation, fragment) has a tree of nodes with "selections"
  2. when it starts processing fragments, it hits a lazy reducer which enumerates all of the schema types / interfaces (FragmentWithTypeStrategy) 2a. when it enters visiting a FragmentDefinition, it pushes it on the fragments stack
  3. when it gets to a Field under a fragment, the Node:Field.enter visitor looks up that field from the parent irep node or else creates a new irep node. it pushes it on the @nodes stack, and pushes empty parent directives? is that right? at this point, the Field AST node has directives as child AST nodes, which get traversed next
  4. when it visits the Directive AST node, it makes an irep node and pushes it on the @parent_nodes stack
  5. Arguments are children of the Directive AST, which is visited next. things unwind. ba
.pl-c {
color: #969896
}
.pl-c1,.pl-s .pl-v {
color: #0086b3
}
.pl-e,.pl-en {
color: #795da3
@junosuarez
junosuarez / firstJank.js
Created August 16, 2016 17:05
key RUM perf metric: time-to-first-jank
if (window.requestAnimationFrame) {
function checkForJank () { // eslint-disable-line no-inner-delcarations
const frameStart = Date.now()
window.requestAnimationFrame(() => {
const frameDuration = Date.now() - frameStart
if (frameDuration > 17) {
Perf.log(FirstJank)
} else {
checkForJank()
}
@junosuarez
junosuarez / monkeypatch_selenium.rb
Created August 10, 2016 01:05
If you suddenly get a lot of cryptic errors in travis like `Errno::EINVAL: Errno::EINVAL: Invalid argument - bind(2) for "fe80::4001:aff:::fff" port 9515` then maybe this will save you 5 hours
# Monkeypatch Selenium Webdriver to work on Travis IPv6 infrastructure
module Selenium
module WebDriver
class PortProber
IGNORED_ERRORS = [Errno::EADDRNOTAVAIL, Errno::EINVAL, Errno::EACCES].freeze
IGNORED_ERRORS << Errno::EBADF if Platform.cygwin?
def self.free?(port)
interfaces = Socket.getaddrinfo('localhost', 8080).map { |e| e[3] }
interfaces.each do |host|
rbenv install
gem install bundler
bundle install
# bootstrap all the things
<blink>im being held in san francisco working on legacy rails apps against my will</blink>
let a = []; for(let i = 0; i < .5e6; i++) a.push(i);
let lag = 0
let last = Date.now()
let int = setInterval(_=>{let now = Date.now();let diff=now-last;lag = Math.max(lag, diff);last = now; console.log('x'.repeat(40), now, lag, diff)}, 500)
(function safe(arr, fn, i) { i = i || 0; setImmediate(_=> { fn(i++); if (i < arr.length - 1) safe(arr, fn, i)}) })(a, console.log)