Skip to content

Instantly share code, notes, and snippets.

└─┬ ember-cli@2.4.3
├─┬ amd-name-resolver@0.0.5
│ └── ensure-posix-path@1.0.1
├── bower@1.7.9
├─┬ bower-config@1.3.1
│ ├── graceful-fs@4.1.3
│ ├── mout@1.0.0
│ ├─┬ optimist@0.6.1
│ │ ├── minimist@0.0.10
│ │ └── wordwrap@0.0.3
@benpop
benpop / up
Created January 5, 2016 07:33
Update repositories.
#!/bin/bash
UPROOT=$HOME/src
NOUP=$UPROOT/noup # ban list
pushd () {
command pushd "$@" >/dev/null
}
popd () {
@benpop
benpop / brew-up-all
Created January 5, 2016 07:24
brew-up-all
#!/bin/sh
cmd() {
echo '==>' "$@"
eval "$@"
}
src() {
pushd ~/src > /dev/null
./up
@benpop
benpop / xstrings.c
Last active December 20, 2015 15:19
UNIX tool "strings" that works on (nearly?) all files.
/*
"strings" that works on (nearly?) all files.
$ man strings
Automatically exclude strings that start with '_', '@', or are all whitespace.
DO NOT look in specific sections of the file for strings.
1) That's where we get in trouble trying to run strings on a dylib.
2) That's more work.
Call:
@benpop
benpop / sortline.c
Last active December 20, 2015 05:28
/*
Example usage:
cat /usr/share/dict/words | tr -cd '[:alpha:]\n' | tr '[:lower:]' '[:upper:]' |
sortline | sort | uniq -c | awk '$1 > 1'
Compile & install:
cc -O3 -o sortline sortline.c && install -p sortline ~/bin
----------------------------------------------------------------
@benpop
benpop / charpointer.c
Last active May 2, 2023 14:24
Illustrate the difference between char *, char [], char *[], etc., in C.
#include <stdio.h>
#include <string.h>
/* z is format specifier for size_t, the return type of sizeof */
#define SIZEFMT "\t%zu\t%s\n"
/* sizeof gives the memory compiler allocates for x.
# is the stringify operator in the C preprocessor.
for example, #token -> "token". */
#define printsize(x) printf(SIZEFMT, sizeof(x), #x)
@benpop
benpop / iterOrderedKeys.lua
Last active December 20, 2021 17:47
Iterate through table by the sorted order of the table keys.
function iterOrderedKeys(t, compare)
local keys = {}
for k in pairs(t) do
keys[#keys+1] = k
end
table.sort(keys, compare)
local i = 1
return function ()
local k = keys[i]
local v = t[k]