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

it’s not as difficult as it first looks:

Given two water faucets, one hot and one cold, and one bucket. The hot water fills the empty bucket in eight minutes. The cold water fills the bucket in seven minutes. Then I make a hole in the bucket such that the full bucket drains in four minutes. Now take the empty bucket, with the hole, and place under both faucets together. Turn on the hot and cold water at the same time. How long does it take to fill the bucket halfway?

reversing a string is a classic tech interview question. of course you’re not allowed to call any built-in reverse() function. A solution might look like, in my pseudocode:

someString = new string("732432424");
char temp;
int end=someString.length()-1;

for (int x=0;x<end;x++)
{
	temp=someString[end];
	someString[x]=someString[end];
	someString[end]=temp;
	end--;
}

but sometimes the interviewer asks you to reverse the string in place, without using other memory, and for that, we’ll need our XOR friend

A B  XOR
----+---
0 0 | 0
0 1 | 1
1 0 | 1
1 1 | 0
someString = new string("732432424");
char temp;
int end=someString.length()-1; //assume zero based char arrays

for (int x=0;x<end;x++)
{
	someString[x]=someString[x] XOR someString[end];
        // first loop: someString[x]=3
	someString[end]=someString[end] XOR someString[x];
        //first loop: someString[end]=7
	someString[x] = someString[x] XOR someString[end];
       //first loop: someString[x]=4
	end--;
}

ME: did you install xampp?
ME: and, in the xampp control panel, did you start apache?
ME: and, in a browser, did you go to http://localhost
ME: and, once, there, did you see a xampp welcome message?
SOMEGUY: yes, yes and yes
ME: when you go to http://www.whatismyip.com what does it say for your ip address?
SOMEGUY: [address ]
ME: is that computer running microsoft’s firewall? if so, can you shut it off?
SOMEGUY: ok
ME: are you using a local router/firewall? if so, you need to let/forward port 80 through to that “server”
ME: the point is that port 80 is not responding externally, so we need to fix it. to get into your router, you just need to know your default gateway.
ME: start->run
ME: type “cmd”
ME: then type “ipconfig” (no quotes) and press enter
ME: you’re looking for the Default Gateway IP address
SOMEGUY: it is 192.168.1.1
ME: ok. go to that in a browser
ME: if you use default linksys settings, there will be no username and the password is admin
ME: ok, so there should be some provision for forwarding ports.
ME: sometimes it’s under firewall->single port forwarding
ME: you’ll need to forward port 80 to the ip address of that server computer
ME: it says prot range forward
ME: yeah, so you can forward 80 to 80 to the ip of the server at 80 to 80
ME: you can find the ip of that server by doing the start->run, cmd, ipconfig command again
ME: go to http://www.[sitename].com/ (i set up DNS for you)
ME: does it work for you?
SOMEGUY: it brings up xampp for windows
ME: yup, that means it’s working
ME: ok, now we need to edit us some files
ME: step 1
ME: in that folder create a file called index.html, and in that file put “hello world”
ME: you could use notepad to create a new text file, but when you save it, be sure it doesn’t append a .txt to the end of index.html
SOMEGUY: can i use word
ME: if word allows you save in plain text format, then yes
ME: again, make sure the file name is index.html and not index.html.txt
ME: when you browse that folder (c:\xampp\htdocs\[sitename]) can you now see a little browser file icon called index, and if you double click it, does ie open a window with the text you typed in?
SOMEGUY: yes
ME: now time to edit another file
ME: go to: C:\xampp\apache\conf\extra
ME: and use notepad to edit httpd-vhosts.conf
ME: delete everything out of that file, and paste in the following:
ME: NameVirtualHost *:80

DocumentRoot “C:\xampp\htdocs\[sitename]”
ServerName *.[sitename].com

