Skip to content

Instantly share code, notes, and snippets.

View aymanalzarrad's full-sized avatar
👨‍💻
9223372036854775807

Ayman Al Zarrad aymanalzarrad

👨‍💻
9223372036854775807
View GitHub Profile
@aymanalzarrad
aymanalzarrad / keypair.go
Last active March 27, 2024 13:59
Golang RSA key pair string and PEM generator
package utils
import (
"crypto/rand"
"crypto/rsa"
"crypto/x509"
"encoding/base64"
"encoding/pem"
)
@aymanalzarrad
aymanalzarrad / EloquentCheatSheet.md
Created March 10, 2022 17:21 — forked from avataru/EloquentCheatSheet.md
Eloquent relationships cheat sheet
@aymanalzarrad
aymanalzarrad / lumen-laravel.variables.md
Last active October 19, 2021 16:15
Lumen/Laravel environment variables

Lumen/Laravel All environment variables used across the framework with the corresponding defaults.

UTC
Variable Default
APP_TIMEZONE
@aymanalzarrad
aymanalzarrad / phpvm.fish
Created June 11, 2020 17:16
Manage installing/switching between all available PHP versions (in brew) using fish shell and brew.
# phpvm
# A fish command function to manage installing/switching between all available php versions using brew.
# Usage: phpvm {version}
# Note: {version} is optional.
# if not provided we check to see if php is installed with brew:
# if yes, we switch to whatever that version is.
# if no, we attempt to install php by running "brew install php"
function phpvm
# Default run means we want default version (The one installed using brew install php)
@aymanalzarrad
aymanalzarrad / nodevm.fish
Last active June 11, 2020 17:12
Manage installing/switching between all available node versions (in brew) using fish shell and brew.
# nodevm
# A fish command function to manage installing/switching between all available node versions using brew.
# Usage: nodevm {version}
# Note: {version} is optional.
# if not provided we check to see if node is installed with brew:
# if yes, we switch to whatever that version is.
# if no, we attempt to install node by running "brew install node"
function nodevm
# Default run means we want default version (The one installed using brew install node)
@aymanalzarrad
aymanalzarrad / setup_dnsmasq.sh
Created July 4, 2018 21:41
Pointing .test domains using dnsmasq on Ubuntu 18.04
sudo echo "address=/test/xxx.xxx.xxx.xxx" >> /etc/NetworkManager/dnsmasq.d/domains.conf
sudo nano /etc/NetworkManager/NetworkManager.conf
# [main]
# plugins=ifupdown,keyfile
# dns=dnsmasq
# ...
sudo rm /etc/resolv.conf
sudo ln -s /var/run/NetworkManager/resolv.conf /etc/resolv.conf
sudo systemctl restart NetworkManager
@aymanalzarrad
aymanalzarrad / autoResizeTextarea.js
Last active April 5, 2018 20:43
Auto-grow / Auto-shrink Textarea element.
let textarea = document.getElementById('textarea');
textarea.style.resize = 'none';
textarea.style.overflow = 'hidden';
textarea.addEventListener('input', () => {
textarea.style.height = '';
if( textarea.clientHeight !== textarea.scrollHeight ){
textarea.style.height = (textarea.scrollHeight + 'px');
}
});
@aymanalzarrad
aymanalzarrad / EventsEmitter.js
Last active April 17, 2018 07:05
Simple events emitter in JavaScript
export default class EventsEmitter{
constructor(){
this._events = {};
}
on(event, callback, once){
if( !(this._events[event] instanceof Array) ){
this._events[event] = [];
}
@aymanalzarrad
aymanalzarrad / dnsmasq.md
Last active March 2, 2018 16:17
Setting up dnsmasq on Ubuntu 17.4/17.10 and pointing a TLD to a local ip address

Install

sudo apt update
sudo apt install dnsmasq

Point a TLD to a local ip

Replace test with your domain and xxx.xxx.xxx.xxx with your local ip address

sudo echo "local=/test/" > /etc/dnsmasq.d/test
@aymanalzarrad
aymanalzarrad / js-observables-binding.md
Created June 13, 2017 17:30 — forked from austinhyde/js-observables-binding.md
Vanilla JavaScript Data Binding

Observables

You don't really need a framework or fancy cutting-edge JavaScript features to do two-way data binding. Let's start basic - first and foremost, you need a way to tell when data changes. Traditionally, this is done via an Observer pattern, but a full-blown implementation of that is a little clunky for nice, lightweight JavaScript. So, if native getters/setters are out, the only mechanism we have are accessors:

var n = 5;
function getN() { return n; }
function setN(newN) { n = newN; }

console.log(getN()); // 5

setN(10);