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 →

Recent Posts

  • Red Shouldered Hawk
  • Protected: 2026 Fireflies
  • Gondola PlottyBot v2
  • Corkscrew Sounds a Mystery no Longer
  • Copper

Recent Comments

  1. ben on PlottyBot
  2. Selmo B on PlottyBot
  3. santry on Gondola PlottyBot v2
  4. santry on Built Me Another
  5. ben on Built Me Another

Archives

  • June 2026
  • May 2026
  • April 2026
  • March 2026
  • February 2026
  • January 2026
  • December 2025
  • November 2025
  • October 2025
  • September 2025
  • August 2025
  • July 2025
  • June 2025
  • May 2025
  • April 2025
  • March 2025
  • February 2025
  • January 2025
  • December 2024
  • November 2024
  • October 2024
  • September 2024
  • August 2024
  • July 2024
  • June 2024
  • May 2024
  • April 2024
  • March 2024
  • February 2024
  • January 2024
  • December 2023
  • November 2023
  • October 2023
  • September 2023
  • August 2023
  • July 2023
  • June 2023
  • May 2023
  • April 2023
  • March 2023
  • January 2023
  • December 2022
  • November 2022
  • October 2022
  • September 2022
  • August 2022
  • July 2022
  • June 2022
  • May 2022
  • April 2022
  • March 2022
  • February 2022
  • January 2022
  • December 2021
  • November 2021
  • October 2021
  • September 2021
  • August 2021
  • July 2021
  • June 2021
  • May 2021
  • April 2021
  • March 2021
  • February 2021
  • January 2021
  • December 2020
  • November 2020
  • October 2020
  • September 2020
  • August 2020
  • July 2020
  • June 2020
  • May 2020
  • April 2020
  • March 2020
  • February 2020
  • January 2020
  • December 2019
  • November 2019
  • October 2019
  • September 2019
  • August 2019
  • July 2019
  • June 2019
  • May 2019
  • April 2019
  • March 2019
  • February 2019
  • January 2019
  • December 2018
  • November 2018
  • October 2018
  • September 2018
  • August 2018
  • July 2018
  • June 2018
  • May 2018
  • April 2018
  • March 2018
  • February 2018
  • January 2018
  • December 2017
  • November 2017
  • October 2017
  • September 2017
  • August 2017
  • July 2017
  • June 2017
  • May 2017
  • April 2017
  • March 2017
  • February 2017
  • January 2017
  • December 2016
  • November 2016
  • October 2016
  • September 2016
  • August 2016
  • July 2016
  • June 2016
  • May 2016
  • April 2016
  • March 2016
  • February 2016
  • January 2016
  • December 2015
  • November 2015
  • October 2015
  • September 2015
  • August 2015
  • July 2015
  • June 2015
  • May 2015
  • April 2015
  • March 2015
  • February 2015
  • January 2015
  • December 2014
  • November 2014
  • October 2014
  • September 2014
  • August 2014
  • July 2014
  • June 2014
  • May 2014
  • April 2014
  • March 2014
  • February 2014
  • January 2014
  • December 2013
  • November 2013
  • October 2013
  • September 2013
  • August 2013
  • July 2013
  • June 2013
  • May 2013
  • April 2013
  • March 2013
  • February 2013
  • January 2013
  • December 2012
  • November 2012
  • October 2012
  • September 2012
  • August 2012
  • July 2012
  • June 2012
  • May 2012
  • April 2012
  • March 2012
  • February 2012
  • December 2011
  • November 2011
  • October 2011
  • September 2011
  • August 2011
  • July 2011
  • May 2011
  • April 2011
  • February 2011
  • January 2011
  • December 2010
  • November 2010
  • October 2010
  • September 2010
  • August 2010
  • July 2010
  • March 2010
  • December 2009
  • October 2009
  • September 2009
  • August 2009
  • June 2009
  • May 2009

Categories

  • 3D modeling / printing
  • aesthetics
  • agriculture
  • AI
  • all out geekery
  • apiculture
  • apple
  • Books
  • building
  • canning
  • crochet
  • electronics
  • foraging
  • homestead automation
  • hunting
  • I.T.
  • Lego / Duplo
  • life in the U.S.
  • maniacal paranoia
  • maple syrup
  • miscellaneous
  • nature encounters
  • old vinyls
  • organs
  • plots
  • plotters
  • poultry
  • preserving
  • self sustainability
  • solar power
  • specular holography
  • trip to a new life
  • unix / linux
  • video games
  • water
  • web development
  • web games
  • wood
Theme by Bloompixel. Proudly Powered by WordPress