Groxx

Programming paradigm of choice: Nyarlathotep 

Chrome extensions - a short story with a happy ending

So, over the long-weekend I'm taking to visit family with my wife, I saw a tweet.

Which got a tweet.

Which gave me an idea (namely, "Oh, sure.").

Unnamed

Which lead to a frustration.

Screen_shot_2012-01-08_at_20

Which lead to a solution.

Screen_shot_2012-01-08_at_19

Which is available here: https://github.com/Groxx/Chrome-Extension-Boilerplate

Ever made a Chrome extension?  It's really, shockingly easy to do most things, but the boilerplate is pretty hefty, and the documentation doesn't really give you a quick-start option.  It's especially hefty if you want to have an options page, which just about every extension should have, because then you can have 'about' text, contact info (if you want it), and most importantly, an off switch.  Which my extension currently lacks (sorry about that! It's coming, I promise!).

So I fixed it.  Partially - it's basically all the options page right now, though a small amount of helpers are coming in time for basic stuff like script communication and one-time injection.  It's also currently dependent on jQuery (which I plan on removing, but it helps with building it).  The styles are pretty basic and possibly terrifyingly-poorly made.  It needs more documentation and boilerplating, especially for the manifest.json file.

Though I am pretty happy with the localization setup - much, much easier than messing around with it other ways I've tried.

But it's good enough for me, and I'll be battle-testing it on some of my past (and future) projects, and will be making and pushing changes and whatnot.  If you (or anyone you know) could benefit from it, or might find it interesting, or could lend a hand, I'd love input!  Give it a try and leave me a comment somewhere/how!

This has been a productive vacation :)

Filed under  //   chrome   extension   github   javascript  

Comments [0]

Bookmarklets + Mobile Safari = suck. But a little bit less, now!

If you've ever tried to get bookmarklets from random-page-X into your iThing, you have likely experienced all kinds of pain.  A good example of which exists at the Quix install page:
* Synchronize all your Safari bookmarks to your iThing?  Slow, and lame!  That likely means copying links back and forth, and plugging it in... no.  No no no.
* Click this link and remove our URL?  This works, and is the main method, but A) their link doesn't actually work (it's not the full script), and B) requires random-site-X to make a link just for Mobile Safari.  Lame!  Nobody does that!  Not even Firebug Lite!

So, in the "there, I fixed it" vein:
There, I fixed it.  I think I'll call it "Blet". Apologies about the remote file, I can't post javascript links on Posterous :/  Or just about anywhere.  I should run by own blog server some time...

Instructions:
1) Visit the link, and click the "Blet" link.  It will convert itself, so you can...
2) click the link again to load the custom URL...
3) and bookmark the page...
4) and edit the bookmark to remove the "about:" from the beginning of the path.

Viola!  Internet-wide bookmarklet-fixing for Mobile Safari.  It even works on the Firebug Lite page, frustration-with-which caused this whole to-do. Now try cornifying something with your phone! (the link in "cornify any website" on the right)

Source code for those who are interested:

Comments [0]

Hidden files in OSX: A Wayback (machine) Story

On OSX, if you attempt to open a file / location in most applications you can't (usually) step into .app packages, or see or step into hidden files or folders.  Preventing this hides a bit of usually-unnecessary cruft from littering every folder.

But what if you really want to?  Well, there's one way to solve the second one: tell Finder to show hidden files and folders (essentially only possible via the command line).  They'll then appear in any open / save dialog.  If anyone knows a way to get past the first, I'd be interested!

A while back, I found an application called "blind" which does just this.  

Download
(image pulled from the linked MacUpdate site, below)

