Skip to content

Instantly share code, notes, and snippets.

View jdx's full-sized avatar
⚜️
mise-en-place!

jdx

⚜️
mise-en-place!
View GitHub Profile
def check_same_object(object1, object2)
same_object = false
if object1[:id] == object2[:id]
same_object = true
end
return same_object
end
@jdx
jdx / sqlproblem.md
Last active December 14, 2015 04:49
SQL problem

Background

I'm writing a query to generate a page that will show people involved in entertainment who they are connected to through a social graph. I may end up using Neo4j for it, but I do want to at least attempt it using PostgreSQL.

Schema

Here is a simplified schema:

#!/bin/bash
# current Git branch
branch=$(git symbolic-ref HEAD | sed -e 's,.*/\(.*\),\1,')
# v1.0.0, v1.5.2, etc.
versionLabel=v$1
# establish branch and tag name variables
devBranch=develop
@jdx
jdx / sync.rb
Last active December 17, 2015 09:29
heroku db sync script
#!/usr/bin/env ruby
require 'optparse'
def sync(delete: false)
if !delete and File.exists? 'db.dump'
puts 'Existing database found in db.dump'
else
puts 'Downloading database...'
run "heroku pgbackups:capture -a pb-production --expire"
@jdx
jdx / dotplus.md
Last active December 17, 2015 11:38
dotplus: tech meetups 2.0

dotplus

dotplus is a group of mobile/web/hardware developers that come together once a month to talk about software development. The goals are:

  • Everyone learns something.
  • Everyone has fun.
  • Everyone meets somebody new.

A typical night will look like the following:

@jdx
jdx / beast_score.rb
Last active December 17, 2015 11:39
def beast_score
max_score = Person.maximum('beast_points')
max_score = 100 if max_score == 0
(Math.log(beast_points+2, max_score) * 100).to_i
end
@jdx
jdx / crazy_town.js
Last active December 18, 2015 04:39
console.table([
{"name":"Ricky","age":33,"grade":10},
{"name":"Julian","age":34,"grade":12},
{"name":"Bubbles","age":32,"grade":12},
{"name":"Lahey","age":60,"grade":12},
{"name":"Randy Bo-Bandy","age":33,"grade":11}
]);
class IndexUsersEmails < ActiveRecord::Migration
def self.up
execute "END"
add_pg_index :users, :email, :lock => false
execute "BEGIN"
end
end
@jdx
jdx / consecutive.rb
Last active December 18, 2015 08:29
consecutive numbers?
def consecutive?(array)
array.each_with_index.all? { |a, i| a+1 == a[i+1] }
end
def to_consecutive(array)
if consecutive?(array)
"#{array.first}-#{array.last}"
else
array.to_sentence
end
@jdx
jdx / twilio.rb
Created June 14, 2013 05:30
sending twilio texts in ruby
require 'rest-client'
TWILIO_ACCOUNT_SID = "YOUR_TWILIO_ACCOUNT_SID"
TWILIO_AUTH_TOKEN = "YOUR_TWILIO_AUTH_TOKEN"
TWILIO_NUMBER = 'YOUR_TWILIO_NUMBER'
RestClient.post "https://#{TWILIO_ACCOUNT_SID}:#{TWILIO_AUTH_TOKEN}@api.twilio.com/2010-04-01/Accounts/#{TWILIO_ACCOUNT_SID}/SMS/Messages", {
"From" => TWILIO_NUMBER,
"To" => '+19712227154',
"Body" => "BEWD Rocks!",