Skip to content

Instantly share code, notes, and snippets.

View elliotlarson's full-sized avatar

Elliot Larson elliotlarson

View GitHub Profile
Foo foo foo
@elliotlarson
elliotlarson / awk_zip_plus4.md
Created March 8, 2016 05:48
awk command for working with zero fill values

Lets say you have a zipcode file paramount.csv:

90242,5121
90280,8140
90280,8168
90280,8178
90280,8238
90723,1
90723,2
@elliotlarson
elliotlarson / pedantically_commented_playbook.yml
Created July 7, 2016 02:35 — forked from marktheunissen/pedantically_commented_playbook.yml
Insanely complete Ansible playbook, showing off all the options
---
# ^^^ YAML documents must begin with the document separator "---"
#
#### Example docblock, I like to put a descriptive comment at the top of my
#### playbooks.
#
# Overview: Playbook to bootstrap a new host for configuration management.
# Applies to: production
# Description:
# Ensures that a host is configured for management with Ansible.
@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
@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 / 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,
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 / 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
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 / 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