-
iPhone in-app purchasing now a…
Posted on October 15th, 2009 No commentsiPhone in-app purchasing now available for FREE apps. No more “Lite” versions! http://bit.ly/2eeRMQ
-
Thoughtful take on SEO. There’…
Posted on October 13th, 2009 No commentsThoughtful take on SEO. There’s basic solid advice and markup improvements but “experts” are just selling snake oil. http://bit.ly/3aAMya
-
Javascript: get remote data in one method call
Posted on October 8th, 2009 No commentsI came across this useful bit of javascript when I had some parameters and wanted to call the server and get some data from the db(preferably in a nice json object). All in one line, as if I was calling a local function without having to mess with callbacks. ajax and jQuery make this very simple.
Here’s what the code looks like:
var jsonLoader = function(url, params) { this.url = url; this.params = params; this.retrievedData = {}; this.getRawData(); }; jsonLoader.prototype.getRawData = function() { var json = $.ajax({ type: 'POST', contentType: "application/json; charset=utf-8", url: this.url, data: JSON.stringify(this.params), dataType: 'json', success: this.setRawData(this), async: false }); }; jsonLoader.prototype.setRawData = function(self) { return function(json) { self.retrievedData = json; }; };And you’d call it like this:
var params = new Object(); params.var1 = "something"; params.var2 = 22; var data = new jsonLoader("/WebService/MyMethod", params); data.retrievedData.d.{json object name returned by the server}The method blocks until data is retrieved(async: false), so you can start using data right away.
Make sure you have jQuery and JSON libraries loaded.
Credit to the original jsonLoader sniplet author for the idea, shown here tweaked to accept parameters.
-
All WebKits are not created eq…
Posted on October 8th, 2009 No commentsAll WebKits are not created equal: http://bit.ly/3Y5iNT (WebKit powers Safari, Chrome, iPhone, Pre, Android to name a few.)
-
Brilliant bit of marketing fro…
Posted on October 8th, 2009 No commentsBrilliant bit of marketing from the North Face. New products: sticks, rocks, and leaves! http://bit.ly/q66hq
-
Rails has_many Time.now gotcha
Posted on October 7th, 2009 No commentsIt’s one of those face palm moments for me, but don’t use has_many in your rails models if it’s time dependent data. In the production environment the Time.now will be the time the environment loads the class, which is only once per server start. Keep in mind your code will work in development and test mode. So basically the solution is to move those has_many statements into a function.
has_many :recent_stuff, :conditions => ["starts_at =?", Time.now]
becomes…
def recent_stuff
timenow = Time.now
self.find(:all, :conditions => ["starts_at = ?", timenow])
end
-
Scammy LLC Statement of Information Letters
Posted on September 30th, 2009 No commentsWe’ve gotten two of these now.
In short, it’s a scam. Do not send them money. While you do need to file a Statement of Information with the state for your LLC, you only need do it once every two years (at least in California) and the cost is somewhere around $25-30.
It all looks very scary, and on the back there’s many warnings about penalties and how they’re gonna kill your puppy or something.
Tell the USPS and BBB (California already gives this company an “F”).
Also contact your state AG, which can’t work on your behalf, but may keep data for a class action to shut these scammers down.
Update: the State of California has a page up concerning these fools.
-
They’re stealing your code!
Posted on September 24th, 2009 No commentsThe great security scare of the day is rouge (possibly Russian!) thieves on the prowl looking for source code on your websitez by poking through repository directories, such as .svn. Anyway, it’s simple to block, but please folks, look at where your web servers are pointed and what may be exposed. It’s a problem as old as the web itself.
In Apache, this can be done easily:
<IfModule mod_rewrite.c>
RewriteRule ^(.*/)?\.svn/ - [F,L]
ErrorDocument 403 "Access Forbidden"
</IfModule>But sitting in front of Apache and Mongrel we use the pound load balancer. Here’s a bit of code which will catch anything trying to get into the svn directory, even though directory listings weren’t possible in the first place:
Service
URL ".svn.*"
Redirect "http://d27n.com/public/404.html"
EndYou can even skip the Redirect if you want to be lazy or don’t have a 404 page. This will just deadend the service.
-
authlogic facebook-connect and rspec
Posted on September 22nd, 2009 No commentsThe past week I’ve had a chance to add facebook-connect to a rails site we’ve been working on by using the fantastic Authlogic and the Authlogic Facebook Connect add on. However I found that all my existing controller tests blew up after adding the facebook-connect add on and after a little digging realized I needed to stub a method on the rspec TestRequest method.
The TestCase rdoc explains how to setup authlogic within your rspec controller tests, so I won’t get into that here. Since I already had everything setup with a login method in my spec_helper.rb file, I just had to add a single line to that method.
~/spec/spec_helper.rb
def login(user)
request.stub!(:set_facebook_session)
UserSession.create(users(user))
end
Eventually I’ll have to write some tests for any features that use the facebook api, but for now stubbing that method does the trick.
-
iStat Menus 2.0 Released
Posted on September 3rd, 2009 No commentsMy favorite system monitor which sits in your menu bar (great for large screens). Now Snow Leopard compatible. It’s free!
A few years ago I wrote the developer asking for a link to Activity Monitor in the menus and it appeared in the next version. Very awesome. Neat new organization options for the menus, too. Much goodness to be had.



Recent Comments