Skip to content

Instantly share code, notes, and snippets.

View ryanwinchester's full-sized avatar
⚗️
Working on open-source and side projects

Ryan Winchester ryanwinchester

⚗️
Working on open-source and side projects
View GitHub Profile
@ryanwinchester
ryanwinchester / gencert.sh
Created December 27, 2019 21:30 — forked from crpietschmann/gencert.sh
OpenSSL Generate 4096-bit Certificate (Public/Private Key Encryption) with SHA256 Fingerprint
# Generate Private Key and Certificate using RSA 256 encryption (4096-bit key)
openssl req -x509 -newkey rsa:4096 -keyout privatekey.pem -out certificate.pem -days 365
# Alternatively, setting the "-newkey" parameter to "rsa:2048" will generate a 2048-bit key.
# Generate PKCS#12 (P12) file for cert; combines both key and certificate together
openssl pkcs12 -export -inkey privatekey.pem -in certificate.pem -out cert.pfx
# Generate SHA256 Fingerprint for Certificate and export to a file
openssl x509 -noout -fingerprint -sha256 -inform pem -in certificate.pem >> fingerprint.txt
@ryanwinchester
ryanwinchester / gen-ca.sh
Last active December 26, 2019 08:30 — forked from mtigas/gist:952344
Mini tutorial for configuring client-side SSL certificates.
#!/bin/bash
###### PICK ONE OF THE TWO FOLLOWING ######
# OPTION ONE: RSA key. these are very well-supported around the internet.
# you can swap out 4096 for whatever RSA key size you want. this'll generate a key
# with password "xxxx" and then turn around and re-export it without a password,
# because genrsa doesn't work without a password of at least 4 characters.
#
# some appliance hardware only works w/2048 so if you're doing IOT keep that in
@ryanwinchester
ryanwinchester / remote-node.sh
Created September 5, 2018 18:14
You can run observer locally for a remote node
#!/bin/sh
set -e
BEAM_PORT=32815
EPMD_PORT=4369
COOKIE='cookiestring'
ssh -f -o ExitOnForwardFailure=yes \
-L "$EPMD_PORT:localhost:$EPMD_PORT" \
@ryanwinchester
ryanwinchester / poker.exs
Last active May 15, 2018 21:50
Just having fun...
defmodule Poker do
@deck ~w(
A♣ 2♣ 3♣ 4♣ 5♣ 6♣ 7♣ 8♣ 9♣ 10♣ J♣ Q♣ K♣
A◆ 2◆ 3◆ 4◆ 5◆ 6◆ 7◆ 8◆ 9◆ 10◆ J◆ Q◆ K◆
A♠ 2♠ 3♠ 4♠ 5♠ 6♠ 7♠ 8♠ 9♠ 10♠ J♠ Q♠ K♠
A♥ 2♥ 3♥ 4♥ 5♥ 6♥ 7♥ 8♥ 9♥ 10♥ J♥ Q♥ K♥
)
def deck, do: Enum.with_index(@deck)
@ryanwinchester
ryanwinchester / fib.exs
Last active April 3, 2018 20:08
Fibonacci Solution
defmodule Fibonacci do
def fib(0), do: 0
def fib(1), do: 1
def fib(n), do: fib(n-1) + fib(n-2)
end
@ryanwinchester
ryanwinchester / stop keybase from auto launching.sh
Created February 7, 2018 21:35
Stop keybase from auto launch
keybase uninstall --components service
@ryanwinchester
ryanwinchester / PHP-Guzzle.php
Last active September 7, 2025 05:08 — forked from bkilshaw/gist:3624901
MACVendors.com API :: V1 Code Samples
<?php
// PHP using Guzzle example
use GuzzleHttp\Client;
$client = new Client();
$mac_address = "FC:FB:FB:01:FA:21";

Here’s an example of an list comprehension in Haskell from Wikipedia:

a = [(x,y) | x <- [1..5], y <- [3..5]]
-- [(1,3),(1,4),(1,5),(2,3),(2,4) ...

In this example, a list of pair of integers is constructed from 2 lists of integers.

Here is what that example would be in Python:

@ryanwinchester
ryanwinchester / example.php
Created December 12, 2017 08:04
Is it clean?
<?php
function canView(string $scope, int $owner_id): bool
{
return $scope === 'public' || $this->userCanView(Auth::user(), $owner_id);
}
function userCanView(User $user, int $owner_id): bool
{
return $user->hasRole('admin') || $user->id === $owner_id;
@ryanwinchester
ryanwinchester / _hover_example.py
Created October 4, 2017 19:54 — forked from dankrause/_hover_example.py
Example code to use the (unofficial, unsupported, undocumented) hover.com DNS API.
import requests
class HoverException(Exception):
pass
class HoverAPI(object):
def __init__(self, username, password):
params = {"username": username, "password": password}
r = requests.post("https://www.hover.com/api/login", params=params)