Skip to content

Instantly share code, notes, and snippets.

Pete Nicholls Aupajo

Block or report user

Report or block Aupajo

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@Aupajo
Aupajo / verify-ssl.rb
Created Feb 3, 2020
SSL verification in Ruby
View verify-ssl.rb
# Usage: ruby verify-ssl.rb domain1.com domain2.com domain3.com
require 'socket'
require 'openssl'
SSL_PORT = 443
def verify(domain, cert_store)
puts "---"
puts "Domain: #{domain}"
@Aupajo
Aupajo / gist:4133515
Last active Dec 30, 2019
A few of my favourite Git settings
View gist:4133515
# Colours
git config --global color.status auto
git config --global color.branch auto
git config --global color.diff auto
# Short-hand aliases
git config --global alias.st status
git config --global alias.ci commit
git config --global alias.co checkout
git config --global alias.br branch
@Aupajo
Aupajo / 01.1.lifecycle.rb
Last active Nov 21, 2019
Sockets in Ruby
View 01.1.lifecycle.rb
require 'socket'
# 1. Create
# AF_INET means IPv4 (xxx.xxx.xxx.xxx)
# SOCK_STREAM means communicating with a stream (TCP)
#
# Can be simplified to symbols :INET and :STREAM, respectively
server = Socket.new(Socket::AF_INET, Socket::SOCK_STREAM)
View deterministic-fake-names.rb
require 'digest/md5'
# This demonstrates an approach you can use to deterministically generate fake
# data based on user data to anonymize it.
# An array of substitute names read from a file
substitute_names = File.read('names.txt').split("\n")
# Real customer data, e.g., from a database
real_name = "John Realname"
View deterministic-fake-names.rb
require 'digest/md5'
# This demonstrates an approach you can use to deterministically generate fake
# data based on user data to anonymize it.
# An array of substitute names read from a file
substitute_names = File.read('names.txt').split("\n")
# Real customer data, e.g., from a database
real_name = "John Realname"
@Aupajo
Aupajo / 32bitapps.rb
Last active Oct 12, 2019
Find out which 32-bit apps won't make the leap to Catalina
View 32bitapps.rb
#!/usr/bin/env ruby
begin
require 'plist'
rescue LoadError
abort "Missing dependency. Please run: `gem install plist` and try again."
end
raw_output = `system_profiler SPApplicationsDataType -xml -detailLevel mini`
@Aupajo
Aupajo / gist:4654510
Created Jan 28, 2013
List of TZInfo timezones
View gist:4654510
Africa/Abidjan
Africa/Accra
Africa/Addis_Ababa
Africa/Algiers
Africa/Asmara
Africa/Asmera
Africa/Bamako
Africa/Bangui
Africa/Banjul
Africa/Bissau
@Aupajo
Aupajo / list_of_countries.rb
Created Apr 19, 2010
List of countries in a handy Ruby array
View list_of_countries.rb
COUNTRIES = [
"Afghanistan",
"Aland Islands",
"Albania",
"Algeria",
"American Samoa",
"Andorra",
"Angola",
"Anguilla",
"Antarctica",
@Aupajo
Aupajo / demo.html
Created Sep 26, 2013
Simple jQuery multiple-choice quiz
View demo.html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Simple Quiz</title>
</head>
<body>
<form action="/success-page" class="simple-quiz">
<h3>Question 1</h3>
@Aupajo
Aupajo / restforce.md
Last active May 11, 2019
How Restforce handles refreshing OAuth tokens
View restforce.md

Summary

You can hook into authentication success by passing an authentication_callback to the client.

If you're happy relying on an internal API call, you can make sure your token is fresh by calling:

restforce_client.authenticate!
You can’t perform that action at this time.