Put this shell script somewhere in your path and run it by feeding it value/label pairs like this:
$ bars
10 one
20 two
30 three
#!/usr/bin/env bash | |
# Cut some text into smaller snippets without cutting words in half | |
# | |
# @param ... - text to cut (optional) | |
snip() | |
{ | |
local TEXT=${*:-$(cat)} LIMIT=${LIMIT:-140} GLUE=${GLUE:-'..'} | |
(( LIMIT -= ${#GLUE} )) |
#!/usr/bin/env bash | |
# Post a tweet | |
# | |
# @param ... - tweet | |
tweet() | |
{ | |
# Make a SSL request | |
# | |
# @param ... - request arguments |
#!/usr/bin/env bash | |
# Generate a pseudo UUID | |
uuid() | |
{ | |
local N B C='89ab' | |
for (( N=0; N < 16; ++N )) | |
do | |
B=$(( $RANDOM%256 )) |
#include <stdio.h> | |
#include <stdlib.h> | |
/** | |
* Create random UUID | |
* | |
* @param buf - buffer to be filled with the uuid string | |
*/ | |
char *random_uuid( char buf[37] ) | |
{ |
#include <arpa/inet.h> | |
#include <string.h> | |
#include <unistd.h> | |
#include <netdb.h> | |
/** | |
* Local IP address | |
* | |
* @param buf - buffer to take ip address | |
* @param len - length of buffer |
#!/usr/bin/env bash | |
# Send UPnP message | |
# | |
# @param 1 - host:port/query (optional when UPNP_URL is set) | |
# @param 2 - service#action (optional when UPNP_ACTION is set) | |
# @param 3 - message arguments in XML format (optional) | |
upnp_send() | |
{ | |
# prefer arguments over presets |
#ifndef _androidlog_h_ | |
#define _androidlog_h_ | |
#include <android/log.h> | |
#define LOG_TAG "your_tag_here" | |
#define LOGI(...) ((void)__android_log_print(ANDROID_LOG_INFO, LOG_TAG, __VA_ARGS__)) | |
#define LOGW(...) ((void)__android_log_print(ANDROID_LOG_WARN, LOG_TAG, __VA_ARGS__)) | |
#define LOGE(...) ((void)__android_log_print(ANDROID_LOG_ERROR, LOG_TAG, __VA_ARGS__)) |