Add Scroogle to your search area in Firefox 2.0 Install the 'Scroogle Scraper' search plugin.

Screen Shot 2013-05-10 at 1.19.53 PMMaybe you’re giving a presentation and you’d like a quick “text your vote to this number” real-time poll. Maybe you don’t want to pay the commercial services out there and you have access to a php/mysql server. Here, below, below is some code to make your free poll become a reality. It’s based on this other open source text to vote system: https://github.com/rahims/Text-to-Vote and http://www.twilio.com/blog/2011/05/how-to-create-a-simple-sms-voting-system-using-php.html but instead of sqlite, my version uses MySQL:
handle_incoming_sms.php

<?php
	header('Content-type: text/xml');
	echo '<Response>';
	$phone_number = $_REQUEST['From'];
	$team_number = (int) $_REQUEST['Body'];
 
	if ( (strlen($phone_number) >= 10) && ($team_number > 0) )
	{
            $db=mysql_connect("localhost","user","pass");
            mysql_selectdb("database",$db);
            if (!$db)
            {
              echo "Failed to connect to MySQL: " . mysqli_connect_error();
            }
            $phone_number = mysql_real_escape_string($_REQUEST['From']);
            $team_number = mysql_real_escape_string($_REQUEST['Body']);
            $sql="insert into table set phone='".$phone_number."', team='".$team_number."'";
            $result=mysql_query($sql,$db);
            if (!$result) 
            {
   	        die('Invalid query: ' . mysql_error());
            }
	}
	else 
        {
		$response = 'Sorry, I didn\'t understand that. Text the team number to vote. For example, texting 1 will vote for Team 1.';
	}
 
	echo '<Sms>'.$response.'</Sms>';
	echo '</Response>';
?>

cat get_votes.php

<?php
     $db=mysql_connect("localhost","user","pass");
     mysql_selectdb("database",$db);
 
if (!$db)
  {
  echo "Failed to connect to MySQL: " . mysqli_connect_error();
  }
 
$sql="SELECT COUNT(CASE WHEN team = '1' THEN 1 ELSE NULL END) AS team1,
COUNT(CASE WHEN team = '2' THEN 1 ELSE NULL END) AS team2,
COUNT(CASE WHEN team = '3' THEN 1 ELSE NULL END) AS team3
FROM table";
$result=mysql_query($sql,$db);
                if (!$result)
                {
                         die('Invalid query: ' . mysql_error());
                }
$row = mysql_fetch_assoc($result);
$team1= $row['team1'];
$team2= $row['team2'];
$team3= $row['team3'];
$votes=array((int)$team1, (int)$team2, (int)$team3);
	echo json_encode($votes);
?>

elevatorDetractors of lateral/logic thinking puzzles for interview questions protest that the questions do not serve the purpose of the interview, which is ostensibly to identify those candidates who are likely to be valuable employees. “Some people aren’t good at puzzles!” or “They’ll just Google the answers beforehand and parrot them back to you!”

Others dislike difficult programming challenges in interviews, saying the problems do not reflect the type of real world problems one is likely to face. Who cares if I can find the longest string of increasing integers in a three dimensional array? What does that have to do with apartment management software?

Still more believe that the questions should focus on design skills rather than algorithmic prowess, “you can always Google the algorithm.”

It is with those objections that I present the Elevator Interview Question. It’s not new and generally goes something like, “Design a basic set of objects/methods to be used to simulate an elevator bank. What are the objects and their attributes/methods?”

Being able to show the Object Oriented design for an elevator bank in pseudo-code should satisfy those who demand good design. The follow up questions though, I feel are a combination of algorithmic and lateral thinking which could help spotlight those who are capable of deeply considering a problem.

  • How do you optimize the elevator system for availability?
  • How would variation of traffic over a typical work week, floor, or time of day affect this?
  • How would you test this optimization system?
  • What would be the effect of replacing the “up” and “down” buttons outside the elevator with floor buttons and removing the floor buttons in the elevators?
  • One elevator design has no doors (Paternoster) and constantly move either up or down. Is this a good idea?
  • How might technology help with the optimization (RFID tags on people), people counters outside of elevators?

