Skip to content

Instantly share code, notes, and snippets.

@jeffcarp
jeffcarp / gist:f1fb015e38f50e82d30b8c69b67faa74
Last active July 13, 2017 00:52
Analyze WPT Export latency
#!/usr/bin/python3
# Warning: this file is kind of a mess at the moment
import json
import csv
import requests
import re
import time
import subprocess
var session
if (window.ApplePaySession) {
var merchantIdentifier = 'merchant.com.canine-clothing'
ApplePaySession.canMakePaymentsWithActiveCard(merchantIdentifier)
.then(function (canMakePayments) {
if (canMakePayments) {
showApplePayButtons()
}
});
}
@jeffcarp
jeffcarp / development-practices.md
Last active July 25, 2016 21:38
Development Practices

Development Practices

This is currently an unstructured dump of development practices across all of the projects I maintain. I will probably link here in the CONTRIBUTING.md of each repo.

Reporting bugs

Depending on how much time you have, in order of preferredness:

  1. Submit a PR that fixes the bug and includes tests
  2. Submit a PR with failing tests that demonstrates the bug
@jeffcarp
jeffcarp / generic.scss
Last active March 31, 2016 14:49
Idea for generating generic classes in Sass
@mixin space($type, $name, $size: 1em) {
$prefix: '';
@if $type == 'padding' { $prefix: 'p'; }
@if $type == 'margin' { $prefix: 'm'; }
.#{$prefix}#{$name} { #{$type}: $size; }
.#{$prefix}#{$name}t { #{$type}-top: $size; }
.#{$prefix}#{$name}l { #{$type}-left: $size; }
(use 'clojure.java.io)
(defn debug [expr str]
(do
(println str expr)
(identity expr)))
(defn basic-comment? [str]
(not (empty? (re-seq #"^\s*\/\/" str))))
@jeffcarp
jeffcarp / gist:6959725
Last active December 25, 2015 10:09
Max Consecutive Sum (problem of the week on http://codingforinterviews.com)
(defun max_consecutive_sum (arr)
(let ((max_ending_here 0) (max_so_far 0))
(dotimes (x (length arr))
(setf max_ending_here (max 0 (+ (aref arr x) max_ending_here)))
(setf max_so_far (max max_so_far max_ending_here)))
max_so_far))
(format t "~S~%" (max_consecutive_sum #(-1 5 6 -2 20 -50 4))) ; 29
(format t "~S~%" (max_consecutive_sum #(-2 1 -3 4 -1 2 1 -5 4))) ; 6
@jeffcarp
jeffcarp / gist:6618224
Last active December 23, 2015 09:59
Color your git branch green or red based on whether you have uncommitted changes. (Put it in your ~/.bash_profile)
XRED="\033[0;31m"
XGREEN="\033[0;32m"
XNO_COLOUR="\033[0m"
function parse_git_branch () {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'
}
branch_colorize () {
if [ -d .git ]
@jeffcarp
jeffcarp / reset.css
Created February 15, 2013 20:00
My current reset.css
html, body, div, span, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
abbr, address, cite, code,
del, dfn, em, img, ins, kbd, q, samp,
small, strong, sub, sup, var,
b, i,
dl, dt, dd, ol, ul, li,
fieldset, form, label, legend,
table, caption, tbody, tfoot, thead, tr, th, td,
article, aside, figure, footer, header,

Keybase proof

I hereby claim:

  • I am jeffcarp on github.
  • I am gccv (https://keybase.io/gccv) on keybase.
  • I have a public key whose fingerprint is 2A47 25AE 39FC 881D 1A29 0273 BEAB 00E2 A10B 2BAB

To claim this, I am signing this object:

@jeffcarp
jeffcarp / gibberish.js
Last active October 13, 2015 07:08
Gibberish
// Generate a random string of characters
function gibberish(max_length) {
var gibberish = '';
var ascii;
while (max_length > 0) {
ascii = Math.floor(Math.random()*58)+65;
if (ascii >= 91 && ascii <= 96) continue;
gibberish += String.fromCharCode(ascii);
max_length -= 1;