Ben's Blog

nature encounters ben June 26, 2014

Luna Moth

IMG_0051

 

life in the U.S., miscellaneous ben June 18, 2014

Summer in VT is pretty crazy

weird noises, lightning bugs, thunderstorms and giant moths.

Hey pssssssssst! Let me in! I want to snuggle. luna_moth

 

Wikipedia

self sustainability ben June 15, 2014

Protected: It ain't easy being cheap

This content is password-protected. To view it, please enter the password below.

I.T. ben June 11, 2014

iPXE booting with vlan support

Getting a version of iPXE that supports vlans

Download

ipxe_with_vlan_support_2014-06-12.iso

Build it yourself

[code]
git clone git://git.ipxe.org/ipxe.git
cd ipxe/src
sed -i ‘s///#define VLAN_CMD/#define VLAN_CMD/’ config/general.h
make
[/code]

There is multiple ways you can use your compiled binary, for testing just mounting bin/ipxe.iso and booting from it is good.

Using it

Boot from the ROM/ISO.

CTRL+B to get a command line when prompted.

Then assuming a desired vlan ID of 123:

[code]
vcreate –tag 123 net0
dhcp net0-123
chain tftp://${next-server}/${filename}
[/code]

self sustainability, trip to a new life ben May 11, 2014

Acres

In what is probably the biggest step taken towards our dream, we just bought a chunk of land of ~50 acres.

We have little money left to do anything with it at the moment but we’ll throw a house on it in due time. We are cleaning it up in the mean time.

It is an invigorating feeling to stare at your life goal.

IMG_3601

IMG_3583

apiculture, self sustainability ben May 11, 2014

Let's hope for a better season

 

IMG_3499

IMG_3501

IMG_3554

poultry, self sustainability ben May 11, 2014

biodegradation – the chicken difference

Without chickens

IMG_3470

 

With chickens

IMG_3471

I.T., web development ben April 16, 2014

PHP 2-dimensional array sorting algorithms

For 2-dimensional arrays looking like:

[code]
Array
(
[0] => Array
(
[id] => 1
[name] => roger
[age] => 31
)

[1] => Array
(
[id] => 2
[name] => brutus
[age] => 24
)

[2] => Array
(
[id] => 3
[name] => ganesh
[age] => 92
)

)
[/code]

I find that comb sort is usually the fastest but its worst case is much worst than quick sort so it could become a bottleneck depending on your data.

[php]
<?php

ini_set( ‘memory_limit’, ‘128M’ ) ;

/**
* @desc bubble_sort for 2 dimensional array (all the arrays of the 2nd dimension need to have the field $sort_by)
* @param array^2 $data the array of arrays
* @param string $sort_by the parameter that will be used for comparison
* @param string $sort_direction "asc": ascending, "desc": descending
*/
function bubble_sort( $data, $sort_by, $sort_direction ) {
if( $sort_direction==’asc’ ) {
for( $i=1 ; $i<count($data) ; $i++ ) {
for( $j=1 ; $j<count($data) ; $j++ ) {
if( $data[$j-1][$sort_by]>$data[$j][$sort_by] ) {
$temp = $data[$j-1] ;
$data[$j-1] = $data[$j] ;
$data[$j] = $temp ;
}
}
}
} else {
for( $i=1 ; $i<count($data) ; $i++ ) {
for( $j=1 ; $j<count($data) ; $j++ ) {
if( $data[$j-1][$sort_by]<$data[$j][$sort_by] ) {
$temp = $data[$j-1] ;
$data[$j-1] = $data[$j] ;
$data[$j] = $temp ;
}
}
}
}
return $data ;
}

