pathologicalhandwaving
1/28/2017 - 4:27 AM

Random Scripts

#!/usr/bin/python

import yaml

stream = file('students.yml', 'r')
yaml.load(stream)


#!/usr/bin/python3

import os
configfile_name = "config.yml"

if not os.path.isfile(configfile_name):
    cfgfile = open(configfile_name, 'w')

    Config = ConfigParser()
    Config.add_section('student')
    Config.add_section('id')
    Config.set('student', 'id')
    Config.add_section('name')
    Config.set('name', 'firstname', 'lastname')
    Config.set('student', 'id', 'name')
    Config.add_section('grade')
    Config.set('grade', 'gnumber', 'gname')
    Config.add_section('days')
    Config.set('days', 'monday', 'tuesday', 'wednesday', 'thursday', 'friday')
    Config.set('student',
                ['id',
                'name',
                'grade',
                'days'])
    Config.set('student')
    Config.write(cfgfile)
    cfgfile.close()
#!/bin/bash

weasels="many|various|very|fairly|several|extremely\
  |exceedingly|quite|remarkably|few|surprisingly\
  |mostly|largely|huge|tiny|((are|is) a number)\
  |excellent|interestingly|significantly\
  |substantially|clearly|vast|relatively|completely"

wordfile=""

# Check for an alternate weasel file
if [ -f $HOME/etc/words/weasels ]; then
    wordfile="$HOME/etc/words/weasels"
fi

if [ -f $WORDSDIR/weasels ]; then
    wordfile="$WORDSDIR/weasels"
fi

if [ -f words/weasels ]; then
    wordfile="words/weasels"
fi

if [ ! "$wordfile" = "" ]; then
    weasels="xyzabc123";
    for w in `cat $wordfile`; do
        weasels="$weasels|$w"
    done
fi


if [ "$1" = "" ]; then
    echo "usage: `basename $0` <file> ..."
    exit
fi

egrep -i -n --color "\\b($weasels)\\b" $*

exit $?
#!/usr/bin python3

from itertools import product

while True:
    bexp = input('\nBoolean Expression: ')
    bexp = bexp.strip()
    if not bexp:
        print("\nThank You")
        break
    code = compile(bexp, '<string>', 'eval')
    names = code.co_names
    print('\n' + ' '.join(names), ':', bexp)
    for values in product(range(2), repeat=len(names)):
        env = dict(zip(names, values))
        print(' '.join(str(v) for v in values), ':', eval(code, env))
#!/usr/local/bin/bash

FILE="$HOME/.myscripts/outfiles/tricks.yml"

read -p 'Trick: ' trick

echo "  - $trick" >> $FILE

cat $FILE | tail -3

exit 0
#!/usr/local/bin/bash

FILE=$HOME/.myscripts/outfiles/tools.yml

echo " "
read -p 'Tool Name: ' tool
read -p 'Description: ' desc
read -p 'Example Usage: ' uses
echo " "

echo "  tool: $tool" >> $FILE
echo "    description: >" >> $FILE
echo "      '$desc'" >> $FILE
echo "    example: |" >> $FILE
echo "      $uses" >> $FILE

cat $FILE | tail -5

exit 0

#1/usr/local/bin/bash

date_now=$(date "+%Y-%m-%d")
time_12=$(date -d "-5 hours" "+%I:%M %p %Z")
time_24=$(date -d "-5 hours" "+%H:%M:%S %Z")
time_utc=$(date -u)

function print() {
	echo " "
	echo "Current Date: $date_now"
	echo "Time (12 hour): $time_12"
	echo "Time (24 hour): $time_24"
	echo "UTC: $time_utc"
	echo " "
}

print | lolcat

exit 0
# Safari Information
# Date: 20161020

application: Safari
osx_version: 10.11.6
application_path: /Users/Em/Library/Safari
cmds:
  cmd: safari_parser.py --history -f  history.plist -o history-results.tsv
  cmd: safari_parser.py --topsites -f  TopSites.plist -o topsite-results.tsv
  cmd: safari_parser.py --downloads -f  Downloads.plist -o download-results.tsv
  cmd: safari_parser.py --bookmarks -f Bookmarks.plist -o bookmark-results.tsv
  cmd: safari_parser.py -d /Users/maridegrazia/Library/Safari -o /Cases/InternetHistory/Reports
  cmd: safari_parser.py --history -f  history.plist -o history-results.tsv
  cmd: safari_parser.py --iPhonebookmarks -f bookmarks.db -o bookmark-results.tsv
  cmd: safari_parser.py --iPhonerecentsearches -f recentsearches.plist -o recentsearches-results.tsv
program:
  - biplist
  language: python
#!/usr/local/bin/bash

FILE = /Users/Em/.myscripts/outfiles/questions.yml

read -p 'Question: ' question

echo "  - $question" >> $FILE

