Skip to content

Instantly share code, notes, and snippets.

@jwliechty
jwliechty / testSpecRequires.sh
Created August 18, 2012 17:20
Find rspec tests missing requires
#!/bin/bash
runSpec(){
local specTest="$1"
bundle exec rspec "${specTest}" > /dev/null 2>&1
if [ $? -eq 0 ]; then
echo -n "."
else
echo -n "F"
echo "${specTest}" >> failed_individual_spec_tests.txt
@jwliechty
jwliechty / touchContinuously.sh
Created October 4, 2012 13:58
Continually touches a file
#!/bin/bash
DIR="/home/someone/somedir"
FILE="${1:?"First argument must be the filename name"}"
COUNT=1
FILE_TO_TOUCH="${DIR}/${FILE}"
handleTrap(){
echo -e "\n\nTouched '${FILE_TO_TOUCH}' ${COUNT} times."
exit 0
}
@jwliechty
jwliechty / script_directory.sh
Last active December 25, 2015 14:39
bash: Determine script directory
SCRIPT_DIR="$(readlink -f $(dirname $0))"
#or if must be supported on MAC
SCRIPT_DIR="$(cd "$(dirname "$0")"; pwd)"
@jwliechty
jwliechty / gist:8920847
Last active August 29, 2015 13:56
Stuff with ports
# see what process is using a port
sudo netstat -anp
# scan the ports
sudo nmap -sS -O 127.0.0.1
@jwliechty
jwliechty / gist:9936616
Created April 2, 2014 15:37
run_until_fails.sh
runUntilFails(){
local cmd="${1:?"Must give a command as a string"}"
local count=0
echo "Running cmd: ${cmd}"
while eval "${cmd} ; return $?"; do
((count+=1))
echo "Try count: ${count}"
done
}
@jwliechty
jwliechty / gist:0fe68a416d338c373c82
Last active August 29, 2015 14:04
Update RubyMine on Ubuntu
cd /usr/local/lib/ruby/
sudo mv ~/Downloads/RubyMine-7.1.1.tar.gz .
tar xzf RubyMine-7.1.1.tar.gz
sudo chown -R jwliechty:jwliechty RubyMine-7.1.1
update-alternatives --list rubymine
sudo update-alternatives --install /usr/bin/mine rubymine /usr/local/lib/ruby/RubyMine-7.1.1/bin/rubymine.sh 1
sudo update-alternatives --config rubymine
vi /home/jwliechty/.gnome2/panel2.d/default/launchers/mine-1.desktop
@jwliechty
jwliechty / delete_unused_foreign_keys.sql
Last active August 29, 2015 14:06
Delete all unused foreign keys in 'child' that are supposed to be referenced from 'parent'. (Rows in child belong to rows in parent where child.id = parent.child_id).
DELETE FROM child WHERE id IN
(
SELECT child.id FROM child LEFT JOIN parent ON child.id=parent.child_id WHERE parent.child_id IS NULL
);
@jwliechty
jwliechty / find_ids_of_demension_mult_attributes.sql
Created September 15, 2014 19:15
Find id's of a dimension referenced from a fact table via multiple attributes.
SELECT dim.id FROM dim WHERE dim.id NOT IN
(
SELECT DISTINCT fact.dim_one_id FROM fact
)
AND dim.id NOT IN
(
SELECT DISTINCT fact.dim_two_id FROM fact
)
AND dim.id NOT IN
(
@jwliechty
jwliechty / createPatchTarBetween.sh
Last active January 31, 2017 16:20
This script helps in creating a tar.gz file containing only modified and added files from between two commits in a git repository. The idea is for deployed applications, to update only the changed files for a hotfix or small update, this tar can be created and extracted over that existing directory. Of course this only works if there were additi…
#/bin/bash -e
START_BRANCH="$1"
END_BRANCH="$2"
PATCH_TAR=patch.tar.gz
COMMIT_HASH_FILE=commit_hash
usage(){
echo ""
echo "USAGE: $0 START END"
@jwliechty
jwliechty / rpm_build_commands.sh
Created November 18, 2014 17:26
Building RPMs
# install tools for working with RPMs
sudo yum groupinstall "Development Tools"
sudo yum install rpmlint rpmdevtools yum-utils
# add a Centos source repository
cat <<EOF | sudo tee /etc/yum.repos.d/srpm.repo >/dev/null
[centos-source]
name=Centos Vault $releasever - $basearch - Source
baseurl=http://vault.centos.org/6.3/os/Source
enabled=1