Skip to content

Instantly share code, notes, and snippets.

View masukomi's full-sized avatar

masukomi (a.k.a. Kay Rhodes) masukomi

View GitHub Profile
@masukomi
masukomi / parraleln.cr
Created May 3, 2018 19:25 — forked from oprypin/parraleln.cr
Crystal parallel jobs from an array
def paralleln(items : Indexable(T), &block : T -> R) forall T, R
results = Array(R).new(items.size) { r = uninitialized R }
done = Channel(Exception?).new
items.each_with_index do |item, i|
spawn do
begin
results[i] = block.call(item)
rescue e
done.send e
#!/bin/sh
[insert command to compile your app here]
# copy all the optional ones
rm -rf dylibs/*
# REPLACE path/to/my/new/binary below with the path to your newly compiled binary
DYLIBS=`otool -L path/to/my/new/binary | grep "/opt" | awk -F' ' '{ print $1 }'`
for dylib in $DYLIBS
do
@masukomi
masukomi / gale
Last active December 20, 2016 20:43
find the last thing edited and add it to git. (Git Add Last Edited)
#!/bin/sh
# find the last thing edited and add it to git.
# useful when you're editing items in a merge conflict
# and are running a command to edit each file in the command line.
# Run gale after each edit so that the list of conflicting items gets shorter
# and you don't have to keep copy pasting the name of the file
HISTFILE=~/.bash_history
set -o history
extract
┌─────────────────this ──────────────────────────┐
│ column │
│ ▼
│ ┌──┐
│ │ │
│ ┌────────────┼──┼───────┐
#!/bin/bash
for i in `cal | awk '{print $5}'`; do
if [ "x" != "x"$i ]; then
target_day=$i
fi
done
today=`date | awk '{print $3}'`
# I need your help geeks. ;)
# I have an array of items
# Some items have a number on both sides
# I'll call these "matched pairs".
# The matched pairs are the keystones of this problem.
# I need to sort the items between the matched pairs
# in a particular way.
# There's a "from number" and a "to number"
extension SomeClass {
func getLowOrHighNum(numA: Int?, numB: Int?, lowOrHigh: String) -> Int? {
let numArray = [numA, numB].filter({ $0 != nil});
return numArray.sort(
lowOrHigh == "low" ? { $0! < $1} : {$0! > $1 }
).first!!;
}
}

Keybase proof

I hereby claim:

  • I am masukomi on github.
  • I am masukomi (https://keybase.io/masukomi) on keybase.
  • I have a public key whose fingerprint is D438 8455 A3D2 5EEF 5BD9 0DDC 906B 307D DE60 0AF9

To claim this, I am signing this object:

We use a simple shell script like the one below. You'd, obviously, have to tweak it somewhat to tell it about the different file names and decide which box to look for which on but you get the basic idea. In our case we are tailing a file at the same location on multiple boxes. This requires ssh authentication via stored keys instead of typing in passwords.

#!/bin/bash
FILE=$1
for box in box1.foo.com box2.foo.com box3.foo.com box4.foo.com; do
     ssh $box tail -f $FILE &

done

#!/bin/sh
#installs ncurses 6.0 on os x
curl -O ftp://ftp.gnu.org/gnu/ncurses/ncurses-6.0.tar.gz
tar -xzvf ncurses-6.0.tar.gz
cd ./ncurses-6.0
./configure --prefix=/usr/local \
--without-cxx --without-cxx-binding --without-ada --without-progs --without-curses-h \
--with-shared --without-debug \