Skip to content

Instantly share code, notes, and snippets.

View eramax's full-sized avatar
🎯
Focusing

Ahmed Morsi eramax

🎯
Focusing
View GitHub Profile
@klingtnet
klingtnet / enable-hibernate-arch-linux.md
Created November 22, 2016 17:23
Enable hiberate in Arch Linux usind kernel 4+, grub2 and a swapfile

This guide is based on the hibernate article from the Arch wiki.

  • edit /etc/default/grub and add resume as well as resume_offset kernel parameters
    • resume=UUID=abcd-efgh contains the UUID of the partition on which the swapfile resides. In most cases the swapfile resides in root, to identify the root parition's UUID run blkid or lsblk -O.
    • resume_offset=1234 is the offset of the swapfile from the partition start. The offset is the first entry in the physical_offset column of the output of filefrag -v /swapfile.
    • update grub: grub-mkconfig -o /boot/grub/grub.cfg
    • example: GRUB_CMDLINE_LINUX_DEFAULT="resume=UUID=75972c96-f909-4419-aba4-80c1b74bd605 resume_offset=1492992"
  • add the resume module hook to /etc/mkinitcpio.conf:
    • HOOKS="base udev resume autodetect ...
  • rebuild the initramfs mkinitcpio -p linux
@MichaelLawton
MichaelLawton / deleteAmazonSavedItems.js
Last active March 30, 2025 19:53
Removes all Amazon saved for later items on the cart page. It will only remove visible items. You might want to scroll first to make more items visible. To use paste code in developer console (Ctrl+Shift+J or Cmd+Opt+J in Chrome) then press enter.
function deleteSavedItems() {
var query = document.querySelectorAll("#sc-saved-cart input[value=Delete]")
if (query.length) {
query[0].click();
}
if (query.length > 1) {
setTimeout(deleteSavedItems,100);
}
else {
console.log('Finished');
@osowski
osowski / incept-minikube.sh
Last active April 16, 2020 23:28
Install Minikube, Kubectl, and Virtualbox on Ubuntu
#Installing VirtualBox
echo "Installing VirtualBox........................"
sudo apt-get install virtualbox
#Installing kubectl https://kubernetes.io/docs/getting-started-guides/kubectl/
echo "Installing kubectl..........................."
wget https://storage.googleapis.com/kubernetes-release/release/v1.4.4/bin/linux/amd64/kubectl
chmod +x kubectl
sudo mv kubectl /usr/local/bin/kubectl
@leonardo-m
leonardo-m / gist:6e9315a57fe9caa893472c2935e9d589
Last active October 13, 2024 14:40
A selection of 101 LINQ Samples converted to Rust
// Port of the C# 101 LINQ Samples rewritten into Apple's Swift 3.
#![feature(ordering_chaining, step_by)]
fn main() {
// linq5: Where - Indexed
/*
//c#
public void Linq5()
{
@jesperorb
jesperorb / cors.md
Last active February 21, 2024 14:17
Handle CORS Client-side

Handle CORS Client-side

Cross-origin resource sharing (CORS) is a mechanism that allows restricted resources (e.g. fonts) on a web page to be requested from another domain outside the domain from which the first resource was served. This is set on the server-side and there is nothing you can do from the client-side to change that setting, that is up to the server/API. There are some ways to get around it tho.

Sources : MDN - HTTP Access Control | Wiki - CORS

CORS is set server-side by supplying each request with additional headers which allow requests to be requested outside of the own domain, for example to your localhost. This is primarily set by the header:

Access-Control-Allow-Origin
@e23z
e23z / hardening.sh
Created July 25, 2017 15:08
[Ubuntu 16.04 Server Hardener] A script to make it easy to harden an Ubuntu 16.04 server. Its purpose is to setup simple security measures out-of-the-box, not to apply advanced security measures. #scripts #security #configuration #utils
#!/bin/bash
cd ~
read -s -p 'Sudo password: ' PASSWORD
echo ""
echo "Configuring server..."
read -p "What's the hostname of this machine? " NEW_HOSTNAME
echo $PASSWORD | sudo -Sk hostnamectl set-hostname $NEW_HOSTNAME
sudo sed -i -e "s/^127.0.0.1.*$/127.0.0.1 localhost $NEW_HOSTNAME/g" /etc/hosts
sudo dpkg-reconfigure tzdata
sudo service cron restart
@devcfgc
devcfgc / ThreadSafeList.cs
Created August 4, 2017 04:41
Thread Safe List in C#
##https://stackoverflow.com/questions/5874317/thread-safe-listt-property
public class ThreadSafeList<T> : IList<T>
{
protected List<T> _interalList = new List<T>();
// Other Elements of IList implementation
public IEnumerator<T> GetEnumerator()
{
return Clone().GetEnumerator();
@mrw34
mrw34 / postgres.sh
Last active March 26, 2025 21:35
Enabling SSL for PostgreSQL in Docker
#!/bin/bash
set -euo pipefail
openssl req -new -text -passout pass:abcd -subj /CN=localhost -out server.req -keyout privkey.pem
openssl rsa -in privkey.pem -passin pass:abcd -out server.key
openssl req -x509 -in server.req -text -key server.key -out server.crt
chmod 600 server.key
test $(uname -s) = Linux && chown 70 server.key
docker run -d --name postgres -e POSTGRES_HOST_AUTH_METHOD=trust -v "$(pwd)/server.crt:/var/lib/postgresql/server.crt:ro" -v "$(pwd)/server.key:/var/lib/postgresql/server.key:ro" postgres:12-alpine -c ssl=on -c ssl_cert_file=/var/lib/postgresql/server.crt -c ssl_key_file=/var/lib/postgresql/server.key
@chrisdone
chrisdone / gist:02e165a0004be33734ac2334f215380e
Last active April 16, 2025 07:20
Build and run minimal Linux / Busybox systems in Qemu

Common

export OPT=/opt
export BUILDS=/some/where/mini_linux
mkdir -p $BUILDS

Linux kernel

@Daniel-Abrecht
Daniel-Abrecht / my_hello_world_distro.sh
Created January 28, 2018 21:56
Shellscript to build the most minimalistic linux live CD which just starts /sbin/init from the CD root directory and outputs "Hello World!"
#!/bin/bash
# Vorhandensein der Programme prüfen
MKISOFS=( $(which genisoimage mkisofs) )
if ! [ -x "$MKISOFS" ]; then echo "genisoimage aka mkisofs is missing"; exit 1; fi
if ! [ -x "$(which gcc)" ]; then echo "gcc is missing"; exit 1; fi
if ! [ -x "$(which nasm)" ]; then echo "nasm is missing"; exit 1; fi
if ! [ -x "$(which cpio)" ]; then echo "cpio is missing"; exit 1; fi
if ! [ -x "$(which tar)" ]; then echo "tar is missing"; exit 1; fi