Skip to content

Instantly share code, notes, and snippets.

View gf3's full-sized avatar
🍊
workin' goodly

Gianni Chiappetta gf3

🍊
workin' goodly
View GitHub Profile
@gf3
gf3 / env2yaml64.rb
Created September 10, 2021 18:29
Create the `data` part of a kubernetes opaque secret from an ENV file
require "base64"
require "dotenv"
require "yaml"
if ARGV.empty?
puts "Usage: #{__FILE__} <env file>"
exit 1
end
file = ARGV[0]
@gf3
gf3 / boot options
Created May 27, 2020 03:03
Grub boot options (threadripper/nvidia)
mce=off blacklist=nouveau modprobe.blacklist=nouveau
@gf3
gf3 / 81-disable-onboard-audio.rules
Created April 7, 2020 05:34
Linux on AMD TRX40 (Threadripper) and NVIDIA 2080ti RTX
# /etc/udev/rules.d/81-disable-onboard-audio.rules
#
# Disable onboard Asustek USB audio device
SUBSYSTEM=="usb", ATTRS{idVendor}=="0b05", ATTRS{idProduct}=="1917", ATTR{authorized}="0"
@gf3
gf3 / main.rs
Created May 29, 2019 21:12
error[E0507]: cannot move out of borrowed content
extern crate unidiff;
use unidiff::PatchSet; // http://messense.github.io/unidiff-rs/unidiff/struct.PatchSet.html
pub struct Printer {
patch_set: PatchSet,
}
impl Printer {
pub fn new(source: &str) -> Self {
@gf3
gf3 / setup.sh
Last active January 22, 2019 20:20
Neovim config setup
#!/bin/sh
# Install:
# curl -fsL https://gist.githubusercontent.com/gf3/3d90fd82deaa4cab19fb8d817a370e27/raw/setup.sh | sh
# Directories
mkdir -p ~/.local/share/nvim/{backup,swap,undo}
# Config
curl -fLo ~/.local/share/nvim/site/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
@gf3
gf3 / README.md
Last active January 22, 2019 18:07
Docker: VPN + DNS Proxy + App

Docker setup

Using the docker-compose.yml below as a template, replace the webapp section with your application.

VPN setup

Follow the setup guide here: https://github.com/kylemanna/docker-openvpn

Afterwards we'll want to modify the VPN config so that it points to our local DNS proxy.

@gf3
gf3 / uuid.ts
Created February 20, 2018 19:57
Generate a secure RFC4122-compliant v4 UUID
/**
* Convert a number or array of integers to a string of padded hex octets.
*/
function asHex(value: number[] | Uint8Array): string {
return Array.from(value).map(i => ('00' + i.toString(16)).slice(-2)).join('');
}
/**
* Attempt to securely generate random bytes/
*/
@gf3
gf3 / email-test.js
Last active March 17, 2023 20:13
Validate and correct misspelled emails using a fuzzy matcher
/* eslint-env jasmine */
import { validate, suggest } from './email';
describe('email', () => {
describe('validate', () => {
it('should correctly validate correct email addresses', (done) => {
const promises = [
validate('user@gmail.com'),
validate('user+dix@host.ca'),
@gf3
gf3 / keybase.md
Last active April 13, 2021 17:28
keybase.md

Keybase proof

I hereby claim:

  • I am gf3 on github.
  • I am gf3 (https://keybase.io/gf3) on keybase.
  • I have a public key ASBSUcu3p7hJhvRo-yZRFSGw8dpcfC6SjR2A8PQHo84l1go

To claim this, I am signing this object:

@gf3
gf3 / Spotify.swift
Created August 29, 2017 20:55
Spotify ScriptingBridge from Swift
import AppKit
import ScriptingBridge
@objc public protocol SBObjectProtocol: NSObjectProtocol {
func get() -> Any!
}
@objc public protocol SBApplicationProtocol: SBObjectProtocol {
func activate()
var delegate: SBApplicationDelegate! { get set }