Skip to content

Instantly share code, notes, and snippets.

View cisoun's full-sized avatar

Cyriaque Skrapits cisoun

View GitHub Profile
@cisoun
cisoun / fibonacci.md
Last active April 1, 2021 08:58
Performance comparison between PHP vs Python vs Ruby

Performance comparison between PHP vs Python vs Ruby

Here's a performance comparison between PHP vs Python vs Ruby done by doing a Fibonacci sequence of 35 iterations in each language. I tried to adapt the codes in order to have the exact same behavior.

Tested versions are the following:

➜ php --version   
PHP 8.0.3 (cli) (built: Mar  4 2021 20:39:15) ( NTS )
Copyright (c) The PHP Group
@cisoun
cisoun / router.php
Last active October 9, 2020 08:00
PHP router
<?php
$uri = $_SERVER['REQUEST_URI'];
# Serve static ressources.
if (preg_match('/\.(?:png|jpg|jpeg|gif|css|js|svg)$/', $uri)) {
return false;
}
function register($method, $route, $callback) {
global $uri;
@cisoun
cisoun / create_chroot_env_arch.md
Last active April 9, 2020 06:07
Create a chroot environment in Arch

Create a chroot environment in Arch

I wanted to use my cloud server to compile large projects for me.
For that, I needed to create a chroot environment to keep my main system clean and which will handle that process.

Here's how I did...

My chroot environment: /mnt/chroot

1. Installation

@cisoun
cisoun / fetch.js
Created January 29, 2020 12:20
Wrapper for window.fetch that handles JSON responses
/**
* Custom wrapper using the Fetch API.
*/
const Fetch = {
async get (url) { return this.request(url, 'GET'); },
async post (url, data={}) { return this.request(url, 'POST', data); },
/**
* Do a request.
@cisoun
cisoun / instagram.css
Last active November 7, 2019 15:49
Remove blocker popup from Instagram web with Stylus
/*
Create a new stylesheet for "instagram.com" with the Stylus* extension and
add the following lines to it to remove their goddamn popup.
* Install it from there:
Firefox: https://addons.mozilla.org/en/firefox/addon/styl-us/
Chrome: https://chrome.google.com/webstore/detail/stylus/clngdbkpkpeebahjckkjfobafhncgmne
*/
body { overflow: unset !important; }
.RnEpo { display: none; }
@cisoun
cisoun / rename.sh
Created October 17, 2019 07:40
Rename folders, files and their content at once.
#/usr/bin/env bash
#
# rename.sh
#
# Replace any occurency of "<source>" to "<target>" in a given <directory>.
# This apply to (sub)folders/files name and files content.
# Think about it like a refactoring function.
#
# Usage: rename.sh <source> <target> <directory>
#
@cisoun
cisoun / medium_com.css
Last active October 17, 2019 07:41
Remove modales from Medium.com with Stylus
/* Remove Medium.com's modal. */
.ar.as.dx.nn.no.np.nq.nr.ns.m.n.nt.o.p.nu {
display:none;
}
@cisoun
cisoun / ram.sh
Last active November 2, 2021 14:06
Shell script to mount a disk on RAM with a specific name and size on Mac OS X
#!/bin/bash
#
# Create a virtual disk on RAM with a given name and size.
# To remove it, just unmount it in Finder.
#
# Usage: ram.sh <name> <size in MB>
#
function usage() {
echo "$0 <name> <size in MB>"
@cisoun
cisoun / How2Bash.md
Last active August 13, 2024 11:57
How2Bash

How2Bash

A collection of useful tips in bash.

Streams

Redirections

command >/dev/null # Silent all output.
@cisoun
cisoun / gist:b9cd5d8f256c906c5e082999af942b49
Created February 15, 2019 14:59
Short song in bash shell using SoX
#!/bin/bash
while :
do
play -n -c1 synth sin %-12 sin %-9 sin %-5 sin %-2 fade h 0.1 0.25 0.1
play -n -c1 synth sin %-12 sin %-9 sin %-0 sin %-2 fade h 0.1 0.25 0.1
play -n -c1 synth sin %-12 sin %-9 sin %-5 sin %-2 fade h 0.1 0.25 0.1
play -n -c1 synth sin %-12 sin %-9 sin %-0 sin %-2 fade h 0.1 0.25 0.1
play -n -c1 synth sin %-12 sin %-9 sin %-5 sin %-2 fade h 0.1 0.25 0.1
play -n -c1 synth sin %-12 sin %-9 sin %-0 sin %-2 fade h 0.1 0.25 0.1