/**
* @desc comb_sort for 2 dimensional array (all the arrays of the 2nd dimension need to have the field $sort_by)
* @param array^2 $data the array of arrays
* @param string $sort_by the parameter that will be used for comparison
* @param string $sort_direction "asc": ascending, "desc": descending
*/
function comb_sort( $data, $sort_by, $sort_direction ) {
$gap = count( $data ) ;
$swaps = -1 ;
while( !($gap<=1 && $swaps==0) ) {
if( $gap>1 ) {
$gap = $gap/1.3 ;
if( $gap==10 || $gap==9 ) {
$gap = 11 ;
}
}
$i = 0 ;
$swaps = 0 ;
while( !(($i+$gap)>=count($data)) ) {
if( ($sort_direction==’asc’ && $data[$i][$sort_by]>$data[$i+$gap][$sort_by]) ||
($sort_direction==’desc’ && $data[$i][$sort_by]<$data[$i+$gap][$sort_by]) ) {
$temp = $data[$i] ;
$data[$i] = $data[$i+$gap] ;
$data[$i+$gap] = $temp ;
$swaps = 1 ;
}
$i++ ;
}
}

return $data ;
}

/**
* @desc quick_sort for 2 dimensional arrays (all the arrays of the 2nd dimension need to have the field $sort_by)
* @param array^2 $data the array of arrays
* @param string $sort_by the parameter that will be used for comparison
* @param string $sort_direction "asc": ascending, "desc": descending
*/
function quick_sort( $data, $sort_by, $sort_direction ) {
if( count($data)<=1 || $sort_by==” ) {
return $data ;
} else {
$pivot = $data[0][$sort_by] ;
$x = $y = array() ;
for( $i=1 ; $i<count($data) ; $i++ ) {
if( $data[$i][$sort_by]<$pivot ) {
if( $sort_direction=="asc" ) {
$x[] = $data[$i] ;
} else {
$y[] = $data[$i] ;
}
} else {
if( $sort_direction=="asc" ) {
$y[] = $data[$i] ;
} else {
$x[] = $data[$i] ;
}
}
}
return array_merge( quick_sort($x, $sort_by, $sort_direction), array($data[0]), quick_sort($y, $sort_by, $sort_direction) ) ;
}
}
?>
[/php]

nature encounters ben April 04, 2014

Coyote

coyote

I.T., unix / linux ben April 02, 2014

Gnuplot one-liner from Hell

Here’s a convenient one liner to chronologically plot data on the command line

Screenshot

Screen Shot 2014-04-02 at 11.18.44 AM

Command

[bash]

export width=`stty size | cut -d " " -f2`; export height=`stty size | cut -d " " -f1`-10; cat /tmp/data | sed "s/ /T/" | gnuplot -e "set terminal dumb $width $height; set autoscale; set xdata time; set timefmt \"%Y-%m-%dT%H:%M:%S\"; set xlabel \"time\"; set ylabel \"counter\"; plot ‘-‘ using 1:2 with lines"

[/bash]

Data

/tmp/data contains the following:

[code]2000-01-01 00:00:00 1
2000-01-01 01:00:00 2
2000-01-01 02:00:00 3
2000-01-01 03:00:00 2
2000-01-01 04:00:00 3
2000-01-01 05:00:00 4
2000-01-01 06:00:00 5
2000-01-01 07:00:00 4
2000-01-01 08:00:00 3
2000-01-01 09:00:00 4
2000-01-01 10:00:00 4
2000-01-01 11:00:00 5
2000-01-01 12:00:00 4
2000-01-01 13:00:00 4
2000-01-01 14:00:00 3
2000-01-01 15:00:00 2
2000-01-01 16:00:00 3
2000-01-01 17:00:00 4
2000-01-01 18:00:00 4
2000-01-01 19:00:00 5
2000-01-01 20:00:00 6
2000-01-01 21:00:00 6
2000-01-01 22:00:00 7
2000-01-01 23:00:00 8
2000-01-02 00:00:00 7
2000-01-02 01:00:00 7
2000-01-02 02:00:00 6
2000-01-02 03:00:00 8
2000-01-02 04:00:00 9
2000-01-02 05:00:00 9
2000-01-02 06:00:00 9
2000-01-02 07:00:00 8
2000-01-02 08:00:00 7
2000-01-02 09:00:00 5
2000-01-02 10:00:00 4
2000-01-02 11:00:00 4
2000-01-02 12:00:00 4
2000-01-02 13:00:00 3
2000-01-02 14:00:00 2
2000-01-02 15:00:00 2
2000-01-02 16:00:00 1[/code]

