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
@infinite-system
infinite-system / Kernel.ts
Last active August 25, 2023 15:23
Basic IOC container similar to Inversify
class Mapping {
constructor (public from: ObjectConstructor) {
this.to = from
}
to: ObjectConstructor
scope = 'singleton'
onActivation: (resolved, ...args) => {}
}
export class Kernel {
@tech-otaku
tech-otaku / macbook.sh
Last active March 24, 2022 11:54
Ubuntu Desktop Configuration on MacBook Pro
#!/usr/bin/env bash
# Note: LOGIN SCREEN SCALE (200%), LOGIN SCREEN SIZE (1152x864) and DISPLAY SCALE (200%) below are dependant on
# Virtual Machine > Settings > Display > 'Use full resolution for Retina display' in VMware Fusion being checked
# (gui.fitGuestUsingNativeDisplayResolution = "TRUE" in .vmx file)
# Get the installed Ubuntu version e.g. 20, 18, 16 etc.
VERSION=$(lsb_release -r | awk '{print $2}' | cut -d '.' -f 1)
@bulletinmybeard
bulletinmybeard / fix-for-sudo-command-error-unable-to-initialize-pam-no-such-file-or-directory.md
Last active April 8, 2024 08:16
macOS - Fix for sudo command error: "unable to initialize PAM: No such file or directory" (Intel+M1)

In most cases, the sudo command displays the error unable to initialize PAM: No such file or directory mostly appears when the pluggable authentication module file /etc/pam.d/sudo has been edited with a typo or an incorrect PAM module.

Via Single-User-Mode > Terminal

If you have an older Mac, you can boot into single-user mode, which allows you to access the command line mode of macOS directly, bypassing the UI.

  • Press and hold down the COMMAND + S keys until you see commands being executed in the Terminal.

  • Open the sudo file with vi /Volumes/Macintosh\ - Data/etc/pam.d/, fix what's wrong, save and close the file by switching from INSERT to the COMMAND mode with the ESC key, type :wq!, and hit enter.

@nivsherf
nivsherf / edit_sinon_docs.sh
Created September 6, 2018 23:15
Sinon Doc Editor
#!/bin/sh
# Usage example: ./edit_sinon_docs.sh stubs 4.1.1
# Will open stubs.md from 4.1.1 for editing and propagate the changes to later versions.
# Make sure you have SINON_HOME pointing to the repository root.
# You'll need git and the npm "semver" package installed (npm i -g semver)
cd $SINON_HOME/docs
FILENAME=$1.md
//
// This program reads a sourcemap from stdin
// and replaces the "mappings" property with
// human readable content. It writes the output
// to stdout.
//
// 1. install the dependencies:
// npm i concat-stream vlq
//
// 2. optional: install jq for pretty printing json
@zeraphie
zeraphie / !-readme.md
Last active October 16, 2019 11:56
Add a service worker that can read a sitemap

Service Workers with a Sitemap Parser

This is a collection of ES2017 classes (so a transpiler is needed, webpack is used here with babel and the env preset) that utilize Service Workers to add offline support for a site. This example should work for WordPress sites as well

Installation

Because DOMParser is not included in Service Workers, you will need to install the npm package xmldom

npm install xmldom --save-dev

With Service Workers

@klaaspieter
klaaspieter / ASS.md
Created June 22, 2017 07:59 — forked from anonymous/ASS.md
Acronyms Seriously Suck - Elon Musk

From time to time, Musk will send out an e-mail to the entire company to enforce a new policy or let them know about something that's bothering him. One of the more famous e-mails arrived in May 2010 with the subject line: Acronyms Seriously Suck:

There is a creeping tendency to use made up acronyms at SpaceX. Excessive use of made up acronyms is a significant impediment to communication and keeping communication good as we grow is incredibly important. Individually, a few acronyms here and there may not seem so bad, but if a thousand people are making these up, over time the result will be a huge glossary that we have to issue to new employees. No one can actually remember all these acronyms and people don't want to seem dumb in a meeting, so they just sit there in ignorance. This is particularly tough on new employees.

That needs to stop immediately or I will take drastic action - I have given enough warning over the years. Unless an acronym is approved by me, it should not enter the SpaceX glossary.

const SITEMAP_CACHE_KEY = 'sitemap-cached-pages-v1'
self.addEventListener('install', event => {
event.waitUntil(cacheSitemap())
})
const cacheSitemap = _ => caches.open(SITEMAP_CACHE_KEY)
.then(cache =>
cacheSitemap()
.then(urls => urls.map(u => u.toString()))
@buger
buger / time_tracker.sh
Last active July 26, 2017 21:13
Bash time tracker
active_time() {
# Query display logs
logs=$(/usr/bin/pmset -g log | grep 'Display is turned')
# By default Mac turn off monitor after 15 minutes
timeout=900
# Read logs line by line
# Line format: 2016-07-12 07:50:02 +0300 Notification Display is turned on
echo "$logs" | while IFS= read -r line; do
d=$(echo $line | cut -c 1-19); # extract full date
@fatso83
fatso83 / sinon-issue-usage-question.md
Last active May 1, 2018 15:06
Close message for questions on the Sinon issue tracker

We are trying to keep the GitHub issues list tidy and focused on bugs and feature discussions. This ticket looks like a usage question; please post it to StackOverflow and tag it with sinon, so the bigger community can help answer your questions.

If you feel that your topic is an issue with Sinon, please open a new ticket and follow the guidelines for reporting an issue.