Skip to content

Instantly share code, notes, and snippets.

View GitSquared's full-sized avatar
👨‍🎤

Gabriel Saillard GitSquared

👨‍🎤
View GitHub Profile
@GitSquared
GitSquared / index.html
Created February 26, 2017 18:12
Render de dégats pour jeux HTML5
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Déganimation</title>
<script src="https://code.jquery.com/jquery-3.1.1.min.js"></script>
<script>
window.cursorPos = {x: 0, y: 0};
@GitSquared
GitSquared / form-keyboard-submit-jquery.js
Last active July 20, 2017 14:41
Automatically run the onsubmit="" function of forms when the enter key is pressed on the last input field.
$(() => {
let update_form_listeners = () => {
// Always check that the onsubmit attribute ends by return false; otherwise the page will reload
$("form[onsubmit] input:last-of-type").each((index, element) => {
if ($(element).parents('form').attr('onsubmit').substr(-13) !== 'return false;') {
$(element).parents('form').attr('onsubmit', $(element).parents('form').attr('onsubmit')+'return false;');
}
});
$("form[onsubmit] input:last-of-type").keypress((e) => {
@GitSquared
GitSquared / colorify.js
Created September 30, 2017 23:28
Colorify a whole CSS theme using color.js
const Color = require('color');
const colorifyTarget = Color("#bee6c1");
let original = require('fs').readFileSync("original.css", {encoding: "utf-8"});
console.log(original);
let colorified = original.replace(/(#{1}[0-g]{6})+/ig, (match) => {
console.log(match);
return Color(match).grayscale().mix(colorifyTarget, 0.3).hex(); // Edit colorify options here
});
console.log(colorified);
@GitSquared
GitSquared / configFileReader.js
Last active March 1, 2018 17:33
Node.js module to load a configuration file.
/*
Configuration file reader module. Takes an absolute file path and the boolean watch as arguments.
* filePath is expected to be the path to a JSON file (with the .json extension).
* watch is optional and defaults to false. If set to true, the config file will be watched by fs and any changes made to it will be automatically reflected on the module instance.
Returns an object:
* filePath: The file currently in use.
* watching: Boolean, indicate if the config file is being monitored for changes.
* config: Object containg the parsed data of the config file.
* parseFile(path, watch): Parse a config file. If you specify a new file, set watch to true to start watching it for changes, too. As always, watch defaults to false.
console.log("START");
let i = 0;
let left = ["left_one", "left_two", "left_three", "left_four"];
let right = ["right_one", "right_two"];
let x = setInterval(() => {
if (!left[i] && !right[i]) {
console.log("DONE!");
clearInterval(x);
} else {
console.log(`RUN ${i}: ${(i+1)*500}MS`);
@GitSquared
GitSquared / timecodes_edex_fr.md
Created February 3, 2019 12:03
List of all sound effects needed for eDEX-UI (copy of a mail I sent to a sound designer friend of mine, in French)

Liste des SFX pour eDEX-UI

  1. Boot log (utilisation des SFX "feedback output" - voir plus bas - donc rien à faire ici en principe)
  2. Jingle/Séquence titre (Black screen 400ms, Titre 300ms, Effet glitch 600ms, Titre 1200ms)
  3. Apparition terminal *(Étendu largeur 500ms, étendu hauteur 500ms)
  4. Apparition clavier (Étendu largeur de chaque rangée de touche, timing pour chaque rangée du haut vers le bas: 800ms, 600ms, 500ms, 800ms, 600ms - toutes les animations sont lancées en synchro)
  5. Message de bienvenue (Welcome, user! Lancé en même temps que l'apparition clavier - Apparition fondu 500ms, hold 100ms, disparition fondu 500ms) (ptetre utiliser un bip de feedback pour ça?)
  6. Apparition des panneaux latéraux (Apparition fondu 500ms enchainée de module en module)
{
"colors": {
"r": 170,
"g": 207,
"b": 209,
"black": "#000000",
"light_black": "#05080d",
"grey": "#262828"
},
"cssvars": {
@GitSquared
GitSquared / launch.sh
Created April 28, 2019 09:28
Bash script to make a Debian-based "eDEX system"
#!/bin/bash
#
# This script was designed for a blank Debian install
# Only dependencies are X.org (not automatically starting at boot),
# pulseaudio for sound support, ssh, plus any dependency required by
# AppImage - you can see them by trying to launch the AppImage manually
# before installing this auto-start script.
#
# Place "eDEX-UI.Linux.x86_64.AppImage" in the user folder
# $ chmod +x ~/launch.sh
@GitSquared
GitSquared / pubkey.class.js
Last active November 20, 2019 22:03
Node.js ssh-rsa public key parser
/*
* PubKey class
* Reads, parses and provides a usable node-rsa key object
* from a ssh-rsa PEM-encoded public key file.
*/
class PubKey {
constructor(path) {
const Rsa = require('node-rsa');
const fs = require('fs');
@GitSquared
GitSquared / caesar-cypher.js
Created January 16, 2020 21:34
JS Caesar Cypher
const letters = 'abcdefghijklmnopqrstuvwxyz';
let circleBackAlphabet = new Proxy({ letters }, {
get: (obj, index) => {
let ltrs = obj.letters;
while(index > ltrs.length-1) {
index = index - ltrs.length;
}
return ltrs[index];
}