This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule RangeMap do | |
def to_function(in_min, in_max, out_min, out_max) do | |
difference_in = in_max - in_min | |
difference_out = out_max - out_min | |
factor = difference_out / difference_in | |
midpoint_in = (in_min + in_max) / 2 | |
midpoint_out = (out_min + out_max) / 2 | |
constant = midpoint_out - midpoint_in |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Usage: | |
# ./compare-branches.sh "./some-command arg-1 arg-2" branch-1 branch-2 | |
# | |
# https://twitter.com/elliotthilaire/status/1083859808086720512 | |
# Thanks to @schneems, @tosbourn, and @matthewrudy for their input. | |
current_branch=$(git symbolic-ref --short HEAD) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ffmpeg -r 12.5 -pattern_type glob -i '*.JPG' -s 1920:1440 -vcodec libx264 timelapse.mp4 | |
ffmpeg -r 30 -start_number 71543 -i G00%d.JPG -s 1920:1440 -vcodec libx264 timelapse.mp4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ATtiny85 Night Light | |
void setup() { | |
pinMode(1, OUTPUT); | |
pinMode(2, OUTPUT); | |
} | |
void loop() { | |
if (digitalRead(2) == HIGH) { | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# http://sequel.jeremyevans.net/rdoc/classes/Sequel/SQL/Builders.html#method-i-case | |
# http://sequel.jeremyevans.net/rdoc/classes/Sequel/Dataset.html#method-i-order | |
# http://www.justinweiss.com/articles/how-to-select-database-records-in-an-arbitrary-order/ | |
# Given an array of ids. How can we retrieve the records in that order. | |
# Using the Sequel gem. | |
# SELECT * FROM items WHERE id IN (2, 3, 1, 4) ORDER BY | |
# CASE id | |
# WHEN 2 THEN 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
COPY package.json /usr/src/app/ | |
COPY yarn.lock /usr/src/app/ | |
# TODO: replace custom repository when yarn is no longer in edge/community | |
RUN apk add yarn --no-cache --repository http://dl-cdn.alpinelinux.org/alpine/edge/community/ && \ | |
yarn install && \ | |
apk del yarn |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<%= form_tag project_assets_path(project), multipart: true, class: 'upload-form' do %> | |
<%= file_field_tag 'file' %> | |
<%= submit_tag 'Upload' %> | |
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# http://guides.rubyonrails.org/asset_pipeline.html#controller-specific-assets | |
Dir[Rails.root.join('app/controllers/**/*_controller.rb')].each do |path| | |
controller_path = path.match(/controllers\/(.*)_controller.rb/)[1] | |
Rails.application.config.assets.precompile += ["#{controller_path}.js", "#{controller_path}.scss"] | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const EventEmitter = require('events') | |
const myEmitter = new EventEmitter() | |
function start () { | |
myEmitter.emit('ready') | |
myEmitter.emit('set') | |
myEmitter.emit('go') | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# To reinstall this script in the same or another git repo run: | |
# curl -sSL https://gist.github.com/elliotthilaire/5e56566b75781b8cd9d2/raw/pre-commit > .git/hooks/pre-commit; chmod +x .git/hooks/pre-commit | |
# check that pronto is installed first | |
hash pronto 2>/dev/null || { | |
echo >&2 "Pronto is not installed. Install with 'gem install pronto pronto-rubocop'"; | |
echo >&2 "Find other pronto runners at https://github.com/mmozuras/pronto#runners"; | |
exit 0; |
NewerOlder