Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am henryaj on github.
  • I am henryaj (https://keybase.io/henryaj) on keybase.
  • I have a public key ASDYhCv2mChD8bYHRsEQyqe_4yKoSRp8BHzq-j5xvkvDYgo

To claim this, I am signing this object:

@henryaj
henryaj / fmt.rs
Last active May 25, 2018 16:36
Rust experiments
use std::fmt;
struct Matrix(i32, i32, i32, i32);
impl fmt::Display for Matrix {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
let result = format!(
"{0}, {1}, {2}, {3}",
self.0, self.1, self.2, self.3
);
@henryaj
henryaj / main.go
Last active December 1, 2016 10:17
ASCII-armored RSA key generation in Golang
package main
import (
"crypto/rand"
"crypto/rsa"
"crypto/x509"
"encoding/pem"
"fmt"
)

A pain no more!

  1. Run bosh-get-targets to dump your saved BOSH targets as YAML.
  2. Run bosh-save-targets (where `` is the output of step 1) to merge the targets into your existing targets.
@henryaj
henryaj / binary_search.rb
Last active November 1, 2016 18:32
Binary search in Ruby
def binary_search(array, target)
return false if array.length == 0
if array.length == 1
return true if array.first == target
return false
end
midpoint = array.length / 2
lower = array[0..midpoint-1]
import sys
def main():
sys_write = sys.stdout.write
entries = 3.2 * 1e8 # Modify to increase disk usage, this is ~15GB at default
for i in xrange(int(entries)):
sys_write('SET Key%i Value%i\r\n' % (i, i))
@henryaj
henryaj / keepalive.applescript
Created March 10, 2016 13:41
AppleScript to keep a VPN connection alive
repeat
tell application "System Events"
tell current location of network preferences
set myConnection to the service "YOUR_VPN_NAME"
if myConnection is not null then
if current configuration of myConnection is not connected then
connect myConnection
end if
end if
end tell