Skip to content

Instantly share code, notes, and snippets.

View elliotlarson's full-sized avatar

Elliot Larson elliotlarson

View GitHub Profile
require('fileutils')
require('tempfile')
class AddRspec
def self.call
new.call
end
def call
spec_filepaths.each { |spec_filepath| process_file(spec_filepath) }
@elliotlarson
elliotlarson / class-vs-hash-bench.rb
Created August 14, 2017 20:43
Benchmarking class creation vs hash
require 'benchmark/ips'
class FooBar
attr_accessor :foo, :bar
def initialize(foo:, bar:)
self.foo = foo
self.bar = bar
end
end
require 'benchmark/ips'
FooBar = Struct.new(:foo, :bar) do
def self.call(foo:, bar:)
new(foo, bar)
end
end
Benchmark.ips do |b|
b.report('creating a struct') do
@elliotlarson
elliotlarson / profiler.rb
Last active July 12, 2017 18:30
Profiling some Ruby
require 'ruby-prof'
require 'fileutils'
require 'launchy'
# https://gist.github.com/hiltmon/1929287
# Saves profs to tmp/performance/
# Make sure you `gem install ruby-prof` first
# Profiling::Profiler.call('import') do
# # Your slow code here
# end
# Results are saved in tmp/performance
var fs = require('fs');
var readline = require('readline');
var stream = require('stream');
var instream = fs.createReadStream('votes.txt');
var outstream = new stream;
var rl = readline.createInterface(instream, outstream);
var ballotCount = 0;
var ballotVotes = [];
@elliotlarson
elliotlarson / vs-code-angular-debug.json
Created April 25, 2017 19:20
Debugging Angular in VS Code
{
"name": "Launch Chrome against localhost, with sourcemaps",
"type": "chrome",
"request": "launch",
"url": "http://localhost:4200",
// This forces chrome to run a brand new instance, allowing existing
// chrome windows to stay open.
"userDataDir": "${workspaceRoot}/.vscode/chrome",
"sourceMaps": true,
"webRoot": "${workspaceRoot}",
@elliotlarson
elliotlarson / sierra-config.md
Last active February 25, 2018 16:53
Configuration Of Mac OS Sierra

Clean Install of Mac OS Sierra

Create install USB drive

Download Sierra (or current Mac OS) via the AppStore App. Cancel out of the installer window when it loads up after it downloads.

The installer app will be in the Applications directory.

After inserting the USB stick, run the following command on the terminal. Note this expects the USB drive to be named Untitled:

@elliotlarson
elliotlarson / vscode-conf.json
Last active June 15, 2017 22:02
Visual Studio Code Setup
{
"window.zoomLevel": 1,
"vim.useCtrlKeys": true,
"editor.tabSize": 2,
"editor.fontSize": 11,
"editor.renderLineHighlight": false,
"vsicons.dontShowNewVersionMessage": true,
"workbench.activityBar.visible": false,
"typescript.check.workspaceVersion": false,
@elliotlarson
elliotlarson / favicon-creator.sh
Created January 8, 2017 20:34
Create favicon from PNG
convert my-image.png -define icon:auto-resize=128,64,48,32,16 favicon.ico
@elliotlarson
elliotlarson / create-app-user.html
Created November 17, 2016 23:51
Utility web page for creating a Firebase application user via Google provider authentication
<!--
You need to run this in a webserver environment over HTTP for it to work.
Start a basic server with:
```bash
$ http-server
```
Then navigate to: http://localhost:8080/create-app-user.html