Skip to content

Instantly share code, notes, and snippets.

View rosston's full-sized avatar

Ross Brandes rosston

View GitHub Profile
@rosston
rosston / digest-performance.js
Last active January 18, 2017 05:35
Angular digest performance
// Simple, single run
(function() {var body = angular.element('body'); var start = Date.now(); body.scope().$apply(); console.log((Date.now() - start) + 'ms digest');})();
// Average of 50
(function() { var body = angular.element('body'); var numRuns = 50; var totalRunTime = 0; for (var i = 0; i < numRuns; i++) { var start = Date.now(); body.scope().$apply(); totalRunTime += Date.now() - start; } console.log((totalRunTime / numRuns) + 'ms average over ' + numRuns + ' digests'); })();
@rosston
rosston / find-lodash-method.js
Last active January 9, 2024 20:22
jscodeshift "transform" to find uses of any lodash method
'use strict';
//
// Usage:
// jscodeshift -t find-lodash-method.js /path/to/dir/or/file --method-name=<lodash_method> [--min-args=<min_num_args>] [--chain-only=1]
//
// Prints all locations of matching uses of the lodash method (e.g., `map`).
//
// Function copied from https://github.com/jfmengels/lodash-codemods/blob/v1.0.1/lib/method-calls-conditional-name-changes.js#L163-L179
@rosston
rosston / git-cherry-pick-merge.sh
Created January 18, 2017 22:31
cherry-pick merge commit (and its ancestors from merged branch)
#!/bin/bash
set -e
USAGE=$(cat <<"EOF"
Usage:
git-cherry-pick-merge <destination_branch> <merge_commit_ref>
git-cherry-pick-merge --continue
Cherry-pick a merge commit (and its ancestors from the merged branch) onto
@rosston
rosston / .gitignore
Last active April 30, 2017 09:12 — forked from phybros/update-route53.sh
BASH Script to keep Route53 updated with your current external IP address
*.ip
*.log
/*
* Doubly-nested timeout ensures we run after browser render. (Sometimes needs
* to be triply-nested timeout in IE/Edge, for reasons unknown to me.)
* Explanation below.
*
* 1. $watch runs, sets up $timeout to be run later (see NOTE below)
* 2. $watch finishes (i.e., Angular has finished manipulating the DOM)
* 3. First $timeout runs, sets up $timeout to be run later (see NOTE below)
* 4. Browser renders
* 5. Second $timeout runs!
/*
Below is one of my favorite timing functions.
It closely mimics jQuery's swing function.
*/
* {
transition: 0.25s transform cubic-bezier(.02, .01, .47, 1);
}
sudo nginx -t -c /etc/nginx/nginx.conf
#!/bin/bash
path="/path/to/some.special.png"
filename=${path%.*}
jpg=$filename.jpg
echo "$jpg"

Keybase proof

I hereby claim:

  • I am rosston on github.
  • I am rosston (https://keybase.io/rosston) on keybase.
  • I have a public key ASAEF2nOt-GgXLEHrk4xLCGATKkz9wRbFbtuH6pdp-2A-Qo

To claim this, I am signing this object:

say_command=$1
if [ -z "$say_command" ]; then
say_command="say"
fi
$say_command "
It's, supercalifragilisticexpialidocious
Even though the sound of it is something quite atrocious
If you say it loud enough, you'll always sound precocious
Supercalifragilisticexpialidocious