Skip to content

Instantly share code, notes, and snippets.

@stfnm
stfnm / nickometer.pl
Created November 12, 2012 10:35
Nickometer
#!/usr/bin/perl -w
#
# Lame-o-Nickometer backend
#
# (c) 1998 Adam Spiers <adam.spiers@new.ox.ac.uk>
#
# You may do whatever you want with this code, but give me credit.
#
# $Id: nickometer.pl,v 1.3 1998/09/05 19:58:15 adam Exp $
#
From 61cc757f0b9df0437a95c039bfc3d01ef0412809 Mon Sep 17 00:00:00 2001
From: simon <simon@cda61777-01e9-0310-a592-d414129be87e>
Date: Sun, 19 Feb 2012 10:27:18 +0000
Subject: [PATCH] Patch from Matsui Nag to implement xterm's "bracketed paste
mode", in which text pasted into the terminal is preceded
and followed by special function-key-like escape sequences
ESC[200~ and ESC[201~ so that the application can identify
it and treat it specially (e.g. disabling
auto-indent-same-as-previous-line in text editors). Enabled
and disabled by ESC[?2004h and ESC[?2004l, and of course
template<typename TO, typename FROM>
TO lexi_cast(const FROM& from) {
std::stringstream s;
TO to;
s << from;
s >> to;
return to;
}
// e.g.:
@stfnm
stfnm / hostname.c
Created February 9, 2012 10:47
hostname.c options
static struct argp_option argp_options[] = {
#define GRP 0
{"aliases", 'a', NULL, 0, "alias names", GRP+1},
{"domain", 'd', NULL, 0, "DNS domain name", GRP+1},
{"file", 'F', "FILE", 0, "set host name or NIS domain name from FILE",
GRP+1},
{"fqdn", 'f', NULL, 0, "DNS host name or FQDN", GRP+1},
{"long", 'f', NULL, OPTION_ALIAS, "DNS host name or FQDN", GRP+1},
{"ip-addresses", 'i', NULL, 0, "addresses for the host name", GRP+1},
{"short", 's', NULL, 0, "short host name", GRP+1},
@stfnm
stfnm / sysuptime.pl
Created January 2, 2012 09:46
win32 sysuptime
use strict;
use Win32;
my $time = Win32::GetTickCount();
my $days = int($time / 1000 / 60 / 60 / 24);
my $hours = int(($time = ($time - $days * 1000 / 60 / 60 / 24)) / 1000 / 60 / 60);
my $min = int(($time = ($time - $hours * 1000 * 60 * 60)) / 1000 / 60);
my $sec = int(($time = ($time - $min * 1000 * 60)) / 1000);
print "System uptime: $days days, $hours hours, $min minutes, $sec seconds\n";