Skip to content

Instantly share code, notes, and snippets.

Alex lmas

Block or report user

Report or block lmas

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@lmas
lmas / generate_token.go
Last active Nov 14, 2019
Generate random, hex encoded tokens
View generate_token.go
package main
import (
"crypto/rand"
"crypto/sha256"
"encoding/binary"
"encoding/hex"
"fmt"
"time"
)
@lmas
lmas / Dockerfile
Created Apr 2, 2019
Minimalist dockerfile for running standalone binaries
View Dockerfile
FROM alpine:3.9 AS builder
RUN apk add --no-cache ca-certificates && \
mkdir -p /build/etc/ssl/certs && \
cp /etc/ssl/certs/ca-certificates.crt /build/etc/ssl/certs/ && \
echo 'app:x:2000:2000::/:' > /build/etc/passwd && \
echo 'app:x:2000:' > /build/etc/group && \
mkdir /data
################################################################################
@lmas
lmas / crt.css
Created Mar 24, 2019
Add CRT scanlines, screen flicker and color separation effects
View crt.css
/*Stolen from http://aleclownes.com/2017/02/01/crt-display.html*/
/*This adds a "crt scanlines" effect to the screen*/
.crt-scanlines::before {
content: " ";
display: block;
position: absolute;
top: 0;
left: 0;
bottom: 0;
@lmas
lmas / http_utils.go
Created Nov 28, 2018
Some simple http utils (http handlers with errors, secure cookies)
View http_utils.go
import (
"net/http"
"time"
"github.com/gorilla/securecookie"
)
type WebError struct {
Code int
Err error
@lmas
lmas / api_client.go
Created Jan 1, 2018
Simple API client with json parsing, gzip compression, ratelimit and oauth tokens
View api_client.go
package main
import (
"compress/gzip"
"context"
"encoding/json"
"fmt"
"net/http"
"net/url"
"time"
@lmas
lmas / summarize.go
Created Sep 28, 2017
Summarizes text
View summarize.go
import (
"strings"
"github.com/JesusIslam/tldr"
)
func Summarize(text string) (string, float64, error) {
sum := tldr.New()
tmp, err := sum.Summarize(text, 6)
if err != nil {
@lmas
lmas / rng_imager.go
Created Sep 8, 2017
Simple attempt at visual analysis of RNG sources
View rng_imager.go
package main
// Inspiration: https://www.random.org/analysis/
import (
"image"
"image/color"
"image/png"
"math/big"
"os"
@lmas
lmas / closing_channels_sends_zero_vals.go
Created Jul 12, 2017
Reading values from a closed channel only returns zero values
View closing_channels_sends_zero_vals.go
package main
import (
"log"
)
func main() {
// Also works with other channel types, like: chan string, chan int etc.
// NOTE: The zero value for "bool" types is == false
ch := make(chan bool)
@lmas
lmas / djb2.go
Created Jun 12, 2017
djb2, a non-cryptographic hash function
View djb2.go
package djb2
// For when you ever need to implement a dictionary hash function,
// that's good enough, simple and fast.
//
// WARNING:
// Not cryptographicly secure!
//
// Source: https://en.wikipedia.org/wiki/DJB2
//
@lmas
lmas / window_title.go
Created Feb 25, 2017
Get the title of the currently active window in linux
View window_title.go
package main
import (
"fmt"
"os/exec"
"strings"
"time"
)
func main() {
You can’t perform that action at this time.