ME: then save that file
ME: and then stop and start xampp
ME: from the control panel
ME: start and stop apache, i mean, from the control panel
ME: go to http://www.[sitename].com/
SOMEGUY: i stopped it and started it
ME: what do you see?
SOMEGUY: HELLO WORLD
ME: that’s what I see, too. you’re hosting a webpage now for the ENTIRE WORLD!!!
ME: you’ll probably need dreamweaver (which you can get a trial version free download) to start pimping out your site
ME: the point is that anything you place in c:\xampp\htdocs\[sitename] will be accessable to the world on www.[sitename].com
ME: so, if you had an mp3 called “mysong.mp3″ and you copied it into c:\xampp\htdocs\[sitename] your friends could download it by going to http://www.[sitename].com/mysong.mp3
ME: the html files are for your webpages, but the server will serve up any file you place in that folder
SOMEGUY: how do i make links
ME: dreamweaver is a good editor and you can get lots of cool templates free.
ME: in dreamweaver it’s easy. if you’re editing raw html text, a link looks like this
SOMEGUY: i now have an mp3 in that folder
ME: obviously, you don’t want the mpaa to know you’re hosting mp3s. it’s illegal and all. i was just providing you an example
ME: that index file is the root file that apache/xampp will serve up if the filename is not explicited stated in the URL. you should just point dreamweaver to that file to edit it.
ME: you can, obviously, add more files to that folder, for other pages on your site. maybe a songs.html, for a list of your songs. then you just link to songs.html from your index.html
ME: as well, because apache/xampp uses index.html as the default name, if you wanted www.[sitename].com/songs to work (instead of songs.html), you simply need to create a subfolder in c:\xampp\htdocs\[sitename] called songs and put an index.html file in that subfolder with your song list

1. http://www.php.net/manual/en/control-structures.alternative-syntax.php shows an alternative syntax for loops:

    foreach($list as $item)
    {
        echo $item;
    } 

can be done as:

    foreach($list as $item):
        echo $item;
    endforeach

2. if your server has short tags enabled, you can do this:

<?

$somevar="hello";

?>

<?=$somevar?>

this script checks to see if a program is running and starts it if it is not. if a certain time has passed the script will kill the running program

#!/bin/bash

#location of script to monitor
PROGRAM=’myscript.php’
COUNTER=0

#!/bin/bash

date2stamp () {
date –utc –date “$1″ +%s
}

# convert a date into a UNIX timestamp
# time afterwhich script should not run
finishtime=$(date2stamp “Thu Nov 1 15:22:00 MDT 2007″)
#echo $finishtime

while [ 1 ];
do

nowtime=`date –utc +%s`
#echo $nowtime
diffTime=$((finishtime-nowtime))
if ((diffTime > 0));
then
echo “still time to go”
else
echo “TIME UP!: checking if running:”
PROG_CHECK=`ps aux|grep $PROGRAM|wc -l`
if [ $PROG_CHECK -gt 1 ];
then
echo “running after time up”
PROG_ID=`ps uax|grep $PROGRAM |head -n 1|awk ‘{print $2}’`
#echo “KILLING”
#kill -9 $PROG_ID
else
echo “not running after time up”
fi
exit 65
fi

PROG_CHECK=`ps aux|grep $PROGRAM|wc -l`
if [ $PROG_CHECK -gt 1 ];
then
echo “running”
else
let COUNTER=COUNTER+1
echo “not running: starting: new log file: $COUNTER”
/usr/local/bin/php /root/$PROGRAM &
fi

#time in seconds to sleep
sleep 5

done

We recently upgraded from MySQL 4 to MySQL 5 and we noticed strange characters in some of the varchar and text fields.

step 1: dump out the contents of the bad field in hex
mysql> select hex(myfieldname) from mytablename where myid=’something’;

step 2: run a php program to print out the chars one at a time
function hex2asc($temp) {
$len = strlen($temp);
for ($i=0;$i<$len;$i+=2) {
$data[$i]=chr(hexdec(substr($temp,$i,2)))." ".substr($temp,$i,2);

}
return $data;
}
$str="HEX GOES HERE";
$data=hex2asc($str);
print_r($data);

?>

step 3: once you’ve identified the bad chars and their hex values, change them in the database

here are some bad chars I found:

– fix apostrophe
update mytablename set myfieldname=REPLACE(myfieldname,UNHEX(’92′),”‘”);

– fix left single quote
update mytablename set myfieldname=REPLACE(myfieldname,UNHEX(’93′),”‘”);

