New site layout.
10-17-09
I just published my new site layout. It is 100% original. I am still using a template for my blog but I will change that soon. Let me know what you think of it.
10-17-09
I just published my new site layout. It is 100% original. I am still using a template for my blog but I will change that soon. Let me know what you think of it.
09-22-09
Hey all, I have a table that has a few varchars and a few int’s. I am storing things like names and ages and timestamps int EPOCH time in an int data type field called polltime. I have an index on polltime but is is just taking FOREVER to get data. please help. Here is better detail.
/* Table Definition */
CREATE TABLE `raw_data` (
`id` int(11) NOT NULL auto_increment,
`name` varchar(64) NOT NULL,
`color` varchar(10) NOT NULL,
`pklsSD` int(4) NOT NULL,
`pklsDS` int(4) NOT NULL,
`polltime` int(14) NOT NULL,
PRIMARY KEY (`id`),
KEY `srckey` (`name`),
KEY `dsttag` (`color`),
KEY `last_updated_date` (`polltime`),
KEY `marketPoll` USING BTREE (`name`,`polltime`)
) ENGINE=MyISAM AUTO_INCREMENT=1959291 DEFAULT CHARSET=latin1;
as you can see by the auto increment, there is a lot of unique data in this DB.
(’1′, ‘albuq’, ‘blue’, ‘2′, ‘10′, ‘1249326616′),
(’2′, ‘bad’, ‘red’, ‘7′, ‘1′, ‘1249326616′),
(’3′, ‘midel’, ‘green’, ‘9′, ‘8′, ‘1249326616′), etc….
I have a few thousand rows per polltime
if I run this query:
SELECT count(c.id) as cnt, SUM(c.pklsSD) as sd, SUM(c.pklsDS) as ds FROM raw_data c WHERE polltime >= 1251763200 and polltime < 1253577600;
it takes about 20 seconds to run and does not use a index. if you do the math on the time stamps it’s from Sep 1st to Sep 22nd. If I shorten the same query to 1 day ie Sep 21st to Sep 22nd it take 0.017 sec to complete and uses the index. What gives? Is there a better way to get this data?
EXPLAIN:
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE c ALL last_updated_date 1961192 Using where
07-09-09
Hi everyone. I wanted to apologize that my normally tech/programming related tweets have been focused on Billy Mays the past two weeks. If you haven’t guessed I was affected by his untimely passing, much like many other people. We have all heard him “Projecting” (as he liked to call it) at us after midnight telling us to buy Oxiclean or Mighty Putty. A lot of people that only know him from the commercials found him to be loud and sometimes annoying. So to thous people, it’s their loss. I have been a fan of the show “Pitchmen” sense it started and I have to say it really showed what a kind and caring person Billy really was. We got to see the sometimes quite and soft side of this hard working Pitchman. Before I became a professional developer I was involved in retail and commercial sales, and I know just how hard it can be to sell one on one or to a group of people, Billy could do this effortlessly. He was the kind of man that you would have loved to have in your family. I am sorry to his family and to his close friends for their loss. I was so moved by his passing that I have been promoting “Pitchmen” on twitter as much as I could. I have also written to his son @Youngbillymays and offered to help with the design of the tribute site he is going to start. So everyone watch “Pitchmen” on the discovery channel.
Also go buy some Mighty Putty, it really freaking works. I fixed a leak in my sink about two weeks ago and it’s been great.
03-23-09
so I have a database that holds MAC addresses in the form of “AA-BB-CC-DD-EE-FF”. note the “-”. So different vendors keep track of macs in different styles, such as:
“AA:BB:CC:DD:EE:FF”, “AA.BB.CC.DD.EE.FF”, “AA BB CC DD EE FF”, “AABB.CCDD.EEFF”, and “AABBCCDDEEFF”. So I needed a way to parse all of these types and convert them to the format I need. Here is how I did it.
NOTE: I am using jquery on the site so you will see CSS selectors for the input id.
if($("#macsearch").val().indexOf(":") > 0)
{
$("#macsearch").val($("#macsearch").val().replace(/\:/g, ""));
}
if($("#macsearch").val().indexOf(" ") > 0)
{
$("#macsearch").val($("#macsearch").val().replace(/\ /g, ""));
}
if($("#macsearch").val().indexOf(".") > 0)
{
$("#macsearch").val($("#macsearch").val().replace(/\./g, ""));
}
if($("#macsearch").val().indexOf("-") > 0)
{
$("#macsearch").val($("#macsearch").val().replace(/\-/g, ""));
}
var output = '';
for (var i=0; i<$("#macsearch").val().length; i++)
{
if (i>0 && i%2 == 0)
output += "-";
output += $("#macsearch").val().charAt(i);
}
$("#macsearch").val(output);
var mac = $("#macsearch").val();
so you can use this if you need it in any of the other formats, just change around the “-” in the replace methods. This also works with totally wrong MACS I.E. “AA:BB,CC-DD.EE FF”
Ok so I have been seeing posts on #PHP through Twitter about a web paged editor called Coda. I have been a web developer for 10 years now with a focus on programming. I have always coded by hand from my c and c++ days and I have used Dreamweaver sense version 6. I love the color coding, especially when making pages that have HTML, CSS, JavaScript (AJAX), and PHP on the same page. I like the code completion and attribute completion.
Now having used Dreamweaver (both PC and Mac) for so long you would think that I am a DW master, but quite the contrary. The features I listed above are what I use all day every day
So now on to this Coda thing….
First Impressions:
Coda is quite amazing. Though it is Mac only, I love it. Off the bat everything that I stated above is covered. and then some. I am not strong on the visual design and layout for sites being a programmer an all, so I am in love with the CSS designer. This hands down is a reason to leave DW and jump right into Coda as your main development application. I made a sample page here and here is the source:
<html>
<head>
<title>Test page made with coda</title>
<style type="text/css">
#logo {
color: black;
text-shadow: 4px 4px #aaaaaa;
text-transform: lowercase;
text-decoration: none;
font-size: 14px;
font-family: "Zapf Chancery", "Comic Sans MS", cursive;
}
#content {
width: 1024px;
}
#main {
width: 768px;
font-size: 12px;
text-transform: lowercase;
text-decoration: none;
text-align: justify;
font-style: normal;
font-weight: normal;
font-family: "Zapf Chancery", "Comic Sans MS", cursive;
float: right;
}
#menu {
width: 256px;
font-size: 12px;
float: left;
list-style-type: none;
font-style: normal;
font-weight: normal;
text-transform: lowercase;
text-decoration: none;
text-overflow: clip;
text-align: left;
font-family: "Zapf Chancery", "Comic Sans MS", cursive;
}
</style>
</head>
<body>
<div id="logo">This is a logo</div>
<div id="content">
<div id="menu">
<ul>
<li>Link 1</li>
<li>Link 2</li>
<li>Link 3</li>
<li>Link 4</li>
</ul>
</div>
<div id="main">
Nam nibh. Integer elit dolor, rhoncus vitae, commodo non, euismod dapibus, sem.
Nunc auctor pulvinar odio. Proin lacus erat, semper viverra, imperdiet eu, laoreet vel, massa.
Aenean pulvinar felis vel leo. Maecenas nibh dolor, viverra sit amet, accumsan ut, vehicula pharetra,
nisl. Etiam sit amet risus et lorem malesuada convallis. Suspendisse potenti. Vestibulum sapien. Fusce
convallis ullamcorper eros. Ut nec ante sit amet turpis ornare consequat. Aliquam erat volutpat. Donec
mollis. Phasellus mollis odio quis massa. Duis lobortis, audio eu aliquet vehicula, eros erat bibendum
lacus, sed scelerisque velit nunc in ipsum. Nulla lectus lorem, feugiat a, cursus quis, vehicula vel, tellus.
Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Proin est. Donec
lobortis. Aenean et neque.
</div>
</div>
</body>
</html>
All the CSS was done by Coda! the tabs did not paste into wordpress but if you look at the source on the page you will see the format. I clicked a few buttons and made the text look the way I wanted it to and Coda did the rest, including the floats. The code completion was good, there are some differences between DW with this. In DW if you start typing and attribute such as “name” even if you type the whole attribute, you can press enter and the =”" will be completed for you. In Coda you have to press enter before you have finished. If you type “nam” and press enter you will get name=”" but if you type “name” and press enter you will get a new line. But that is not really a negative review, it just means you have to do things a little different.
Now I have only used Coda for all of 30 min, so if I assume incorrectly about something, please let me know.
I develop in a header/main/footer format where they are 3 different files. the main includes both the header and footer, this cuts down on coding for me. Coda would not import any of the extra files when I would look at a main page, DW will do that.
There will be more for me to write but as for now Coda has the Pirate Code Monkey seal of approval. Go get it and be prepared to be amazed.
03-12-09
Ok so I run a lot of PHP scripts as binary scripts on Unix systems because I don’t know Perl… but I do know PHP
so I took/moded a php twitter script and put it on my server, and every php script that runs tweets me when it starts and when it finishes, so I can track if ran from any where
ok so here is the main file, I called it “Twitter.php”
<?
/*
This class is compatible with >= PHP 5 only due to the use of:
SimpleXML: http://uk2.php.net/simplexml
Used to parse XML feeds
SimpleXML is enabled by default. If it appears not to be, contact your host.
cURL is also required for this script to operate. http://uk.php.net/curl
The Twitter API documentation used to create this class can be found:
http://groups.google.com/group/twitter-development-talk/web/api-documentation
Written by Matt Jewell
http://mediascratch.com
*/
class twitterAPI
{
public $twitter_base = 'http://twitter.com/statuses/';
private $twitter_username = 'TWIT_USER_NAME';
private $twitter_password = 'TWIT_PASSWORD';
public function fetch_latest_status()
{
/* user_timeline
Returns the 20 most recent statuses posted in the last 24 hours from the authenticating user. It's also possible to request another user's timeline via the id parameter below.
Parameters used: id, count
*/
$buffer = file_get_contents($this -> twitter_base . 'user_timeline/' . $this -> twitter_username . '.xml?count=1');
// Grab the contents of the XML file and store it in the variable.
$xml = new SimpleXMLElement($buffer);
// Creating a new XML string for use with the SimpleXML extension.
$status_item = $xml -> status;
// Creating a new variable using SimpleXML with "status" as the Node.
return $status_item -> text;
// Grab the current status as the Element.
}
function update_status($message)
{
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $this -> twitter_base . 'update.xml?status=' . stripslashes(urlencode($message)));
// The variable could also be substituded by the use of CURLOPT_POSTFIELDS
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
// Enables us to return the result as a string instead of outputting to browser.
curl_setopt($curl, CURLOPT_POST, 1);
// From the Twitter API docs: "Request must be a POST". CURLOPT_POST ensures this.
$username = $this -> twitter_username;
$pass = $this -> twitter_password;
curl_setopt($curl, CURLOPT_USERPWD, "$username:$pass");
// Authenticates the user (you) in the post request.
$exec = curl_exec($curl);
// Execute the cURL request.
// echo curl_error($curl);
// Used to debug cURL.
$httpcode = curl_getinfo($curl, CURLINFO_HTTP_CODE);
// Return the HTTP headers so we can confirm the request.
// A list of what the status codes are and mean can be found here:
// http://www.seoconsultants.com/tools/headers.asp#code-200
curl_close($curl);
// Terminate the cURL session
return ($httpcode == 200) ? 'Updated!' : 'Error!';
/* Ternary operator equivelant to:
IF httpcode equals 200
Return done
ELSE
Return error
*/
}
}
?>
Then I include it in the running script along with a tweet to send me.
include_once('twitter.php');
$curTwitter = new twitterAPI();
$curTwitter-> update_status("Script Started.");
.....
$curTwitter-> update_status("Script Ended.");
I made a special twitter account for my script and set it's tweets to private, and only have my main account following it.
hit me up @wrenbjor
03-08-09
So I decided to check out this whole “Drupal Thing.” I installed a copy on this server, but I have to tell you… for someone that has been using HTML code sense version 2, I just have to code. I really don’t like the point and click stuff. Now I am not giving up on it yet, I;m going to make a few tests and see how it goes, but as it stands right now I am not a fan.
03-07-09
I wrote a PHP script at work that tweets me when my cron jobs start and stop, so I can keep track. I am also doing a lot of work with cURL so I will add some posts about that as well. I will also be doing my first Video post this week. I will cover boring things like coding and other nerdy topics
See ya’ll soon.
I have made it into the top 100 (92) for Team Hack-a-Day (Http://www.hackaday.com) for the Folding @Home project If you have a chance please join. it’s much better to use idle CPU cycles for finding cures for aids and cancer as opposed to seeing if we have received a message from “Aliens” via Seti….
02-24-09
ok I have been following Cali Lewis for a few months now, but I just now watched one of her pod casts. She is really good at giving the lowdown on tech and she’s really cute too. if you have not had the chance to watch her, goto geekbrief.tv and check her out.