Skip to content

Instantly share code, notes, and snippets.

View rjsworking's full-sized avatar

rjsworking rjsworking

View GitHub Profile
@rjsworking
rjsworking / deep-merge.js
Created December 20, 2022 16:46 — forked from ahtcx/deep-merge.js
Deep-Merge JavaScript objects with ES6
// ⚠ IMPORTANT: this is old and doesn't work for many different edge cases but I'll keep it as-is for any of you want it
// ⚠ IMPORTANT: you can find more robust versions in the comments or use a library implementation such as lodash's `merge`
// Merge a `source` object to a `target` recursively
const merge = (target, source) => {
// Iterate through `source` properties and if an `Object` set property to merge of `target` and `source` properties
for (const key of Object.keys(source)) {
if (source[key] instanceof Object) Object.assign(source[key], merge(target[key], source[key]))
}
@rjsworking
rjsworking / watercolors.js
Created October 18, 2022 16:33 — forked from zapthedingbat/watercolors.js
Generate watercolor style blobs: Inspired by tyler hobbs's generative watercolors- https://tylerxhobbs.com/
(function(doc) {
const TWO_PI = Math.PI * 2;
const HALF_PI = Math.PI / 2;
const RADIUS_SCALE = 0.05;
const RADIUS_SD = 15;
const POLYGON_SIDES = 5;
const POSITION_SD = 0.04;
const BASE_DEFORMATIONS = 3;
const LAYER_DEFORMATIONS = 3;
const LAYERS = 40;
@rjsworking
rjsworking / JavaScript - Determine if Hex Color is Light or Dark.js
Created October 13, 2022 15:46 — forked from krabs-github/JavaScript - Determine if Hex Color is Light or Dark.js
[JavaScript - Determine if Hex Color is Light or Dark] JavaScript - Determine if Hex Color is Light or Dark #JavaScript
function lightOrDark(color) {
// Check the format of the color, HEX or RGB?
if (color.match(/^rgb/)) {
// If HEX --> store the red, green, blue values in separate variables
color = color.match(/^rgba?\((\d+),\s*(\d+),\s*(\d+)(?:,\s*(\d+(?:\.\d+)?))?\)$/);
r = color[1];
g = color[2];
@rjsworking
rjsworking / supervisord
Created July 20, 2021 12:24 — forked from lmammino/supervisord
init script and sample configuration for supervisor daemon
#!/bin/sh
#
# Based on a work of Miquel van Smoorenburg <[email protected]>
#
### BEGIN INIT INFO
# Provides: supervisor
# Required-Start: $remote_fs $network $named
# Required-Stop: $remote_fs $network $named
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6

Javascript Sudoku Puzzle Generator

In this demo, backtracking algorithm is used for generating the sudoku. Difficulty and solvability is totally random as I randomly left a number of hints from a full-filled board.

A Pen by Mustafa Enes on CodePen.

License.

@rjsworking
rjsworking / checkForUndefinedCSSClasses.js
Created June 16, 2021 07:00 — forked from broofa/checkForUndefinedCSSClasses.js
ES module for detecting undefined CSS classes (uses mutation observer to monitor DOM changes). `console.warn()`s undefined classes.
/**
* Sets up a DOM MutationObserver that watches for elements using undefined CSS
* class names. Performance should be pretty good, but it's probably best to
* avoid using this in production.
*
* Usage:
*
* import cssCheck from './checkForUndefinedCSSClasses.js'
*
* // Call before DOM renders (e.g. in <HEAD> or prior to React.render())
@rjsworking
rjsworking / luminance.scss
Created May 13, 2021 22:49 — forked from vimtaai/luminance.scss
Functions to calculate luminance of colors and contrast ratio of colors in SASS
// Calulates power with integer exponent
@function pow($number, $exponent) {
$value: 1;
@if $exponent > 0 {
@for $i from 1 through $exponent {
$value: $value * $number;
}
} @else if $exponent < 0 {
@for $i from 1 through -$exponent {
@rjsworking
rjsworking / downloadFakePeople.sh
Created April 29, 2021 11:06 — forked from johnjreiser/downloadFakePeople.sh
Download Fake People - quick script to grab images from This Person Does Not Exist
#!/bin/bash
MAX=10
if [[ ! -z "$1" ]]; then
MAX=$1
fi
for i in $( seq $MAX ); do
FILE=image${i}.jpg
curl 'https://thispersondoesnotexist.com/image' -H 'authority: thispersondoesnotexist.com' -H 'pragma: no-cache' -H 'cache-control: no-cache' -H 'upgrade-insecure-requests: 1' -H 'user-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.80 Safari/537.36' -H 'accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3' -H 'referer: https://thispersondoesnotexist.com/' -H 'accept-encoding: gzip, deflate, br' -H 'accept-language: en-US,en;q=0.9' --compressed -o $FILE
@rjsworking
rjsworking / extend-trial-jetbrains-windows.bat
Created April 28, 2021 11:01
JetBrains IDE trial reset windows
REM Delete eval folder with licence key and options.xml which contains a reference to it
for %%I in ("WebStorm", "IntelliJ", "CLion", "Rider", "GoLand", "PhpStorm", "Resharper", "PyCharm") do (
for /d %%a in ("%USERPROFILE%\.%%I*") do (
rd /s /q "%%a/config/eval"
del /q "%%a\config\options\other.xml"
)
)
REM Delete registry key and jetbrains folder (not sure if needet but however)
rmdir /s /q "%APPDATA%\JetBrains"
@rjsworking
rjsworking / Makefile
Created April 15, 2021 09:51 — forked from alwynallan/Makefile
Hardware PWM Controller for the Raspberry Pi 4 Case Fan
CC = gcc
RM = rm -f
CFLAGS = -Wall
LIBS = -lbcm2835
TARGET = pi_fan_hwpwm
all: $(TARGET)