Use grep
to search for a pattern in a set of files, but in the output, display the last modification time (mtime) of each file along with the matching line.
This file contains 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
#!/usr/bin/env python | |
# demo_subprocess.py - demonstrate Python subprocess polling and termination | |
# Andrew Ho (andrew@zeuscat.com) | |
import os, time, subprocess | |
sleep_for = 5 # How long in seconds should our test subprocess sleeps | |
timeout_after = 3 # Send SIGTERM to the subprocess after this many seconds | |
poll_delay = 0.5 # Sleep this long between polling for subprocess status |
This file contains 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
#!/usr/bin/env python | |
# show_poll.py - show that zombie processes get reaped by poll() | |
# Andrew Ho (andrew@zeuscat.com) | |
# | |
# To test: open two terminals. Run this program in one terminal, cut and | |
# paste the "ps" command that is printed in the other terminal, and keep | |
# re-running that ps command (Ctrl+P, Enter). After 5 seconds, the sleep | |
# subprocess exits and becomes a (sleep) zombie. After another 5 seconds, | |
# the parent process calls child.poll() and you should see it disappear. |
This file contains 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 | |
# is_steal_sort.sh - return true for GrabScrab steal (via letter sorting) | |
# Andrew Ho (andrew@zeuscat.com) | |
# | |
# Given two words, exits with zero return status if the second word is a | |
# GrabScrab steal for the first (see <http://grabscrab.com>). | |
# | |
# This solution counts letters and compares the letter counts, with best | |
# case O(n*log(n)) performance, where n is total letter count. |
This file contains 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 | |
# is_steal_count.sh - return true for GrabScrab steal (via letter counting) | |
# Andrew Ho (andrew@zeuscat.com) | |
# | |
# Given two words, exits with zero return status if the second word is a | |
# GrabScrab steal for the first (see <http://grabscrab.com>). | |
# | |
# This solution counts letters and compares the letter counts, with best | |
# case linear performance, by total letter count. |
This file contains 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
# Original: https://gist.githubusercontent.com/pcorliss/5628491/raw/eccb38d840734854dd5a10b25e7d52b71612f0d7/sphinx.rb | |
require 'formula' | |
class Libstemmer < Formula | |
# upstream is constantly changing the tarball, | |
# so doing checksum verification here would require | |
# constant, rapid updates to this formula. | |
head 'http://snowball.tartarus.org/dist/libstemmer_c.tgz' | |
homepage 'http://snowball.tartarus.org/' |
The first equivalent in each section is what I use.
Measuring cup:
Mixing vessel:
This file contains 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
/* gcc -Wall -Wno-char-subscripts -o is_steal is_steal.c */ | |
#include <stdio.h> | |
int is_steal(const char *base, const char *steal) { | |
char count[26] = {0}; | |
int bl, sl; | |
for(bl = sl = 0; base[bl]; bl++) { | |
if(count[base[bl]] > 0) { |
This file has been truncated, but you can view the full file.
This file contains 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
==> Installing gcc49 from homebrew/homebrew-versions | |
==> Downloading http://ftpmirror.gnu.org/gcc/gcc-4.9.2/gcc-4.9.2.tar.bz2 | |
Already downloaded: /Library/Caches/Homebrew/gcc49-4.9.2.tar.bz2 | |
==> Verifying gcc49-4.9.2.tar.bz2 checksum | |
tar xf /Library/Caches/Homebrew/gcc49-4.9.2.tar.bz2 | |
==> ../configure --build=x86_64-apple-darwin14.3.0 --prefix=/usr/local/Cellar/gcc49/4.9.2_1 --libdir=/usr/local/Cellar/gcc49/4.9.2_1/lib/gcc/4.9 --enable-languages=c,c++,objc,obj-c++ --program-suffix=-4.9 --with-gmp=/usr/local/opt/gmp4 --with-mpfr=/usr/local/opt/mpfr2 --with-mpc=/usr/local/opt/libmpc08 --with-cloog=/usr/local/opt/cloog018 --with-isl=/usr/local/opt/isl011 --with-system-zlib --enable-libstdcxx-time=yes --enable-stage1-checking --enable-checking=release --enable-lto --disable-werror --with-pkgversion=Homebrew gcc49 4.9.2_1 --with-bugurl=https://github.com/Homebrew/homebrew-versions/issues --enable-plugin --disable-nls --enable-multilib --with-native-system-header-dir=/usr/include --with-sysroot=/Applications/Xcode. |
This file contains 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
#!/usr/bin/env ruby | |
# wordchomp - given set of letters, generate sets of words that use them all | |
# Andrew Ho (andrew@zeuscat.com) | |
require 'multimap' | |
ME = File.basename(__FILE__) | |
USAGE = "usage: #{ME} letters" | |
# Given set of letters, generate set partitions, look for matches in dictionary |
OlderNewer