Skip to content

Instantly share code, notes, and snippets.

Avatar

Elijah Miller jqr

View GitHub Profile
@jqr
jqr / linear_contention.rb
Created Feb 21, 2018
Easy to reason about linear overlapped execution of multiple threads to force contention for tests.
View linear_contention.rb
require "thread"
# Easy to reason about linear overlapped execution of multiple threads to
# force contention for tests.
#
# -------- Time ------->
# Thread.current 1 ---------------------------------- 4
# t2 2 ------- 3
m = Mutex.new
@jqr
jqr / namespaces_and_nesting.rb
Created Feb 20, 2018
Namespaces and Nesting
View namespaces_and_nesting.rb
# Show an issue with reopened namespaces having lookups done using nesting
# instead of namespaces. Then show a simple work-around.
# Define a constant in a module with namespaced classes.
module Something
CONSTANT = true
end
# Reopen Something add add a class using nesting.
module Something
View vegan_chili.md
View test.md
summary deets!
@jqr
jqr / weird.rb
Created Jan 6, 2016
Ruby scope issue with if statements
View weird.rb
if false
x = 1
else
puts x.inspect # echos "nil", does not raise exception
end
@jqr
jqr / mongoelcapitan.diff
Created Oct 4, 2015
Patch for scons to compile mongodb on El Capitan
View mongoelcapitan.diff
diff --git a/SConstruct b/SConstruct
index 5965b53..50a76ef 100644
--- a/SConstruct
+++ b/SConstruct
@@ -320,7 +320,7 @@ add_option('propagate-shell-environment',
0, False)
if darwin:
- osx_version_choices = ['10.6', '10.7', '10.8', '10.9']
+ osx_version_choices = ['10.6', '10.7', '10.8', '10.9', '10.10', '10.11']
@jqr
jqr / DocRaptor.cs
Last active Apr 8, 2018 — forked from janxious/DocRaptor.cs
DocRaptor Examples Set 1 - Non-Ruby
View DocRaptor.cs
using System;
using System.IO;
using System.Text;
using System.Net;
using System.Web;
namespace DocRaptorConsoleExample {
class DocRaptor {
private const string PostFormat = "doc[{0}]={1}&doc[name]={2}&doc[document_type]={3}&doc[test]={4}";
private const string ApiKey = @"YOUR API KEY HERE";
View Gemfile
source "https://rubygems.org"
gem "doc_raptor"
@jqr
jqr / ssl_certificate_request.rb
Last active Apr 8, 2018
Easily generate wildcard SSQL certificate requests
View ssl_certificate_request.rb
#!/usr/bin/env ruby
company_name = "__YOUR_COMPANY_NAME__"
state = "__YOUR_STATE__"
if ARGV.size == 0
puts "Usage: #{$0} <domain>"
puts "Generates a new private key and a certificate signing request."
puts
puts "NOTE: Always produces a wildcard certificate request."
puts
@jqr
jqr / ssl_certificate_fingerprint.sh
Created May 30, 2015
Easy command line SSL certificate fingerprinting
View ssl_certificate_fingerprint.sh
#!#!/bin/bash
if [ $1 ]; then
echo -e "GET / HTTP\1.1\n" | openssl s_client -connect $1:443 2> /dev/null | openssl x509 -noout -fingerprint | cut -f2 -d'=' | head -n 1 2> /dev/null
else
echo "Usage: $0 <host>"
echo "Generates an SSL fingerprint for a host. Useful in comparing certificate changes."
echo
echo "Examples:"
echo " $0 google.com"
echo " $0 amazon.com"
You can’t perform that action at this time.