Skip to content

Instantly share code, notes, and snippets.

View cisoun's full-sized avatar

Cyriaque Skrapits cisoun

View GitHub Profile
@cisoun
cisoun / photogear.md
Created November 11, 2024 22:17
Photography gear

Photography gear

A-MoDe — Hong Kong
Straps, bags, etc... I don't like the stiffness.

ARTISAN&ARTIST* — Japan
Straps, bags. Good reputation.

Cooph — Austria

/* ==UserStyle==
@name gmail--mono
@namespace github.com/openstyles/stylus
@version 1.0.9
@description Implementation of https://x.com/guerriero_se/status/1792924958579900781.
@author Sebastiano Guerriero, Cyriaque 'cisoun' Skrapits
==/UserStyle== */
/*
* WARNING: Use Gmail's default theme with this!
@cisoun
cisoun / localization-js.md
Created April 9, 2024 06:39
Localization in JS, the cheap way

Localization in JS

The Cheap way.

Summary

Here, we'll rely on a "lang" parameter in the URL (E.g: "?lang=fr") to know which language to use. The code will then look for HTML elements with a data-i18n attribute. This attribute contains the key of the translation whose value will be set as the inner HTML of the element.

@cisoun
cisoun / js-tricks.md
Last active March 30, 2022 18:09
JavaScript tricks

JavaScript Tricks

Object declaration

// Method 1
function obj() {
  return { a: 1 };
}
@cisoun
cisoun / htpasswd.md
Created August 19, 2021 17:28
File securization on Apache

File securization on Apache

Here, I explain how to provide securized access to a file (or folder) on an Apache server with a basic authentication. Let's say we are on folder /srv/http and we would like to restrain access to hello.txt to user alice only.

cd /srv/http
touch hello.txt
@cisoun
cisoun / keyboard.md
Last active August 13, 2024 11:57
Implementing a keyboard

Implementing a keyboard

Recommendations

General

  • Use the text provider from the OS to handle the texts within the apps from the keyboard.
    • TextDocumentProxy on iOS.
    • InputMethodService on Android.
  • Loading must be fast (ressources might not be reused each time the keyboard appears).
@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.