What other follow up questions make the Elevator Design Dilemma an optimal interview question?

http://en.wikipedia.org/wiki/Elevator#Destination_control_system

http://www.reddit.com/r/compsci/comments/1at0zj/elevator_algorithm_questions/

http://dan-nolan.com/how-i-would-optimize-the-elevators-in-our-office-building/

http://www.angelfire.com/trek/software/elevator.html

http://www.acetheinterview.com/questions/guide_excerpts.pdf

http://danielparejaortiz.es/ascensores/documentos/dynamic%20optimization%20-%20I.pdf

http://codereview.stackexchange.com/questions/5723/c-code-for-oop-elevator-design-evaluation

http://www.cs.cmu.edu/~luluo/Courses/18540PhDreport.pdf

What do you do when you need a file from a remote linux server and that server has libcrypto and libssl messed up? Also, ftp client isn’t installed. Also, they don’t want you to install anything. also the file you need is very large?

ssh user@remotehost.example.com "cat somebigfile.tgz" > localcopyoffile.tgz

That’s it. As it turns out,

cp a b

is (for most purposes) equivalent to

cat a>b

Now you know. knowing is 1/2 the battle.

Once you have more than a few servers, you’ll find that you have lots of log files from things like apache, your dbms, java, etc. You’ll also find that when something goes wrong it’s very useful to be able to correlate those different logs. That means a centralized logging solution. (Open Source Splunk)

