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
@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?
@justasm
justasm / NonPersistentCookieJar.java
Last active April 21, 2019 10:03
OkHttp 3 non-persistent CookieJar with an ACCEPT_ALL policy
import java.util.ArrayList;
import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;
import okhttp3.Cookie;
import okhttp3.CookieJar;
import okhttp3.HttpUrl;
@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")
@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

@pylover
pylover / ssh-tun-freebsd.sh
Last active June 10, 2023 10:57
SSH TUN/TAP for various platforms.
#! /usr/bin/env bash
HOST=example.com
USER=alice
LTUN=0
RTUN=3
LADDR=192.168.2.4/31
RADDR=192.168.2.3
HOSTADDR=$(dig $HOST +short)
GW=192.168.1.1
FLAGS="-p7575 -N -v -w $LTUN:$RTUN"
@Zoybean
Zoybean / fix-git
Last active December 5, 2023 05:37
For when you've got a local git repo that's just too hard to recover
#!/bin/bash
# Author: Zoey Llewellyn "Zobean" Hewll
#
# Usage: fix-git [REMOTE-URL]
# Must be run from the root directory of the repository.
# If a remote is not supplied, it will be read from .git/config
#
# For when you have a corrupted local repo, but a trusted remote.
# This script replaces all your history with that of the remote.
@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

@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
@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}")"
@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