Skip to content

Instantly share code, notes, and snippets.

@csexton
csexton / mov2gif.rb
Created July 3, 2019 17:43
Simple script to convert a mov file to an animated gif. Requires ffmpeg.
#!/usr/bin/env ruby
# frozen_string_literal: true
require 'optparse'
options = {
rate: 30,
log: 0,
}
@csexton
csexton / ip_address.rb
Created April 18, 2012 13:47
Store the IP Addresses as integers in MongoDB
module MongoidTypes
#
# Store the IP Addresses as integers in MongoDB.
#
# The documents would look something like this in mongo
#
# { "_id" : ObjectId("4f8e2ea261455b704d000001"), "ip_address" : NumberLong("3232235777") }
#
# To have your model use this class simply set the type for the feild in mongoid
#
@csexton
csexton / neopixel.cc
Created June 27, 2019 20:07
Simple Neopixel with serial command control
// 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 / local-rails.diff
Created June 2, 2019 16:17
Terrastories local dev mode
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 / gist:3772971
Created September 23, 2012 20:36
/etc/init.d/znc startup script
#! /bin/sh
### BEGIN INIT INFO
# Provides: znc
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: znc initscript
# Description: This is the init-Script for znc.
### END INIT INFO
# Author: Henner M. Kruse
@csexton
csexton / ice.md
Created April 29, 2019 21:51
Icebreaker Questions

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 April 10, 2019 16:45
Attempt to generate a compressed public key from EC private key
#!/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
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 October 22, 2018 15:35
Get the Pull Request number from a git branch
# 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
@csexton
csexton / app.rb
Created October 10, 2012 23:38
jquery-localtime sinatra example
require 'sinatra'
require 'sinatra/ratpack'
require 'coffee-script'
helpers do
def localtime_tag(time)
time = Time.parse(time) unless time.respond_to? :strftime
formatted_str = time.strftime('%Y-%m-%dT%H:%M:%S%z')
content_tag :span, formatted_str, class: 'localtime'
end