Ben's Blog

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.

Posts pagination

← Previous 1 … 96 97 98 … 119 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
  • Books3
  • I.T.202
    • 3D modeling / printing21
    • AI6
    • all out geekery36
    • electronics27
    • homestead automation6
    • maniacal paranoia25
    • plotters49
    • unix / linux29
    • video games4
    • web development29
    • web games3
  • Lego / Duplo67
  • life in the U.S.42
  • miscellaneous202
  • nature encounters114
  • old vinyls3
  • organs2
  • self sustainability560
    • agriculture105
    • apiculture38
    • apple20
    • building131
    • canning3
    • crochet6
    • foraging6
    • hunting10
    • maple syrup47
    • poultry39
    • preserving2
    • solar power28
    • water23
    • wood84
  • trip to a new life6
Theme by Bloompixel. Proudly Powered by WordPress