Tagged: code code RSS Toggle Comment Threads | Keyboard Shortcuts

  • rajbot 4:07 am on December 17, 2007 Permalink | Reply
    Tags: , code code, , html,   

    How To Style a DIV to look like an iChat speech balloon using CSS 

    This technique works in standards compliant browsers, such as FireFox 3 and Safari 3. You can make it work in non-standards compliant browsers if you want to, but it requires some tweaking.

    These instructions are simplified. When posting a chat transcript, you will want to have speech balloons originating from the left alternating with balloons alternating on the right. In this example, we will only discuss the case of the balloons originating from the right. We will generalize ‘CBmsgR’ and ‘CBmsgL’ as just ‘CBmsg’.

    1. Start with a container div with its css display property set to ‘table’. We will set the css class of this div to be CBmsg.

    2. Add two table-cells to the CBmsg div. The CBmsg will contain a CBtxt and a CBicon. This will create the following layout:

    The CSS for this will look like this:

    <style type="text/css">
     
    div.CBmsg {
                      display: table; 
                margin-bottom: 0.5em;
                        float: right;
                   text-align: right;
               }
     
    div.CBtxt {
                      display: table-cell;  
                     position: relative;
                       margin: 0px auto;
                    min-width: 8em;
                    max-width: 760px;
                      z-index: 1;
                  margin-left: 12px;
               }
     
    div.CBicon {
                      display: table-cell; 
               vertical-align: bottom;
                 padding-left: 10px;
                }
    </style>

    And the HTML will look this this:

    <div class="CBmsg">
      <div class="CBtxt">txt</div>
      <div class="CBicon">icon</div>
    </div>

    3. Add the user’s chat icon. It looks like this:

    This is what the CSS looks like. The padding property is only necessary if your blog template sets padding for all images, like ours does.

    div.CBicon > img {
    		  padding: 0px;
    		    width: 32px;
    		   height: 32px;
    		}

    And this is the HTML:

      <div class="CBicon"><img src="IconRajbot.jpg"></div>

    4. OK, now comes the complicated part. We use the Even More Rounded Corners technique to draw a bubble. We use a 800×1600 png that looks like an empty iChat bubble. Here is what it looks like:

    We copy the ‘content’, ‘t’, and ‘b’ CSS classes from Even More Rounded Corners verbatim:

    .CBtxt .CBcontent,
    .CBtxt .CBt,
    .CBtxt .CBb,
    .CBtxt .CBb div {
     background:transparent url(BubbleBlueR800x1600.png) no-repeat top right;
    }
     
    .CBtxt .CBcontent {
     position:relative;
     zoom:1;
     _overflow-y:hidden;
     padding:0px 12px 0px 0px;
    }
     
    .CBtxt .CBt {
     /* top+left vertical slice */
     position:absolute;
     left:0px;
     top:0px;
     width:12px; /* top slice width */
     margin-left:-12px;
     height:100%;
     _height:1600px; /* arbitrary long height, IE 6 */
     background-position:top left;
    }
     
    .CBtxt .CBb {
     /* bottom */
     position:relative;
     width:100%;
    }
     
    .CBtxt .CBb,
    .CBtxt .CBb div {
     height:10px; /* height of bottom cap/shade */
     font-size:1px;
    }
     
    .CBtxt .CBb {
     background-position:bottom right;
    }
     
    .CBtxt .CBb div {
     position:relative;
     width:12px; /* bottom corner width */
     margin-left:-12px;
     background-position:bottom left;
    }
    [/pre]
     
    And the HTML now looks like this:
    <pre lang="html">
    <div class="CBmsg">
      <div class="CBtxt">
        <div class="CBcontent">
          <div class="CBt"></div>
          txt
        </div>
        <div class="CBb"><div></div></div>
      </div>
      <div class="CBicon"><img src="IconRajbot.jpg"></div>
    </div>
     
    • cacaosteve 1:09 am on January 1, 2008 Permalink | Reply

      Could you post the necessary images and show an example? :-)

    • cacaosteve 11:02 am on January 3, 2008 Permalink | Reply

      I found an example in another entry here. This is an excellent tutorial, thank you!

  • rajbot 2:48 am on December 7, 2007 Permalink | Reply
    Tags: code code, GoogleCharts, , , jquery, , ,   

    Announcing TikiChart! 

    I hacked up a front end to google charts api using jquery. You can play with it at TikiChart.com. It’s GPLed, so please help make it better!

     
    • may 12:12 pm on December 7, 2007 Permalink | Reply

      neat! I was wondering what the google charts api was for!

    • MPaulo 3:39 pm on December 7, 2007 Permalink | Reply

      Great! So it was you who make the first wraper for it!

      What I don’t like about Google chart API is the fact axis don’t have nothing to do with values.

      Thus, in order for a simple x,y graph to make sense, you have to find the percentage of all your values and then plot them. I mean, if your max value is 150, you must make 150=100% and then calculate all values below it in terms of percentage. Your laber on the x axe will be 150, but your value will be 100%.

      Regards,
      Jose

      Also: it does not work on forums with the [IMG] tag…
      It would be usefull for the PHP class to load the url as binary and outputs it as .png, so that it can be recognized everywhere.

  • rajbot 7:54 pm on November 21, 2007 Permalink | Reply
    Tags: , , code code, , , netradio, , streaming   

    Creative Commons Radio from archive.org 

    Shag and I are testing a netradio station, streaming CC ShareAlike-licensed tracks from archive.org. Give these a listen and let us know what you think!

    Ambient Drone Electronic Folk Indie IDM Pop

    Ambient:
    Drone:
    Electronic:
    Folk:
    Indie:
    IDM:
    Pop:

     
    • may 4:11 pm on November 26, 2007 Permalink | Reply

      is there a way to listen without starting up itunes?

    • rajbot 4:19 pm on November 26, 2007 Permalink | Reply

      Sure, just go here and click on the ‘Click To Listen’ link. It should open in your default mp3 player. If iTunes starts up, then the default player is set wrong… are you using windows?

    • rajbot 4:27 pm on November 26, 2007 Permalink | Reply

      Alternatively, you can open up your favorite mp3 player, choose the ‘Open Stream’ or ‘Open URL’ menu option, and paste in one of the the .m3u urls from above…

    • may 7:05 pm on November 26, 2007 Permalink | Reply

      oh, I guess i can use itunes then. i was just wondering if there was a way to stream the music from the browser (i’ve been listening to music via pandora a lot and also through a music blog app via facebook. i think i sent you a linky today :-)

    • rajbot 12:46 am on November 27, 2007 Permalink | Reply

      Oh, of course!

      I updated the post to have in-browser players! The ID3 tags don’t seem to show up, but you can listen to the stations just fine. Maybe I need to install a newer audio plugin for wordpress…

    • may 12:51 pm on November 27, 2007 Permalink | Reply

      awesome! thank you!!

    • shag 2:26 pm on November 27, 2007 Permalink | Reply

      heh, we need to hack in resampling support to the server. some of the bitrate changes wig audacious out.

    • rajbot 2:28 pm on November 27, 2007 Permalink | Reply

      Yeah, I have a bunch of ideas of how to make this much more awesome. Do you want to get lunch tomorrow and talk about it?

    • may 5:17 pm on November 28, 2007 Permalink | Reply

      i just discovered this neat music site today! http://www.seeqpod.com/
      apparently it used to be a lawrence berkely national labs project

  • rajbot 2:18 pm on November 13, 2007 Permalink | Reply
    Tags: code code, , , jpeg, jpeg2000, kakadu, mogrify   

    How to quickly convert a bunch of JPEG2000s to JPEGs 

    Let’s say you have a directory full of jp2 files, and you want to convert them to jpg. The usual way of doing something like this is to use ImageMagick’s mogrify command:
    mogrify -format jpg *.jp2
    ImageMagick uses JasPer to decompress the jp2, and it is unbelievably slow. If you want to do the same conversion, but five times faster, use the free Kakadu software instead.

    Here is a script that will quickly convert the jp2s in the current directory to jpegs. You will have to edit the paths to the Kakadu binary and library.

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    
    #!/usr/bin/python
     
    """
    mogrify -format jpg *.jp2 is taking 24.5 seconds/image.
    The same jp2->jpg process takes 4.5 seconds/image on the same box when using 
    Kakadu, even when creating a temporary ppm file.
     
    You can get the free Kakadu binary here:
    http://www.kakadusoftware.com/
     
    This script operates on jp2 files in the current dir.
    """
     
    import commands
    import glob
     
    files = glob.glob("*.jp2")
     
    for file in files:
        print "Processing " + file
     
        cmd = "LD_LIBRARY_PATH=/usr/local/lib/kakadu /usr/local/bin/kdu_expand -i %s -o tmp.ppm" %(file)    
        retval = commands.getstatusoutput(cmd)[0]
        assert (0 == retval)
     
        cmd = "pnmtojpeg tmp.ppm > %s" % (file.replace('.jp2', '.jpg'))
        retval = commands.getstatusoutput(cmd)[0]
        assert (0 == retval)
     
    from os import unlink
    unlink('tmp.ppm')
     
  • rajbot 11:27 pm on November 6, 2007 Permalink | Reply
    Tags: , , code code, , , , QuickSilver   

    QuickSilver Now Open Source 

    QuickSilver is now open source! Check it out on Google Code..

     
  • rajbot 4:25 pm on August 17, 2007 Permalink | Reply
    Tags: code code, , , , ,   

    Shoes, a Tiny Toolkit for Making Web-like Desktop Apps 

    Shoes is a new project by the infamous why:

    Shoes is a very informal GUI toolkit. It’s for making regular old windowing apps. It’s a blend of my favorite things from the Web, some Ruby style, and a sprinkling of cross-platform widgets. (More in the README.)

    Check out the book reader tutorial on Hackety.org

    simple screenshots:

     
    • may 8:38 pm on August 17, 2007 Permalink | Reply

      it’s friday night and i’m playing with hackety hack – i am nerdy beyond hope! although, i do have a secret crush on mr. why-the-lucky-stiff :-)

  • rajbot 12:20 pm on August 15, 2007 Permalink | Reply
    Tags: code code,   

    Linking WordPress to DokuWiki 

    I wrote a WordPress plugin that turns any CamelCase word into a link to our DokuWiki, assuming a wiki page of the same name exists.

    For example, you can link to RanchTronix or KiteSurfing or whatever, just by typing a word in CamelCase. The wiki is really out of date, so please update it!

    DokuWiki is not case-sensitive, so you can use RaNChTroNiX style capitalization :)

    You can also use double-square brackets to surround a non-camelcase word to turn it into automagic wiki link like so: [[AVR]]

    If you want to use it on your own site, the source is here.

     
  • rajbot 2:19 pm on May 24, 2007 Permalink | Reply
    Tags: , , code code, ,   

    reCAPTCHA: stop spam and help digitize books 

    reCaptcha is a project by Prof. Luis van Ahn at CMU.

    Over 60 million CAPTCHAs are solved every day by people around the world. reCAPTCHA channels this human effort into helping to digitize books from the Internet Archive. When you solve a reCAPTCHA, you help preserve literature by deciphering a word that was not readable by computers.

    reCAPTCHA is a great project. I added the WordPress plugin to TikiRobot, which will hopefully reduce all the crap that Akismet fails to catch. If you haven’t seen Prof. van Ahn’s TechTalk on Human Computation, check it out. It’s very good!

    His other projects are The ESP Game and PeekABoom.

    Update: Here is a quote from Brewster:

    “I think it’s a brilliant idea — using the Internet to correct OCR mistakes,” said Brewster Kahle, director of the Internet Archive, in a statement. “This is an example of why having open collections in the public domain is important. People are working together to build a good, open system.”

     
  • rajbot 5:40 pm on May 23, 2007 Permalink | Reply
    Tags: code code,   

    Make a grid using ImageMagick 

    I needed a jpeg with gridlines on it. Here is a python script that will generate the arguments to ImageMagick to create a grid:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    
    #!/usr/bin/python
     
    cmd = 'convert -size 1000x1000 xc:white -strokewidth 1 '
     
    for i in range(0, 999, 100):
      cmd += "-draw 'line "+str(i)+",0 "+str(i)+",999' "
     
    for i in range(0, 999, 100):
      cmd += "-draw 'line 0,"+str(i)+" 999,"+str(i)+"' "
     
    cmd += "grid.jpg"
     
    print cmd
     
  • rajbot 12:42 pm on May 22, 2007 Permalink | Reply
    Tags: , code code, , ,   

    Canvas3D 

    This video of a canvas3d/javascript demo in Firefox gives me hope. Some parts of my canvas(2d) web app runs 100x slower in Firefox/linux than Safari/OSX. It looks like they have hardware acceleration working, finally :)

    Here is some info on Canvas3d in javascript.

     
  • rajbot 10:55 pm on March 20, 2007 Permalink | Reply
    Tags: code code, ,   

    How to keep WordPress from borking your post 

    Sometimes you just want to post a code snippet or some xml on your blog, but WordPress borks the formatting. So we installed the iG Syntax Hilighter, which mostly works great. It uses GeSHi under the hood.

    But sometimes, the syntax highlighter does too much highlighting. I wrote a minimal GeSHi language file for ‘nocode’, which basically lets me use the syntax highlighter like a glorified pre tag. No more worrying about wptexturize() pulling a Swedish Chef on your post! Here is the language file if you want to use it:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    
    <?php
    /*************************************************************************************
     * nocode.php
     * -------
     * Author: rajbot
     * I wanted a <pre> that didn't fuck everything up..
     ************************************************************************************/
     
    $language_data = array (
    	'LANG_NAME' => 'NOCODE',
    	'COMMENT_SINGLE' => array(),
    	'QUOTEMARKS' => array(),
    	'KEYWORDS' => array(),
    	'OBJECT_SPLITTERS' => array(
    		),
    	'REGEXPS' => array(),
    	'SCRIPT_DELIMITERS' => array(
    		)
    );
    ?>
     
  • rajbot 12:44 am on March 20, 2007 Permalink | Reply
    Tags: code code,   

    Announcing the TikiWikiFormatting WordPress plugin! 

    I wrote a plugin that lets us use UseMod Wiki’s formatting syntax to format posts more easily… You can read more about it here. It’s already installed here, so go nuts!

    I’m sure the first thing that jumped into your head is why not just use MarkDown? Well, I don’t like MarkDown’s link format. UseMod’s is much easier!

    Compare Markdown:

    [The TikiRobot Blog!](http://tikirobot.net/)

    And UseMod links:

    [http://tikirobot.net The TikiRobot Blog!]

    Also,

    • I like the way
      • UseMod syntax
        • lets me easily create sublists

    Are there any other UseMod syntax elements I should add?

     
  • rajbot 2:35 am on March 18, 2007 Permalink | Reply
    Tags: code code, , , , ,   

    Example Scripts: REST web services and system calls 

    I’ve been translating all the new perl and php scripts I write into Python and Ruby in order to learn more about those two languages. I checked some more example scripts into SourceForge, which might be useful for others who know one of these languages and want to learn a new one.

    These scripts are available in perl, php, python, and ruby:


    The REST Web Service PHP and Perl scripts don’t work in Mac OS X, because OS X doesn’t ship with Perl’s XML::Simple or PHP’s simplexml. More surprisingly, OS X doesn’t ship with Perl’s LWP module.

    I’m starting to like Ruby more every day. It would be nice if Ruby and Python had a XML::Simple equivalent in their standard distributions.

     
  • rajbot 1:36 am on March 15, 2007 Permalink | Reply
    Tags: code code, , , , ,   

    Example scripts: directory listing in perl, php, python, and ruby 

    I remember when I fell in love with Perl. It was the summer of 1995, and peliom and I had just met, and were working at the Lab. Postscript hacking using MacPerl on OS 8. It was beautiful.

    That was more than ten years ago, and even though I’ve remained a Perl hacker the whole time, I see massive amounts of development happening on Python and Ruby, and the Perl community seems to be slowing down (what’s up with Perl 6 anyway?), so, despite the lack of block-level scope, I think it might finally be time to move on.

    I don’t know enough about either Python or Ruby to figure out which to learn, so I’ll learn them both, and deal with choosing one later. Along the way I’ll post some example scripts. Anyone else making the jump from Perl or PHP to something modern might find these useful. Here is the first example: printing out a directory listing using readdir and glob in your favorite scripting language:

    (More …)

     
    • Pete 6:10 am on March 15, 2007 Permalink | Reply

      Neat, I’ve been thinking of looking in to ruby recently, but haven’t had the time.

      Oh, and with perl, there’s always more than one way to do it :)

      Neat thing about fileglobbing in perl is that you don’t need to use glob(), you can just use the diamond operator:

      foreach(@_=){print “$_\n”;}

      works great!

    • Pete 6:11 am on March 15, 2007 Permalink | Reply

      Oops, there should be a (greaterthan)/*(lessthan) after @_=

    • rajbot 9:10 am on March 15, 2007 Permalink | Reply

      Thanks Pete!

      I’m intentionaly trying to avoid using Perl idioms that only Perl people can understand. After talking to a few non-perl people, it seems like they mostly hate perl because they can’t grok the syntax of the idioms, and those are easy to avoid. Well, also, objects.

      I totally understand the desire to type as few chars as possible, but I’ve found that non-perl people are generally ok with perl code that doesn’t use idioms and special variables.

      You can enclose code blocks in

      [code]

      followed by /code in square brackets

  • rajbot 3:59 pm on February 28, 2007 Permalink | Reply
    Tags: , code code, , ,   

    How to render text using HTML Canvas 

    I’ve been using HTML5 Canvas for a few web apps, and for the last year I’ve been avoiding rendering any text because Canvas lacks text support. Over the last year, several people have come up with workarounds.

    • Firefox decided to add a non-standard method called drawWindow(), which lets you composite a hidden iframe with html text.
    • The TextCanvas project adds a drawString method to the canvas api, which positions a HTML element on top of the canvas.
    • The Variable Width Canvas Fonts project pre-generates an image containing characters at known locations and then uses drawImage to display the necessary characters.
    • The very cool CanvasPaint project went nuts and implemented vector fonts in canvas! (more info here)
    • None of the above links work in Safari. Despite being the original developers of Canvas, Safari’s Canvas support is extremely buggy. Things work better with the nightly builds, but even then, many things are broken.

    I’ve been thinking about giving up on supporting Safari completely, and maybe trying out dojo’s gfx 2D graphics API, which has text support but uses SVG/VML instead of Canvas. For the time being though, I found a silly workaround. Since I only need to display numbers, I can just create 10 pngs, one for each digit. Here is a bash script that creates the number pngs using ImageMagick:

    for ((i=0;i<10;i++)); do 
         convert -size 75x100 xc:transparent -quality 100 -font Courier-Bold -pointsize 144 -fill green -draw "text -5,95 '$i'" g$i.png; 
    done

    Here’s a blurry screenshot of how it looks:
    6.jpg

     
  • peliom 12:32 pm on February 24, 2007 Permalink | Reply
    Tags: code code,   

    Frances E. Allen wins ACM Turing Award 



    IBM Researcher Frances Allen won this year’s A. M. Turing Award, the ACM’s “most prestigious technical award.” The mainstream news story here is that Allen is the first woman to win the award although as
    The Register notes

    As Turing himself was famously gay, there are now relatively few inclusiveness milestones for the prestigious gong to pass.



    An annoying property of these types of news stories is their bland and tasteless descriptions of a person’s important contributions to an academic field, to wit:

    Her pioneering compiler work culminated in algorithms and technologies that are the basis for the theory of program optimization today and are widely used throughout the industry.

    And that’s the detailed version, taken from Allen’s bio page.

    Don’t hold back guys … where are the papers? I love seeing old scientific papers, thinking back to a time when techniques that are printed in thousands of textbooks we love to hate were just being invented.

    I wish I could tell you what Allen did, but our stupid society keeps that information locked up. After over an hour of search, I found an early Allen paper called Control flow analysis … a hearty fuck you to the ACM (of which I used to be a member) for keeping this and all the rest of the Computer Science corpus locked up behind a password protected for-pay-only website. Scientific knowledge belongs to all of us.

    Control flow analysis is my favorite topic from my favorite CS class, Compiling Techniques. Control flow is used by compilers to make my crappy code run faster. The idea is to build graph of the various execution paths that are possible in a given piece of code and then using graph traversal techniques to remove redundant code paths or introduce new paths that exploit hardware features. I also like it because debugging control flow (when you are making a compiler) involves making pretty pictures as in this comparison of three different control flow algorithms.

    In Figure 5.5 the three approaches are compared using a method of medium size. The start block is marked dark gray, loop headers are red, blocks with loop depth greater than zero are orange and blocks without successors are drawn green. All other blocks are painted yellow. This way one can easily see the differences between the three algorithms.





    Link to Frances Allen Turing Award on CNN

     
  • rajbot 1:33 am on January 29, 2007 Permalink
    Tags: , code code, ,   

    Update Twitter via iChat status message, part II 

    A while back I posted a perl script that would update your Twitter status whenever you changed your iChat status message. Unfortunately, you had to configure launchd or cron to use it, which no one wanted to do. So I made an open-source Cocoa app that is easy to use! It’s called TikiTwit, and you can download it for free!

    TikiTwit.png

    Download it here! This is a very early version, so please help me test it!

     
    • may 9:10 am on January 29, 2007 Permalink

      yay! i’ll try to get you an icon / graphics for it later on tonight :-)

    • Seth 3:11 pm on January 29, 2007 Permalink

      Is there any way to make this work the other way around? I want my iChat status (if I’m online) to change whenever I update my Twitter.

      Can this be done?

    • rajbot 3:54 pm on January 29, 2007 Permalink

      Yeah, we’ll add this in the next version. In the mean time, it looks like there are a bunch of other Twitter/iChat apps out there now. Here is one that might do what you want:

      http://code.google.com/p/twittereeze/

    • rajbot 7:26 pm on January 29, 2007 Permalink

      The guy who wrote Twittereeze has a pretty great blog.

    • EJ 6:28 pm on February 22, 2007 Permalink

      Very cool! It would be sweet if you could make something similar for Adium.

    • rajbot 6:41 pm on February 22, 2007 Permalink

      I’ll add skype and adium support when I get a chance…

    • mikey 9:15 am on April 13, 2007 Permalink

      Very cool app – does exactly what it says on the tin. Was just wondering if you could fix it so that when you have your status set to your currently playing song in iTunes that is posts that rather than “%Title – %Artist”?

    • rajbot 11:03 am on April 13, 2007 Permalink

      I’ve really been neglecting this little app, but I’ll probably add the requested features, including the iTunes fix, before the month is up. I sketched out a flow of how the next version of the app is supposed to work, but I spent a good part of this month drinking and sleeping and playing with my dog..

    • mikey 3:03 am on April 16, 2007 Permalink

      Not teaching my grandmother how to suck eggs here or anything, but http://www.leroux.ca/archive/dsp_view_470.cfm has an applescript that parses the song name out of iTunes…

    • Matt 8:13 am on April 20, 2008 Permalink

      I don’t know if this is possible – but I would love it to run in the background with an icon in the menubar.

      Otherwise – great app and I haven’t had any problems with it!

    • rajbot 11:51 am on April 21, 2008 Permalink

      Wow.. people are still using TikiTwit!

      I’ve been moving more of my life over to Linux, so I don’t know how soon I’ll get to it. I’m tickled that it’s still getting use!

      The code is checked in on SourceForge, so if anyone wants to take over and improve it..

  • rajbot 2:17 pm on January 27, 2007 Permalink | Reply
    Tags: , code code,   

    url encode in cocoa 

    Let’s say you need to url-encode a string. No problem! You can call uri_escape in perl, or urlencode in php, or urlencode in python, or CGI.escape in ruby…

    But now let’s say you are writing in Cocoa. ugh. Before you shell out to your favorite scripting language, check out CFURLCreateStringByAddingPercentEscapes() It doesn’t encode the RFC 2396/RFC 2732 reserved characters by default (other than ‘[' and ']‘), but you can specify additional characters to encode in the fourth argument. Use something like this:

    CFURLCreateStringByAddingPercentEscapes(
        NULL, 
        (CFStringRef)@"escape this %;/?:@&=+$[] string", 
        NULL, 
        (CFStringRef)@";/?:@&=+$,", 
        kCFStringEncodingUTF8
    );

    It took me quite a while to figure this out… I found the NSString method stringByAddingPercentEscapesUsingEncoding, but that doesn’t escape the reserved characters.

    (I have a suspicion that Cocoa developers are getting paid per letter…)

     
    • Travis Cripps 5:07 pm on February 14, 2007 Permalink | Reply

      Thanks for this tip! It was exactly what I needed.

    • Serge 7:07 pm on December 3, 2008 Permalink | Reply

      +(NSString *)stringByAddingPercentEscapesForUrl:(NSString *)s {
      NSString *reserved = @”;/?:@&=+$,”;
      return [NSMakeCollectable(CFURLCreateStringByAddingPercentEscapes(kCFAllocatorDefault, (CFStringRef)s, NULL, (CFStringRef)reserved, kCFStringEncodingUTF8)) autorelease];
      }

  • rajbot 11:17 pm on December 5, 2006 Permalink | Reply
    Tags: , code code,   

    MSPaint implemented using HTML Canvas 

    mspaint.pngYou know how I’m always talking about how HTML Canvas is going to enable all kinds of new and interesting web apps? Well, someone implemented MSPaint in Javascript using Canvas! You KNOW someone out there is working on a Canvas version MacPaint… or how about a Canvas version of System 7???

     
    • may 12:01 pm on December 6, 2006 Permalink | Reply

      i was playing with this yesterday too! it works on both my tabletPC and the mac. hooray for javascript :-)

  • rajbot 1:46 pm on December 3, 2006 Permalink | Reply
    Tags: code code, ,   

    Metroid Level and Room Design 

    hexmap.pngIf you like old video games, you might get a kick out of this description of Metroid level design. I spent hundreds of hours playing Metroid in the eighties, and now I spend countless hours reading about it. But since it’s time that I should probably be working, I like to think that it’s time well spent! (via)

     
  • rajbot 10:02 pm on November 10, 2006 Permalink | Reply
    Tags: code code,   

    How to create transparent PNGs 

    I wanted to create a transparent PNG, and couldn’t figure out how to do it easily until I remembered about netpbm. Here is how to create a transparent PNG on unix or OSX with the netpbm tools installed:

    pngtopnm in.png | pnmtopng -transparent white -compression 9 > out.png

    The -transparent white option specifies the color in your PNG file that should become transparent. You can also specify a RGB tuple by using -transparent rgb:ff/ff/ff

    If the color you specified doesn’t exactly match an existing color in your image, netpbm will try to find the color that is closest to the one you specified and make that color transparent. If you don’t want netpbm to do this, you can use the =color syntax: -transparent =white

    The -compression 9 option tells netpbm to use the maximum PNG compression level. If you are a compression nerd and want your PNGs even more efficiently compressed, check out OptiPNG.

    Finally, if you need to find the RGB tuple of a particular pixel in your image, check out the DigitalColor Meter app in /Applications/Utilities/ on OS X.

     
  • rajbot 1:09 pm on November 1, 2006 Permalink | Reply
    Tags: code code,   

    Thanks, WordPress Team! 

    wordpress-logo.jpgThe WordPress team is doing some awesome work these days. They’ve just released WordPress MU 1.0. The MU stands for multi-user.. This is the software that powers wordpress.com; it lets you set up a site that hosts thousdands of blogs. Perfect for setting up a walled garden.

    Also check out bbPress. It’s forum software that doesn’t suck. I wish bbPress was around when we set up the-forum-that-shall-not-be-named..

    Also, the WordPress Team just released WordPress 2.0.5, which has a ton of bugfixes. They are on a roll!

    Lastly, Laughing Squid points to this awesome Flickr Photo Album WordPress plugin. Check out Scott’s example of his full flickr album. He writes:

    Another fantastic feature of this plugin is that it adds a “photo” tab in the upload section of your WordPress editing screen. That gives you access all of your photos or even other people’s photos (searching by tag). Once you find the photo you want to include with your blog post, just click on it and you are presented with 5 size options. Choose the size you want and it will automatically add the correct code to your blog post at the cursor location. This blows away the WordPress photo upload feature or Flickr’s “Blog This” option.

    Thanks to Joe Tan who wrote the flickr plugin :)

     
    • Travis 1:33 pm on November 1, 2006 Permalink | Reply

      Awesome!

    • may 4:15 pm on November 1, 2006 Permalink | Reply

      oh wow, the flickr plugin totally rocks. can we install that in our plugins directory?

  • peliom 2:20 am on October 27, 2006 Permalink | Reply
    Tags: , , , code code, , , , ,   

    RSS is the New Email: A Polemic in ObjC 




    About a month ago I was going on about trying to use a newsreader to keep up with all the RSS flying around. I tried Google News Reader, hated it. I tried about 10 other RSS readers, both web based and client software (mac)… I felt like they all missed the point.

    When I’m reading RSS, I actually don’t give a monkey’s tail about the RSS. RSS is stupid, unformatted, unstyled text with no soul and even less information. The way to consume RSS coming from websites is to read it in it’s richest form: from the website itself. Some client newsreaders go a short way down this path by giving you button to open the article in your web browser. But this is totally lame. I mean, a drunk dog could open up a web browser and sit there through the World Wide Wait and sift through the blink tags and advertisements and try to read the article.

    I am happy to make the first public mention of TikiRobotReader, a Mac OS X application that (eventually) will handle RSS in a way that is not totally dain bramaged. TRR is Open Source, a Cocoa application, and a work in progress.

    The basic idea is that for a given Article, TRR will download the link to the article’s web representation and convert it to PDF so the articles are all nice and shiny and ready for your skimming pleasure, no waiting required. Here is what I want TRR to be:

    Principles of Operation

    • Simple keyboard commands everywhere. Should be operable one-handed while eating lunch.
    • RSS is disposable content. It’s not critical like most (personal) Email.
    • Read the content as presented by the website, not some random choice of Font and Color.
    • Blog posts and status messages from friends are way more important than Yahoo/CNN headlines.
    • Streamline the reading process. No nagging feelings of “should I delete this article or save it?”
    • Download and cache web pages as PDF. Zero latency when switching articles.
      • PDF loads immediately, vs 1-5 seconds for an HTML page to render
      • PDF is a static page, no blinking and bouncing flash ads and animated GIFs
    • RSS is a source of content. Provide easy hooks for the sinks: Sharing and Research.

    The current release is ugly as hell, but functional. At this point TRR is best enjoyed by running out of XCode so you can debug crashes and implement nifty features. I will be using it as my daily news reader in this fashion. But the nightly builds are functional and get the idea across. Feel free to contribute! Design ideas are helpful and code contributions are always a good thing. TikiRobotReader is meant to present RSS the way you, the discerning TikiRobot! blog reader, think is best. TRR will be a great place to implement all those Web 2.0/client features we want but can’t get anywhere else.

    Link to TikiRobotReader nightly build
    Link to TikiRobotReader SourceForge page

     
    • jamie 5:11 am on October 27, 2006 Permalink | Reply

      Very nifty. I think I would prefer real HTML to PDF though. It be nice to be able to click on links in articles, as well as on the site itself.

    • rajbot 7:31 am on October 27, 2006 Permalink | Reply

      Yay!!!!!!!! Congrats on the first release :)

    • may 8:42 am on October 27, 2006 Permalink | Reply

      hooray!

    • rajbot 11:21 am on October 30, 2006 Permalink | Reply

      I added code to decode html entities and char codes, because I didn’t like those &8217s that were showing up.. I also made it strip html tags.. BUT

      How would html tags get in the RSS anyway? They would have to be escaped I think.. which means I have to do the html entity decode before running the strip process, right? If so, I have more stuff to do..

      Do you have an example of html tags in an RSS feed? I’ve only heard about this, but haven’t come across any..

  • peliom 7:33 pm on October 14, 2006 Permalink | Reply
    Tags: , code code,   

    A Joyous Crash in removeObserver:forKeyPath: / _NSKeyValueObservationInfoCreateByRemoving 

     Images Frustration Today I had the joy of trying to figure out a tough crashing bug somewhere deep inside a Cocoa / Core Data / KVC / KVO application. In case anyone else is running into this crash, it’s not your fault:

    Ah, the infamous _NSKeyValueObservationInfoCreateByRemoving crash bug.
    That’s shown up with a number of triggers, and is definitely not
    reproducible, nor is your code at fault. I filed a bug on it, and Jim
    Correia (who often posts on this list) has sent in a reproducible case.

    If you can figure out the interface item or binding that’s triggering it,
    you may be able to work around it. In my case, I was able to have an object
    traverse a relationship for me, instead of binding through the relationship,
    and that stopped the crashing.

    I was able to avoid this crash by overriding removeObserver:forKeyPath: to do nothing (especially not call NSObject’s implementation, which was doing the crashing).

    I’m also getting a crash in -[NSOutlineView _sendDelegateWillDisplayCell:forColumn:row:] which I don’t understand. I’ve turned off all my NSOutlineView customizations….maybe I’m calling reloadData too often. If anyone has ideas, I’m all ears.

    Link to a cocoa-dev message I wish I had seen about six hours ago

     
    • killerdemouches 5:29 am on June 4, 2007 Permalink | Reply

      It may interess someone.

      I add some problem working arround with this bug, so i decided to fix this issue of NSObject by myself:

      // NSObjectKVOCrashFixer.h

      1. import

      @interface NSObjectKVOCrashFixer : NSObject {

      }

      @end

      // NSObjectKVOCrashFixer.m

      1. import “NSObjectKVOCrashFixer.h”

      @implementation NSObjectKVOCrashFixer
      - (void)_removeObserver:(NSObject *)anObserver forProperty:(id)property
      {
      if([self observationInfo]!=NULL)
      [super _removeObserver:anObserver forProperty:property];
      else
      NSLog(@”Fixed an Apple crash!”);
      }
      @end

      and

      // main.m

      1. import
      2. import “NSObjectKVOCrashFixer.h”

      int main(int argc, char *argv[])
      {
      [NSObjectKVOCrashFixer poseAsClass:[NSObject class]];
      return NSApplicationMain(argc, (const char **) argv);
      }

      I know this is dirty. But it works and it seems necessary for me until apple check by themselves if value==NULL before doing a CFRelease…

  • peliom 2:35 pm on October 13, 2006 Permalink | Reply
    Tags: code code,   

    Hans Reiser Arrested; Suspicion of Murder 

    For those unfamiliar with ReiserFS, it’s a filesystem authored by a notoriously argumentative dude. Inclusion of ReiserFS in the Linux Kernel has always been controversial because, well … ReiserFS sucks, but for some reason some people want to include it in Linux.



    Link to Reiser Murder / Arrest Story

     
c
compose new post
j
next post/next comment
k
previous post/previous comment
r
reply
e
edit
o
show/hide comments
t
go to top
l
go to login
h
show/hide help
shift + esc
cancel