exit 0
#!/bin/bash

irregulars="awoken|\
  been|born|beat|\
  become|begun|bent|\
  beset|bet|bid|\
  bidden|bound|bitten|\
  bled|blown|broken|\
  bred|brought|broadcast|\
  built|burnt|burst|\
  bought|cast|caught|\
  chosen|clung|come|\
  cost|crept|cut|\
  dealt|dug|dived|\
done|drawn|dreamt|\
driven|drunk|eaten|fallen|\
fed|felt|fought|found|\
fit|fled|flung|flown|\
forbidden|forgotten|\
foregone|forgiven|\
forsaken|frozen|\
gotten|given|gone|\
ground|grown|hung|\
heard|hidden|hit|\
held|hurt|kept|knelt|\
knit|known|laid|led|\
leapt|learnt|left|\
lent|let|lain|lighted|\
lost|made|meant|met|\
misspelt|mistaken|mown|\
overcome|overdone|overtaken|\
overthrown|paid|pled|proven|\
put|quit|read|rid|ridden|\
rung|risen|run|sawn|said|\
seen|sought|sold|sent|\
set|sewn|shaken|shaven|\
shorn|shed|shone|shod|\
shot|shown|shrunk|shut|\
sung|sunk|sat|slept|\
slain|slid|slung|slit|\
smitten|sown|spoken|sped|\
spent|spilt|spun|spit|\
split|spread|sprung|stood|\
stolen|stuck|stung|stunk|\
stridden|struck|strung|\
striven|sworn|swept|\
swollen|swum|swung|taken|\
taught|torn|told|thought|\
thrived|thrown|thrust|\
trodden|understood|upheld|\
upset|woken|worn|woven|\
wed|wept|wound|won|\
withheld|withstood|wrung|\
written"

if [ "$1" = "" ]; then
    echo "usage: `basename $0` <file> ..."
    exit
fi

egrep -n -i --color \
    "\\b(am|are|were|being|is|been|was|be)\
     \\b[ ]*(\w+ed|($irregulars))\\b" $*

exit $?

#!/usr/bin/env bash
#
# vim: set ft=sh:
#
# Based on https://gist.github.com/pkuczynski/8665367

parse_yaml() {
    local prefix=$2
    local s
    local w
    local fs
    s='[[:space:]]*'
    w='[a-zA-Z0-9_]*'
    fs="$(echo @|tr @ '\034')"
    sed -ne "s|^\($s\)\($w\)$s:$s\"\(.*\)\"$s\$|\1$fs\2$fs\3|p" \
        -e "s|^\($s\)\($w\)$s[:-]$s\(.*\)$s\$|\1$fs\2$fs\3|p" "$1" |
    awk -F"$fs" '{
    indent = length($1)/2;
    vname[indent] = $2;
    for (i in vname) {if (i > indent) {delete vname[i]}}
        if (length($3) > 0) {
            vn=""; for (i=0; i<indent; i++) {vn=(vn)(vname[i])("_")}
            printf("%s%s%s=(\"%s\")\n", "'"$prefix"'",vn, $2, $3);
        }
    }' | sed 's/_=/+=/g'
}

parse_yaml safari.yml
#!/bin/bash


KDATE=$(date "+%B, %A %Y ")
KTIME=$(date "+%I:%M %p ")
NTIME=$(date -d "-3 hours" "+%I:%M %p ")
UTIME=$(date -u)

function ptimes() {
	echo " "
	echo "Date: " $KDATE
	echo "Time: " $KTIME
	echo " "
	echo "Nik's Time: " $NTIME
	echo " "
	echo "UTC Time: " $UTIME
	echo " "
}


clear

ptimes | boxes -d nuke | lolcat -a -d 3 -F 0.2

exit 0
#!/usr/local/bin/bash

FILE=/Users/Em/.myscripts/outfiles/notes.yml

read -p 'Note: ' note

echo "  - $note" >> $FILE

cat | tail -10

exit 0
#!/usr/bin/env perl

# Finds duplicate adjacent words.

use strict ;

my $DupCount = 0 ;

if (!@ARGV) {
    print "usage: dups <file> ...\n" ;
    exit ;
}

while (1) {
    my $FileName = shift @ARGV ;
    
    # Exit code = number of duplicates found.  
    exit $DupCount if (!$FileName) ;
    
    open FILE, $FileName or die $!; 
    
    my $LastWord = "" ;
    my $LineNum = 0 ;
    
    while (<FILE>) {
        chomp ;
        
        $LineNum ++ ;
        
        my @words = split (/(\W+)/) ;
        
        foreach my $word (@words) {
            # Skip spaces:
            next if $word =~ /^\s*$/ ;
            
            # Skip punctuation:
            if ($word =~ /^\W+$/) {
                $LastWord = "" ;
                next ;
            }
            
            # Found a dup? 
            if (lc($word) eq lc($LastWord)) {
                print "$FileName:$LineNum $word\n" ;
                $DupCount ++ ;
            } # Thanks to Sean Cronin for tip on case.
            
            # Mark this as the last word:
            $LastWord = $word ;
        }
    }
    
    close FILE ;
}
#!/bin/bash
echo "**************************************"
echo " "
echo "Tools and OS X Default Installation"
echo "version 1.0 PathologicalHandwaving"
echo " "
echo "**************************************"
echo "OS X Defaults Installation"
echo "**************************************"
echo " "

