Skip to content

Instantly share code, notes, and snippets.

View fatso83's full-sized avatar
🐢
Two toddlers. Very little time for OSS after work hours. File a PR!

Carl-Erik Kopseng fatso83

🐢
Two toddlers. Very little time for OSS after work hours. File a PR!
View GitHub Profile
@fatso83
fatso83 / NOTES.md
Created October 9, 2021 07:31
Installing Vagrant on Apple Silicon Macs (M1, M1X, etc)

VirtualBox only supports the x86 platform, so the default installation instructions for Vagrant does not work on Apple silicon. Thankfully Vagrant has a VMWare Provider (more on providers here), and so if I can get VMWare running on my M1 MacBook, I should be able to run Vagrant as well!

These are my notes during figuring this out.

Get the VMWare Tech Preview released in September 2021!

We are in luck, as VMWare released this just a few weeks ago.

  • See [their blog entry][1]
@fatso83
fatso83 / mp3_make_comp
Last active March 13, 2024 11:47
Set the TCMP flag on all the MP3′s in the current directory, or the files specified on the command line.
#!/usr/bin/perl -w
# mp3_make_comp
# Max Baker
# 4/29/09
#
# This script will set the I-Tunes Compilation Tag (TCMP)
# on Files passed to it. If no files are passed, it works on *.mp3 in the current directory.
#
# found here: http://warped.org/blog/2009/05/02/itunes-setting-the-compilation-flag-on-mp3s-using-perl/
if [ -n "$BASH_VERSION" ]; then
# include .bashrc if it exists
if [ -f "$HOME/.bashrc" ]; then
. "$HOME/.bashrc"
fi
fi
export VISUAL='vim'
export EDITOR='vim'
export PYTHONSTARTUP="$HOME/.pystartup"
@fatso83
fatso83 / macos-ramdisk.md
Created November 20, 2023 05:01 — forked from htr3n/macos-ramdisk.md
Creating RAM disk in macOS

Built-in

diskutil erasevolume HFS+ 'RAM Disk' `hdiutil attach -nobrowse -nomount ram://XXXXX`

where XXXXX is the size of the RAM disk in terms of memory blocks.

Notes:

@fatso83
fatso83 / srcset-debug-util.js
Last active October 30, 2023 10:53
SrcSet debug utility to print info on the currently loaded image
/**
* Use this to help determine which images are being used
* at which breakpoint. Will print lots of useful information
* on shown resolution, actual resolution, DPR and more
* Usage:
* var elems = document.querySelectorAll('.c-hero-banner__background img')
* responsiveImageDebugOutput(elems);
*
* Author: Carl-Erik Kopseng
* Source: https://gist.github.com/fatso83/55fc446df3f3965ecd66e8307a5dc0e6
@fatso83
fatso83 / Code Sandbox oddities.md
Last active June 3, 2023 08:57
Code Sandbox weirdness

CODESANDBOX ODDITIES

Code Sandbox oddities observed while working on LogicRoom exercises

codesandbox.io does its best to give the impression of a locally running environment, but the abstraction is sometimes a bit leaky. Here's some weirdness (with possible fixes)

Delayed execution of console.log

The console.log statement is actually proxied via a server and executed at a later stage. That sometimes results in weird behaviours, as the value of some field on an object can be different when it is printed than when it was logged ... The fix is making something like this and using that instead:

@fatso83
fatso83 / collaborator.js
Last active January 26, 2023 10:54
Demonstrates how to stub and test for collaborators in a class constructor using sinon and proxyquire. See https://github.com/sinonjs/sinon/issues/831
module.exports = function(n){
// do something with n
}
@fatso83
fatso83 / jane-redirect-prevent.js
Last active August 26, 2022 21:07
This TamperMonkey script will allow you to download manuals from the Concord page without being redirected nilly-willy. Requires TamperMonkey extension in Chrome/Edge/Firefox
// ==UserScript==
// @name Prevent Jane redirect
// @namespace http://tampermonkey.net/
// @version 0.1
// @description Out-trick the neanderthals responsible for redirecting the Concord customers to the Jane page with JS
// @author Carl-Erik Kopseng
// @match https://no.concord.es/support/nedlastinger/
// @icon https://www.google.com/s2/favicons?sz=64&domain=concord.es
// @grant none
// @run-at document-start
@fatso83
fatso83 / fremtind.js
Last active April 18, 2022 04:47
Bompengeskript Fremtind
/* Used on https://minside.fremtindservice.no/passings */
(function() {
const priceCols = document.querySelectorAll('.MuiBox-root div div div:nth-child(3n+1) div:nth-child(1)');
let sum=0;
for(let n of priceCols) {
if( n?.nextSibling?.textContent === 'NOK') {
sum+=parseInt(n.textContent,10)
}
@fatso83
fatso83 / PublicPlanData.php
Created January 19, 2022 11:54
A fixture example for Symfony where a hardcoded connection is made between a local entity and the Stripe id.
class PublicPlanData extends AbstractFixture implements OrderedFixtureInterface
{
public function load(ObjectManager $manager)
{
$planUnlimitedFree = new PlanInfo();
$planUnlimitedFree->setName('FREE UNLIMITED PLAN')
->setAmount(0)
->setCurrency('USD')
->setDescription('Special plan for users that should never pay for using the service')