Skip to content

Instantly share code, notes, and snippets.

Avatar

Pete Nicholls Aupajo

View GitHub Profile
@Aupajo
Aupajo / georgia.js
Last active Nov 5, 2020
Georgia Bitbar
View georgia.js
#!/usr/bin/env node
const fetch = require('node-fetch')
function formattedCount(number) {
return number.toLocaleString()
}
async function start() {
const url = 'https://www.huffpost.com/elections/president.json'
@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}"
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`
View nist-800-171.md

3.1 ACCESS CONTROL

Basic Security Requirements

3.1.1 Limit system access to authorized users, processes acting on behalf of authorized users, and devices (including other systems).

3.1.2 Limit system access to the types of transactions and functions that authorized users are permitted to execute.

Derived Security Requirements

@Aupajo
Aupajo / pre-commit
Created Feb 14, 2018
Check for `.only` in a Git pre-commit hook. Gives you the option to show the diffs and continue with the commit.
View pre-commit
#!/bin/bash
match_pattern=".only"
file_pattern="*.js"
# Exit if any command fails
set -e
function matching_diff {
git diff --staged -G "$match_pattern" $@ -- $file_pattern
@Aupajo
Aupajo / app.js
Last active Jan 24, 2018
Continuations in Node
View app.js
const { createNamespace } = require('continuation-local-storage')
const createUUID = require('uuid/v1')
// Application
const logger = require('./logger')
const performSomeProcessing = require('./processing')
// Establish a new storage area for the continuation
const context = createNamespace('context')
View safe-thread-yielding.rb
require 'thread'
def thing_yielder(&block)
things = %i( a b c )
yieldings = Queue.new
threads = things.map do |thing|
Thread.new do
sleep rand(1..3) # Simulate work
yieldings << thing
View vol
#!/usr/bin/env ruby
# Examples:
# vol Print the current sound volume
# vol 30 Set the volume to 30%
# vol mute
# vol unmute
command = case ARGV.first
when 'mute' then "set volume output muted true"