Skip to content

Instantly share code, notes, and snippets.

View emcorrales's full-sized avatar
🏠
Working from home

Emmanuel Corrales emcorrales

🏠
Working from home
View GitHub Profile
#!/bin/sh
#
# Adam Sharp
# Aug 21, 2013
#
# Usage: Add it to your PATH and `git remove-submodule path/to/submodule`.
#
# Does the inverse of `git submodule add`:
# 1) `deinit` the submodule
# 2) Remove the submodule from the index and working directory
#!/bin/bash
# Copied from https://apple.stackexchange.com/questions/191879/how-to-find-the-currently-connected-network-service-from-the-command-line
services=$(networksetup -listnetworkserviceorder | grep 'Hardware Port')
while read line; do
sname=$(echo $line | awk -F "(, )|(: )|[)]" '{print $2}')
sdev=$(echo $line | awk -F "(, )|(: )|[)]" '{print $4}')
#echo "Current service: $sname, $sdev, $currentservice"
if [ -n "$sdev" ]; then
ifout="$(ifconfig $sdev 2>/dev/null)"
@emcorrales
emcorrales / find-active-network-interface.sh
Created May 30, 2019 19:52
A simple script for finding the active network interface on Mac.
#!/bin/bash
# Copied from https://apple.stackexchange.com/questions/191879/how-to-find-the-currently-connected-network-service-from-the-command-line
services=$(networksetup -listnetworkserviceorder | grep 'Hardware Port')
while read line; do
sname=$(echo $line | awk -F "(, )|(: )|[)]" '{print $2}')
sdev=$(echo $line | awk -F "(, )|(: )|[)]" '{print $4}')
#echo "Current service: $sname, $sdev, $currentservice"
if [ -n "$sdev" ]; then
ifout="$(ifconfig $sdev 2>/dev/null)"
@emcorrales
emcorrales / docker-macos-installation.sh
Created February 28, 2019 01:51
Script for installing docker on my mac.
#!/bin/sh
# Install Homebrew
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
# Install Homebrew Cask
brew tap caskroom/versions
# Install Docker
brew cask install docker
@emcorrales
emcorrales / jdk-oracle-macos-setup.bash
Last active March 16, 2024 14:15
Bash script for installing Oracle JDK on a Mac using Homebrew and Cask. https://emcorrales.com/blog/install-oracle-jdk-macos-homebrew
#!/bin/bash
# Install Homebrew
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
# Install Cask
brew tap caskroom/versions
# Install the latest version of Java
brew cask install java
@emcorrales
emcorrales / elb_aws_deploy.rb
Created October 30, 2018 15:46 — forked from cvele/elb_aws_deploy.rb
Capistrano 3 (ruby) snippet to deploy to multiple AWS servers attached to ELB dynamically. Add this to production.rb (or whatever stage) instead of servers definition. AWS ec2 cli required.
require 'rubygems'
require 'json'
LOADBALANCER = 'your-elb-load-balancer-name'
lb_instances = %x( aws elb describe-instance-health --load-balancer-name #{LOADBALANCER} )
lb_instances = JSON.parse(lb_instances)
instances = lb_instances["InstanceStates"]
#!/bin/bash
# Script for restoring backed up database that was moved to the RAM Disk.
if [ $(uname) = "Linux" ]; then
# Delete detached symlink
[ -L /var/lib/mysql ] && sudo rm -rf /var/lib/mysql
# Restore backups
[ -d /var/lib/mysql.bak ] && sudo cp -pRL /var/lib/mysql.bak /var/lib/mysql
else
echo "Unsupported platform."
fi
SET FOREIGN_KEY_CHECKS = 0;
SET GROUP_CONCAT_MAX_LEN=32768;
SET @tables = NULL;
SELECT GROUP_CONCAT('`', table_name, '`') INTO @tables
FROM information_schema.tables
WHERE table_schema = (SELECT DATABASE());
SELECT IFNULL(@tables,'dummy') INTO @tables;
SET @tables = CONCAT('DROP TABLE IF EXISTS ', @tables);
PREPARE stmt FROM @tables;
@emcorrales
emcorrales / README.md
Last active September 14, 2018 15:19 — forked from hofmannsven/README.md
MySQL Command Line Cheatsheet

Bash command line Shortcuts

Picked these from here

Command Editing Shortcuts

Command Note
Ctrl + a go to the start of the command line
Ctrl + e go to the end of the command line
Ctrl + k delete from cursor to the end of the command line