echo "csrutil"
csrutil disable && reboot
echo " "

echo "Show percentage battery not time remaining"
sudo defaults write com.apple.menuextra.battery ShowPercent -string "YES"
sudo defaults write com.apple.menuextra.battery ShowTime -string "NO"
echo " "
echo "Enable full access keyboard for all controls"
sudo defaults write NSGlobalDomain AppleKeyboardUIMode -int 3
echo " "
echo "Transparency Off"
sudo defaults write com.apple.universalaccess reduceTransparency -bool true
sudo defaults write com.apple.universalaccess reduceTransparency -bool false
echo " "

echo "Key Repeat not Key Press and Hold"
sudo defaults write NSGlobalDomain ApplePressAndHoldEnabled -bool false
echo " "
echo "Really Fast Keyboard Repeat Rate"
sudo defaults write NSGlobalDomain KeyRepeat -int 0
echo " "
echo "Disable Auto-Correct"
sudo defaults write NSGlobalDomain NSAutomaticSpellingCorrectionEnabled -bool false
echo " "
echo "Show Full POSIX Path in Finder"
sudo defaults write com.apple.finder _FXShowPosixPathInTitle -bool true
echo " "

echo "Disable Warning on Rename"
sudo defaults write com.apple.finder FXEnableExtensionChangeWarning -bool false
echo " "
echo "Show Library"
sudo chflags nohidden ~/Library
echo " "
echo "Disable Animations"
sudo defaults write com.apple.dock launchanim -bool false
sudo defaults write com.apple.dock autohide-time-modifier -float 0.25
sudo defaults write com.apple.Dock autohide-delay -float 0
defaults write com.apple.dock enable-spring-load-actions-on-all-items -bool false
sudo defaults write -g NSScrollAnimationEnabled -bool false
sudo defaults write -g NSScrollViewRubberbanding -bool false
sudo defaults write -g AppleShowScrollBars -string "Always"
echo " "
echo "Expand Save Panel"
sudo defaults write -g NSNavPanelExpandedStateForSaveMode -bool true
sudo defaults write -g NSNavPanelExpandedStateForSaveMode2 -bool true
echo " "
echo "Dont Create DS_STORE on Network Drives and USB"
sudo defaults write com.apple.desktopservices DSDontWriteNetworkStores -bool true
sudo defaults write com.apple.desktopservices DSDontWriteUSBStores -bool true
echo " "
echo "Show hidden files"
sudo defaults write com.apple.finder AppleShowAllFiles YES
echo " "
echo "Disable Resume System Wide"
sudo defaults write NSGlobalDomain NSQuitAlwaysKeepsWindows -bool false
echo " "
echo "Enable Cut in Finder"
defaults write com.apple.finder AllowCutForItems YES
echo " "
echo "Safari Defaults"
sudo defaults write com.apple.Safari ProxiesInBookmarksBar "()"
sudo defaults write NSGlobalDomain WebKitDeveloperExtras -bool true
sudo defaults write com.apple.Safari FindOnPageMatchesWordStartsOnly -bool false
sudo defaults write com.apple.Safari IncludeInternalDebugMenu -bool true
sudo defaults write com.apple.Safari DebugSnapshotsUpdatePolicy -int 2
sudo defaults write NSGlobalDomain AppleShowScrollBars -string "WhenScrolling"
echo "Safari Defaults Finished"
echo " "
echo "iCal, Mail, Contacts"
sudo defaults write com.apple.iCal IncludeDebugMenu -bool true
sudo defaults write com.apple.addressbook ABShowDebugMenu -bool true
sudo defaults write com.apple.Mail DisableReplyAnimations -bool true
sudo defaults write com.apple.Mail DisableSendAnimations -bool true
sudo defaults write com.apple.mail AddressesIncludeNameOnPasteboard -bool false
sudo defaults write com.apple.mail DisableInlineAttachmentViewing -bool true
sudo defaults write com.apple.finder FXDefaultSearchScope -string "SCcf"
echo " "
echo "Firewall"
sudo sudo /usr/libexec/ApplicationFirewall/socketfilterfw --getglobalstate
sudo /usr/libexec/ApplicationFirewall/socketfilterfw --setglobalstate on
echo " "
echo "Disable Gatekeeper"
sudo spctl --master-disable
echo " "
echo "Locks"
sudo defaults read com.apple.screensaver askForPasswordDelay
sudo defaults write com.apple.screensaver askForPasswordDelay -int 0
sudo defaults read com.apple.screensaver askForPassword
sudo defaults write com.apple.screensaver askForPassword -int 1
echo " "
echo "Fuck Notification Center"
sudo launchctl unload -w /System/Library/LaunchAgents/com.apple.notificationcenterui.plist && killall -9 NotificationCenter
" "
echo "No Remote Apple Events"
sudo systemsetup -setremoteappleevents off
echo " "
echo "Screenshots are pngs"
sudo defaults write com.apple.screencapture type -string "png"
echo " "
echo "Turn Off Auto Software Updates"
sudo mdutil -i off -d /Users/Em
echo " "
echo "No Google Updates"
sudo ~/Library/Google/GoogleSoftwareUpdate/GoogleSoftwareUpdate.bundle/Contents/Resources/ksinstall --nuke
echo " "
echo "TextEdit Plaintext Default"
sudo defaults write com.apple.TextEdit RichText -int 0
echo " "
echo "X-code Developer Tools"
sudo xcode-select --install
xcrun simctl delete unavailable
echo " "
echo "Disable Sudden Motion Sensor"
sudo pmset -a sms 0
echo " "

