Skip to content

Instantly share code, notes, and snippets.

@LolWalid
LolWalid / fur_elise.js
Created August 4, 2020 21:46
Für Elise Javascript
// Mostly Inspired by https://github.com/KilledByAPixel/1Keys
var octave = 1
var key = 0
var shape = 'sine'
var audioCtx = new AudioContext();
var instruments = [ "1", "2", "4", "8" ]
var soundDuration = 250
play = (i) => {
@LolWalid
LolWalid / ram.sh
Created March 3, 2020 23:54
Get 25 process consuming the most RAM
#!/bin/sh
ps -eo rss,pid,user,command | sort -rn | head -25 | awk '{
hr[1024**2]="GB"; hr[1024]="MB";
for (x=1024**3; x>=1024; x/=1024) {
if ($1>=x) { printf ("%-6.2f %s ", $1/x, hr[x]); break }
} } { printf ("%-6s %-10s ", $2, $3) }
{ for ( x=4 ; x<=NF ; x++ ) { printf ("%s ",$x) } print ("\n") }
'
@LolWalid
LolWalid / rebase.sh
Created December 5, 2019 09:56
Git Rebase
# fetch data from master
git co master
git pull origin master
git co feature/branch
git rebase -i diverged_commit
# Keep only the first commit (the upper one, dont know why...)
git rebase master
@LolWalid
LolWalid / README.md
Created November 7, 2019 22:34
Yarn link packages dependencies

Yarn link packages dependencies

If you have a react project that depends on a package and you need to update your package, keep reading! This article will not talk about example folder created with create-react-library.

We are building a simple React App that will have only one component that take a string as props and display the reversed string. Then adding a new Component that take a sentence and reverse the words inside the sentence.

Not very usefull but easy example to get started with dependencies.

@LolWalid
LolWalid / module_ruby.rb
Created September 25, 2019 12:03
[Ruby] Class/Instance methods when using module
module A
def method_a
puts 'instance method A'
end
class_methods do
def method_a
puts 'class method A'
end
end
@LolWalid
LolWalid / extract_uniq_keys.rb
Created June 13, 2019 07:49
Extract Values and Keys from Nested Hash
test_hash = {
a: 1,
b: 2,
c: {
d: 4,
e: 5,
a: 1
}
}
@LolWalid
LolWalid / certbot.md
Created June 11, 2019 12:44
Rails, passenger, nginx setup Let's Encrypt

Generate certificate

certbot --nginx certonly

Edit nginx config

server {
    rails_env    production;

listen 443 ssl; # managed by Certbot

@LolWalid
LolWalid / and_syntax.rb
Created October 29, 2018 17:44
Ruby && vs and
a = 1
b = nil
c = a and b #(c = a) and b
=> c = 1
c = a && b # c = (a && b)
=> c = nil
@LolWalid
LolWalid / ssl_certificate.md
Created March 15, 2018 11:47
SSL Certificate With Gandi

SSL Certificate With Gandi

Generate Signing Certicate Request

With current private key (preferred for Certificate Pinning):

$ openssl req -new -key example.com.key > example.com.csr 
You are about to be asked to enter information that will be incorporated
into your certificate request.

What you are about to enter is what is called a Distinguished Name or a DN.

@LolWalid
LolWalid / clean.md
Last active January 12, 2018 09:30
Clean Ubuntu Partition

The purge

My Ubuntu Version

uname -r

All Kernel Installed

dpkg --list | grep linux-image

Get kernel to remove