Skip to content

Instantly share code, notes, and snippets.

# Remove logs older than 7 days ago
log_file="$1"
days=7
old_log_count=$(cat "$log_file" | cut -d ' ' -f 1,2,3 | awk '{print "date -d \"" $0 "\" +%s"}' | sh | awk -v days=$days -v date=$(date +%s) '{if ($1 < date - 86400 * days) print $0}' | wc -l)
[ $old_log_count -gt 0 ] && sed -i "1,${old_log_count}d" "$log_file"
#!/bin/zsh
LC_CTYPE="en_US.UTF-8"
file=/Users/lliu/dev/icons/Automation/auto.png
printf "\u263C" | convert -size 1024x1024 -background green -fill white -pointsize 800 \
-gravity center label:@- $file
open $file
@happylance
happylance / prepare_icons.sh
Last active October 4, 2019 02:56 — forked from Lerg/prepare_icons.sh
Make all app icons with imagemagick, iOS and Android
#!/bin/sh
# https://gist.github.com/Lerg/b0a643a13f751747976f
base=$1
if [ -z $base ]
then
echo No argument given
else
##
## iOS files
@happylance
happylance / swiftShebang
Last active February 14, 2016 04:46
Shebang for swift with relative library path
#!/usr/bin/awk BEGIN{a=ARGV[1];sub("[A-z_.]+$","Carthage/Build/Mac",a);system("/usr/bin/env\tswift\t-F\t"a"\t"ARGV[1])}
@happylance
happylance / retry.sh
Created January 28, 2016 15:18
Retry a failed task automatically
#!/bin/bash
set -e
retry_count=3
task() {
echo $i
[ $1 -ge 2 ]
}
for i in $(seq 1 $retry_count)
@happylance
happylance / bubu.sh
Last active January 9, 2016 21:02 — forked from boogah/ale.bash
Never think about maintaining your homebrew install again with this shitty (but useful) shell script & cron job!
#!/bin/bash
echo ""
echo "`date`: RUNNING: brew update"
/usr/local/bin/brew update
echo "`date`: FINISHED: brew update"
echo ""