From the BlogSubscribe Now

Inputs in Firefox storing previous values


Today’s problem came as a result of a Firefox anomaly. It’s one of those problems that comes up after launching because we were too lax in testing. Here’s how it broke down, without going into great detail about the application.

We’re building a CRM that stores asks and closes of our sales reps. The application shows recent asks and closes on the main screen, with the ability for the user to update said activities. The update option are in input fields, named the same, and updated via javascript behind the scenes.

When adding a new activity, the application inserts that entry into the table of current asks and closes. On reload, Firefox was showing old data in those fields, but if the user clicked on a different page and came back to the dashboard, they would see the correct data. Upon inspection, the value of the input was correct. Meaning the browser was replacing the input with what it believed to be good data.

Unfortunately this bug wasn’t caught until production. The answer was simple. We only needed to turn off autocomplete on each of the inputs. This immediately solved the problem.

autocomplete=off

Add that line to the input and the problem disappeared.

How to Force Javascript File Updates onto Users

Wonka wonka wonka cache busting memeThe question came up when working with a new application that relies heavily on Javascript, How can we force users to renew the javascript file? This is especially important for single page applications that rely heavily on Javascript for everything from authentication to storing data.

In researching this problem, I found there to be a great deal many options at hand. Some suggested using a paramater in the overall application which could be used to version the javascript.

http://yoururl.com?v=19228

This would work, but it also requires a paramater in the URL, which I didn’t like for our needs.

Instead we opted to use a very similar method but in the file include statement, where it would be updated for future versioning. So where we call the javascript in the template files, we added a parameter to that javascript file, like so…

<script src="/js/custom.js?v=19228" type="text/javascript">

Let me know in the comments how you handle this problem and if there are any issues you find with our way of solving it.

 

Magento update breaks site

Magento is open-source software for e-commerce

I helped a friend update their Magento site from version 1.9.1 to 1.9.3.2. The software has a few ways to update, one using a command line utility and the other a web based service called Magento Connect. We used the latter to update and ran into a few issues before finally getting the site to update.

The first problem was the update process failed in Magento Connect with a message that there were conflicts between all the packages being updated. The root cause of this was inside the /public_html folder on the server was a folder called pkginfo which had a Latest_Mage_All.txt folder and another file. We needed to manually delete these and the updates ran as expected.

Once we got the updates to run, then the site returned a white screen. This was caused by an error in the Apache configuration on the server. Because Magento overwrites the .htaccess files, we needed to modify the file to suit the local configuration needs of the server. In this case, that meant SymLinksIfOwnerMatch. This resolved the issue and allowed the pages to load.

Once that was complete, we did need to delete the var/cache folder, as the site was having trouble showing a query that was no longer available in the latest version. That fix could have been prevented by turning off caching prior to updating, but was an easy enough fix nonetheless.

The final fix was template specific and cost us a new support fee with the good people at RocketTheme. The site for this nonprofit uses a module call RokMage HomePageGrid. The grid stopped working after the update, but the fix was simple. By adding the block to the allowed blocks permission page, the frontpage again populated with the necessary information.

The Scream

The clapboard shutters banged against the cedar planks. The wind dislodged debris from the barn that ratcheted against the house. Dan sat motionless on the couch in the living room. He muted the TV so he could listen again for the scream.

This time it sounded like a cave woman being beaten. The scream was piercing, like a nail dragging down aluminum siding. Sally down the road would have called for him by name. His mother would have screamed for a moment, then remembered her son would be terrified and stopped, sucking up whatever death and despair lay ahead. No, it couldn’t be anyone he knew.

On TV, a fat man in a tank top stood on top of a beat-up car. Dan watched as the car’s hood flipped up and knocked the man from the car. He lay on his back, supine, shaking a fist at his luck.

Outside the cat-like scream etched itself across Dan’s reality. He sat bolt upright. He could ignore it no longer. He thought for a moment about what he’d need to protect whoever was outside suffering such horrors at the hands of what — an animal? Dan wasn’t a fighter. Christ, he’d barely been able to manage the twenty pushups for his P.E. Final. How was he supposed to fight off an aggressor?

