Skip to content

Instantly share code, notes, and snippets.

View amitkgupta's full-sized avatar
🐿️
https://akgupta.ca

Amit Gupta amitkgupta

🐿️
https://akgupta.ca
View GitHub Profile
@amitkgupta
amitkgupta / boshv3_demo.sh
Created September 10, 2019 22:06
BOSH v3 demo script for github.com/amitkgupta/boshv3
## Demo for BOSH v3
## https://github.com/amitkgupta/boshv3
# Versions
bosh env
bosh —version
minikube status
minikube version
kubectl version
@amitkgupta
amitkgupta / examples__main.go
Last active March 18, 2018 06:24
Linearize x509 certificates where partial order is derived from issuing authority
package main
import (
"crypto"
crand "crypto/rand"
"crypto/rsa"
"crypto/x509"
"crypto/x509/pkix"
"math/big"
mrand "math/rand"
@amitkgupta
amitkgupta / minesweeper.go
Last active September 3, 2017 18:56
Simplistic text-based minesweeper game
package main
import (
"errors"
"fmt"
"math/rand"
"os"
"os/exec"
)
@amitkgupta
amitkgupta / cryptopals-set-1-challenge-6.go
Last active May 21, 2017 06:22
Breaking repeating-key XOR [Cryptopals | Set 1 | Challenge 6]
// Problem: https://cryptopals.com/sets/1/challenges/6
//
// Solution: http://www.azlyrics.com/lyrics/vanillaice/playthatfunkymusic.html (more or less)
//
// Usage: Just 'go run' this file!
package main
import (
"fmt"
@amitkgupta
amitkgupta / goodlearn-knn-perf.svg
Last active August 29, 2015 14:06
kNN Classifications on a large dataset with different packages.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@amitkgupta
amitkgupta / is_fibonacci.rb
Created July 10, 2013 08:25
A very fast, near-constant runtime algorithm for determining whether a given number is Fibonacci, accurate up to numbers with trillions of trillions of digits (or something like that)
def is_fibonacci?(num)
n = (Math.log(num*2.23606797749979 + 0.5) * 2.0780869213681945).floor
num == (1.6180339887**n * 0.4472135954999579).round
end
@amitkgupta
amitkgupta / earth_midpoint.rb
Created February 23, 2013 09:55
Find a point on the sphere minimizing the average distance to a given set of points, within a given degree of precision.
class Point
attr_reader :lat, :long
def initialize(lat, long)
@lat = lat.to_f
@long = long.to_f
if (-Math::PI/2 > @lat || @lat > Math::PI/2)
raise "lat must between -PI/2 and PI/2, inclusive"
end