Skip to content

Instantly share code, notes, and snippets.

@colthreepv
colthreepv / retry.js
Created September 11, 2015 21:57
angular forever $http retry
'use strict';
var retryForever = true;
var retryTimeout = 5000;
exports = module.exports = function ($http, $q, $timeout) {
function httpRetry () {
var args = arguments;
var httpPromise = $http.apply(null, args);
@l8on
l8on / monitoring-jank.coffee
Last active August 24, 2018 12:10
Monitoring Jank Example
# Simple function that uses a heuristic to tell if a function
# is native code. Luckily this isn't security related code.
isNative = (fn) ->
return (/\{\s*\[native code\]\s*\}/).test('' + fn)
# An easy check to ensure we are on a modern browser
isModernBrowser = ->
return (
window.addEventListener &&
window.performance?.now &&
@travisbrown
travisbrown / tower-of-hanoi.scala
Created September 23, 2012 17:44
Solving the Tower of Hanoi at the type level
/**
* Type-level Tower of Hanoi
* by Travis Brown
*
* Note: not optimal, and probably won't work for some valid inputs.
* Tested with Scala 2.9.2 and Shapeless 1.2.3.
*/
import shapeless._, Nat._
See https://github.com/electron/electron/issues/7375
Copyright (c) 2017 Christophe Bol
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
@bellbind
bellbind / app.html
Created May 20, 2015 07:23
[electron]Use electron as a Web Server
<!doctype html>
<html><head><script src="app.js"></script></head><body></body></html>
@DerLobi
DerLobi / pre-commit
Last active May 9, 2022 09:45
Don't commit focused tests. Use this as a pre-commit hook and the commit won't succeed if you have staged changes that contain `fdescribe`, `fcontext`, `fit`, `fspecify` or `fexample`. Copy this file as `pre-commit` into the `.git/hooks` folder of your repository (create it if neccessary) and chmod +x the file.
#!/bin/sh
#
# This pre-commit hook looks for `fdescribe`, `fcontext`, `fit`, `fspecify` and `fexample` in the
# staged files and exits with an error code of 1 if there are such changes.
#
STATUS=0
DESCRIBEFILES=$(git diff --staged -G"^\s*fdescribe\(" --name-only | wc -l)
if [ $DESCRIBEFILES -gt 0 ]
@lhorie
lhorie / longest-keyword-sequence.md
Last active November 14, 2022 23:21
What's the longest keyword sequence in Javascript?
@2bard
2bard / mitmproxy cheat sheet
Created February 13, 2015 19:44
mitmproxy cheat sheet
Movement:
j, k down, up
h, l left, right (in some contexts)
space page down
pg up/down page up/down
arrows up, down, left, right
@zeuxisoo
zeuxisoo / gist:980174
Created May 19, 2011 04:15
How to use git diff to patch file

Create patch file

git diff --no-prefix > [path file name]

Apply path file

patch -p0 < [path file name]

@jonathanlurie
jonathanlurie / jsont.js
Last active August 16, 2023 08:33
Serialize/deserialize json and conserve typed arrays
/*
Author: Jonathan Lurie - http://me.jonathanlurie.fr
License: MIT
The point of this little gist is to fix the issue of losing
typed arrays when calling the default JSON serilization.
The default mode has for effect to convert typed arrays into
object like that: {0: 0.1, 1: 0.2, 2: 0.3} what used to be
Float32Array([0.1, 0.2, 0.3]) and once it takes the shape of an
object, there is no way to get it back in an automated way!