Skip to content

Instantly share code, notes, and snippets.

View todgru's full-sized avatar

todgru

  • Portland, OR
View GitHub Profile
@todgru
todgru / launchd.md
Last active April 20, 2023 17:54
Launchd and plist, replace cron in Mac OS X

#launchd Usage

I have a bash script called foo.sh that takes one command line argument, bar. I want it to run every 60 seconds and load at startup.

  • an XML plist is Apple Property List
  • com.mydomain.foo.plist Name of launchd plist file should be a reverse fqdn, like (this may not be required, but convention)
  • com.mydomain.foo.plist lives in $HOME/Library/LaunchAgents and is ran as that user.
  • com.mydomain.foo.plist can also live /Library/LaunchDaemons or /Library/LaunchAgents, have requirements, ran as root
  • Load plist with launchctl load com.mydomain.foo.plist
  • Unload plist with lauchctl unload com.mydomain.foo.plist
@todgru
todgru / resque.md
Last active December 11, 2015 03:08
resque redis
@todgru
todgru / solid.md
Created January 18, 2013 23:02
solid object oriented oop

#SOLID

  • S SRP Single responsibility principle, an object should have only a single responsibility.
  • O OCP Open/closed principle, “software entities … should be open for extension, but closed for modification”.
  • L LSP Liskov substitution principle, “objects in a program should be replaceable with instances of their subtypes without altering the correctness of that program”. See also design by contract.
  • I ISP Interface segregation principle, “many client-specific interfaces are better than one general-purpose interface.”
  • D DIP Dependency inversion principle, one should “Depend upon Abstractions. Do not depend upon concretions.” Dependency injection is one method of following this principle.

see http://en.wikipedia.org/wiki/SOLID_(object-oriented_design)

@todgru
todgru / mp3.md
Last active December 11, 2015 09:58
id3 mp3 taga bash cli command line

#Setting mp3 tags, ID3 from command line

install using brew, brew install id3lib

set tag:

$ id3tag --artist="The Best Band Ever" --album="Greatest Hits" --song="Number One Forever" --year="1975" --track="1" --total="12" --genre="Jazz"

help

@todgru
todgru / bash2.md
Created January 22, 2013 01:54
bash, BASH, sleep, at, kill

#BASH

BASH Process Control

response=$(curl --write-out %{http_code} --silent --output /dev/null servername)
  • Start <command>, assign the pid value to $PID, sleep for N minutes. Then end process $PID:

& PID=$!

@todgru
todgru / bash.md
Last active December 11, 2015 12:39
bash
  • du -sh {directory} list display size of directory in human readable format.
  • du -sh * show size of each directory in the current path
  • df disk space usage
$ du -sh *
 11M  Applications
1.9G	Desktop
 14G	Documents
8.0K	Downloads
#!/usr/bin/perl
use v5.10;
use strict;
use warnings;
# Usage: gist_backup.pl <user>
# Clone all the gists of a GitHub user
#!/bin/sh
#cloneall.sh by Jan-Piet Mens, February 2012
# Obtain a list of gists (mine) and clone them into the current directory
# Requires jsonpipe (https://github.com/dvxhouse/jsonpipe)
URL=http://gist.github.com/api/v1/json/gists/jpmens
CLONEURLFMT="git://gist.github.com/%d.git\n"
curl -qs $URL |
jsonpipe -s ' ' |
@todgru
todgru / bash3.md
Last active December 11, 2015 18:58
bash ls directories directory grep sed ls

list only directories names

ls -1F | grep / | sed 's_/$__'
for fn in `ls -1F | grep / | sed 's_/$__'`; do
    echo "the next file is $fn"

done
@todgru
todgru / vim_git_gpg.md
Last active December 12, 2019 19:27
vim git gpg password manage gnupg