Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

Istvan l1x

🏠
Working from home
View GitHub Profile
@l1x
l1x / getting_started_aarch64.md
Last active Nov 23, 2020
Getting started with AWS Firecracker on aarch64 (Raspberry Pi 4 for example)
View getting_started_aarch64.md

Getting started with Firecracker on Raspberry Pi 4B

Creating a new kernel

Getting the kernel source

We only need version 4.20

wget https://github.com/torvalds/linux/archive/v4.20.zip
@l1x
l1x / aws-update-policy-v2.sh
Created Nov 16, 2020
Updating managed policy in AWS
View aws-update-policy-v2.sh
#!/bin/bash
set -e
#set -x
AWS_PROFILE="dev-deploy"
POLICY_ARN="arn:aws:iam::2314123:policy/PolicyName"
POLICY_DOC="file://policies/PolicyNameOnDisk.json"
which aws >/dev/null 2>&1 || ("ERROR: aws command is not installed!"; exit 1)
which jq >/dev/null 2>&1 || ("ERROR: jq command is not installed!"; exit 1)
@l1x
l1x / git_delete_sensitive.sh
Last active Nov 12, 2020
Deleting a sensitive file from Git (including history) starting a certain commit hash
View git_delete_sensitive.sh
#!/usr/bin/env bash
PATH_TO_BE_DELETED="${1}"
if [[ -z ${PATH_TO_BE_DELETED} ]]; then
echo "Path variable a is not set"
exit 1
else
echo "Deleting $PATH_TO_BE_DELETED"
fi
View spiral.fs
let rec spiral m =
match m with
| [] -> []
| x::xs -> x @ spiral (List.rev (List.transpose xs))
[<EntryPoint>]
let main argv =
System.Console.WriteLine(sprintf "%A" (spiral [[1;2;3];[8;9;4];[7;6;5]])) // 1 2 3 4 5 6 7 8 9
System.Console.WriteLine(sprintf "%A" (spiral [[1; 2; 3; 4]; [5; 6; 7; 8]; [9; 10; 11; 12]; [13; 14; 15; 16]])) // 1 2 3 4 8 12 16 15 14 13 9 5 6 7 11 10
System.Console.WriteLine(sprintf "%A" (spiral [[1;2;3;4;5;6]; [7;8;9;10;11;12];[13;14;15;16;17;18]])) // 1 2 3 4 5 6 12 18 17 16 15 14 13 7 8 9 10 11
@l1x
l1x / ntp.erl
Last active Apr 28, 2020
NTP client in Erlang
View ntp.erl
-module(ntp).
-export([get_time/1, get_time/0]).
-define(NTP_PORT, 123). % udp
-define(SERVER_TIMEOUT, 5000). % ms
-define(EPOCH, 2208988800). % offset yr 1900 to unix epoch
ntp_servers() ->
[ "0.europe.pool.ntp.org",
@l1x
l1x / convert.sh
Last active Apr 25, 2020
Converting MKV or AVI to MP4 (h264, aac)
View convert.sh
# with handbrake cli
for i in *.mkv; do
handbrake --preset-import-file fast.json --ab 192 -i "$i" -o "${i%.mkv}".mp4;
done
# or with ffmpeg
for f in *.avi; do
ffmpeg -i "$f" -c:v libx264 -c:a aac "${f%.avi}".mp4;
done
@l1x
l1x / Spiral.hs
Last active May 10, 2020
Spiral print in Haskell
View Spiral.hs
module Main where
transpose :: [[Int]] -> [[Int]]
transpose m =
case m of
[] -> []
([]:_) -> []
x -> (map head x) : transpose (map (drop 1) x)
spiralPrintShort :: [[Int]] -> [Int]
@l1x
l1x / DateTime.elm
Last active Apr 8, 2020
Displaying Date and Time (zero padded values)
View DateTime.elm
-- Show the current time in your time zone.
--
-- Read how it works:
-- https://guide.elm-lang.org/effects/time.html
import Browser
import Html exposing (..)
import Task
import Time exposing (..)
@l1x
l1x / raspberry.provision.sh
Last active Apr 5, 2020
Some provisioning for a default installation Raspbian
View raspberry.provision.sh
sudo apt update -y && sudo apt upgrade -y
sudo systemctl enable ssh
sudo systemctl start ssh
@l1x
l1x / rocksdb.build.centos7.sh
Last active Mar 31, 2020
CentOS 7 build script for RocksDB
View rocksdb.build.centos7.sh
#!/bin/bash
set -ex
ROCKSDB_VERSION="6.7.3"
ZSTD_VERSION="1.4.4"
echo "This script configures CentOS with everything needed to build and run RocksDB"
yum update -y && yum install epel-release -y
You can’t perform that action at this time.