Skip to content

Instantly share code, notes, and snippets.

View paceaux's full-sized avatar
🌐
Obsessing with languagey things

Paceaux paceaux

🌐
Obsessing with languagey things
View GitHub Profile
@paceaux
paceaux / tinyRules.css.md
Last active April 3, 2024 01:19
Tiny rules for how to name things in CSS and JS

Tiny rules for how to name stuff

CSS

How to name CSS classes

Stateful Class names

Is it a state that is only one of two conditions? (i.e. a boolean)

@paceaux
paceaux / levenshtein.js
Last active February 26, 2024 18:15
String comparisons
/**
* @description calculates the levenshtein distance between words
* @param {string} str a string
* @param {string} str2 another string
* @returns {object} with properties 'steps' and 'transitions'
*/
function levenshtein(str, str2) {
if (typeof str !== 'string' || typeof str2 !== 'string') return;
let [shorter, longer] = [str, str2].sort((a, b) => a.length - b.length);
@paceaux
paceaux / headless-screenshots_v2.js
Last active February 20, 2024 02:54
Improved command line options for headless screenshots in Chrome
/** Pre requisites
* MAC ONLY FOR RIGHT NOW! Not my fault. We have to wait for Headless Chrome to hit Windows users
1) Make an Alias to Chrome
alias chrome="/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome"
alias chrome-canary="/Applications/Google\ Chrome\ Canary.app/Contents/MacOS/Google\ Chrome\ Canary"
2) Make Sure yarn is installed (it caches packages so you don't have to download them again)
`npm i yarn`
3) Use yarn to install dependencies:
@paceaux
paceaux / clientStorage.js
Last active January 19, 2024 22:39
ClientStorage Module for saving things in a namespaced way to local or session storage.
class ClientStorage {
/**
* Converts a string into a namespaced string
* @param {string} namespace the namespace
* @param {string} keyname keyname
* @returns {string} a string with namespace.keyname
*/
static getNamespacedKeyName(namespace, keyname) {
let namespacedKeyName = "";
@paceaux
paceaux / find-balada-infection.sh
Last active November 9, 2023 18:13
Find Balada-infected files on your wordpress host
#!/bin/bash
echo "hello" $USER "we're gonna find some infected files";
echo "=====First: let's find .oti Injections=====";
grep --include=\*.php -Hnrwo -P '^(@include)+.+(\.ot(i|\\x69|c)\"\);)' . ;
find . -type f -name "*.oti";
echo "=====Next: let's find PHP files with obfuscated code being evaluated=====";
echo " looking for the cookie/post files";
grep --include=\*.php -Hwnro -P '(\$_COOKIE(,|;))+.+(\$_POST)' . ;
echo " looking for the die() files"
grep --include=\*.php -Hwnro -P "(die+)(?:.[^'\"\$\s_a-z0-1]+)(\);)" . ;
@paceaux
paceaux / sorter.py
Last active October 4, 2023 15:39
Camera Phone Image Sorter
# Description:
# Sorts files created with a date and time in the file name, puts them in their respective folders
# This was created to sort images taken with a Samsung Galaxy phone
# Expected file naming convention is
# "year-month-day hour.minute.second.fileextension"
# "2017-7-5 18.23.45.jpg"
#
#
# requires Pillow:
# pip install Pillow
@paceaux
paceaux / regexes.js
Created January 6, 2023 16:30
Pronoun Regexes
const masculinePronouns = new RegExp('\b(she|(her(s(elf|\b)|\b))|s(on|a|u(a|\b))|el{1,2}(a|e)(-même|\b))\b((\W(m(i|e)sma)|\b))', 'gi');
const femininePronouns = new RegExp('\b(she|(her(s(elf|\b)|\b))|s(on|a|u(a|\b))|el{1,2}(a|e)(-même|\b))\b((\W(m(i|e)sma)|\b))','gi');
/*
English: she, her, hers, herself
French: elle, elle-même, son, sa
Spanish: ella, su, ella misma
Portuguese: ela, sua, ela mesma
@paceaux
paceaux / debug.css
Last active October 15, 2022 08:43
A Sass/SCSS debug mixin
.isDebugging .debug {
outline: 1px solid rgba(200, 100, 50, 0.9);
}
.isDebugging .debug * {
outline: 1px solid rgba(200, 100, 50, 0.9);
}
@paceaux
paceaux / attribute-promise.js
Created June 16, 2017 21:11
A promise that can be set on an element, to resolve when that element's attributes have changed
** AttrPromise
* @param {element} DOM element. required
* @param {attributeName} String. Optional. Attribute that is expected to change.
* @param {rejectTime} Int. Optional. Seconds (not ms) to wait before rejecting. 0 means there is no reject time.
* @returns {promise}
*/
function attrPromise(element, attributeName,rejectTime = 0) {
return new Promise((resolve,reject) => {
let hasChanged = false;