poultry, self sustainability ben March 30, 2014

Chickens ain't dumb

IMG_3132

miscellaneous ben March 26, 2014

Why yes Amazon

I wish to share my buying with all of facebook, twitter and email.

Screen Shot 2014-03-26 at 1.36.01 PMGUESS WHAT GUYS? I just bought a ‘PS2 Keyboard to USB Adapter’! That’s right! I bet you’re jonesing all the crap I buy.

In all fairness I did just blog about it.

life in the U.S., self sustainability ben February 17, 2014

Snow

IMG_0503

 

self sustainability, wood ben February 02, 2014

Sexy!

It still needs a bit of work.

IMG_2744

I.T., poultry, self sustainability ben January 08, 2014

Staying warm under the heat lamp

chickengif

Lego / Duplo ben December 24, 2013

Protected: Cool Duplo Project #07 – Slippers

This content is password-protected. To view it, please enter the password below.

Lego / Duplo ben December 24, 2013

Protected: Cool Duplo Project #06 – Portal to Another Universe

This content is password-protected. To view it, please enter the password below.

Lego / Duplo ben December 06, 2013

Cool Duplo Project #05 – The Tallest Tower in the World

IMG_1760

 

Lego / Duplo ben December 06, 2013

Protected: Cool Duplo Project #04 – Hacked Train

This content is password-protected. To view it, please enter the password below.

Lego / Duplo ben December 06, 2013

Protected: Cool Duplo Project #03 – Spinning Tops

This content is password-protected. To view it, please enter the password below.

Lego / Duplo ben December 06, 2013

Cool Duplo Project #02 – Toy Carts

IMG_1535

IMG_1450

Lego / Duplo ben December 06, 2013

Protected: Cool Duplo Project #01 – Monocular

This content is password-protected. To view it, please enter the password below.

miscellaneous ben December 05, 2013

A liability of inheriting books from religious family members

The cognitive dissonance is so strong with that one it took my brain minutes to accept what was going on. Trying to find every other possible explanations between the moment of surprise and the moment of acceptance.

The classic replacing “trillions” by “thousands”.

IMG_0814

White-out can fix Satan’s science (no copyright, feel free to use this in your next advertisement campaign).

IMG_0815

Homo Erectus is getting a free upgrade & a skirt!

IMG_0816

Censorship: a tool that is always on the right side of history.

Posts pagination

← Previous 1 … 42 43 44 … 52 Next →

This blog is solar powered

Interactive

Handwriting Capture
Mandalagaba
IPv6 link-local to MAC converter
IPv6 MAC to link-local converter
Markov Text Generation
Markov Word Generation
Markov Music Generation
Duplogrifier
Flood Fill Algorithms
Homestead Metrics
RGB Playground
Web Games

Categories

  • aesthetics111
    • plots54
    • specular holography6
  • Books4
  • I.T.203
    • 3D modeling / printing21
    • AI6
    • all out geekery36
    • electronics27
    • homestead automation6
    • maniacal paranoia26
    • plotters49
    • unix / linux29
    • video games4
    • web development29
    • web games3
  • Lego / Duplo67
  • life in the U.S.42
  • miscellaneous204
  • nature encounters115
  • old vinyls3
  • organs2
  • self sustainability563
    • agriculture107
    • apiculture38
    • apple20
    • building132
    • canning3
    • crochet6
    • foraging6
    • hunting10
    • maple syrup47
    • poultry39
    • preserving2
    • solar power28
    • water23
    • wood84
  • trip to a new life6
Theme by Bloompixel. Proudly Powered by WordPress