Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am jpterry on github.
  • I am jpterry (https://keybase.io/jpterry) on keybase.
  • I have a public key ASAompS9pHRt4J0VI14O23klN3ZMTjoRDC0brxAg5UJ2vQo

To claim this, I am signing this object:

@jpterry
jpterry / osx-for-hackers.sh
Created November 24, 2015 22:03 — forked from brandonb927/osx-for-hackers.sh
OSX for Hackers: Yosemite Edition. This script tries not to be *too* opinionated and any major changes to your system require a prompt. You've been warned. Also, please don't email me about this script, my poor inbox...
#!/bin/sh
# Alot of these configs have been taken from the various places
# on the web, most from here
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
# Set the colours you can use
black='\033[0;30m'
white='\033[0;37m'
red='\033[0;31m'
@jpterry
jpterry / file_splitter.rb
Last active August 29, 2015 14:12
Pipe delimted file splitter
require 'csv'
class FileSplitter
SPLIT_COUNT = 250_000
COPY_HEADERS = true
def initialize(filename)
@filename = filename
@header = nil
@file_count = 1
# Excel column string to 0 indexed position
def self.excel_col_to_index(str)
offset = 'A'.ord - 1
str.upcase.chars.inject(0) { |x,c| x * 26 + c.ord - offset } - 1
end
# 0 based index to column letter
def self.index_to_excel_col(index)
'A'.tap do |name|
index.times { name.succ! }
def write_csv(excelx_filename, outfile_name)
CSV.open(outfile_name, "wb") do |csv|
Roo::Excelx.new(excelx_filename, minimal_load: true).each_row_streaming do |row_cells|
csv << row_cells.map(&:value)
end
end
end
#!/usr/bin/env ruby#
# encoding: utf-8
require 'thor'
require 'octokit'
require 'etc'
class GithubKeyGenerator < Thor
include Thor::Actions
GITHUB_KEY_NAME = 'github_key'
@jpterry
jpterry / a.rb
Created September 3, 2014 23:03
lib/elixir_sips_downloader/extractors/catalog.rb
@jpterry
jpterry / gist:4cb722e319269c55ba7d
Last active August 29, 2015 14:04
Ruby Decendants
class Class
def descendants
ObjectSpace.each_object(::Class).select {|klass| klass < self }
end
end
should "contain a sip_number_format that doesn't allow nil or bogus" do
@sip_integration.set!(:sip_number_format => :E164)
assert_raise ActiveRecord::StatementInvalid, /sip_number_format' cannot be null/ do
@sip_integration.set!(:sip_number_format => nil)
end
assert_equal :E164, @sip_integration.sip_number_format
end
diff --git a/lib/token_generator.rb b/lib/token_generator.rb
index 8481154..a80ca28 100644
--- a/lib/token_generator.rb
+++ b/lib/token_generator.rb
@@ -2,7 +2,6 @@
module TokenGenerator
def self.generate
- random_text = ([Time.now.to_f] + (1..10).map{rand}).join('--')
- ActiveSupport::Base64.encode64_url(Digest::SHA1.digest(random_text))