Skip to content

Instantly share code, notes, and snippets.

Taylor Brooks taylorbrooks

Block or report user

Report or block taylorbrooks

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View group_by_levenshtein.rb
emails = Customer.select(:email).map(&:email)
emails.map do |email|
grouping = emails
.group_by{|em| Levenshtein.distance(email, em) }
.select {|k,v| k < 5 && != 0 } # ignore exact matches and ones far off
if !grouping.empty?
[email, grouping]
end
View charts.html.erb
<script>
$(document).ready(function(){
var start = moment().startOf('year');
var end = moment().endOf('year');
$('#group_by').change(function(e){
var val = $(this).val();
var string = Chartkick.charts["chart-1"].dataSource;
string = paramReplace("group_by", val, string);
View charts.js
<script>
$(document).ready(function(){
var start = moment().startOf('year');
var end = moment().endOf('year');
$('#group_by').change(function(e){
var val = $(this).val();
var string = Chartkick.charts["chart-1"].dataSource;
string = paramReplace("group_by", val, string);
View thread_safe??.rb
# Is it thread-safe if this class is instantiated based on a new HTTP req
# and two separate reqs happen at the same time?
class BingBong
attr_reader :uuid, :person
def initialize(person:,)
@uuid = SecureRandom.uuid
@person = person
end
View process_file.cr
s = Time.now
lines = File.read_lines("./files/2014.txt").compact_map{|line| process(line) }
things = lines.select{|hsh| hsh[:amount] > 100000 }
e = Time.now
p things.size
p e-s
def process(line)
@taylorbrooks
taylorbrooks / passwordless_login.md
Last active Aug 8, 2016
Passwordless Login for Phoenix
View passwordless_login.md

I'd like to build an Elixir library for passwordless login.

Modeled after this post, with a few alterations: http://inaka.net/blog/2016/07/27/passwordless-login-with-phoenix

The library would generate (or provide) a number of things:

  1. A migration for a login_keys table with 3 columns: [email, key, created_at]
  2. HTML template for submitting an email
  3. Email template for mailing login key
  4. Session routes and controllers
@taylorbrooks
taylorbrooks / s3_photo_app.md
Last active Aug 4, 2016
React or Ember, S3 Photo App
View s3_photo_app.md

This is a paid project.

I'm looking for someone to build a single page JavaScript app in either Ember or React/Redux.

The person should have a pretty good handle of AWS services, particularly S3 and the JS sdk

Project:

Here's a rough idea of what I'd like built.

  • Host photos in an S3 bucket
  • JS spa would be hosted in a separate bucket that provides an interface to:
View thing.ex
# grab a user
user = User |> preload(:emails) |> Repo.get_by!(api_key)
# set the current_user in conn.assigns
conn
|> assign(:current_user, user)
|> put_session(:user_id, user.id)
|> configure_session(renew: true)
# try to use in a view
@taylorbrooks
taylorbrooks / date_setter.md
Last active Feb 20, 2016
Set correct days.
View date_setter.md

This is a paid project. I'll accept answers in Ruby, Elixir, or NodeJS. Or all 3.

  • I need the project done by Saturday, February 27th.
  • DONE I'll pay $500 for the Ruby answer.
  • And $250 for an Elixir or Node answer.
# Before starting, please email me at:
e = "dGJyb29rc0BnbWFpbC5jb20="
Base64.decode64(e)
View gist:a7af181d907fe423bac2
(0..6).each do |i|
day = Date.today.next_week + i
it "should have emails with send_at on weekdays when started on #{day.strftime('%A')}" do
Timecop.freeze(day) do
p Date.today
end
end
end
You can’t perform that action at this time.