or learn more

Moleskine Notes for June 2008

Jul 16, 2008

Lambda C++

\#define Lambda(args, ret, body) \
  class MakeName(__Lambda__) { \
    public: ret operator() args { body; }}

Lambda((int a, int b), int, return a+b) foo;
cout << "foo(1,2) is " << foo(1, 2) << endl;

/** Recursive lambda **/
Lambda((int n), int, 
       if( n <= 0) 
         return 1; 
         return n * (*this)(n - 1)) fact;

/** Mega-example **/
template struct pair { T fst, snd; };

Lambda((int x),
    struct xv: public pair
    { xv(void) { fst=0; snd=0; }
      xv(const int a, const int b) { fst = a; snd = b; }};
      pair cache;
      int do_cache(const xv prev, const xv curr)
         if( curr.fst > cache.snd.fst )
         { cache.fst = prev; cache.snd = curr; }
         return curr.snd;
      if( x == 1 ) return 1;
      if( x == 2 ) return 1;
      if( x == cache.fst.fst ) return cache.fst.snd;
      if( x == cache.snd.fst ) return cache.snd.snd;
      if( x == (cache.snd.fst + 1) )
         return do_cache(cache.snd, xv(x,cache.fst.snd + cache.snd.snd));
      const int vp = (*this)(x-1);
      return do_cache(xv(x-1,vp), xv(x,vp+(*this)(x-2)))) fib;
    template void print_every_other(const int n)
        T closure;
        cout << closure(1);
        for(register int i=3; i<=n; i+=2)
            cout << " " << closure(i);
        cout << endl;
    main() {

Some Tab


VERSE (PART1)              (PART2)


           ^let ring and pick slide until verse begins again

Song Structure
Spirits fly high, but they die so easily
 I cry when they do
  Young energy, that flame inside seems so Free, Yeah,
 can i rely on you?
 I feel the years pass through me,
 Keep my soul awake,
 Don't wanna lose that feeling,
 Keep my soul awake.
 Keep my soul awake.
Don't let it slide, we all grow up so quickly.
 Hang on to what's inside
 So young at heart, just take your time,
 There's no hurry,
 don't want to lose my mind.
 I feel the years pass through me,
 Keep my soul awake,
 Don't wanna lose that feeling,
 Keep my soul awake.
 Keep my soul awake.

Read File in one Java line

String file = new Scanner( new File( “test.txt” ) ).useDelimiter( “\Z” ).next();

Kick-ass js Toolkit

  1. jquery
  2. Taffy DB
  3. Greybox-redux
  4. jquery UI
  5. js2-mode.el
  6. Chilli source highlighter
  7. Simile Timeline
  8. dragtable
  9. Erlang-in-js
  10. Thread.js
  11. Processing.js

Y-Combinator in js

// The Y combinator, applied to the factorial function

function factorial(proc) {
    return function (n) {
        return (n <= 1) ? 1 : n * proc(n-1);

function Y(outer) {
    function inner(proc) {
        function apply(arg) {
            return proc(proc)(arg);
        return outer(apply);
    return inner(inner);

print("5! is " + Y(factorial)(5));

Thoughts on gor

object-relational impedance mismatch

Transgressional Fiction

  • William S. Burroughs Naked Lunch, Junkie
  • Hubert Selby Jr. Last Exit to Brooklyn, Requiem for a Dream
  • Emile Zola
  • Fyodor Dostoyevsky
  • Knut Hamsun Hunger
  • Gordon Lish
  • Henry Miller Tropic of Cancer, Tropic of Capricorn
  • Alan Ginsberg
  • J.G. Ballard Crash
  • Kathy Acker
  • Charles Bukowski
  • Douglas Coupland Generation X
  • Bret Easton Ellis American Psycho, Lunar Park
  • Irvine Welsh Trainspotting
  • Chuck Palahniuk Choke, Fight Club
  • Craig Clevenger The Contortionist's Handbook
  • Luke Rhinehart Dice Man
  • Georges Bataille

Splatterpunk - Clive Barker Books of Blood - Craig Spector The Light at the End - David Schow The Kill Riff - Joe R. Lansdale The Nightrunners - Rex Miller Slob - Kathe Koja The Cipher - Jack Ketchum Off Season

Writing tips from Chuck Palahniuk

Number One: Two years ago, when I wrote the first of these essays it was about my "egg timer method" of writing. You never saw that essay, but here's the method: When you don't want to write, set an egg timer for one hour (or half hour) and sit down to write until the timer rings. If you still hate writing, you're free in an hour. But usually, by the time that alarm rings, you'll be so involved in your work, enjoying it so much, you'll keep going. Instead of an egg timer, you can put a load of clothes in the washer or dryer and use them to time your work. Alternating the thoughtful task of writing with the mindless work of laundry or dish washing will give you the breaks you need for new ideas and insights to occur. If you don't know what comes next in the story… clean your toilet. Change the bed sheets. For Christ sakes, dust the computer. A better idea will come.

Number Two: Your audience is smarter than you imagine. Don't be afraid to experiment with story forms and time shifts. My personal theory is that younger readers distain most books - not because those readers are dumber than past readers, but because today's reader is smarter. Movies have made us very sophisticated about storytelling. And your audience is much harder to shock than you can ever imagine.

Number Three: Before you sit down to write a scene, mull it over in your mind and know the purpose of that scene. What earlier set-ups will this scene pay off? What will it set up for later scenes? How will this scene further your plot? As you work, drive, exercise, hold only this question in your mind. Take a few notes as you have ideas. And only when you've decided on the bones of the scene - then, sit and write it. Don't go to that boring, dusty computer without something in mind. And don't make your reader slog through a scene in which little or nothing happens.

Number Four: Surprise yourself. If you can bring the story - or let it bring you - to a place that amazes you, then you can surprise your reader. The moment you can see any well-planned surprise, chances are, so will your sophisticated reader.

Number Five: When you get stuck, go back and read your earlier scenes, looking for dropped characters or details that you can resurrect as "buried guns." At the end of writing Fight Club, I had no idea what to do with the office building. But re-reading the first scene, I found the throw-away comment about mixing nitro with paraffin and how it was an iffy method for making plastic explosives. That silly aside (… paraffin has never worked for me…) made the perfect "buried gun" to resurrect at the end and save my storytelling ass.

Number Six: Use writing as your excuse to throw a party each week - even if you call that party a "workshop." Any time you can spend time among other people who value and support writing, that will balance those hours you spend alone, writing. Even if someday you sell your work, no amount of money will compensate you for your time spent alone. So, take your "paycheck" up front, make writing an excuse to be around people. When you reach the end of your life - trust me, you won't look back and savor the moments you spent alone.

Number Seven: Let yourself be with Not Knowing. This bit of advice comes through a hundred famous people, through Tom Spanbauer to me and now, you. The longer you can allow a story to take shape, the better that final shape will be. Don't rush or force the ending of a story or book. All you have to know is the next scene, or the next few scenes. You don't have to know every moment up to the end, in fact, if you do it'll be boring as hell to execute.

Number Eight: If you need more freedom around the story, draft to draft, change the character names. Characters aren't real, and they aren't you. By arbitrarily changing their names, you get the distance you need to really torture a character. Or worse, delete a character, if that's what the story really needs.

Number Nine: There are three types of speech - I don't know if this is TRUE, but I heard it in a seminar and it made sense. The three types are: Descriptive, Instructive, and Expressive. Descriptive: "The sun rose high…" Instructive: "Walk, don't run…" Expressive: "Ouch!" Most fiction writers will only use one - at most, two - of these forms. So use all three. Mix them up. It's how people talk.

Number Ten: Write the book you want to read.

Number Eleven: Get author book jacket photos taken now, while you're young. And get the negatives and copyright on those photos.

Number Twelve: Write about the issues that really upset you. Those are the only things worth writing about. In his course, called "Dangerous Writing," Tom Spanbauer stresses that life is too precious to spend it writing tame, conventional stories to which you have no personal attachment. There are so many things that Tom talked about but that I only half remember: the art of "manumission," which I can't spell, but I understood to mean the care you use in moving a reader through the moments of a story. And "sous conversation," which I took to mean the hidden, buried message within the obvious story. Because I'm not comfortable describing topics I only half-understand, Tom's agreed to write a book about his workshop and the ideas he teaches. The working title is "A Hole In The Heart," and he plans to have a draft ready by June 2006, with a publishing date set in early 2007.

Number Thirteen: Another Christmas window story. Almost every morning, I eat breakfast in the same diner, and this morning a man was painting the windows with Christmas designs. Snowmen. Snowflakes. Bells. Santa Claus. He stood outside on the sidewalk, painting in the freezing cold, his breath steaming, alternating brushes and rollers with different colors of paint. Inside the diner, the customers and servers watched as he layered red and white and blue paint on the outside of the big windows. Behind him the rain changed to snow, falling sideways in the wind.

The painter's hair was all different colors of gray, and his face was slack and wrinkled as the empty ass of his jeans. Between colors, he'd stop to drink something out of a paper cup.

Watching him from inside, eating eggs and toast, somebody said it was sad. This customer said the man was probably a failed artist. It was probably whiskey in the cup. He probably had a studio full of failed paintings and now made his living decorating cheesy restaurant and grocery store windows. Just sad, sad, sad.

This painter guy kept putting up the colors. All the white "snow," first. Then some fields of red and green. Then some black outlines that made the color shapes into Xmas stockings and trees.

A server walked around, pouring coffee for people, and said, "That's so neat. I wish I could do that…"

And whether we envied or pitied this guy in the cold, he kept painting. Adding details and layers of color. And I'm not sure when it happened, but at some moment he wasn't there. The pictures themselves were so rich, they filled the windows so well, the colors so bright, that the painter had left. Whether he was a failure or a hero. He'd disappeared, gone off to wherever, and all we were seeing was his work.


No Comments, Comment or Ping

Reply to “Moleskine Notes for June 2008”