Skip to content

Instantly share code, notes, and snippets.

View magnusja's full-sized avatar
👨‍💻
..

magnus magnusja

👨‍💻
..
View GitHub Profile
@tivrfoa
tivrfoa / roman-to-integers.rs
Last active December 2, 2021 23:27
Rust HashMap macro
// https://leetcode.com/problems/roman-to-integer
use lazy_static::lazy_static;
use std::collections::HashMap;
macro_rules! map {
($( $t: expr),*) => {{
let mut map = HashMap::new();
$( map.insert($t.0, $t.1); )*
map
@mvanga
mvanga / music_theory.py
Last active December 28, 2023 04:33
Basic Music Theory in ~200 Lines of Python
# The code for my article with the same name. You can find it at the URL below:
# https://www.mvanga.com/blog/basic-music-theory-in-200-lines-of-python
# MIT License
#
# Copyright (c) 2021 Manohar Vanga
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
@depau
depau / README.md
Last active January 13, 2020 17:11
Libaums QEMU setup

Steps

  • Install qemu-system-x86_64
  • Download Android-x86 RPM from https://www.fosshub.com/Android-x86.html
  • Extract the RPM (I'm using rpmextract from Arch, GitHub)
  • cd into the android-[version] directory from the RPM
  • Create a backing image for the USB drive:
    • qemu-img create -f raw USB.img 4G
  • Use my adapted QEMU launcher script
/*
LED audio inputVisualizer for ES8266
Hardware requirements:
- ESP8266 or any compatible controller.
- Microphone with amplifier
- LED strip ws2812b
- Optional: battery for portable use (else power through USB or adapter)
Software requirements:
- Adafruit NeoPixel library
@oseme-techguy
oseme-techguy / Correct_GnuPG_Permission.sh
Last active April 10, 2024 07:46
This fixes the " gpg: WARNING: unsafe permissions on homedir '/home/path/to/user/.gnupg' " error while using Gnupg .
#!/usr/bin/env bash
# To fix the " gpg: WARNING: unsafe permissions on homedir '/home/path/to/user/.gnupg' " error
# Make sure that the .gnupg directory and its contents is accessibile by your user.
chown -R $(whoami) ~/.gnupg/
# Also correct the permissions and access rights on the directory
chmod 600 ~/.gnupg/*
chmod 700 ~/.gnupg
@mlgill
mlgill / docker_hygiene.sh
Created May 17, 2018 21:48
Docker Cleanup
# Remove all exited containers
docker rm `docker ps -a -q --filter status=exited` 2>/dev/null
# Remove any orphaned containers related to "INSERT_CONTAINER_NAME_HERE"
docker rm `docker ps -a -q --filter ancestor=INSERT_CONTAINER_NAME_HERE` 2>/dev/null
# Remove any orphaned images from aborted/old builds
docker rmi `docker images -q -f "dangling=true"` 2>/dev/null
# Clean up whatever disk-hogging stuff Docker leaves lying aroung
@dylanmckay
dylanmckay / facebook-contact-info-summary.rb
Last active March 12, 2024 22:46
A Ruby script for collecting phone record statistics from a Facebook user data dump
#! /usr/bin/env ruby
# NOTE: Requires Ruby 2.1 or greater.
# This script can be used to parse and dump the information from
# the 'html/contact_info.htm' file in a Facebook user data ZIP download.
#
# It prints all cell phone call + SMS message + MMS records, plus a summary of each.
#
# It also dumps all of the records into CSV files inside a 'CSV' folder, that is created
@enricofoltran
enricofoltran / main.go
Last active April 1, 2024 00:17
A simple golang web server with basic logging, tracing, health check, graceful shutdown and zero dependencies
package main
import (
"context"
"flag"
"fmt"
"log"
"net/http"
"os"
"os/signal"
@eLement87
eLement87 / mqtt_tls_working.ino
Created December 10, 2017 13:12
ESP8266 Secure MQTT Connection with Client Certificate Authentication
#include <FS.h>
#include <ESP8266WiFi.h>
#include <WiFiClientSecure.h>
#include <PubSubClient.h>
#include <time.h>
// Insert your FQDN of your MQTT Broker
#define MQTT_SERVER "mqtt.srvx1.local"
const char* mqtt_server = MQTT_SERVER;
@hhromic
hhromic / raspbian-stretch-lite-slimdown.md
Last active May 22, 2023 11:02
Slimming Down Raspbian Stretch Lite

Slimming Down Raspbian Stretch Lite

Notes for slimming down a fresh installation of Raspbian Stretch Lite. This guide does not strip Raspbian of basic functionality such as Bluetooth and mDNS.

Instructions

Install a fresh Raspbian Stretch Lite image into the SD card ([source][1]).

$ unzip -p 2018-04-18-raspbian-stretch-lite.zip | dd bs=4M of=/dev/sdX conv=fsync