– fix right single quote
update mytablename set myfieldname=REPLACE(myfieldname,UNHEX(’94′),”‘”);

– fix bullets
update mytablename set myfieldname=REPLACE(myfieldname,UNHEX(’95′),”& #8226;”);

– fix double dash
update mytablename set myfieldname=REPLACE(myfieldname,UNHEX(’96′),”–”);

– fix triple dash
update mytablename set myfieldname=REPLACE(myfieldname,UNHEX(’97′),”—”);

— fix supscripted TM
update mytablename set myfieldname=REPLACE(myfieldname,UNHEX(’99′),”<sup>TM</sup>”);

– replace jacked up apostrophe/single quote
– delete EFs
update mytablename set myfieldname=REPLACE(myfieldname,UNHEX(’EF’),”");
– replace BFs with single quote
update mytablename set myfieldname=REPLACE(myfieldname,UNHEX(’BF’),”‘”);
– delete BDs
update mytablename set myfieldname=REPLACE(myfieldname,UNHEX(’BD’),”");

see also: http://www.oreillynet.com/onlamp/blog/2006/01/turning_mysql_data_in_latin1_t.html

forward a single IP

  • ssh into a server
  • right click on toolbar, change settings
  • ssh->tunnels
    • source: 80
    • destination: someip:80
    • CLICK Add
    • click Apply
  • in a browser: goto localhost and you’ll see the contents of someip

forward all addresses

  • ssh into a server
  • right click on putty toolbar, change settings
  • ssh->tunnels
    • source: 5432
    • select (*) Dynamic
    • Click Add
    • Click Apply
  • in firefox:
    • tools->options, advanced, network
    • (*) manual proxy configuration
    • SOCKS host: 127.0.0.1, port: 5432

To make it more secure, set the user shell on the ssh server to /bin/false and in ssh settings click [x] don’t start a shell or command at all
don’t forget to change the network settings back when you want to surf normally. Also once the ssh session closes your internet access will not work

mcbride-lies.jpgWe all know that SCO sucks. By extension, the people who work for that deplorable company also suck and because now SCO isn’t doing so well financially, SCO is laying off a bunch of employees. These people took the bet that SCO would win and now that SCO is losing, they’ll expect to pretend that nothing ever happened and jump to another job. Of course, they stood to gain a lot if SCO’s attempt to extort money out of the Linux world would have worked. Fortunately SCO’s plan has failed miserably. Sorry SCO employees, You can’t eat your cake and have it too (as the saying originally went) — no jobs for you!

exit.jpgBecause tech companies seem to have a high rate of turnover, you’ll soon likely be in the position of leaving or interviewing an employee who is leaving. Either way, it’s important to find answers to some important questions such as:

  • If the CEO left unexpectedly today and you were put in charge, what are the first things you would change?
  • What could have changed six months ago that would have prevented you from looking for a new job?
  • If you weren’t looking, what factors tipped the scale when an opportunity came up?
  • Who do you think is next to resign and why?
  • If one person leaving the firm would cause you to think twice about leaving, who would that person be?
  • Why didn’t you leave us sooner than now?
  • How did your manager communicate your responsibilities? DO you think he or she was fair and reasonable?
  • Describe any areas of conflict that have affected either your performance or morale, or that you believe affected other employees

src: Inc. Magazine, April 2006

You all remember Josh Coates, CEO of Berkeley Data Systems/Mozy, right? Mozy is the company with the Windows program which allows you to backup your harddrive to their petabyte array all safe and securely. Truth be told, I could never get their app to work on my system, but that’s hardly significant. What is important is that EMC, the king of storage, just bought Mozy for a cozy 76 million dollars.

Mozy had raised only 1.9 million in capital, which makes their VC people (Wasatch Ventures) very, very happy.

You’ll also remember that Josh’s Mozy held the popular $20,000 dollar computer programming “death matches.”

Strong work, Josh!

* yes, I know that “mozying” is not a word; it’s “moseying”

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-2006, Ryan Byrd. All Rights Reserved.
Ryan Byrd dot net -- probably the coolest site in Utah