Categories
post

jQuery Mobile Select Box Not Showing Up

jQuery Mobile is a great framework with lots of great out-of-the-box magic.

I am in the middle of converting a site over from a full website to a mobile version. I was really frustrated when I tried to click on a select box and nothing would happen. If my header/footer were fixed, they would just toggle on and off. I assumed it was the fixed positioning, and I was wrong.

Through some FireBug debugging, I found the problem. It probably won’t affect many people, but it’s worth pointing out. I had a set a width through CSS on the select item for the desktop version. When I ported into the mobile version, I left the CSS width in there. So if I happened to click on the very far left of the button, it worked.

I removed the width and all is right in the world again. 🙂

Categories
post

Running Apache Benchmark (ab) and receiving apr_socket_recv: Connection reset by peer (54)

I was having this issue and was getting quite frustrated. All of my researched turned up nothing. Finally I decided to run this from another machine instead of my Mac, and it worked just fine. So this had nothing to do with my server, it was a client side related issue.

I still don’t know what caused it. I was just able to identify the issue and thus find a work around.

Categories
post

Google +1 Button Shows Zero (0) Count When Not Logged Into Google Account

I had a situation that my boss pointed out yesterday that was very confusing.

He was on a competitor’s website and their +1 button was showing a count. However, the same product on our website was showing 0. I knew that I had +1’d it.

So I go to my machine and I see (3) +1’s. I logout of Google and sure enough the 3 went away. ?!?!?!?

I was so confused that I went as far as copying the +1 code from the competitor’s site and theirs showed a number and ours still did not until I logged in. My mind was boggled.

Next step: ask another person in the office to create a Google Profile and +1 our product. Bringing our +1’s up to 4. There you have it, it showed whether I was logged in or out of Google.

I hope this save someone else time from searching hours for an answer. It was ridiculously confusing. Why is 4 the magic number?

Categories
post

I am coining a new term “Arsonistic Firefighter”

I find myself putting out fires in my code base all the time. The problem is, I set the fires to begin with. 🙁

Categories
post

Lazy Loading Images with JQuery

I am trying to speed up a website every way that I can. I decided to look into lazy loading which I have read about numerous times.

Lazy loading is basically not wasting time loading images that are off the screen, or out of the viewport.

This got me thinking, why do the browsers not do this for us? They would be better equipped to handle this than a JS developer. Especially since the browser is doing the rendering, it knows what it needs in order to display the screen.

Categories
post

Git Flow Bump Version Script

I wrote a simple bump version PHP script that does quite a bit of lifting for me.

  • It maintains my version number, very basic
  • It takes an argument on whether I need my templates updated due to CSS/JS changes.
    • If necessary, creates a new assets directory based on version number to fix caching issues
    • Pulls latest css/js into that directory
    • Updates template to new assets directory
    • Adds and commits new template
  • Optional second argument overrides the version #
  • Starts a new release branch
  • Opens my RELEASE notes for editing
  • Adds and commits my release notes
  • Finishes my release branch

Below is specific to my situation. PATH_TO_TEMPLATE_FILE would need to be changed, as well as the preg_replace lines to suite your needs.


if (!in_array($argv[1], array('y', 'n'))) {
print "Usage: {$argv[0]} (y/n) [version]\n y=update css/js\n n=no update\n";
exit;
}

if ($argv[2] && !preg_match('#v\d\.\d*\.\d*#', $argv[2])) {
print "Invalid version (should be v\d.\d.\d)\nUsage: $0 (y/n) [version]\n y=update css/js\n n=no update\n";
exit;
}

chdir(dirname(__FILE__));

$fileName = '.Version';

$v = file_get_contents($fileName);
$a = explode('.', $v);
$minor = $a[2]+1;
$v = "{$a[0]}.{$a[1]}.$minor";
$fh = fopen($fileName, 'w');
fputs($fh, $v);
fclose($fh);
`git add $fileName`;
`git commit -m "Increased version to $v"`;
echo "Version updated to $v and added to git\n";

