# Get local computer IP address for LAN network
alias myip="ifconfig | sed -En 's/127.0.0.1//;s/.*inet (addr:)?(([0-9]*\.){3}[0-9]*).*/\2/p'"
# Public facing ip
alias myippub='wget -qO- icanhazip.com'
# Get mac address for en0
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
List the hosts on your LAN, their MAC addresses and IP's and then count them: | |
``` | |
$ arp -an | tee >(wc -l) | |
``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if ! type "$brew" > /dev/null; then | |
echo "homebrew is not installed, please install homebrew" | |
else | |
if ! type "$curl" > /dev/null; then | |
echo "curl is not installed, please install homebrew" | |
else | |
if ! type "$jq" > /dev/null; then | |
echo "jq is not installed, please install homebrew" | |
else | |
if [ -z "$2" ]; then |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
echo -e "\nScan LAN for other computers.\n" | |
if [ -n ""$@"" ]; then | |
ip=$(/sbin/ifconfig $1 | grep 'inet ' | awk '{ print $2}' | cut -d"." -f1,2,3 ) | |
nmap -sP $ip.1-255 | |
else | |
echo "Enter Interface parameter ex:" | |
echo -e "\t./scannetwork.sh $(ifconfig -lu | awk '{print $2}')\n" | |
echo "Available interfaces: " | |
for i in $(ifconfig -lu) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ApplicationController < ActionController::Base … | |
private | |
def client_will_not_cache_response | |
response.headers["Cache-Control”] = “no-cache, no-store” | |
response.headers[“Pragma”] = “no-cache” | |
response.headers[“Expires”] = “Fri, 01 Jan 1990 00:00:00 GMT” | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ApplicationController < ActionController::Base | |
prepend_before_filter :authenticate_user! | |
private | |
## Tell client not to cache the response | |
def client_will_not_cache_response | |
response.headers["Cache-Control”] = “no-cache, no-store” | |
response.headers[“Pragma”] = “no-cache” | |
response.headers[“Expires”] = “Fri, 01 Jan 1990 00:00:00 GMT” | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
params = {} | |
## Using string interpolation in where clauses is always dangerous | |
## BAD (Strings unescaped) | |
params[:firstname] = "'cat' OR lastname='Kelley'" | |
User.find(:first, conditions: "firstname = #{params[:firstname]}") | |
#=> AR Relation matching conditions | |
## GOOD (Escaped/Parameterized via Hash or Array) | |
User.find(:first, conditions: {firstname: params[:firstname]}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
if [ -f "`find . -name .DS_Store`" ] ; then | |
if [ ! -f "`git rev-parse --is-inside-work-tree`" ] ; then | |
echo "no git repository found" | |
while true; do | |
read -p "Do you wish to initialize git repository in this folder $(echo $(pwd))?" yn | |
case $yn in |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
case "$(uname -s)" in | |
Linux*) sys=Linux;; | |
Darwin*) sys=Mac;; | |
CYGWIN*) sys=Cygwin;; | |
MINGW*) sys=MinGw;; | |
*) sys="UNKNOWN:$(uname -s)" | |
esac | |
echo ${sys} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
if [ ! -f "`which brew`" ] ; then | |
echo "installing homebrew" | |
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" | |
else | |
brew update | |
fi | |
if brew ls --versions imagemagick > /dev/null; then |