Update: 2023/11/30 Bruce Momjian's take on things: https://momjian.us/main/blogs/pgblog/2023.html#November_22_2023
Given a table...
CREATE TABLE foo (
id SERIAL PRIMARY KEY,
created_at TIMESTAMP WITH TIME ZONE DEFAULT NOW(),
...
);
#!/bin/bash | |
# Check swap usage of Erlang VMs | |
for p in $(ps -e | grep beam | cut -d" " -f 1); do | |
SWAP=$(grep "Swap:" /proc/${p}/smaps | awk '{swap = swap + $2} END {print swap}') | |
CMDPREFIX=$(head -c 100 /proc/${p}/cmdline) | |
printf "PID ${p} SWAP %dKB CMDPREFIX '%s...'\n" ${SWAP} ${CMDPREFIX} | |
done |
-module(map). | |
-export([map/1, | |
to_base_62/1, | |
test/1]). | |
%% | |
%% @doc Deterministically map a linear integer sequence to a non-linear sequence. | |
%% | |
-spec map(N::non_neg_integer()) -> string(). |
Update: 2023/11/30 Bruce Momjian's take on things: https://momjian.us/main/blogs/pgblog/2023.html#November_22_2023
Given a table...
CREATE TABLE foo (
id SERIAL PRIMARY KEY,
created_at TIMESTAMP WITH TIME ZONE DEFAULT NOW(),
...
);
PostgreSQL 9.1 does not support the JSON datatype.
I want to use the HSTORE column type for metadata which eventually will be returned as part of JSON encoded structure. Unfortunately PostgreSQL 9.1 does not have the funky JSON goodies (which are available from 9.2).
{ok, Cols, Rows} = dbutils:equery("select msisdn, operator, subscribe_datetime, uuid,
Taken from http://comments.gmane.org/gmane.comp.lang.erlang.general/15718 with minor fix:
reload_config(AppNames, ConfigFile) ->
{ok, [Config]} = file:consult(ConfigFile),
Apps = [{application, A, element(2,application:get_all_key(A))}
|| {A,_,_} <- application:which_applications()],
application_controller:change_application_data(Apps,Config).
#!/bin/bash | |
S3_LOG_LOCATION="s3://thelogbucket/logdir" | |
LOCAL_LOG_LOCATION="/tmp/log/" | |
REPORT_TITLE="My report title" | |
HTML_OUTPUT_DIR="/tmp/reporthtml" | |
REPORT="/tmp/report.ps" | |
# Sync log files to a local directory | |
s3cmd -v sync ${S3_LOG_LOCATION} ${LOCAL_LOG_LOCATION} |
Example of how to calculate an HMAC signature using command line utilities:
echo -n "/path/subscribe?account_id=my_account&club_id=club%20id&msisdn=27820000000×tamp=2012-05-29T15%3A00%3A12Z" | openssl dgst -sha256 -hmac "secret_value" -binary | base64
#!/usr/bin/env php | |
<?php | |
$RENDER_URL = "https://api.github.com/markdown"; | |
$INPUT = $argv[1]; | |
$OUTPUT = $argv[2] | |
$payload["text"] = file_get_contents($INPUT); |
<?php | |
# | |
# This script provides an HTTP interface to carbon/graphite. | |
# The intention is that this script will | |
# [1] allow for easy integration with core apps, | |
# [2] can provide access control via Apache's authentication mechanisms. | |
# | |
function publish_data($path, $value, $timestamp) |
#!/bin/bash | |
# | |
# Utility to display JSON data in a pretty-printed, syntax highlighted form. | |
# If the data is not valid JSON, an error will be reported. | |
# | |
# An optional filename can be specified, otherwise input is read from stdin. | |
# | |
set -o pipefail |