The whole of the house took on a sinister glow to it. There was not light enough in the kitchen to find the flashlight that must have been there — black as the darkened storm outside. Of course, he couldn’t turn on the light. Sure there was power, but what if the muscle-bound thug saw the light come on and decided to get his ass out of the cold and slashing rain.

Why would someone be outside his house attacking a woman? It really didn’t make sense. He’s just imagining it, Dan tried his best to convince himself. It would pass and he would see. Maybe he should just go to bed. Get up in the morning and check for blood splatter. Maybe look for footprints heading back to the main road, out to Route 17. Then he could call Sheriff Black and have him come take a look at the evidence. Sure it was circumstantial — no he couldn’t prove the blood was that of a woman, but just look at the bootprints; they practically scream aggression, fat, blocky wedges of mud separated by thick lines, with a massive V at the base. A work boot, sure. But couldn’t he see, this was a man’s boot who had done something unspeakable to a sweet woman.

Outside a lightning strike lit up the night sky. Dan crouched down instinctively just as he heard a moaning sound, coming from around the corner of the house, off the patio, down a small flight of wooden steps, and near his mother’s geranium plants. His father had pulled a rather large bush from the area several years earlier, and the geraniums were a recent addition. Dan imagined them getting beaten by the hectic rain outside. He wondered how quickly flowers recovered from such abuse.

The moaning continued with the wind and the sounds seem to coincide with increased gusts, like the injured person was somehow speaking in concert to the aggravating increase in wind speeds. Of course, they would. It was terrible outside.

If he could just find the flashlight, he would be able to shine it out the window and see exactly what was out there. He could cast a light into the darkness and identify it. He thought for a moment that that sounded a bit poetic, like he was terrified of the unknown and could suddenly end the hysteria. He could lance it like a  boil, ending it’s power over him. In the vernacular of his peers, he could make it his bitch.

Then he found it, a pen like wand of a flashlight, cold and gritty from caked on mud around the handle. It was stuffed in the back of the drawer, just behind a refrigerator bulb and tucked underneath an old atlas.

Dan held that tiny pen flashlight and with anxious breath turned it on against his leg, so the light would only illuminate the coin sized spot on his jeans, not the entire room. Again, he didn’t want some thug realizing salvation was coming for him. He wanted to keep the element of surprise.

A crack of lightning confirmed Dan’s suspicion that the person outside was indeed groaning and moaning with the increased severity of the storm. The glowing golden coin of light on Dan’s leg confirmed that the flashlight was in working order. Now he could make his way to his parent’s bedroom window, where the moaning sounds seemed to be directed, and shine the flashlight into the bush-less area outside, where the geraniums would bound to be beaten and bruised by the storm.

He crept to the windowsill, listening for any sounds. He found his parents room to smell like the familiar scent of mothballs — the white, stinky resistance.

In the corner between the narrow edge of his father’s sturdy dresser and the tan colored wall, rested a 12 gauge shotgun loaned to his father from his grandfather. It was a pump shotgun, the kind used to fell deer from a hundred yards. He knew a box of shells lay secured in a box in the top dresser drawer. They were slugs, again used in the act of killing deer. His father wasn’t a hunter though. He fenced in college, but hunting was beneath him. It was due to the house, the new job, and making a name for himself. He was the marketing director of a hunting apparatus manufacturer. He needed to practice and Dan’s grandfather gave him the means to do so.

Dan thought he saw a spark of light outside the window that stretched underneath those geranium petals. It wasn’t bright, not a flash or reflection from lightning either. It was stronger than a firefly. It was more like a solid gleam of green, an emerald purchase against the darkened velvet of night. He positioned himself on the edge of the curtain, off to the side, nearest the corner with the gun and the buckshot secured in a box near his shoulder. He could reach into the dresser and pull that box out if whatever was outside came crashing through the window, into the house.