That’s where Splunk (http://www.splunk.com/) comes in. With Splunk, you ship your logs to a central server and it indexes those logs and allows you to search them in a sexy interface. Spunk is awesome. It’s also awesomely expensive. They charge you by the bandwidth of logs coming into the central server and it adds up very fast. Expect to spend many thousands of dollars, even for a couple of dozen servers per year. What’s worse, if your application gets suddenly log-chatty, or if someone DDOSs you, your Splunk will shutdown until you pay up to Splunk and they unlock it for you.

Fortunately there is the open source community. They’ve come out with some amazing tools that beat not only the functionality of Splunk, but it’s sweet user interface too.

  1. logstash for routing and mangling logs: logstash.net
  2. elasticsearch for log indexing: www.elasticsearch.org
  3. kibana as a query interface for elasticsearch logs: kibana.org

Other related reading:

  1. http://www.vmdoh.com/blog/centralizing-logs-lumberjack-logstash-and-elasticsearch
  2. http://logstash.net/docs/1.1.0/filters/grok
  3. http://www.youtube.com/watch?feature=player_embedded&v=RuUFnog29M4#!

Thanks Z, from that LMS organization!

Yahoo has been struggling to regain significance in the IT world. Unfortunately for them, the recent announcement by their CEO (Marissa Mayer) to end telecommuting is likely another step towards their ultimate irrelevance. Is Yahoo the new MySpace?

Mayer contends you have to be physically in the office to be productive. She says there are too many distractions at home. I think she is missing the mark here.

The world is full of talent and it’s costly to relocate them. To compete today, you have to pull from this world-wide talent pool and that means allowing remote workers, at least some of the time. As well, I have found that many computer programmers are SIGNIFICANTLY more productive at home than in the office.

Here are the telecommuting benefits that Mayer seems to have overlooked:

  • Increases Productivity “in the zone”
  • Boosts Morale, increases retention, reduces stress
  • Forces use of efficient technology
  • Better tracks productivity and results
  • Sick? Stay home & work!
  • 1-2 hours extra work each day
  • More ecofriendly

What would happen if 40% of the US work force worked from home 1/2 of the time? Fortunately, there’s a study for that:

  • $200 billion productivity gains
  • $190 billion savings from reduced real estate expenses, electricity bills, absenteeism, and employee turnover
  • 100 hours per person not spent commuting
  • 50 million tons of greenhouse gas emissions cut
  • 276 million barrels of oil saved, or roughly 32 percent of oil imports from the middle east
  • 1,500 lives not lost in car accidents
  • $700 billion total estimated savings to American businesses

src:http://www.inc.com/magazine/20100401/telecommuting-by-the-numbers.html

Way to Go, Marissa Mayer.

For those companies who want to succeed, here’s how you implement telecommuting at your organization:

  1. Define specific accountability measures: (e.g. Tickets closed, tasks completed, availability, Scrum story points, etc.)
  2. Put it on trial: Pick a day (Wednesdays are good)
  3. Measure, Evaluate, Decide

When’s the last time you used a Yahoo product?

photo(1)

Adafruit’s $39.00 eTape Liquid Level Sensor is a solid-state sensor with a resistive output that varies with the level of the fluid. The eTape sensor’s envelope is compressed by the hydrostatic pressure of the fluid in which it is immersed. This results in a change in resistance that corresponds to the distance from the top of the sensor to the surface of the fluid. The sensor’s resistive output is inversely proportional to the height of the liquid: the lower the liquid level, the higher the output resistance; the higher the liquid level, the lower the output resistance.

#define SERIESRESISTOR 560
    // What pin to connect the sensor to
    #define NUMSAMPLES 15    
    int samples[NUMSAMPLES];
    #define SENSORPIN A0
    #define FLAP 1
    #define FUDGE 0.3
    void setup(void) {
    Serial.begin(9600);
    analogReference(EXTERNAL);
    }
 
    void loop(void) {    
     uint8_t i;
     float average;
     float waterlevel;
     float lastwaterlevel=0;
    // take N samples in a row, with a slight delay
    for (i=0; i< NUMSAMPLES; i++) {
    samples[i] = analogRead(SENSORPIN);
    delay(10);
    }
    // average all the samples out
    average = 0;
    for (i=0; i< NUMSAMPLES; i++) {
    average += samples[i];
    }
    average /= NUMSAMPLES;
    //Serial.print("Average analog reading ");
    //Serial.println(average);
    // convert the value to resistance
    average = 1023 / average - 1;
    average = SERIESRESISTOR / average;
    //Serial.print("Sensor resistance ");
    //Serial.println(average);
    waterlevel = 0;
    waterlevel= -1 * 0.006958 * average + 11.506958+ FUDGE;
    if (lastwaterlevel<(waterlevel-FLAP)||lastwaterlevel>(waterlevel+FLAP))
    {
        Serial.print("Water level (inches) ");
        Serial.println(waterlevel);
    }
    delay(1000);
    lastwaterlevel=waterlevel;
    }

The wiring is pretty simple: the sensor comes with a 560 ohm resistor. the sensors two middle pins (2&3) are where the action is at. pin 2 goes to gnd. pin 3 goes to one side of the 560 resistor and to analog input 0. the other side of the resistor goes to 3.3v and to aref.

photo(2)
water_sensor_graphScreen Shot 2013-02-22 at 2.08.38 PM

cnnSelenium can take screenshots, but it does it by launching a browser. What if you need a screenshot of a website, but don’t want the overhead of a browser launching?

That’s where phantomjs comes in. First, install it (CentOS directions):

yum install qt47-devel qt47-webkit qt47-webkit-devel sqlite-devel
yum install xorg-x11-server-Xvfb
yum install xorg-x11-server-Xorg
yum install xorg-x11-fonts*
chmod +x /etc/init.d/Xvfb
/etc/init.d/Xvfb start
git clone git://github.com/ariya/phantomjs.git
cd phantomjs/
git checkout 1.6
./build.sh

Next, create a short js file and pass it to phantomjs!

[user@server ~]# cat cnn.js 
var page = require('webpage').create();
page.open('http://www.cnn.com', function () {
        page.render('cnn.png');
    phantom.exit();
});
[user@server ~]# phantomjs google.js

WHAMMO! you now have a webkit rendered cnn.png ready in half a second!

finalImagine you were tasked with a photobooth for your local non-profit’s group valentine’s day party. Imagine you’d need to setup a backdrop, photograph couples and then print out photo prints with a nice graphic overlay. How might you automate this all?

Step 1: with your canon camera, download the EOS utility which allows you to remotely control your camera and save the pictures to your harddrive immediately.
Step 2: create this bash script which combines the last four most recent photos onto a blank 8″x10″ (at 300dpi) and then puts a graphic overlay on top of them:

user@server:~/Pictures$ cat makeprint.sh 
#!/opt/local/bin/bash
Col1X=95
Row1Y=80
Col2X=1400
Row2Y=1270
 
# Assume .JPG
PONE=`ls *.JPG|tail -n 4|head -n 1|sed 's/\.JPG//'`
PTWO=`ls *.JPG|tail -n 3|head -n 1|sed 's/\.JPG//'`
PTHREE=`ls *.JPG|tail -n 2|head -n 1|sed 's/\.JPG//'`
PFOUR=`ls *.JPG|tail -n 1|head -n 1|sed 's/\.JPG//'`
echo "processing pics"
echo "PONE: $PONE"
echo "PTWO: $PTWO"
echo "PTHREE: $PTHREE"
echo "PFOUR: $PFOUR"
 
#resize pics
convert ${PONE}.JPG -resize 1300x867 ${PONE}_resized.JPG
convert ${PTWO}.JPG -resize 1300x867 ${PTWO}_resized.JPG
convert ${PTHREE}.JPG -resize 1300x867 ${PTHREE}_resized.JPG
convert ${PFOUR}.JPG -resize 1300x867 ${PFOUR}_resized.JPG
 
rm -f stage1.jpg
rm -f stage2.jpg
rm -f stage3.jpg
rm -f stage4.jpg
rm -f final.jpg
 
#place resized image onto blank canvas
composite -geometry +$Col1X+$Row1Y ${PONE}_resized.JPG blank_canvas.png stage1.jpg
composite -geometry +$Col2X+$Col1X ${PTWO}_resized.JPG stage1.jpg stage2.jpg
composite -geometry +$Col1X+$Row2Y ${PTHREE}_resized.JPG stage2.jpg stage3.jpg
composite -geometry +$Col2X+$Row2Y ${PFOUR}_resized.JPG stage3.jpg stage4.jpg
 
#add template on top
composite valentine-photo-template.png stage4.jpg final.jpg
 
rm -f ${PONE}_resized.JPG
rm -r ${PTWO}_resized.JPG
rm -f ${PTHREE}_resized.JPG
rm -f ${PFOUR}_resized.JPG
rm -f stage1.jpg
rm -f stage2.jpg
rm -f stage3.jpg
rm -f stage4.jpg
open -a Preview final.jpg
mv ${PONE}.JPG printed/${PONE}.JPG
mv ${PTWO}.JPG printed/${PTWO}.JPG
mv ${PTHREE}.JPG printed/${PTHREE}.JPG
mv ${PFOUR}.JPG printed/${PFOUR}.JPG
 
lp -o landscape -o fit-to-page -o MediaType=hp-premium-photo-paper -o OutputMode=highest final.jpg

Step 3: you’ll need to have installed imagemagick

Here is a picture of my setup:
photoboothsetup

Ubuntu apparently supports blowfish, but an FTP service (pure-ftpd) running on ubuntu stubbornly refuses to either authenticate from a passwd of blowfish passwords or create new users with blowfish. it reverts to MD5.

in order to move an existing ftp service to this new ubuntu server, I wrote this external auth code:

#!/usr/bin/php
<?php 
define('LOGFILE','/var/log/ftp_custom_auth.log');
$passwdFile=file('/etc/pure-ftpd/pureftpd.passwd');
$passedInUsername=getenv('AUTHD_ACCOUNT');
$passedInPassword=getenv('AUTHD_PASSWORD');
$match=0;
function WriteLog($msg){
    $date = date('d.m.Y h:i:s');
    $log = $date.'|'.$msg."\n";
    file_put_contents(LOGFILE,$log,FILE_APPEND);
}
foreach($passwdFile as $passwdLine)
{
	$passwdLineArray=explode(':',$passwdLine);
	$username=$passwdLineArray[0];
	if ($username!=$passedInUsername) continue;
	$match=1;
	$blowfish=$passwdLineArray[1];
	$UID=$passwdLineArray[2];
	$GID=$passwdLineArray[3];
	$homeDir=$passwdLineArray[5];
	$salt=substr($blowfish,0,29).'$';
	$saltArray=explode('$',$salt);
	$authType=$saltArray[1]=='2a'?'blowfish':'md5';
	$justTheSalt=$saltArray[3];
	$hash=substr($blowfish,29,31);
	$computedHash=$computedBlowfish=crypt($passedInPassword,$salt);
	if ($computedBlowfish==$blowfish)
	{
		WriteLog("$username authd OK with $authType and $computedHash");
        	echo("auth_ok:1\n");
        	echo("uid:$UID\n");
        	echo("gid:$GID\n");
        	echo("dir:$homeDir\n");
                echo("end\n");
	}
	else
	{
		WriteLog("$username did NOT auth with $authType and $computedHash");
		echo("auth_ok:0\n");
	}
}
if (!$match)
{
	WriteLog("$username did NOT auth");
	echo("auth_ok:0\n");
}
echo("end\n");

Paessler is a company that makes software that monitors hardware assets, like web servers. Not too long ago, their CEO Dirk blogged about how they measure/rank new software feature requests.

I modified their formula slightly to reflect Scrum Story Points, because any formula that attempts to use development hours/days to calculate the value will be innately inaccurate. Instead, we should use a relative measure of complexity of projects and features (this is the idea of story points in Scrum) in place of trying to accurately estimate the amount of time something will take to complete.

To determine the business value of new software features:

  • Users: how many paying (or soon-to-be paying) customers will use and benefit from the requested feature? (also, potentially accounted for: Requested: how many Users asked for the feature?)
  • Thrill: How many (or how likely) will those Users be impressed, happy or relieved by the requested feature?
  • Annoyance: How much pain will be caused to those customers if this feature is NOT implemented (this is squared because an annoying problem is worse than a Thrill is good)
  • DevPoints: number of scrum story points to design, engineer, document, deploy and test the feature

Then, the modified Paessler formula is:
business_value_of_new_feature = ( Users * ( 1 + Thrill ) * ( 1 + Annoyance )² ) / DevPoints

For example:

  1. If we think of a feature that affects 100% of our users, has a Thrill of 100%, has an annoyance factor² of 100% and can be created with 1 story point: This reaches the maximum value of 800. Unfortunately no feature of such greatness is likely to be so easy to implement.
  2. Or think of a problem that affects half of our users (users=50%), with a medium annoyance (50%) and can be fixed in 2 story points: The bang for the buck is 56.

Schedules slip and scope creeps when so-called must-have-features (and even worse when low value features) bloat the original software requirements. 37signals (the creators of Basecamp) had this to say about the avalanche of feature requests.

In general, Feature Requests can be ranked:

  1. Issues related to a recent upgrade or migration (most important).
  2. Security fixes.
  3. Broken functionality of the existing system.
  4. Broken functionality in RC and beta features.
  5. Paid feature requests.
  6. R&D feature requests from a large part of the user base.
  7. R&D feature requests from only one or two users.

How do you decide which features will be implemented into your software?

Next Page »

Send to a friend * Print this page * Join the club * Talk with my robot * Advertise here * Search this Site * Donate * Link to me


Web hosting by Utah Hub *  Powered by CreativeTap *  In association with Segomo
Unless otherwise noted, Copyright 2004-2013, Ryan Byrd. All Rights Reserved.
Ryan Byrd dot net -- probably the coolest site in Utah