echo " "
echo "**************************************"
echo "Homebrew Installation"
echo "**************************************"
echo " "


if [ ! -x /usr/local/bin/brew ]; then
    echo "installing homebrew"
    /usr/bin/env ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
else
    echo "homebrew is installed"
fi

echo "Installing Cask "
brew install caskroom/cask/brew-cask

echo "Updating app lists"
brew update
brew upgrade
brew cask update

echo " "
echo "Get and Set Real Bash"
brew install bash && \
sudo echo $(brew --prefix)/bin/bash >> /etc/shells && \
chsh -s $(brew --prefix)/bin/bash

brew install vim --with-lua

brew install tree
brew install coreutils
brew install findutils
brew install moreutils
brew install readline
brew install sqlite
brew install imagemagick
brew install wget
brew install curl
brew install gnupg2
brew install gpg-agent

brew install go
brew install node
brew install nodebrew
brew install ocaml
brew install python3
brew install lua
brew install shyaml

brew cask install iterm2
brew install itermocil
brew install ranger

brew install graphviz
brew install calc
brew install gnuplot

#Browsers
brew cask install firefox
brew cask install torbrowser
brew install elinks
brew install w3m
brew install mutt
brew install lynx

brew install task
brew install tasksh
brew install taskd
brew install timewarrior
brew install tty-clock
brew install vit
brew install tag

brew install teapot
brew install toilet
brew install somafm-cli
brew install shpotify
brew install borg
brew install boxes
brew install ansiweather
brew install asciiquarium
brew install cheat
brew install cpanimus
brew install cowsay
brew install figlet
brew install fortune
brew install sl
brew install youtube-dl
brew install nmap
brew install pandoc
brew install pandoc-citeproc
brew install bibutils
brew install bibtexconv
brew install bibclean
brew install pianobar
brew install poppler
brew install s-search
brew install rem
brew install wiki
brew install libcaca


#torrent client
brew cask install utorrent
brew cask install spotify

#anti malware
brew cask install malwarebytes-anti-malware


brew cask install karabiner
brew cask install seil

#media players
brew install mp3blaster

brew doctor;
brew cleanup;
brew cask cleanup;


#!/usr/local/bin/bash

FILE=/Users/Em/.myscripts/outfiles/ideas.yml

read -p 'Idea: ' idea

echo "  - $idea" >> $FILE

exit 0

#!/usr/local/bin/bash

FILE="$HOME/.myscripts/outfiles/glossary.yml"

clear

read -p 'Term: ' term
read -p 'Term Label: ' label
read -p 'Term Description: ' descr
read -p 'Tags: ' tags


echo " "
echo "  label: $label" >> $FILE
echo "    term: $term" >> $FILE
echo "    description: >" >> $FILE
echo "      '$descr'" >> $FILE
echo "    tags: $tags" >> $FILE
echo " "


cat $FILE | tail -5 | lolcat

echo " "

exit 0

#!/Users/Em/local/bin/bash

set -e

# Config
FILE="$HOME/.myscripts/outfiles/FlashCards/wellposed.csv"



function main() {
	IFS=$'\t'; read -a q <<<$(gshuf -n 1 "$FILE")
	echo "========================================================"
	echo "Category: ${q[0]}"
	echo " "
	echo "Question: ${q[1]}"
	read -p "Guess: " guess
	echo "Answer: ${q[2]}"
	echo " "
}


while true; do
	main
done

weaselwords

Matt Might’s weaselwords scripts found on his site