Dan positioned the flashlight’s lens against the glass. He realized too late that the exterior storm window pane would reflect back the light and make the entire operation moot. In fact, he was so startled by the light bouncing back at him that he could only faintly hear the startled scurry of a raccoon, or opossum, or tiny deer as it kicked and hurtled itself back into the bosom of the crashing storm.

How to get a larger album cover image from iTunes API

I ran into this issue recently. I wanted a larger version than what’s returned from the basic response API search. The images there are intended for mobile applications and are available at 60 wide and 100 wide. Easy to get those. What are you going to do with it though? Take a look at the size of the largest version returned from the API.

But how do you get a larger version if your web application requires it? It doesn’t mention anything in the API documents.

Hence a bit of search and replace…take a look at this returned url from the basic api search.

http://is4.mzstatic.com/image/pf/us/r30/Music/ff/c9/01/mzi.jornkthw.100x100-75.jpg

Now all you need to do is replace where it says 100×100 with any value. Need an image that’s 400×400 wide? Change the values to equal that and you’re good to go.

A simple php string replace should do the trick. Here’s what I used to get a 200×200 version of the album.

$albumArt = $response->results[0]->artworkUrl100;
$albumArt = str_replace('100x100', '200x200', $albumArt);

I received the response from the iTunes search library made by Vinelab

The Good Lord Bird – A Review

The Good Lord Bird Book Cover The Good Lord Bird
James McBride
Fiction
Riverhead
August 20th, 2013
Kindle version
433
http://www.amazon.com/gp/product/1594486344/ref=as_li_qf_sp_asin_tl?ie=UTF8&camp=1789&creative=9325&creativeASIN=1594486344&linkCode=as2&tag=jasfryonwri-20

The story of Onion, a young black boy who gets mistaken for a girl by John Brown on the Kansas frontier. Onion plays the part of the girl and follows along with the adventures of John Brown as he attempts to eradicate the world of the injustice of slavery.

I loved this book. I’ve never read anything by James McBride prior to this award winner. I did mention this won the National Book Award for Fiction in 2013, right? It did. Notable book. I looked it up on Amazon after it won. One thing struck me right off — there were only 100 reviews at the time. That was on the day after the award was announced. I felt like it was under-represented for having won that award.

Before I get into the book, I want to explore something that I feel needs to be said. Books win these awards because they have merits that a group of fellow writers deem laudable. Last year The Round House won. I was familiar with Erdrich’s work from Love Medicine, and readily jumped on the bandwagon for The Round House afterward. It was a compelling read that offered more than lyrical prose — there was a lot of humanity tucked away in those pages. Some real telling bits. And that’s what I found in The Good Lord Bird.

McBride makes much of the story comical. The perspective of the book is from this boy who’s father is killed outright in attempt to free him of slavery. The boy is scooped up by John Brown and absconded to the prairie where he’s met by the band of freedom fighters bound in glory. The boy was dressed in a potato sack and mistaken for a girl because the father went to correct John Brown after he’d said Henry was a girl, but only got out the word “Henry ain’t a…” and John Brown thought his name was Henrietta. That’s just one piece of the comedy and there was plenty more.

John Brown was painted a lunatic Christian soldier whose merits could be seen in his immovable defiance of the institution of slavery and his hell-bent quest to liberate the slaves using military means.

Most of the way through the book, I found myself wondering just how much Onion (Henry) would put up with before running off to get a taste of freedom. He had chances throughout, but he stuck it out and the ending was as compelling an ending as I could ever hope to read. I blew through the final 25% of the book, in a mad dash to resolve the conflict, even knowing the outcome from history for Old John Brown.

The folksy language used by the narrator adds to the period and immerses you into the story. There’s much to learn of historical significance, but so much more to learn about humanity, freedom, and the overarching depths of the human soul.

I have a new goal to read the past winners of the National Book Award as well as the latest ones as they’re announced. Two years running, I’ve not been disappointed.

The Road – A Taste of Hope

