| @@ -980,74 +980,6 @@ if ($valid){ | |||
| exit 0; | |||
| #+END_SRC | |||
| * ~/bin/portchk | |||
| Just find out if a port responds to anything tcp related or not. | |||
| #+BEGIN_SRC perl :padline no :tangle tmp/bin/portchk | |||
| #!/usr/bin/env perl | |||
| # | |||
| # Dumb wrapper to get the gecos information from a uid/username. | |||
| foreach my $input (@ARGV){ | |||
| my $gecos = undef; | |||
| my $uid = undef; | |||
| my $name = undef; | |||
| if ( $input =~ m/^\d+$/ ) { | |||
| ( $name,$uid,$gecos ) = ( getpwuid($input) )[0,2,6]; | |||
| } else { | |||
| ( $name,$uid,$gecos ) = ( getpwnam($input) )[0,2,6]; | |||
| } | |||
| print "$name is '$gecos' uid '$uid'\n" if $gecos; | |||
| } | |||
| #+END_SRC | |||
| * TODO ~/bin/nix-update still worth keeping? :cleaning: | |||
| More for nix on macos, but just merges NixOS/nipkgs origin/master to the current branch in a tmux window and watches it. | |||
| #+BEGIN_SRC sh :padline no :tangle (tangle/file "bin/nix-update" (bound-and-true-p nix-p)) :mkdirp t | |||
| #!/usr/bin/env sh | |||
| #-*-mode: Shell-script; coding: utf-8;-*- | |||
| # File: tmux-nix.sh | |||
| # Copyright: 2017 Mitch Tishmack | |||
| # Description: instantiate tmux nix session | |||
| export script=$(basename "$0") | |||
| export dir=$(cd "$(dirname "$0")"; pwd) | |||
| export iam=${dir}/${script} | |||
| set -e | |||
| session=nix | |||
| PKGS=${PKGS:-nixpkgs} | |||
| if "${PKGS}" != "nixpkgs"; then | |||
| cd ~/src/github.com/NixOS/nixpkgs/${PKGS} | |||
| else | |||
| cd ~/src/github.com/NixOS/nixpkgs | |||
| fi | |||
| if ! tmux has-session -t ${session}; then | |||
| tmux new-session -d -s ${session} -n nix | |||
| tmux send-keys -t ${session}:0 'sleep 30 | |||
| while true; do | |||
| blah=$(nix-env -f "<${PKGS}>" -iA --dry-run stdboth default | grep /nix); echo "${blah}" | head -n $(echo "$LINES - 2" | bc); echo "${blah}" | grep -c /nix | ts | |||
| echo "${blah}" | grep /nix > /dev/null 2>&1 | |||
| if [ $? -eq 0 ]; then | |||
| sleep 60 | |||
| clear | |||
| else | |||
| exit 0 | |||
| fi | |||
| done | |||
| ' C-m | |||
| tmux split-window -v -t ${session}:0 | |||
| tmux send-keys -t ${session}:0.1 'git fetch --all && git short HEAD > last-$(iso8601) && git rebase --autostash origin/staging && | |||
| time nix-env -f "<${PKGS}>" -iA default && nix-env -f "<${PKGS}>" -u --leq && exit 0 | |||
| ' C-m | |||
| tmux select-window -t ${session}:0 | |||
| fi | |||
| tmux attach -t ${session} | |||
| #+END_SRC | |||
| * ~/bin/notify | |||
| OSX only really, just fires off a notification when its ran. | |||
| @@ -1056,53 +988,25 @@ Example: | |||
| notify "some command" "not ok" | |||
| First param is the message, second title of the notification. | |||
| #+BEGIN_SRC sh :padline no :tangle (tangle/file "bin/notify" (bound-and-true-p macos-p)) | |||
| #+BEGIN_SRC sh :padline no :tangle (tangle/file "bin/notify" (bound-and-true-p macos-p)) :mkdirp t | |||
| #!/bin/sh | |||
| message=${1:="no message"} | |||
| title='' | |||
| if [ "${2}" != "" ]; then | |||
| message="${2}" | |||
| title="${1}" | |||
| message=${1:-"no message"}; shift | |||
| extra="" | |||
| if [ -n "${1}" ]; then | |||
| extra="with title \"${1}\"" | |||
| fi | |||
| notification="display notification \"${message}\"" | |||
| [ "${title}" != "" ] && notification="${notification} with title \"${title}\"" | |||
| osascript -e "${notification}" | |||
| osascript <<END | |||
| display notification "${message}" ${extra} | |||
| END | |||
| #+END_SRC | |||
| * ~/bin/today | |||
| Stupid ruby script I wrote to highlight the week/day in a calendar. I don't remember why I wrote it. | |||
| TODO: why the hell is :mkdirp yes needed here but nowhere else? | |||
| #+BEGIN_SRC ruby :padline no :tangle tmp/bin/today :mkdirp t | |||
| #!/usr/bin/env ruby | |||
| cal, today, week_color, day_color, reset = %x(cal).split(%r(\n)), Time.now.day, %x(tput sgr0;tput setab 4;tput setaf 7), %x(tput sgr0; tput setab 0;tput setaf 7;tput bold), %x(tput sgr0) | |||
| done=false | |||
| cal.each do |line| | |||
| if done then | |||
| puts line | |||
| next | |||
| end | |||
| if(line =~ /^(.*\s+?)#{today}(\s+?.*)$/ or | |||
| line =~ /^(.*\s+?)#{today}$/ or | |||
| line =~ /^()#{today}(\s+?.*)$/ or | |||
| line =~ /^#{today}$/ ) then | |||
| puts "#{week_color}#{$1}#{day_color}#{today}#{week_color}#{$2}#{reset}" | |||
| done=true | |||
| else | |||
| puts line | |||
| end | |||
| end | |||
| #+END_SRC | |||
| * ~/bin/close | |||
| macos only, simple wrapper around osascript to send close to a gui application so I don't have to use the mouse/trackpad cause I'm lazy af. | |||
| #+BEGIN_SRC sh :padline no :tangle (tangle/file "bin/close" (bound-and-true-p macos-p)) | |||
| #+BEGIN_SRC sh :padline no :tangle (tangle/file "bin/close" (bound-and-true-p macos-p)) :mkdirp t | |||
| #!/bin/sh | |||
| if [ -z "${1}" ]; then | |||
| printf "usage: close app_name\n no application to close provided\n" | |||
| exit 1 | |||