This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
use warnings; | |
use strict; | |
my $val1; | |
if(($ARGV[0] // '') eq 'fixed') { | |
require Math::FixedPoint; | |
$val1 = Math::FixedPoint->new(2.1, 2); # fixed-point number | |
} else { | |
$val1 = 2.1; # floating point number |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Facter.add(:rpms) do | |
setcode do | |
gs = "\x1D" | |
rs = "\x1E" | |
us = "\x1F" | |
# see: | |
# "rpm --querytags" | |
# http://rpm5.org/docs/api/queryformat.html | |
# http://www.rpm.org/max-rpm/ch-queryformat-tags.html | |
rpmtags = { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Perform a fetch in a background worker thread, and use a mutex to safely grab chunks from the buffer. | |
* | |
* Usage: | |
* cc threadmutex.c -lcurl -lpthread -o threadmutex | |
* ./threadmutex | |
* | |
* Or, if curl will be using OpenSSL define "USE_OPENSSL": | |
* cc threadmutex.c -lcurl -lpthread -lcrypto -DUSE_OPENSSL -o threadmutex | |
* ./threadmutex |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
use warnings; | |
use strict; | |
sub chunk { sprintf "%x\x0D\x0A%s\x0D\x0A", length($_[0]), $_[0]; } | |
$|=1; | |
print "HTTP/1.1 200 Ok\x0D\x0A"; | |
print "Content-Type: text/html\x0D\x0A"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* HTTP POST with chunked encoding. | |
* | |
* Usage: | |
* cc chunkedpost.c -lcurl -o chunkedpost | |
* ./chunkedpost | |
* | |
*/ | |
#include <stdio.h> | |
#include <stdlib.h> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use warnings; | |
use strict; | |
use Win32::PingICMP; | |
use Socket qw/inet_ntoa/; | |
# The exact error strings as used by ping.exe | |
my %errors = ( | |
'IP_BUF_TOO_SMALL' => 'General failure.', | |
'IP_DEST_NET_UNREACHABLE' => 'Destination net unreachable.', | |
'IP_DEST_HOST_UNREACHABLE' => 'Destination host unreachable.', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* HTTP POST with authentiction using "basic" method. | |
* Hybrid of anyauthput.c and postinmemory.c | |
* Specifically adapted for SOAP use. | |
* | |
* Usage: | |
* cc basicauthsoap.c -lcurl -o basicauthsoap | |
* ./basicauthsoap | |
* | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
use warnings; | |
use strict; | |
use CGI qw/param escapeHTML/; | |
use MIME::Base64; | |
### Apache2's mod_cgi does not pass the HTTP__AUTHORIZATION header by default. | |
### Add this to .htaccess to work around the issue... | |
# RewriteEngine on | |
# RewriteCond %{HTTP:Authorization} ^(.*) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* HTTP POST with authentiction using "basic" method. | |
* Hybrid of anyauthput.c and postinmemory.c | |
* | |
* Usage: | |
* cc basicauthpost.c -lcurl -o basicauthpost | |
* ./basicauthpost | |
* | |
*/ | |
#include <stdio.h> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
((V=N=0)) | |
while :; do | |
((V<<=6,++N)) | |
IFS= read -n1 C && { | |
printf -vC '%d' "'$C" | |
((C=C>64&&C<91?C-65:C>96&&C<123?C-71:C>47&&C<58?C+4:C==43?62:C==47?63:(V>>=6,--N,0),V|=C)) | |
} | |
((N==4)) && { |