Skip to content

Instantly share code, notes, and snippets.

View ianldgs's full-sized avatar
💻
Hacking

Ian Luca ianldgs

💻
Hacking
View GitHub Profile
@ianldgs
ianldgs / go-localhost-cert.sh
Created May 29, 2019 19:48
Create localhost certificate
go run $GOROOT/src/crypto/tls/generate_cert.go --host="localhost"
changeMac() {
local net=${1:-en0}
local mac=$(openssl rand -hex 6 | sed 's/\(..\)/\1:/g; s/.$//')
sudo ifconfig $net ether $mac
sudo ifconfig $net down
sudo ifconfig $net up
echo "Your new physical address for interface $net is $mac"
}
@ianldgs
ianldgs / object-mapper.ts
Last active April 30, 2019 14:20
Object mapper: `_.pick` and `_.omit` type-safe alternatives
const O = {
map: <T, R>(object: T, mapper: (object: T) => R) => mapper(object),
}
const v = O.map(
{foo: 'bar', bar: 'foo', poop: ':)', num: 1},
({ poop, num }) => ({ poop, num }),
);
Angular 2+ React

Sites using:


Google Adwords (dart)
@ianldgs
ianldgs / net.sh
Last active December 5, 2018 18:00
Network calcs in shell
#!/bin/sh
IPV4_OCTET_MAX_BITS=256
IPV4_OCTET_MAX_VALUE=255
net_ips_per_mask() {
local mask=$1
local bitsleft=$((32-$mask))
local ips=$((2**$bitsleft))
@ianldgs
ianldgs / concurrently.sh
Last active November 29, 2022 16:04
Runs two or more processes concurrently in sh
#!/bin/sh
concurrently() {
for cmd in "$@"; do
echo "Process \"$cmd\" started"
$cmd & pid=$!
pids="$pids $pid"
done
trap "kill $pids" INT
#!/bin/sh
# Check this answer for more advanced stuff: https://stackoverflow.com/a/28466267/2502746
while getopts "*-:" arg; do
case $arg in
- ) LONG_OPTARG="${OPTARG#*=}"
case $OPTARG in
only-foo ) ONLY_FOO=1 ;;
only-bar ) ONLY_BAR=1 ;;
@ianldgs
ianldgs / fix-homebrew-npm.md
Created August 28, 2018 12:08 — forked from DanHerbert/fix-homebrew-npm.md
Instructions on how to fix npm if you've installed Node through Homebrew on Mac OS X or Linuxbrew

Fixing npm On Mac OS X for Homebrew Users

Installing node through Homebrew can cause problems with npm for globally installed packages. To fix it quickly, use the solution below. An explanation is also included at the end of this document.

Solution

This solution fixes the error caused by trying to run npm update npm -g. Once you're finished, you also won't need to use sudo to install npm modules globally.

Before you start, make a note of any globally installed npm packages. These instructions will have you remove all of those packages. After you're finished you'll need to re-install them.