Skip to content

Instantly share code, notes, and snippets.

View prenagha's full-sized avatar

Padraic Renaghan prenagha

View GitHub Profile
@kylehowells
kylehowells / FreeSpaceViewController.swift
Created May 4, 2022 23:24
UIViewController subclass to show both the Settings app displayed free space, and the real free space.
//
// FreeSpaceViewController.swift
// Free Space
//
// Created by Kyle Howells on 04/05/2022.
//
import UIKit
class FreeSpaceViewController: UIViewController {
@benkehoe
benkehoe / aws-profile-for-bashrc.sh
Last active April 2, 2024 10:41
AWS_PROFILE env var management
# MIT No Attribution
#
# Copyright 2022 Ben Kehoe
#
# Permission is hereby granted, free of charge, to any person obtaining a copy of this
# software and associated documentation files (the "Software"), to deal in the Software
# without restriction, including without limitation the rights to use, copy, modify,
# merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
# permit persons to whom the Software is furnished to do so.
#
@vovagalchenko
vovagalchenko / LookasideCache.java
Last active November 15, 2020 21:51
Lookaside cache read operation pseudocode. Please don't mistake this for production-ready code. It's not. The aim of the snippet is to illustrate the high level flow of the algorithm.
public class LookasideCache {
private CacheCluster cacheCluster;
private LeaseUtils leaseUtils;
/**
* Read a value utilizing a lookaside cache.
*
* @param key whose value is to be returned
* @param sourceOfTruthComputation the function to use to fetch the value from the
* source of truth if that should become necessary.
@premek
premek / mv.sh
Last active March 5, 2024 17:43
Rename files in linux / bash using mv command without typing the full name two times
# Put this function to your .bashrc file.
# Usage: mv oldfilename
# If you call mv without the second parameter it will prompt you to edit the filename on command line.
# Original mv is called when it's called with more than one argument.
# It's useful when you want to change just a few letters in a long name.
#
# Also see:
# - imv from renameutils
# - Ctrl-W Ctrl-Y Ctrl-Y (cut last word, paste, paste)
@al45tair
al45tair / gist:73be245ab87a66a885742b98be91ac14
Last active April 10, 2024 09:00
Files installed by Zoom for mac OS

The Zoom install package for macOS is mad. Rather than actually using the installer to install things, it does everything in the preinstall script. That's bonkers, and also means that the system won't have a list of the files it installed, because it's doing it using shell script.

The script appears to install two items, namely:

/Applications/zoom.us.app
~/Library/Internet Plug-Ins/ZoomUsPlugIn.plugin

If the user opening the package isn't an administrator, it looks like it will install the app in the user's home folder instead. If they are an administrator, Zoom will delete the ZoomUsPlugIn.plugin from /Library if it's there, but it still installs to ~/Library.

It also adds Zoom to your Dock automatically, without asking.

@gruber
gruber / tot.sh
Last active July 1, 2022 13:58 — forked from chockenberry/tot.sh
A shell script for Tot
#!/bin/bash
# Fork of CHOCK's original tot.sh to add support for dot "0" to target
# the first empty dot.
# https://gist.github.com/chockenberry/d33ef5b6e6da4a3e4aa9b07b093d3c23
#
# 2 Mar 2020
# + Incorporated suggestions from ShellCheck (https://www.shellcheck.net).
# Thanks to Ramsey Dow.
# + Changed call to `python` to `/usr/bin/python` to get Python 2, avoiding
@chockenberry
chockenberry / tot.sh
Last active October 6, 2023 12:23
A shell script for Tot
#!/bin/sh
basename=`basename $0`
if [ -z "$*" ]; then
echo "usage: ${basename} <dot> [ -o | -r | <file> | - ]"
echo ""
echo "options:"
echo " -o open dot in window with keyboard focus"
echo " -r read contents of dot"
@ctkjose
ctkjose / readme.md
Last active March 15, 2024 14:10 — forked from WebReflection/jsc
JavaScriptCore for macOS and Linux

JSC

JSC is the JavaScript engine from Apple's JavaScriptCore (WebKit) as a console application that you can use to run script in the terminal.

For more info visit the JSC's webkit wiki page.

Adding a shortcut to JSC

Using jsc is simple, the one issue is that Apple keeps changing the location for jsc. To deal with this issue I just create a symbolic link to the binary:

@charles-rumley
charles-rumley / 1password-vpn-login.sh
Created May 28, 2019 21:58
Use stored 1Password credentials to authenticate a Cisco AnyConnect VPN client
#!/usr/bin/env bash
# Prerequisites
#
# Download the 1Password CLI tool
#
# brew cask install 1password-cli
#
# Before using this script, you'll need to authenticate the 1Password
# CLI for the first time. Use the following command, replacing
@lizthegrey
lizthegrey / attributes.rb
Last active February 24, 2024 14:11
Hardening SSH with 2fa
default['sshd']['sshd_config']['AuthenticationMethods'] = 'publickey,keyboard-interactive:pam'
default['sshd']['sshd_config']['ChallengeResponseAuthentication'] = 'yes'
default['sshd']['sshd_config']['PasswordAuthentication'] = 'no'