View generic
user name@example.com |
View ere2bre
#!/usr/bin/env awk -f | |
# usage: ere2bre <ere> | |
function bracket( \ | |
pattern, i, \ | |
c, c2, term, len, end \ | |
) { | |
++i # skip opening bracket | |
if (substr(pattern, i, 1) == "]") ++i # skip right bracket |
View shallow-clone
#!/bin/sh | |
# usage: shallow-clone <url> [ref] | |
url=$1 | |
ref=$2 | |
repo=$(basename "$url" .git) | |
head=$(git ls-remote "$url" HEAD | tail -n1 | cut -f1) | |
if [ ! "$head" ]; then exit 1; fi | |
if [ "$ref" ]; then | |
id=$(git ls-remote "$url" "$ref" "$ref^{}" | tail -n1 | cut -f1) | |
else |
View icloud-download
#!/usr/bin/env python3 | |
# Install | |
# 1. Install dependency: `pip3 install --user pyicloud` | |
# 2. Sign in to iCloud: `icloud --username your@email.com` | |
# 3. Copy file to somewhere in your `PATH` | |
# 4. Add `alias icloud-download="ICLOUD_EMAIL=your@email.com icloud-download"` | |
# to ~/.profile or ~/.bashrc, etc | |
# 5. Use via eg. `icloud-download Documents/folder` | |
# which will download `folder` to your current directory |
View vm.sh
# Add to ~/.profile or ~/.bashrc, etc | |
# Use it like: | |
# vm add ubuntu # or vm add ubuntu custom/ubuntu | |
# vm sh ubuntu | |
# <ctrl-d> to detach from shell | |
# vm sh ubuntu # returns to the same shell | |
# vm stop ubuntu && vm rm ubuntu | |
vm() { | |
case $1 in | |
ls) docker ps -a ;; |
View build-nginx-module.sh
#!/bin/sh | |
# A script to build a dynamic Nginx module with the correct configure options. | |
dir="$1" | |
if [ ! "$dir" ]; then | |
echo "usage: $0 module_dir" >&2 | |
exit 1 | |
fi |
View escape-strings.sh
#!/bin/sh | |
# Functions to escape strings for use in utilities like grep, sed and ex | |
# Examples | |
# grep "$(bre "$foo")" file | |
# sed "s/$(ptrn "$foo")/$(repl "$bar")/g" file | |
# echo "s/$(exptrn "$foo")/$(exrepl "$bar")/g | %p | q" | ex file | |
bre() { |
View freebsd-vmware.sh
#!/bin/sh | |
username=$1 | |
if [ ! "$username" ]; then | |
echo usage: $0 username >&2 | |
exit 1 | |
fi | |
if [ "`id -u`" != 0 ]; then |
View schotter.c
/* | |
* Copyright (c) 2018, Salvatore Sanfilippo <antirez at gmail dot com> | |
* All rights reserved. | |
* | |
* Redistribution and use in source and binary forms, with or without | |
* modification, are permitted provided that the following conditions are met: | |
* | |
* * Redistributions of source code must retain the above copyright notice, | |
* this list of conditions and the following disclaimer. | |
* * Redistributions in binary form must reproduce the above copyright |
View matrix.c
#include <stdlib.h> | |
#include <time.h> | |
#include <windows.h> | |
#define WIDTH 80 | |
#define HEIGHT 40 | |
#define idx(x, y) ((x)+WIDTH*(y)) |
NewerOlder