Skip to content

Instantly share code, notes, and snippets.

View encryptable.rb
# frozen_string_literal: true
module Encryptable
ENCRYPTABLE_SALT = "iris.encryptable_salt"
def encrypt(string)
crypt.encrypt_and_sign(string)
end
def decrypt(encrypted_data)
View heroku.log
-----> Ruby app detected
-----> Compiling Ruby/Rails
-----> Using Ruby version: ruby-2.5.3
-----> Installing dependencies using bundler 2.0.2
Running: bundle install --without development:test --path vendor/bundle --binstubs vendor/bundle/bin -j4 --deployment
Using rake 12.3.3
Using concurrent-ruby 1.1.5
Using i18n 1.6.0
Using minitest 5.11.3
Using thread_safe 0.3.6
@csexton
csexton / mov2gif.rb
Created Jul 3, 2019
Simple script to convert a mov file to an animated gif. Requires ffmpeg.
View mov2gif.rb
#!/usr/bin/env ruby
# frozen_string_literal: true
require 'optparse'
options = {
rate: 30,
log: 0,
}
@csexton
csexton / neopixel.cc
Created Jun 27, 2019
Simple Neopixel with serial command control
View neopixel.cc
// NeoPixel Ring simple sketch (c) 2013 Shae Erisson
// Released under the GPLv3 license to match the rest of the
// Adafruit NeoPixel library
#include <Adafruit_NeoPixel.h>
#ifdef __AVR__
#include <avr/power.h> // Required for 16 MHz Adafruit Trinket
#endif
// Which pin on the Arduino is connected to the NeoPixels?
@csexton
csexton / main.go
Created Jun 27, 2019
Get the USB Serial Number from C in Go with IOKit
View main.go
package main
// #cgo LDFLAGS: -framework CoreFoundation -framework IOKit
// #include <CoreFoundation/CoreFoundation.h>
// #include <IOKit/IOKitLib.h>
// #include <IOKit/serial/IOSerialKeys.h>
// #include <IOKit/usb/IOUSBLib.h>
//
// const char *
// getSerialNumber()
@csexton
csexton / local-rails.diff
Created Jun 2, 2019
Terrastories local dev mode
View local-rails.diff
diff --git a/rails/Gemfile b/rails/Gemfile
index 0262b60..61d5bd8 100644
--- a/rails/Gemfile
+++ b/rails/Gemfile
@@ -6,6 +6,7 @@ ruby '2.5.1'
gem 'rails', '~> 5.2.0'
# Use mysql as the database for Active Record
gem 'mysql2', '>= 0.4.4', '< 0.6.0'
+gem 'sqlite3'
# Use Puma as the app server
@csexton
csexton / ice.md
Created Apr 29, 2019
Icebreaker Questions
View ice.md

Icebreaker Questions

  • Is it okay for your job to be really boring if it pays well?
  • Describe yourself in one word (then say “does t follow directions)
  • Are you a different person by the end of each day?
  • If a waiter leaves an item off the bill and you say nothing, is that stealing?
  • Could you ever learn too much?
  • Would you be happy if you had all you wanted?
  • If you have to talk to someone for 2 hours, what topic would you pick?
  • Can you fall asleep fast?
@csexton
csexton / compressed_public_key.rb
Created Apr 10, 2019
Attempt to generate a compressed public key from EC private key
View compressed_public_key.rb
#!/usr/bin/env ruby
require 'bundler/inline'
gemfile do
gem "openssl"
end
# See https://github.com/ruby/openssl/issues/29
def real_public_key(k)
# TODO? .point_conversion_form = :compressed
point = k.public_key
View ph.json
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@csexton
csexton / get_pr_from_branch.rb
Created Oct 22, 2018
Get the Pull Request number from a git branch
View get_pr_from_branch.rb
# frozen_string_literal: true
require "net/https"
require "uri"
require "json"
def find_pr(org, repo, branch)
uri = URI("https://api.github.com/repos/#{org}/#{repo}/pulls?head=#{org}:#{branch}")
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
You can’t perform that action at this time.