Skip to content

Instantly share code, notes, and snippets.

View mahdi13's full-sized avatar
🏝️
I'm still working on my masterpiece

Mahdi Perfect mahdi13

🏝️
I'm still working on my masterpiece
View GitHub Profile
@amiralitaheri
amiralitaheri / branch_cleaner.sh
Last active June 5, 2021 18:03
Bash script to delete branches that are merged and stale
#!/usr/bin/env bash
# List of branches that never should be deleted
protected_branches=('v1.7' 'develop' 'master')
echo "Fetching all from remote to ensure everything is up to date..."
git fetch --all
expiration_date=$(date --date="7 days ago")
@ilap
ilap / The_Hitchhikers_Guide_To_The_Shelley_Chapter_Three.md
Last active January 1, 2024 07:14
The Hitchhikers Guide To The Shelley - Chapter 3 - The Staking

The Hitchhiker's Guide To The Shelley - Chapter 3 - The Staking

This guide's chapter targets the pool operators for getting their head around of Shelley staking. To fully understand the staking mechanism we need to define and interpret the following key concepts:

Keys, Addresses and Certifications

@rordi
rordi / root-password-MariaDB-docker-compose.md
Last active January 23, 2024 15:36
Change root password in MariaDB Docker container running with docker-compose

Change root password in MariaDB Docker container running with docker-compose

Override the entrypoint in docker-compose.yml for the MariaDB Docker container by adding:

entrypoint: mysqld_safe --skip-grant-tables --user=mysql

The start up the Docker Compose stack:

$> docker-compose up -d
@stokito
stokito / firewall.user
Last active January 7, 2024 22:06 — forked from Manouchehri/cloudflare.sh
OpenWrt: Allow only CloudFlare to access HTTP 80 and HTTPS 443 ports. Use if your uhttpd is hidden behind CF. Put this file to /etc/firewall.user. NOTE: It uses HTTP to get the list of IPs because to wget via https we need to install ca-certs. This makes you vulnerable to MiTM attacks but that's ok to be protected from internet's hackers
# https://www.cloudflare.com/ips replace the ips-v4 with ips-v6 if needed
# https://blog.cloudflare.com/cloudflare-now-supporting-more-ports/
for ip in `wget -qO- http://www.cloudflare.com/ips-v4`; do
iptables -I INPUT -p tcp -m multiport --dports 80,443,8080,8443,2052,2053,2082,2083,2086,2087,2095,2096,8880 -s $ip -j ACCEPT
done
@artizirk
artizirk / gnupg_scdaemon.md
Last active April 3, 2024 14:49
OpenPGP SSH access with Yubikey and GnuPG

NB: This document describles a 'Old-School' way of using Yubikey with SSH

Modern OpenSSH has native support for FIDO Authentication. Its much simpler and should also be more stable with less moving parts. OpenSSH also now has support for signing arbitary files witch can be used as replacement of gnupg. Git also supports signing commits/tags with ssh keys.

Pros of FIDO

  • Simpler stack / less moving parts
  • Works directly with ssh, ssh-add and ssh-keygen on most computers
  • Simpler
  • Private key can never leave the FIDO device

Cons of FIDO

@tehmoon
tehmoon / iptables-reload.sh
Last active January 13, 2024 09:21
IPtables and docker reload!
#!/bin/sh
set -e
## SEE https://medium.com/@ebuschini/iptables-and-docker-95e2496f0b45
## You need to add rules in DOCKER-BLOCK AND INPUT for traffic that does not go to a container.
## You only need to add one rule if the traffic goes to the container
CWD=$(cd "$(dirname "${0}")"; pwd -P)
FILE="${CWD}/$(basename "${0}")"
@sdeleuze
sdeleuze / kotlin-frontend.md
Last active October 25, 2022 14:50
My call for Kotlin as a major frontend language

My call for Kotlin as a major frontend language

I try to push for quite a long time for first class support for WebAssembly in Kotlin because I really believe that frontend development is a domain where Kotlin can be as strong as in mobile, and because this is something that would also help to increase even more the adoption on server-side.

I truly appreciate all the work already done by Kotlin/JS and Kotlin/Native teams. The dead code elimination tool and the initial WebAssembly support in Kotlin/Native are important steps in the right direction. But I believe that Kotlin needs now to make frontend a real priority to take it to the next level.

Need for a consistent and unified web frontend strategy

The first point I would like to raise is that what Kotlin needs IMO is a consistent strategy about web frontend wich includes both Javascript and WebAssembly related efforts. I can u

@rtoal
rtoal / rest-auth-notes.md
Last active December 4, 2018 09:03
Notes on authenticating REST APIs

Random Thoughts on Authentication in REST APIs

Disclaimer: I am not an auth expert, but I know someone who is. All errors and ramblings below are mine, not theirs.

First, some considerations:

  • Is your API a public data service or just the "backend piece" of your own web or mobile app?
  • Are you employing a third-party (e.g., "login with Facebook") or are you managing credentials yourself?
  • Basic auth or token auth?
  • Stateless (token fully contains verification info) or stateful (must consult data store every time to verify) tokens?
  • Long-lived tokens or short-lived tokens?
@lovubuntu
lovubuntu / Sha256.kt
Created November 24, 2017 15:58
function to generate Sha-256 in Kotlin
Class Hasher {
fun hash(): String {
val bytes = this.toString().toByteArray()
val md = MessageDigest.getInstance("SHA-256")
val digest = md.digest(bytes)
return digest.fold("", { str, it -> str + "%02x".format(it) })
}
}
@twaddington
twaddington / UserAgentInterceptor.java
Created October 12, 2017 02:17
Injects a User-Agent header into outgoing OkHttp requests.
package com.enlighthq.mobile.http;
import android.os.Build;
import java.io.IOException;
import java.util.Locale;
import okhttp3.Interceptor;
import okhttp3.Request;
import okhttp3.Response;