Skip to content

Instantly share code, notes, and snippets.

@OrionReed
OrionReed / dom3d.js
Last active July 22, 2024 08:58
3D DOM viewer, copy-paste this into your console to visualise the DOM topographically.
// 3D Dom viewer, copy-paste this into your console to visualise the DOM as a stack of solid blocks.
// You can also minify and save it as a bookmarklet (https://www.freecodecamp.org/news/what-are-bookmarklets/)
(() => {
const SHOW_SIDES = false; // color sides of DOM nodes?
const COLOR_SURFACE = true; // color tops of DOM nodes?
const COLOR_RANDOM = false; // randomise color?
const COLOR_HUE = 190; // hue in HSL (https://hslpicker.com)
const MAX_ROTATION = 180; // set to 360 to rotate all the way round
const THICKNESS = 20; // thickness of layers
const DISTANCE = 10000; // ¯\\_(ツ)_/¯
{
"name": "rsms dark v2 mono",
"author": "rsms",
"variables": {
"red": "hsl(5, 0%, 50%)",
"orange": "hsl(27, 0%, 50%)",
"yellow": "hsl(60, 0%, 50%)",
"green": "hsl(150, 0%, 43%)",
"cyan": "hsl(180, 0%, 50%)",
"blue": "hsl(210, 0%, 50%)",
@ksmithut
ksmithut / .dockerignore
Last active June 2, 2024 21:43
Node Docker Compose nodemon
node_modules
import hoistStatics from 'hoist-non-react-statics';
import React from 'react';
/**
* Allows two animation frames to complete to allow other components to update
* and re-render before mounting and rendering an expensive `WrappedComponent`.
*/
export default function deferComponentRender(WrappedComponent) {
class DeferredRenderWrapper extends React.Component {
constructor(props, context) {
@kmohrf
kmohrf / brightness.py
Created February 25, 2017 13:34
Calculate Image brightness with Python Pillow
import sys
from PIL import Image
def calculate_brightness(image):
greyscale_image = image.convert('L')
histogram = greyscale_image.histogram()
pixels = sum(histogram)
brightness = scale = len(histogram)
@rhukster
rhukster / watch.sh
Last active April 5, 2021 16:11
Watch script for wellington sassc wrapper
#!/bin/sh
#
# Configuration
#
# sass source
SASS_SOURCE_PATH="scss"
# sass options
@joepie91
joepie91 / random.md
Last active July 13, 2024 16:15
Secure random values (in Node.js)

Not all random values are created equal - for security-related code, you need a specific kind of random value.

A summary of this article, if you don't want to read the entire thing:

  • Don't use Math.random(). There are extremely few cases where Math.random() is the right answer. Don't use it, unless you've read this entire article, and determined that it's necessary for your case.
  • Don't use crypto.getRandomBytes directly. While it's a CSPRNG, it's easy to bias the result when 'transforming' it, such that the output becomes more predictable.
  • If you want to generate random tokens or API keys: Use uuid, specifically the uuid.v4() method. Avoid node-uuid - it's not the same package, and doesn't produce reliably secure random values.
  • If you want to generate random numbers in a range: Use random-number-csprng.

You should seriously consider reading the entire article, though - it's

@Pepeye
Pepeye / multi-user.md
Created November 11, 2016 13:26
Homebrew multi user
  1. Create a group brew and add Stan
  2. brew doctor (Allen checks if he installed brew correctly)
  3. sudo chgrp -R brew /usr/local (Change the group of homebrew installation directory)
  4. sudo chmod -R g+w /usr/local (Allow group members to write inside this directory)
  5. sudo chgrp -R brew /Library/Caches/Homebrew (Change the group of homebrew cache directory)
  6. sudo chmod -R g+w /Library/Caches/Homebrew (Allow group members to write inside this directory)
  7. sudo chgrp -R brew /opt (Change the group of the cask installation directory)
  8. sudo chmod -R g+w /opt (Allow group members to write inside this directory)
  9. brew doctor (Stan checks if he can use homebrew)
@pjechris
pjechris / Appfile
Last active May 24, 2022 17:46
fastlane
# you can even provide different app identifiers, Apple IDs and team names per lane:
# More information: https://github.com/fastlane/fastlane/blob/master/docs/Appfile.md
app_identifier ENV["APP_IDENTIFIER"] # The bundle identifier of your app
# You will have to set APP_IDENTIFIER into your .env files
apple_id ENV["APPLE_ID"] # Your Apple email address
team_id ENV["TEAM_ID"] # Developer Portal Team ID
@gkhays
gkhays / DrawSineWave.html
Last active July 17, 2024 23:13
Oscillating sine wave, including the steps to figuring out how to plot a sine wave
<!DOCTYPE html>
<html>
<head>
<title>Sine Wave</title>
<script type="text/javascript">
function showAxes(ctx,axes) {
var width = ctx.canvas.width;
var height = ctx.canvas.height;
var xMin = 0;