The Road Book Cover The Road
Cormac McCarthy
Post Apocalyptic
Knopf
2006
Kindle version
241
http://www.amazon.com/gp/product/0307387895/ref=as_li_qf_sp_asin_tl?ie=UTF8&camp=1789&creative=9325&creativeASIN=0307387895&linkCode=as2&tag=jasfryonwri-20

A man and a boy survive a post apocalyptic world by traveling along a desolate road seeking food and shelter. They encounter many bleak adventures.

I went into reading The Road thinking it was a much longer book than it really turned out to be. I thought it was going to be a tome. I must have heard something about it’s length on Reddit or somewhere else. Whoever said it was long was mistaken. It couldn’t have been any shorter. Clocking in at 241 pages hardly counts as a novel these days. Well, it does, but a damn short one.

I was geared up to be oh so depressed afterward. I had some anti-depressants tabbed into an old Pez dispenser. I ordered some Chinese and set to work on this book. To my surprise it was less depressing and more uplifting.

McCarthy has a knack when it comes to presenting evil in an understated manner. He did it so well in No Country for Old Men. I expected there to be a villain like The Judge from Blood Meridian streaking after the man and the boy, but that was not the case. There was plenty of evil in the page. Stretches where the landscape and the aftermath of the ill-fated world was the overall evil presence too. But McCarthy’s other books pulled us through the trenches with those evils and showed us that evil persists, even if there are good men in the world. Whereas the message seemed to change a bit with The Road.

The Road shows that one must have hope to fight through the despair. The ending shocked me a bit. I thought they would end up dead, both of them. Dead as the landscape around them. Again not the way it turned out.

I think I connect with McCarthy’s writing due to his use of language. I’m going to update this review with some excerpts to show exactly what I mean.

Synesthesia as a literary device

a walk in to the woodsA writing exercise book I have used for a while touched on synesthesia today. The term refers to a neurological condition where the patient has one or more sensory experiences linked in their minds. Examples might be someone feeling the color blue or describing the sudden darkness of a room by way of the octaves the room had been lowered. I’d equate it to the belief that LSD makes one hear colors and see sounds.

For your reference, here’s the Wikipedia article on Synesthesia in literature page…

Synesthesia is a neurological condition in which one or more sensory modalities become linked. However, for over a century, the term synesthesia has also been used to refer to artistic and poetic devices which attempt to express a linkage between the senses. To better understand the influence of synesthesia in popular culture and the way it is viewed by non-synesthetes, it is informative to examine books in which one of the main characters is portrayed as experiencing synesthesia. In addition to these fictional portrayals, the way in which synesthesia is presented in non-fiction books to non-specialist audiences is instructive. Author and synesthete Patricia Lynne Duffy has described four ways in which synesthete characters have been used in modern fiction.

Source: http://en.wikipedia.org/wiki/Synesthesia_in_literature

The exercise I read wanted us to use synesthesia in a short description. It should not be obvious we have used the device, but rather hidden it like a down pillow in a newly washed case.

Here’s my sample for you to ridicule.

Pollock stood on the cradle of straw stacks that lined the edge of the barn. Before him, a long wide beam would carry him to the next loft, where he would scrounge and hide from his brother. A cloud passing over on the summer day softened the cracks in the beam, so it almost seemed sturdy.

Pollock placed both feet on the soil-brown beam. He inched across the great expanse, a sour flavor emerging with each step — the air around him thick and wet with humidity. Each creak of the beam colored his soul blacker and blacker until he felt like he would sink into the abyss, dark as night, lost forever. But he kept on, and on, until he made it.

Carrying

ForestThe truck bounced along the inward road, humming by the bare trees of the Herd’s woods north of their home. Two children, Denny and Paul, swayed in their bulky winter outfits, scarves wound round their necks, while their father jerked and guided the truck over the frozen road. Trailing behind them, the family wagon that sometimes hauled the lawnmower, manure, and, today, cut wood, jumped a jutting gray rock just before the truck pulled to a stop.

