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
#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); |
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
#include <stdio.h> | |
#include <time.h> | |
#include <sys/param.h> | |
#include <sys/sysctl.h> | |
int | |
main() | |
{ | |
time_t uptime; |
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
# | |
# 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"; |
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
// 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); |
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 | |
# | |
# $FreeBSD$ | |
# | |
# If there is a global system configuration file, suck it in. | |
# | |
if [ -r /etc/defaults/periodic.conf ] | |
then |
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 strict; | |
foreach my $module ( @ARGV ) { | |
eval "require $module"; | |
printf( "%-20s: %s\n", $module, $module->VERSION ) unless ( $@ ); | |
} |
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 -w | |
use XML::Parser; | |
use strict; | |
if(!@ARGV) { | |
print STDERR "Give me a file to parse.\n"; | |
exit 1; | |
} |
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 | |
# 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 |
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 strict; | |
use warnings; | |
use YAML::Tiny; | |
use Data::Dumper; | |
if(!@ARGV) { | |
print STDERR "Give me a file to parse.\n"; |
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
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); |
OlderNewer