Skip to content

Instantly share code, notes, and snippets.

@florido
florido / node-npm-install.md
Created November 11, 2018 07:48 — forked from rcugut/node-npm-install.md
Install node & npm on Mac OS X with Homebrew

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.

#!/bin/bash
select command in "Hello World" "calculate 1+1" exit;do
if [ "$command" = "exit" ];then
exit
elif [ "$command" = "Hello World" ];then
echo $command
elif [ "$command" = "calculate 1+1" ];then
echo $((1+1))
fi
done
@florido
florido / path_helper.sh
Last active November 11, 2018 03:28 — forked from gilaras/gist:159792
/usr/libexec/path_helper
#!/bin/sh
#
# Each line of the text files in /etc/paths.d are directories that
# should be added to the current path. The text files are read in
# lexical order, and the default file is /etc/paths.d/50-default.
# We source /etc/paths.d/50-default first, so that the default paths
# (/usr/bin:/bin:/usr/sbin:/sbin) appear early in the path.
#
shopt -s extglob
@florido
florido / iTunesMediaLocation.sh
Created November 10, 2018 23:43 — forked from nrollr/iTunesMediaLocation.sh
Retrieve file location of all items in the iTunes Library
#!/bin/bash
# Extract file location of each item from iTunes Music Library.xml (renamed to iTunes.xml)
sed -n 's/.*<key>Location<\/key><string>\([^<]*\)<\/string>.*/\1/p' iTunes.xml > FileLocation.txt
@florido
florido / Python.md
Created November 10, 2018 23:24 — forked from nrollr/Python.md
Python environments in macOS

Python environments in macOS

The latest version of macOS 10.13.3 has Python 2.7.10 installed by default, yet Python has been available on macOS and previously OS X for quite a while now.

Consult the Apple's Open Source Reference Library, and browse through the various releases of the OS to find out which Python version was included). But what if you have a project which requires Python 3 ?

The following instructions will guide you through the process of:

  • installing Python 3 using Homebrew
  • running multiple Python verions as sandboxed environments
@florido
florido / keyboard-symbols.txt
Created November 10, 2018 22:44 — forked from renandf/keyboard-symbols.txt
List of keys and their symbols
⎋ Escape
⇥ Tab forward
⇤ Tab back
⇪ Capslock
⇧ Shift
⌃ Control
⌥ Option (Alt, Alternative)
⌘ Command
␣ Space
⏎ Return
@florido
florido / rbenv-install-system-wide.sh
Created November 4, 2018 11:34 — forked from v1nc3ntlaw/rbenv-install-system-wide.sh
rbenv install ruby 1.9.3-p448 on Ubuntu 12.04 LTS
#
# Run as root
# $ bash <(curl -s https://raw.github.com/gist/1631411)
#
# Update, upgrade and install development tools:
apt-get update
apt-get -y upgrade
apt-get -y install build-essential git-core curl \
libssl-dev \
@florido
florido / launchd.md
Created November 4, 2018 11:16 — forked from todgru/launchd.md
Launchd and plist, replace cron in Mac OS X

#launchd Usage

I have a bash script called foo.sh that takes one command line argument, bar. I want it to run every 60 seconds and load at startup.

  • an XML plist is Apple Property List
  • com.mydomain.foo.plist Name of launchd plist file should be a reverse fqdn, like (this may not be required, but convention)
  • com.mydomain.foo.plist lives in $HOME/Library/LaunchAgents and is ran as that user.
  • com.mydomain.foo.plist can also live /Library/LaunchDaemons or /Library/LaunchAgents, have requirements, ran as root
  • Load plist with launchctl load com.mydomain.foo.plist
  • Unload plist with lauchctl unload com.mydomain.foo.plist

assume we start with a file named foo.txt that has no assigned permissions, like this:

----------

add read permission to the file for all users:

chmod +r foo.txt
-r--r--r--

Next add write permission to the file for all users:

@florido
florido / skeleton-daemon.sh
Created October 31, 2018 09:49 — forked from shawnrice/skeleton-daemon.sh
A template to write a quick daemon as a bash script
#!/bin/sh
# This is a skeleton of a bash daemon. To use for yourself, just set the
# daemonName variable and then enter in the commands to run in the doCommands
# function. Modify the variables just below to fit your preference.
daemonName="DAEMON-NAME"
pidDir="."
pidFile="$pidDir/$daemonName.pid"