Not that it's hard - you can literally do the same thing with an 8 line script.  But blind comes in handy in that it's meant to sit in Finder's toolbar (a seriously under-known / under-used feature), while a couple other mini-apps occasionally "fell out" after use (don't know why).  Since this is a perfect use-case for such a thing, I decided I wanted to add it to my computer again.  I could just make my own version (and I may make a post about how to - it's handy at times), but why re-make when you can just download? (in 10.6, at least, it does still force a Finder relaunch.  Maybe I could find a way to make an updated version...)

 

But alas, it was not to be.  404 not found!  Oh well, it's probably just a new site structure - but no!  This way is blocked too: it's just a placeholder now (つまらない indeed.  I needed that!).  It's gone!  Oh Internets, thy existence is a fickle one at times.

 

Then I decided to try something I'm surprised I never thought of before: why not see if the Wayback Machine archives files?  I mean, an .html is the same as a .zip, unless they decide to ignore .zip files...

And behold!  They do!  I have found the solution to all those broken download links scattered around the internet!  Well, if it has been archived, at least.  But the odds are actually pretty good that that's the case, unless it's really large.

So enjoy, Internets!  I bring goods from the past! Blind_1.1.zip Just drag it into the toolbar, and give it a click.  And this extension (Drag2Up) is amazing.  It even uploads to Dropbox!

 

Comments [0]

Internet: you have one less problem you may not have known you had.

Not that that'll make a dent in the massive list that's there.

What has been solved, you ask?  PHP-formatted date parsing and generating in JavaScript.  In addition, you may not have realized it, but if you're using JavaScript libraries to do date-string parsing you may be helping commit an unforgiveable sin against your browser: `eval`

Sure, eval is useful.  Necessary, even, and you can do some amazing things because it exists.  But it's also a gaping potential-security-hole, and often immensely slower than pre-defined functions because of the time it takes the browser to interpret & inject the code.  And for date parsing, with such strongly-defined methods, `eval` is borderline gross-negligence in code form.

Some examples!  Or skip to the goods: https://github.com/Groxx/PHPharse

Read the rest of this post »

Comments [0]

.NET is a PITA

This, in particular, struck me as exceedingly stupid today.  Normally, things can be iterated over with an IEnumerator, yes?  And then there's the useful generics form, IEnumerator<type>, so everything's strongly typed.  One would assume, given that you can make multi-typed objects (Dictionary<string, string>, for instance), that an IEnumerator could handle these.  It's as simple as IEnumerator<type, type>, right?

Wrong.

Dictionary<string, string>.Enumerator e = dict.GetEnumerator();

Samurai_jack_aku_bah

Bah!

 

Why not, oh I don't know, return a struct with {T1 type1; T2 type2; etc}?  Sure, there's no nice naming like the above Dictionary<string, string>.Enumerator has with e.Current().Key and e.Current().Value, but that's the cost of making something generic! Surely an intermediate-language generator could create such a thing on-the-fly, and Visual Studio could still hint you with the types.  If not, you could always hand-make a dozen or so to handle each length.

To make matters even worse, this all started with a desire to enumerate over the keys of that Dictionary<string, string>.  dict.Keys should be enumerable, right?  It's just a collection of strings, right?  Wrong!  dict.Keys returns a Dictionary<string, string>.KeyCollection, which has its own iterator... a Dictionary<string, string>.Enumerator.

Only in .NET.

Headdesk

Filed under  //   programming   rant  

Comments [1]

JavaScript and Event Architectures

During the course of working on one of my current projects, for The Lacuna Expanse (referral link!), I realized I could make things easier on myself with an evented model.  So I set out experimenting.  What I found was a bit surprising.

Read the rest of this post »

Filed under  //   Lacuna Pro   code   javascript   programming  

Comments [1]

GMail + IMAP gets much happier

Especially if you use Mail.app (which doesn't have folder subscription controls) or just about any email application, and use the delete button to get stuff out of your inbox, which has the annoying behavior of removing the email entirely, not just "archiving" it.  And if you move it to the All (ie, archive) folder, depending on what you're using, you may now have two identical emails in your All folder.

Thankfully, there is a solution.  A slightly crippled one, but far better than the above.

Read the rest of this post »

Filed under  //   tips  

Comments [0]

"Don't type with your mouth full"

Ca62bd83-3dbf-45b9-928a-91c148

We live in a *very* weird world.  Awesome, ain't it? (yes, it's real.)

But, on to the title piece. Sometimes, the weird-awesomeness of the world is made even more awesome by comments such as these:
http://epicwinftw.com/2010/08/01/awesome-photos-tiny-alien/comment-page-1/#comment-53182

I lol'd.  I'm still laughing on the inside.

Read the rest of this post »

Filed under  //   funny   the internets  

Comments [1]

Every browser should have this extension

User CSS, a Safari extension, albeit an unfortunately named one for Googling.  An awesome Safari extension, I dare say, and it's even open source, adding yet more awesome.  It doesn't appear to have much notice yet however, so consider this your notice!

Read the rest of this post »

Filed under  //   extension   safari  

Comments [0]

Range of Doom

I'm particularly proud of this one:

 
Those range definitions took a while to puzzle out.  Probably 30 minutes to come up with, 30 to experiment / make SURE they were working, find one bug, fix it, and make handle both 0-based-array-index results and 1-based-n-th-item results.
 
Why would I do such a thing to myself?

Read the rest of this post »

Filed under  //   code   programming   ruby  

Comments [0]