if ($argv[1] == 'y') {
$asset = "assets/v{$a[1]}.$minor";
mkdir($asset);
chdir($asset);
`sh ../../update_css_js.sh`;
`git add .`;
`git commit -m "Increased css/js version to v{$a[1]}.$minor"`;

chdir('../../');
$template = file_get_contents('PATH_TO_TEMPLATE_FILE');
$template = preg_replace('#data-style="sI" href=".*?" media#', 'data-style="sI" href="/assets/v'.$a[1].'.'.$minor.'/style.css" media', $template);
$template = preg_replace('#jQuery.getScript\(".*?" \+ pluginPack#', 'jQuery.getScript("/assets/v'.$a[1].'.'.$minor.'/" + pluginPack', $template);
$fh = fopen('PATH_TO_TEMPLATE_FILE', 'w');
fputs($fh, $template);
fclose($fh);

`git add PATH_TO_TEMPLATE_FILE`;
`git commit -m "Increased css/js version to v{$a[1]}.$minor"`;
}

`git flow release start $v`;
$date = date('Y-m-d');
$command = << /tmp/out && mv /tmp/out RELEASE
EOF;

system($command);
system("vim RELEASE > `tty`");

`git add RELEASE`
`git commit -m "Updated RELEASE notes"`

system("git flow release finish $v > `tty`");

 

Categories
post

Making WAVs play in Chrome for Mac

I was really frustrated that our voicemail was not working in Chrome. All it said was Missing Plug-in.

Through some research, I found that the voicemail system was loading the files via ajax to a PHP script. Because the extension was not .wav, Chrome was confused.

How did I solve?

Well, this is an internal box with very little traffic and I have complete control of it.

I first told Apache to treat all .php.wav files as PHP. In httpd.conf of php.conf you will see
AddHandler php5-script .php

Add this right below it.
AddHandler php5-script .php.wav

Restart Apache.

Then I symlinked the .php file to a .php.wav file. So that they were identical. Then in the file that pulled in this php file, I changed the filename there as well.

Fixed my issue. 🙂

Categories
post

PHP Parse error: syntax error, unexpected $end in

I was receiving this error and did a quick Google search to figure out why. Most posts referred to a missing curly brace “}”.

I went through about 3-4 posts when it hit me. My code was from an older server that allowed the short tag

Categories
status

I am proud of my progress with Javascript…

I am proud of my progress with Javascript. I used to consider myself a javascript hacker. I could put other people’s components to work, but wasn’t comfortable writing my own.

I would consider myself much more proficient today. I can write maintainable/reusable Javascript. I have become more capable of writing routines that can be used on multiple widgets easily.

My latest code has been able to work on multiple “widgets” within one page. This was exciting for me, and I ended up staying late at work the other night as I got near completion. I was sooo happy with my accomplishment, but being the only programmer, it can be tough. Nobody really appreciates the successes that I feel are so exciting. It’s not their fault by any means, they just are not into the tech as much as I am.

At the end of the day, I tell my wife. She is the best cheerleader a guy could have. While she doesn’t fully understand, she puts on a smile and tells me how great it is when I do accomplish the small things. She tries so hard to be understanding and just there for me. I am a lucky lucky man.

Categories
post

Patch for VisualSearch.js To Prevent AutoSearching

I learned about VisualSearch today when I listened to The Javascript Show podcast.

I started using it for some backend work. However, I did not like the fact that as soon as you completed a facet, it did the search automatically. Don’t get me wrong, it is great for the way DocumentCloud is using it. Very ajax responsive, but for what I am trying to do, I needed that to stop.

I changed it so that I could pass autosearch: false as a parameter to VisualSearch. Now it will only search after hitting enter.

--- visualsearch.js        2011-08-04 13:16:46.000000000 -0400
+++ visualsearch.js     2011-08-04 13:23:21.000000000 -0400
@@ -30,6 +30,7 @@
     var defaults = {
       container   : '',
       query       : '',
+      autosearch  : true,
       unquotable  : [],
       callbacks   : {
         search          : $.noop,
@@ -543,7 +544,9 @@
         var originalValue = this.model.get('value');
         this.set(ui.item.value);
         if (originalValue != ui.item.value || this.box.val() != ui.item.value) {
-          this.search(e);
+            if (this.options.app.options.autosearch) {
+                this.search(e);
+            }
         }
         return false;
       }, this)