Skip to content

Instantly share code, notes, and snippets.

@cryptix
cryptix / pgpTestTool.go
Created December 28, 2014 16:20
PGP file encryption in golang
package main
import (
"archive/zip"
"fmt"
"log"
"os"
"time"
"github.com/cryptix/go/logging"
@karpathy
karpathy / min-char-rnn.py
Last active May 22, 2024 08:28
Minimal character-level language model with a Vanilla Recurrent Neural Network, in Python/numpy
"""
Minimal character-level Vanilla RNN model. Written by Andrej Karpathy (@karpathy)
BSD License
"""
import numpy as np
# data I/O
data = open('input.txt', 'r').read() # should be simple plain text file
chars = list(set(data))
data_size, vocab_size = len(data), len(chars)
// There seem to be problems with "climatically" and "fezzes" as passwords.
// When using "climatically": Program terminates with "openpgp: unsupported feature: public key version"
// When using "fezzes": Program terminates with "openpgp: invalid data: tag byte does not have MSB set"
// Expected behaviour would be a reinvokation of the prompt function in an endless loop until the right password is used.
package main
import (
"bytes"
"errors"
@schmohlio
schmohlio / sse.go
Last active February 13, 2023 08:38 — forked from ismasan/sse.go
Example SSE server in Golang
// v2 of the great example of SSE in go by @ismasan.
// includes fixes:
// * infinite loop ending in panic
// * closing a client twice
// * potentially blocked listen() from closing a connection during multiplex step.
package main
import (
"fmt"
"log"
@wrunk
wrunk / user_test.go
Last active January 25, 2021 23:34
Golang unit test for panic scenario
func TestUserFail(t *testing.T) {
func() {
defer func() {
if r := recover(); r == nil {
t.Errorf("TestUserFail should have panicked!")
}
}()
// This function should cause a panic
CreateUser(12, "hello")
@dariosalvi78
dariosalvi78 / ADS1256.c
Created May 2, 2017 19:24
Simple library for ADS1256 to be used by Arduino. It does not implement the whole set of features, but can be used as a starting point.
/* ADS1256 simple library for Arduino
ADS1256, datasheet: http://www.ti.com/lit/ds/sbas288j/sbas288j.pdf
connections to Atmega328 (UNO)
CLK - pin 13
DIN - pin 11 (MOSI)
DOUT - pin 12 (MISO)
CS - pin 10
DRDY - pin 9
RESET- pin 8 (or tie HIGH?)
@schwern
schwern / permutation.go
Last active August 31, 2021 14:18
A permutation library based on Paul Hankin's from https://stackoverflow.com/a/30230552/14660
package permutation
// Based on https://stackoverflow.com/a/30230552/14660 by Paul Hankin
// perm := NewPermutation( slice )
// for next := perm.Next(); next != nil; next = perm.Next() {
// ...
// }
//
// or