Skip to content

Instantly share code, notes, and snippets.

View magnetikonline's full-sized avatar
💡
I have an idea!

Peter Mescalchin magnetikonline

💡
I have an idea!
View GitHub Profile

Keybase proof

I hereby claim:

  • I am magnetikonline on github.
  • I am magnetikonline (https://keybase.io/magnetikonline) on keybase.
  • I have a public key whose fingerprint is FA4A B218 5B57 20B2 A93C C1E4 9C83 B9FB 627C 44B8

To claim this, I am signing this object:

@magnetikonline
magnetikonline / README.md
Last active June 7, 2023 20:57
AWS Elastic Beanstalk deploy user restricted IAM policy.

AWS Elastic Beanstalk deploy user restricted IAM policy

An IAM user policy document to give minimal rights for deploying an Elastic Beanstalk application.

Where:

  • REGION: AWS region.
  • ACCOUNT_ID: AWS account ID.
  • APPLICATION_NAME: Desired target Elastic Beanstalk application name(space).
  • IAM_INSTANCE_PROFILE_ROLE: The instance profile (IAM role) Elastic Beanstalk EC2 instaces will run under.
@magnetikonline
magnetikonline / script.sh
Last active August 29, 2015 14:21
Bash script to rename collection of JPG images with numeric index, ordered by date created.
#!/bin/bash
IFS=$'\n'
counter=1
for file in $(ls -1tr *.jpg); do
mv "$file" "$(printf "img_%04d.jpg" "$counter")"
counter=$(($counter + 1))
done
@magnetikonline
magnetikonline / README.md
Last active November 10, 2022 00:45
Reset Windows 2012R2 local administrator password.

Reset Windows 2012R2 local administrator password

  • Boot from Microsoft Windows Server 2012R2 DVD/ISO.
  • From the Windows Setup menu, click "Next".
  • Select "Repair your computer".
  • Click on "Troubleshoot".
  • Under Advanced options, click "Command Prompt".

At the command prompt, run the following commands:

@magnetikonline
magnetikonline / README.md
Last active May 19, 2023 05:38
Node.js module dependency injection pattern.

Node.js module dependency injection pattern

The module

'use strict';

let config = {};

// inject dependencies
@magnetikonline
magnetikonline / README.md
Last active June 14, 2025 01:03
Suggested HTTP Content-Types for gzip compression.

Suggested HTTP Content-Types for gzip compression

My current list of Content-Types that are worthy of gzip compression:

application/javascript
application/json
application/vnd.ms-fontobject
application/x-font-ttf
image/svg+xml
@magnetikonline
magnetikonline / README.md
Last active May 18, 2018 17:22
PowerShell if expressions cheatsheet.

PowerShell if expressions cheatsheet

String
Is equal (case insensitive) if ($VAR1 -eq $VAR2)
@magnetikonline
magnetikonline / README.md
Last active April 28, 2026 11:29
NSSM - the Non-Sucking Service Manager cheatsheet.
@magnetikonline
magnetikonline / README.md
Last active May 21, 2023 08:15
macOS SSH client host autocomplete.

macOS SSH client host autocomplete

Snippet for ~/.bash_profile, adding hostname autocomplete to ssh and scp.

Extracts host hints from ~/.ssh/config.

function __completeSSHHosts {
  COMPREPLY=()
 local currentWord=${COMP_WORDS[COMP_CWORD]}
@magnetikonline
magnetikonline / README.md
Last active January 14, 2018 03:39
Enable execute of bash scripts on a partition mounted with noexec.

Enable execute on partition mounted with noexec

The example situation:

  • Wish to execute a bash script at /var/foobah/myscript.sh
  • But /var/ has been mounted using noexec via /etc/fstab.
  • How to solve? Using bind mounts.

Firstly, create a directory to hold script(s), located somewhere that has exec rights, then create the target directory on noexec partition:

$ mkdir --parents /opt/magnetik/foobah