Skip to content

Instantly share code, notes, and snippets.

logging {
level = "debug"
format = "logfmt"
// Soon™
// write_to = loki.write.grafanacloud.receiver
}
/* CRI-formatted log lines.
I'm cheating and just redirecting from stdin for the demo :sweat_smile: */
@tpaschalis
tpaschalis / script.sh
Created November 5, 2020 22:02
Triggering an AWS Lambda through a POST request
$ aws apigateway create-rest-api --name lambda-trigger-api
HEADER 2020-11-05T20:24:08+02:00 False <api-id> lambda-trigger-api
TYPES EDGE
$ aws apigateway get-rest-api --rest-api-id <api-id>
HEADER 2020-11-05T20:24:08+02:00 False <api-id> lambda-trigger-api
TYPES EDGE
$ aws apigateway get-resources --rest-api-id <api-id>
ITEMS <api-root-id> /
@tpaschalis
tpaschalis / hex-and-word.py
Last active June 3, 2020 14:06
Words that are also hex numbers
import re
def is_hex(word):
match = re.match("^[a-f]*$", word)
return match is not None
with open('/usr/share/dict/american-english') as file:
lines = file.readlines()
for item in lines:
if is_hex(item.lower()) and len(item)>2:
@tpaschalis
tpaschalis / sleepsort.go
Created April 2, 2019 09:39
"Comparison-free sorting of positive integers" aka "Sleepsort" in Go, using Goroutines
package main
import (
"fmt"
"os"
"sync"
"time"
"strconv"
)
@tpaschalis
tpaschalis / amb.go
Last active February 12, 2019 15:52
A Go implementation of McCarthy's `amb` ambiguous operator
package main
import "fmt"
import "sync"
func ambString(str []string) chan []string {
c := make(chan []string)
go func() {
for _, s := range str {
c <- []string{s}
@tpaschalis
tpaschalis / crack.go
Created November 21, 2018 19:00
CS50 - Pset 2 - Crack DES hash in Golang - Use of concurrency to speed up naive algorithm, at least 5x gains in speed..
package main
import (
"fmt"
"os"
"bytes"
"unsafe"
"sync"
_"runtime"
)
@tpaschalis
tpaschalis / README-Template.md
Created February 25, 2018 08:56 — forked from PurpleBooth/README-Template.md
A template to make good README.md

Project Title

One Paragraph of project description goes here

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.

Prerequisites

@tpaschalis
tpaschalis / README.md
Last active March 6, 2018 21:24 — forked from edds/README.md
Stream tweets containing a specific hashtag to your browser, using Socket.io

A simple example to create a websocket server and stream tweets of a specific hashtag to your browser.

Setup

$ sudo npm install socket.io 
$ sudo npm install twitter

Get your Standard Twitter API credentials from https://apps.twitter.com/ .
Make sure to include any valid URL (eg. https://www.google.com) as the Callback URL, so that the keys can work as a browser app.

@tpaschalis
tpaschalis / np2lat.py
Last active March 13, 2021 08:33
Convert a Numpy ndarray to LaTeX table/tabular environment.
import numpy as np
def np2lat(A):
filename = 'table.tex'
f = open(filename, 'a')
cols = A.shape[1]
# Change alignment and format of your output
tabformat = '%.3f'
tabalign = 'c'*cols
function mat2lat(A)
filename = 'tabular.tex';
fileID = fopen(filename, 'w+');
[rows, cols] = size(A);
% Change alignment of your output with the following character
tabalign = repmat('c', 1, cols);
fprintf(fileID,'\\begin{table}[h] \n');