Toggle Buttons Should Represent Boolean Values
14 July 2010 at 18:32
Filed Under: coding
Can we just all agree that if you have a button that is supposed to toggle from one state to another, it should represent the current state? For example, on Reddit there's a button in each subreddit that will add or remove that subreddit from your front page. The problem is - if the subreddit is not currently on your front page, the button is green with a plus sign. If it is on your front page it's red with a minus. Every time I see this button I have to stop and guess what it's trying to tell me. The colors and symbols they use don't represent the state of the condition, they represent the result of the action of clicking the button.
I experience the same thing when I use my bittorrent client. When you pause the button, it shows you the resume symbol. When you resume, it shows you the pause button. When I see this button I have to stop and figure out if it's telling me what is currently going on or what it will do if clicked.
I know this sort of makes sense in a way. Most buttons do what they say on the label. If you have a submit button, you expect it to submit your form when you click it. If you have a save button, it better save stuff.
But toggle buttons are different. They perform actions, but they also represent state. They only work if the value they represent is truly boolean. On/Off, black/white, true/false. The only action they should perform is flipping the state - pause / unpause, add / remove.
Ideas are a dime a dozen
30 April 2010 at 09:23
Filed Under: coding
It's common for the "business" people to have an idea and think that's what they're bringing to the table. I've had guys approach me to offer 5-25% equity in their imaginary company if I'll just build the product for free.
My response is, generally, "How about I build this and hire you when I'm done to sell it?" They'll protest "But this is my idea!" Who cares? Ideas are worth absolutely nothing. I have stacks of ideas that are gathering dust because I haven't had the time to do anything with them. Why should I suddenly stop everything and try to make you rich with my skills and then, inevitably, watch you try to screw me later if it works? Because you had an idea? Awesome - go to the library and check out PHP for Dummies and see if you can execute it.
Sales that haven't occurred are also worth nothing. If you want me to work for you, you need to bring something to the table - a paycheck, capital in the bank, connections or contracts that have been signed on the line that is dotted. Otherwise you're just a loser in a suit looking for a handout.
Reposted from a comment on reddit
Coder's Vocab #1 : Idempotent
09 April 2010 at 09:00
Filed Under: Vocab
In programming, the term idempotent describes a method that can be called multiple times without changing the result. Sometimes it can be a symptom of madness or incompetence - I've seen code where a save() method was called repeatedly "just in case."
Besides scratching the itch of the insane among us, idempotent routines are important. For a simple example, consider the "Checkout Button" on a typical ecommerce form. Often you will see strong language around the button asking the user to only click the button once - otherwise multiple orders will be placed and all sorts of pain and confusion may result. A common "solution" to this is disabling the button after the first click. A better solution would be writing the routine that is saving the order as an idempotent operation. In other words, it shouldn't matter how many times you save the order, you're just saving the same thing. This can be accomplished in myriad ways, from using a "replace into" database query or creating the key once and updating the database against that key.
Quiz Time! Which of the methods could be described as idempotent?
1.
function double($x) {
return $x * 2;
}
2.
$x = 2;
3.
$x = md5($x);
4.
function append($x,$y){
$x[] = $y
}
Find creatine and protein supplements now.
The difference between perl and python
22 March 2010 at 07:36
I like this quote from "Dreaming In Code," a book I'm reading this week:
In one observer's characterization of the two languages' partisans, Perlites are "chaotic/good trickster archetypes" where "Pythonistas are peaceful, have-their-glasses-on-a-little-string types, like hobbits or the Dutch."
I'm looking at you Zend
11 March 2010 at 15:24
Sometimes I throw exceptions; sometimes I throw punches. It's your call, code.
Now you have 1000 problems
12 February 2010 at 08:59
Behold, the world's greatest collection of "you're doing it wrong" examples.
Pecan Crusted Pork Chops
10 February 2010 at 08:27
Made these last night - Amanda has demanded an encore so they must be pretty good.
Instructions:
Preheat the oven to 350f. In a food processor, process a handful (about a cup) of pecans, a small handful (maybe 1/8 cup) for dried dates and about 10-12 wheat thins into a coarse meal.
Season pork chops with salt and pepper and pat dry. Dip the chops into an egg wash (one egg beaten with a tablespoon of water) and press into the crust mixture.
Cook the chops over medium heat in a pan that is just coated with a bit of olive oil for four minutes on the first side, and one minute on the second. Remove from the heat and put into the oven for about 10 minutes or until cooked through.
Let them rest on a rack under a foil tent for a few minutes and serve.
I also made a sauce with a sweet red wine and some frozen cherries and blackberries. It was good but the pork didn't need it - and they didn't last long enough to try it.
Jumping the grooveshark
01 February 2010 at 09:50
For the last year my work tunes have been provided by pandora. I had a couple stations that I had pruned and edited to my liking - to the point that I was seriously considering subscribing. I didn't mind the unobtrusive ads and the 40 hour a month limit just reminded how much I relied on it and inspired me to drop some cash their way.
Before I got a chance to do so, however, they switched up their ads to annoying audio ads that seem to show up every couple songs. The ads seemed to be louder than the music I was playing too. Around that time someone suggested I look at grooveshark. I had tried it before but their strange UI had turned me off. It seemed to confusing to bother with. Apparently enough people thought so that they put some good work into the ui, making it much easier to parse and understand what you were doing. Grooveshark seems to have the best mix of features compared to pandora, last.fm and lala.
The Babies Didn't Cry That Night
21 January 2010 at 08:08
the babies didn't cry that night
though the wind was cold
and whipped through the woods where they were huddled
though the wind was cold
and flickered the torches of the men searching
a young father knew cold nights
when his baby would cry as he walked
in front of a fire that flickered in the hearth
"Put the babies to breast." he whispered
to the women crouched behind him
they put their babies to breast
so the babies wouldn't cry that night
a boy of three crouched below his mother
his brother above him suckled and warm
he was cold and wanted to ask his mother
why the men searching with torches and guns
were in their houses
while they crouched in silence behind their fathers
who watched and shivered in the cold wind
that whipped about them in the woods
And the babies full with milk
fell asleep on their mother's breast
as the men with torches
tired of their searching
and turned and walked back down the road
their torches disappeared
flickering in the cold wind
that whipped through the woods that night
the boring part
Waiting for the baby
13 January 2010 at 10:30
I'm hanging out at the hospital with Amanda waiting on this baby. Had a slightly scary moment a bit ago. After they started the epidural Sagan's heart rate slowed down to 100 bpm from 130. They flipped amanda over and gave her some oxygen and that fixed the situation.
as the drain swirls
18 December 2009 at 01:47
We have a system in place that rewards power with power; corporations, political parties, the media all feed off each other in a vicious cycle of corruption. Change is their real enemy. In the same way that citizens (tend) to get more conservative as they age, our institutions gain more power and wealth over time and, having more to lose, become more and more intolerant of change and progress.
I really thought there was a chance -- after the orgy of corruption and excess the republicans fomented over the past decade -- that we could save this country without falling to pieces, that we could have a soft reboot and rejoin the rest of the developed world in rational conversation. It seems like that was an illusion. I don't know if we can put off pulling the plug soon.
With global climate change, rapid development draining the worlds resources faster than innovation can keep up, increasingly polarized politics, declining critical thinking and education among the celebrity addled public, the entrenchment of immortal and amoral corporations in positions of power and regulatory (and legislator) capture, corporate media drowning out all discourse with fluff and misdirection -- what hope do we have?
The only thing we have right now is the internet. This is the last tool of freedom that could keep us out of the corporate powers' hands. Google and Facebook are maybe months or years from taking that away from us. They're figuring out how to buy us off with the convenience and the social pressure of their tools and gadgets. We're letting them further and further into our private lives - even our minds. Soon the internet will be AOL again, a toy we can play with at the price our privacy and attention.
What then? At the end of history, with an exhausted planet, our bodies and minds tools of faceless corporations furiously scrambling to find the last drop of oil and ounce of water before their competitors, we'll finally get a rest. We'll never explore the stars or evolve into new and wondrous lifeforms. We'll die thirsty and hot below a yellow sun and the universe will continue its long stretch without noticing.
How to get Xinha Wysiwyg editor to work in S9y
16 November 2009 at 20:40
Filed Under: coding
For some reason I hadn't been able to get any of the wysiwyg editor plugins in my serendipity install to work. It's been a minor annoyance, so I decided to figure it out tonight. Here are the steps:
- Go to Configure Plugins and download/install the Xinha plugin. If you're lucky, it'll just work.
- Download the Xinha package from the xinha website.
- Drop the file you downloaded (Xinha_0.96beta2.tar.bz2 for example) in a folder of its own.
- Run bunzip2 Xinha0.96beta2.tar.bz2 on the command line in that folder.
- Then run: tar -xvf Xinha0.96beta2.tar
- Copy the files extracted to your plugins folder at:/plugins/serendipity_event_xinha/
- Refresh and hey - it actually works.