“Come on boys. Paul, grab the saw. Denny use these.” Denny grabbed the lifeless brown gloves from his father and slowly pulled them over his hands.

“Why do I always have to carry?”

“Because. We all carry, buddy. Your brother carried once.”

“You’re a runt. That’s why.” Paul strutted to the back of the truck, legs a little rubbery, his build not much heftier than Denny’s.

“Someday you will, Den,” Denny’s father said to him as he rested his broad hand on his son’s shoulder. “Paul, start cutting that fallen one over there. Denny and I will get the tarp.” Paul grabbed the orange chainsaw from the back of the truck and leaned to the left as he carried it to the fallen tree. It looked like a storm had taken this one out; a jagged, bright cut was made about midway up the trunk. Lightning. Denny and his father stood on both sides of the white board wagon. They rolled the blue tarp up so the inside of the wagon, scattered with wood debris, could be filled with fresh wood.

As Paul yanked and yanked the machinated uttering of the cold inner workings fought to come alive. He choked the engine and pulled hard on the cord, shattering the silence of the forest with startling white noise. Denny and his father began scouting around their vicinity for more trees to be cut, so Paul could work on them while they carried the cut wood to the wagon. Every Saturday the routine was the same: pull out from the house around eight and make it back by noon for lunch. Then in the afternoon the wagon would be unloaded into the old coal chute in the back of the house. They would stack it along the limestone rock walls in the small room with the dirt floor, spider webs, and sixty-watt bulb swaying in the dust.

Later, Denny would say he heard his brother yelling as if in trouble. But they had walked farther away from the truck in search of the fallen tree and he at the time couldn’t be sure if he heard something or if the muffler warming his ears had fabricated the sound from the snapping of limbs and the crunch of snow. They kept on searching until Denny’s
father turned to him and said they should get back, they would drive a little further to find some more wood. They walked back. Denny searched the slatted trees for any sign of an antler. He liked to track, to find the hoof prints of deer, imagining himself a superior hunter, heading through a mountainous region, scouting, eating off the land, noticingsigns of disturbance in the trees, being able to smell the descent of his prey. He thought of these things as he and his father curled down the small slope back towards the truck.

From their angle, they couldn’t see the tree that Paul was working on, or the trunk that was split in like a V, jagged and snow covered. Denny’s father couldn’t hear a revving saw and Denny noticed that spindly limbs were still poking out above the truck cab, reaching into the morning sky. Denny’s breath was warm, as it filtered through his scarf. He pulled the scarf down and asked his father if Paul had stopped working again.He was known for that. He was a slacker. Denny knew he would never stop working if he were using the saw. But carrying wasn’t an all the time thing. The wood didn’t come fast enough, so eventually a break came.

The father and son walked around the cab of the truck and they heard the idle saw before they saw it resting a few feet from Paul and the blood soaked snow. They noticed the deep gash in Paul’s left arm, near his bicep. After Denny’s father lifted his oldest son’s limp body from the snow, Denny saw how the blood had warmed the snow, melting it down to the forest floor. He saw the remains of a Sycamore leaf, brown and yellow, pooling the blood in and around its dried veins. He heard his father yell at him, a distressed look peeling across his face, as he carried Paul in both his arms. Paul’s blue striped stocking cap, falling off one side of his face. Snow speckled the cotton pattern of his jacket.

“Take your brother!” Denny’s father laid Paul across Denny’s outstretched arms. Paul was heavy, heavier than Denny expected. His knees almost buckled as his father went and started the truck to back it around, so they could head for home and call for help. Denny watched as his father struggled with backing the wagon up. He could feel the warm blood trickling down his left hand, seeping through his brown gloves. His father was frustrated and unable to back up the truck. The trip straight ahead would lead them miles away from the house that was only a mile away if they could get the truck turned around. Denny started hiking towards the house, talking to his brother, telling him everything would be all right. He was in the hands of an experienced carrier.

Holiday 2012 Photos