Skip to content

Instantly share code, notes, and snippets.

#include <stdio.h>
#include <sys/param.h>
#include <sys/sysctl.h>
int
main (int argc, char **argv)
{
int mp, mib[2] = { CTL_KERN, KERN_MAXPROC };
size_t len = sizeof(mp);
#include <stdio.h>
#include <time.h>
#include <sys/param.h>
#include <sys/sysctl.h>
int
main()
{
time_t uptime;
#
# Find Last Weekday of the Month
#
use DateTime;
my $dt = DateTime->last_day_of_month( year => 2009, month => 5 );
# Day 6 is Saturday, Day 7 is Sunday
while ( $dt->day_of_week >= 6 ) { $dt->subtract( days => 1 ) }
print "Last Weekday is ", $dt->ymd, "\n";
// O(1) in both time and space
unsigned fibonacci(unsigned n)
{
double s5 = sqrt(5.0);
double phi = (1.0 + s5) / 2.0;
double left = pow(phi, (double)n);
double right = pow(1.0-phi, (double)n);
return (unsigned)((left - right) / s5);
#!/bin/sh
#
# $FreeBSD$
#
# If there is a global system configuration file, suck it in.
#
if [ -r /etc/defaults/periodic.conf ]
then
@skreuzer
skreuzer / perlmodver
Created August 9, 2010 13:33
Display the version of a Perl module
#!/usr/bin/perl
use strict;
foreach my $module ( @ARGV ) {
eval "require $module";
printf( "%-20s: %s\n", $module, $module->VERSION ) unless ( $@ );
}
#!/usr/bin/perl -w
use XML::Parser;
use strict;
if(!@ARGV) {
print STDERR "Give me a file to parse.\n";
exit 1;
}
@skreuzer
skreuzer / pushkey
Created August 9, 2010 14:04
Push ssh keys to a new host
#!/bin/sh
# Check if an argument was given.
if [ ! "${1}" ] ; then
echo "No hostname provided" > /dev/stderr
exit 1
fi
if [ ! "${2}" ]; then
KEYFILE=~/.ssh/id_rsa.pub
#!/usr/bin/perl
use strict;
use warnings;
use YAML::Tiny;
use Data::Dumper;
if(!@ARGV) {
print STDERR "Give me a file to parse.\n";
int latchPin = 8;
int clockPin = 12;
int dataPin = 11;
int number[] = {63, 6, 91, 79, 102, 109, 124, 7, 127, 103};
void setup() {
//set pins to output so you can control the shift register
pinMode(latchPin, OUTPUT);
pinMode(clockPin, OUTPUT);