Skip to content

Instantly share code, notes, and snippets.

View hostmaster's full-sized avatar
:dependabot:
Drone pilot at work

Igor Khomyakov hostmaster

:dependabot:
Drone pilot at work
  • Sweden
  • 02:00 (UTC +02:00)
View GitHub Profile
@hostmaster
hostmaster / gist:3720382
Created September 14, 2012 07:05
ipset install log
[user@workstation ~]% lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 12.04.1 LTS
Release: 12.04
Codename: precise
[user@workstation ~]% sudo apt-get install ipset
Reading package lists... Done
Building dependency tree
Reading state information... Done
@hostmaster
hostmaster / gist:4147748
Created November 26, 2012 11:27
A perl script that helps sum up OpenVZ container memory usage
#!/usr/bin/perl
use strict;
use warnings;
# Author: David J. Weller-Fahy
# Inspired by
# Placed in the public domain
my($field, $res_bytes, $res_pages, $value, $total);
@hostmaster
hostmaster / gist:4156129
Created November 27, 2012 18:39
transformable_request
int
transformable_request (TSHttpTxn txnp)
{
TSMBuffer req_bufp;
TSMLoc req_loc;
TSMLoc field_loc;
const char* user_agent_value = NULL;
int user_agent_length = -1;
@hostmaster
hostmaster / check
Created January 11, 2013 16:18
kind of that
//
if (TSHttpTxnClientReqGet(txnp, &req_bufp, &req_loc) != TS_SUCCESS) {
TSError("couldn't retrieve client request header\n");
return 0;
}
length_field_loc = TSMimeHdrFieldFind(req_bufp, req_loc, TS_MIME_FIELD_CONTENT_LENGTH, TS_MIME_LEN_CONTENT_LENGTH);
if (length_field_loc) {
TSMimeHdrDestroy(req_bufp, length_field_loc);
@hostmaster
hostmaster / cl-fix.cc
Last active December 11, 2015 02:19
Adjust content length
length_field_loc = TSMimeHdrFieldFind(bufp, hdr_loc, TS_MIME_FIELD_CONTENT_LENGTH, TS_MIME_LEN_CONTENT_LENGTH);
if (length_field_loc) {
content_length = TSMimeHdrFieldValueUintGet(bufp, hdr_loc, length_field_loc, 0);
TSDebug(DBG_TAG, "Content-Length was: %u", content_length);
new_content_length = content_length + delta;
TSMimeHdrFieldValuesClear(bufp, hdr_loc, length_field_loc);
TSMimeHdrFieldValueUintInsert(bufp, hdr_loc, length_field_loc, -1, new_content_length);
// check value
@hostmaster
hostmaster / bnull-transform.cc
Last active December 11, 2015 21:38
bnull-transform.cc chunked
static int
handle_buffering(TSCont contp, MyData * data) {
TSVIO write_vio;
int towrite, towriteLeft, avail;
/* Create the output buffer and its associated reader */
if (!data->output_buffer) {
data->output_buffer = TSIOBufferCreate();
TSAssert(data->output_buffer);
data->output_reader = TSIOBufferReaderAlloc(data->output_buffer);
#{
# "kind": "urlshortener#url",
# "id": "http://goo.gl/lUmqp",
# "longUrl": "http://drops.from-me.org/"
#}
curl --silent https://www.googleapis.com/urlshortener/v1/url -H 'Content-Type: application/json' -d "{'longUrl': 'http://drops.from-me.org/$ofname'}" | awk -F\" '/"id"/ { printf "%s", $4 } ' | pbcopy
pid = /var/run/stunnel.pid
socket = a:SO_REUSEADDR=1
socket = l:TCP_NODELAY=1
socket = r:TCP_NODELAY=1
debug = 2
[ssl_frontend]
client = no
key = /WOO/server1024.key
cert = /WOO/server1024.crt
@hostmaster
hostmaster / iostat.sh
Created April 2, 2013 10:57
format iostat output
iostat -x 1 | awk 'BEGIN { count=0 } /^sd[a-d]/ { if (count == 0) print "Disk\tawait\tsvctm\t%util"; if (count <= 10) { count++ } else { count=0 }; printf( "%s\t%d\t %d\t%d\n", $1 ,$10 , $11, $12); }'
@hostmaster
hostmaster / zlogin
Created April 8, 2013 11:52
print list of screen sessions
screen -q -ls
if [ "$?" -gt 10 ]; then
echo
screen -ls
fi