Skip to content

Instantly share code, notes, and snippets.

View sfgeorge's full-sized avatar

Stephen George sfgeorge

View GitHub Profile
@sfgeorge
sfgeorge / README.md
Created June 4, 2023 01:21
How to GPG-sign git commits on GitHub, the easy way

How to GPG-sign git commits on GitHub, the easy way

  1. 📋 Copy your GitHub email address.

    Run git config --global user.email and copy the email that is returned. If nothing is returned, you should set that to one of the following 2 addresses on https://github.com/settings/emails :

    i. If you have enabled ✅ Keep my email addresses private, then copy the xxxxx+xxxxx@users.noreply.github.com email address mentioned beneath.
    ii. Otherwise, copy the email address that you have designated under Primary email address.

  2. 📦 Install GPG

@sfgeorge
sfgeorge / rest-client-test.rb
Created January 15, 2021 04:38
exhibit a bug showing that the RestClient::RawResponse#body method doesn't exist in v2.0.2. This was fixed in v2.1.0.
require 'bundler/inline'
gemfile do
source 'https://rubygems.org'
# gem 'rest-client', '= 2.1.0'
gem 'rest-client', '= 2.0.2'
end
def run
puts "The rest-client gem is at version #{RestClient::VERSION}"
@sfgeorge
sfgeorge / printf_templating.sh
Created February 18, 2020 12:18
Simple UNIX templating with the printf command
# Create a template
echo 'I am just a lowly %s,
playing with %s and %s,
dancing in a %s and trying not to get %s.' > jolly.template
# Evaluate the template
printf "$(<jolly.template)" scoundrel sticks 'barbed wire' web caught
# Or Evaluate the template and silently set it to a shell variable
printf -v output "$(<jolly.template)" scoundrel sticks 'barbed wire' web caught
@sfgeorge
sfgeorge / jruby_opts.md
Created July 13, 2018 14:37
Looking at deprecated JRUBY_OPTS for JRuby
JRUBY_OPTS='-Xcompile.mode.fastest=true -Xjit.treshold=20' jruby -v
jruby: warning: unknown property jruby.jit.treshold
jruby: warning: unknown property jruby.compile.mode.fastest
jruby 9.1.2.0 (2.3.0) 2016-05-26 7357c8f Java HotSpot(TM) 64-Bit Server VM 24.79-b02 on 1.7.0_79-b15 +jit [darwin-x86_64]
@sfgeorge
sfgeorge / block_nest_monster.rb
Created July 12, 2018 23:40
Creative and weird ways to conditionally nest Ruby blocks, using the ruby_speech DSL as an example
require 'ruby_speech'
def append_phrase(document, phrase, options = {})
build_phrase = Proc.new { prosody(rate: 1) { string phrase } }
if options[:voice_name]
document.embed RubySpeech::SSML.draw { voice(name: options[:voice_name], &build_phrase) }
else
document.embed RubySpeech::SSML.draw &build_phrase
end
@sfgeorge
sfgeorge / README.md
Last active January 4, 2024 04:24
Carbon / Graphite tip: How to use whisper-resize to change xFilesFactor on existing stats

Carbon / Graphite tip: How to use whisper-resize to change xFilesFactor on existing stats

Detailed Steps

1.) Update /etc/carbon/storage-aggregation.conf to use the new xFilesFactor setting for new stats, if you haven't yet already

2.) Get the retention ranges as defined in storage-schemas.conf

fgrep retentions /etc/carbon/storage-schemas.conf | tr ',' ' '
@sfgeorge
sfgeorge / molasses_server.rb
Last active August 29, 2015 14:07
A silly idle TCP Server
#!/usr/bin/env ruby
# encoding: utf-8
require 'socket'
port = ENV['PORT'] || 5678
idletime = ENV['IDLETIME'] || 20 # seconds
def log(message)
puts "#{Time.now} INFO #{message}"
@sfgeorge
sfgeorge / cats_and_dogs.rb
Created August 18, 2014 15:14
punchblock virtus test
# https://www.youtube.com/watch?v=JmzuRXLzqKk
class Output
include Virtus
attribute :render_documents, String
def render_document=(other)
puts "Reached render_document=(#{other.inspect})"
puts " render_documents before: #{render_documents.inspect}"
@sfgeorge
sfgeorge / request-response-brief.txt
Last active August 29, 2015 14:03
ngrep ASR request/response example
$ nice sudo ngrep -W byline -qt 'grammar|RECOGNITION-COMPLETE|IN-PROGRESS'
interface: eth0 (192.168.10.0/255.255.254.0)
match: grammar|RECOGNITION-COMPLETE
T 2014/06/25 23:15:16.744457 192.168.11.229:41384 -> 192.168.10.208:20103 [AP]
MRCP/2.0 1058 DEFINE-GRAMMAR 1.
Channel-Identifier: bf085f14-f758-4ce2-b@speechrecog.
Content-Type: application/srgs+xml.
Content-Id: grammar-0.
Content-Length: 890.
@sfgeorge
sfgeorge / README.md
Last active August 29, 2015 13:59
godrb watch file for Adhearsion under JRuby

Adhearsion-JRuby monitored by god

A sample godrb watch for Adhearsion JRuby.

Caveats

  • Note that godrb does not currently work under JRuby. You'll need a ruby manager like rvm or rbenv. That way, you can run your god under CRuby and your adhearsion app under JRuby.
  • This script is not perfect. It occasionally produces empty or corrupt PID files. -_-
  • This script makes a few assumptions.. tweak as necessary if any of this is inaccurate:
    • It assumes you use rvm
    • It assumes you use CentOS 6