Skip to content

Instantly share code, notes, and snippets.

Avatar
🤓

Lewis Cowles Lewiscowles1986

🤓
View GitHub Profile
@marcosci
marcosci / render_universe.R
Created December 8, 2021 07:54
Rayrender Universe
View render_universe.R
library(rayrender)
library(glue)
y_dist = 8
circle <- function(x = 0, y = 0 + 20, rad = 1, nvert = 500, ...){
rads <- seq(0,2*pi,length.out = nvert)
xcoords <- cos(rads) * rad + x
ycoords <- sin(rads) * rad + y
cbind(x = xcoords, y = y_dist, z = ycoords)
@ciaranmcnulty
ciaranmcnulty / notes.md
Last active February 11, 2023 20:10
Notes on using Docker on ARM Macs (November 2021)
View notes.md

Docker for Mac

On M1 machines, Docker for Mac is running a lightweight linux ARM VM, then running containers within that, so containers are essentially running natively. Don't be fooled by the fact the UI or binary CLI tools (e.g. docker) might require Rosetta.

Within that VM is an emulation layer called QEmu. This can be used by docker to run Intel containers. This does not use Rosetta at all, and has a roughly 5-6X performance penalty. (If you just upgraded your CPU this may result in a similar performance to your old machine!)

Pulling and running with Docker

Many images in public registries are multi-architecture. For instance at the time of writing on Docker Hub the php:8.0-cli image has the following digests:

@dianewallace
dianewallace / woo-no-shipping-available-message.php
Last active November 17, 2020 17:42
Update the Woocommerce No Shipping message to include contact details.
View woo-no-shipping-available-message.php
add_filter( 'woocommerce_cart_no_shipping_available_html', 'myplugin_no_shipping_available_message' );
add_filter( 'woocommerce_no_shipping_available_html', 'myplugin_no_shipping_available_message' );
/**
* Update the Woocommerce No Shipping message to include contact details.
*/
function myplugin_no_shipping_available_message( $message ) {
$country = WC()->customer->get_shipping_country();
$mailto = 'mailto:' . get_option( 'admin_email' ); // Could also be 'woocommerce_stock_email_recipient'.
$link = sprintf( wp_kses( __( '<a href="%s">contact us</a>', 'my-plugin' ), array( 'a' => array( 'href' => array() ) ) ), esc_url( $mailto ) );
View misleading-cat.cpp
/* So how does this work?
I'm using ANSI escape sequences to control the behavior of the terminal while
cat is outputting the text. I deliberately place these control sequences inside
comments so the C++ compiler doesn't try to treat them as code.*/
//
/*The commands in the fake code comment move the cursor to the left edge and
clear out the line, allowing the fake code to take the place of the real code.
And this explanation uses similar commands to wipe itself out too. */
//
#include <cstdio>
@kafran
kafran / extract_har.py
Last active November 11, 2022 14:44
Python 3 script to extract images from HTTP Archive (HAR) files
View extract_har.py
import json
import base64
import os
# make sure the output directory exists before running!
folder = os.path.join(os.getcwd(), "imgs")
with open("scr.har", "r") as f:
har = json.loads(f.read())
View xbindkeys_per_app.sh
#!/bin/bash
# program-specific xbindkeys bindings
# there's a tool called `autokey`, which does this, but unlike xbindkeys, it doesn't catch mouse buttons
# doesn't interfere with main xbindkeys
# `pacman -S xbindkeys xdotool`
# `sleep 3 && cat /proc/$(xdotool getwindowpid $(xdotool getwindowfocus))/comm`
@freekmurze
freekmurze / bookmarklet
Last active February 22, 2019 10:13
Oh Dear! Reachable bookmarklet
View bookmarklet
javascript:{window.location='https://ohdear.app/tools/reachable?prefill='+encodeURIComponent(window.location.href)}
@lyshie
lyshie / config-deb-i386.json
Last active March 25, 2023 02:10
Scratch Desktop (Scratch 3.0 Offline Editor) on GNU/Linux
View config-deb-i386.json
{
"src": "/tmp/scratch-desktop/",
"dest": "/tmp/",
"arch": "i386",
"icon": "/tmp/scratch-desktop/resources/Icon.png",
"categories": [
"Education"
]
}
View freeze.md

Freezer cgroup FTW

In a terminal start a server.

$ python -m SimpleHTTPServer 8000

In another terminal set up the cgroups freezer.

@jessfraz
jessfraz / boxstarter.ps1
Last active December 17, 2022 21:53
Boxstarter Commands for a new Windows box.
View boxstarter.ps1
# Description: Boxstarter Script
# Author: Jess Frazelle <jess@linux.com>
# Last Updated: 2017-09-11
#
# Install boxstarter:
# . { iwr -useb http://boxstarter.org/bootstrapper.ps1 } | iex; get-boxstarter -Force
#
# You might need to set: Set-ExecutionPolicy RemoteSigned
#
# Run this boxstarter by calling the following from an **elevated** command-prompt: