lazywithclass's posterous

yet another blog from a dev

    • 0
      17 May 2012

      Using the chromebook search button in Ubuntu

      • Edit
      • Delete
      • Tags
      • Autopost

      I've found an usage for the search button which could be useful. Of course this is true when I'm using Ubuntu on my chromebook (which is 99,98% of the time).

      The idea is to use it as a generale purpose button, simple bindings with letter, to handle programs I use the most, staying out of the way from keybindings in emacs.

      I'll provide mplayer as an example, wonderful piece of software btw ;D I always wanted a way to issue a couple of commands from the keyboard, usually I was using some program reduced to icon in the traybar, but that's slow so I've bound two keys, n for next song and spacebar for pause, like so:

      To find out which code a key is bound to is easy, just issue xev | grep keycode and look at the number next to keycode.

      To see the changes run xbindkeys. So after having started mplayer with 

      you'll have it listen to that fifo, no more from the shell (if you usually did that), btw a control c will terminate it.

      P.S.: the sticker keys are from 4keyboard.com (excellent products and service) 

      • views
      • Tweet
    • 0
      26 Feb 2012

      Thoughts after a week of startup work

      • Edit
      • Delete
      • Tags
      • Autopost

      My first week of startup work passed by, here are some things I've highly appreciated, note that the order is not important:

      • I did not open Eclipse, not once, not that I hate it, but it reminds me about years of Java and xml, also I prefer Emacs, even though it (sometimes) makes me cry, but hey: C-x M-c M-butterfly ;D
      • I did not have to write in an ugly 00's looking webapp what I did and for how long I did it during my days (lots of companies do this)
      • I wrote code and pushed it since the first day, okay, I started helping a month ago, but I'm sure this would've happened also if I didn't
      • I worked on something I believe in

      Let me expand a bit on this point because it's the most important. Working on something I believe in it's a terrific improvement on productivity, I'm seeing it in first person, there is no waiting for the weekend, there is no "ok I will relax now, I don't wanna think about that thing again", instead there's "wow, I'm wondering how good we will be at x and how we will solve y, mmmh..."
      This is a game changer. The game changer.

      • There's no "the client said it wants it like this, I know it's stupid and useless but...", everything could be discussed with a chance to have it the way you think it should be, or at least you get a meaningful explanation abut why it is that way and it will not change. Also, since you care about it, a "no" is just no more enough to stop the conversation
      • Experimentation. Damn I love this side of the whole thing 
      • Cutting edge technology. In this first week I started looking seriously into mongo, handlebarsjs, ruby, nodejs (I already worked with it, but doing it at work is another thing), backbonejs. I got a huge headache by Friday, never felt that feeling, perhaps my little brain finished its space :P

      Anyway, tomorrow is another day of exciting work and I can't wait :D 

      • views
      • Tweet
    • 2
      23 Feb 2012

      Adding ECB to Emacs 24 with starter kit

      • Edit
      • Delete
      • Tags
      • Autopost

      I finally succeeded in adding ECB to my Emacs configuration, I believe this will greatly help me in handling projects bigger than my usual personal project. It was not easy, to say the least, maybe it's just because I'm new to Emacs, I do not want to be addressed as heretic lol, following are the instructions.

      My environment:

      • GNU Emacs 24.0.93.1 (I'm using the snapshot gtk version on Ubuntu 11.10)
      • starter-kit 2.0.3
      • CEDET 1.0pre7 (starter kit built-in)
      • latest ECB from CSV repo (http://ecb.cvs.sourceforge.net/ecb/ecb/)
      • speedbar, don't know the version, it's not specified in package-list-packages (starter kit built-in)
      • eieio 1.3 (starter kit built-in)

      Make sure you have the required packages, I am not sure I've got what's listed at point 3 though. The key point for me was taking the latest ECB.

      Also, I've added this in my emacs configuration file:

      The following is a useful configuration I've added to move between windows using shift and the arrow keys, I know that the arrow keys are the evil, but I really don't find C-c . g d any better ;D Maybe I will in a couple of decades.

      Since my theme is heavily inspired by solarized-dark I added those custom settings, since the original ones were like yellow on violet or something like that. 

      This is the result:

      58_pm

      If you have any question just post in the comments.
      • views
      • Tweet
    • 0
      13 Feb 2012

      Everybody is suggesting the same thing

      • Edit
      • Delete
      • Tags
      • Autopost

      Almost everywhere around us the suggestion is the same, with different words or approachs:

      We are all dying. Live as this is your last day.

      If you are not doing all you can, then there's no one else to blame except you. Not the government, not whoever your god might be, not the bad luck, not the cat interrupting you. Just you. Ok, there are edge situations, but these are exactly that, edge situations.

      Here are a few random reflections on the subject.

      The cartoon view

      In a lot of cartoons, especially anime, the main character always has to beat stronger opponents (which often beat him badly the first time), but somehow he manages to survive. It is a fact that one has to leave his comfort zone to do better and better.

      The comfort zone is a behavioural state within which a person operates in an anxiety-neutral condition, using a limited set of behaviours to deliver a steady level of performance, usually without a sense of risk. A person's personality can be described by his or her comfort zones.

      So the main characters is doing just that, leaving his comfort zone facing stronger and stronger opponents. Imagine your favourite hero, do you think he would've been able to defeat any of his enemies had not he faced the previous ones?

      The last samurai view 

      (just the first 36 seconds of the video)

      In this case the concept is shown within a more spiritual perspective, the important passage is

      Like these blossoms, we are all dying. To know life in every breath [...]

      By greatly valuing every single moment one could improve oneself, simply because one will face a lot more opportunities to challenge his preparation.
      This is also true in Kendo which I practice since three years ago, where you are told to "try harder when tired". This is because, in this mental and physical state, each moment that passes by is giving you a lot more than hours spent while training fully rested, that's because you've never been where you are! You're exploring feelings and sensations you will face again, while practising or in a competition, this will prove very useful.

      The gaming view

      If you're a gamer then you already know this very well: the difference between online play and solo play. More often than not how you play in these two environments greatly differs, at such a point that sometimes you could see something like "ESRB Notice: Gameplay may change during online play".
      This is because of other players.
      Just that, you will face others that will be a lot more challenging then the "hard mode", yes of course the notice is there to also warn you that you'll find whiners, lamers and probably some annoying people. But that's ok, you'll also find a lot of people that will help you or challenge you in an entertaining way. Having reached a certain point you will begin to help others, and that's where you'll know you've made progress, you improved by facing others.

      Carpe diem

      Professor Keating inspired his students to find their own words, to find their own verse:

      That movie is full of quotes that fit into this subject, just pick some from wikiquote.

       

      And of course there's the speech gave by Steve Jobs in 2005 at Stanford, but that video it's very famous, I wanted to show that sources for this subject are almost everywhere.

      tl;dr

      I resigned from my job a couple of weeks ago. Next week (well, I already started in my spare time :D) I'll start working for a startup which is on its way to publish its ambitious project. I'm thrilled with it!

      Of course this post has something to do with it, its indeed an attempt to follow the suggestion, one could say that I'm advising myself :D. It's me trying to do what I like, where I like it and how I like it. In Italy finding a job these days is a bit difficult, so is it a wise move to change from a safe job to an entertaining but risky one?
      Maybe, time will surely tell.

      • views
      • Tweet
    • 0
      10 Feb 2012

      Running a single test out of a group

      • Edit
      • Delete
      • Tags
      • Autopost

      In a couple of previous posts I showed a few small functions I've wrote to ease TDD in emacs while developing javascript in js2-mode.
      The more I develop using this environment the more I'm seeing things I'd like to customize to my taste, so this is time is no exception.

      As I was adding tests I noticed I did not need to run all of them everytime, since a lot of them involve querying the server or external site they are not immediate, I needed a way to test each one on his own. The only solution I could come up with was to:

      • mark the region around the test (so in my case around the it("should ...", function() {}); block)
      • by issuing a key combination create a new file with the test in it
      • run mocha on the newly created file
      • display the results in emacs (this is shown for free in the echo area)
      • remove the file

      I would have appreciated a lot more something like "sending the current region to a listening process", but that is out of my current elisp skills :P

      So, here is the code:

      That's it, I'm a bit concerned if this is proper TDD, in the sense that maybe all tests should run all together, but again, as long as I'm more productive (will check if I'll be) I'll stick with this solution.

       

      • views
      • Tweet
    • 0
      8 Feb 2012

      Thoughts on using docco

      • Edit
      • Delete
      • Tags
      • Autopost

      I'm using Docco to have documentation along with code, in this way I believe I could keep both information in a useful and good looking way. I do not like the idea to have information in two different places, it's already difficult to update documentation after having modified the code.

      Having to explain what my code does is a good way to carefully find out if it really does what I mean, or if what I meant could've been done in a cleaner way.

      From what I've understood this is a form of literate programming, I don't care if I'm not following exactly how this is supposed to work as long as I have profits. To do truly literate programming I think I should write what a function have to do and then write how it does it (by writing the code).

      But. Where does TDD goes in all this? Do I have to write the docs, the test, and then the function? I believe this is complicating things, I'll follow this approach and see how it goes:
      1. write the test
      2. watch it fail
      3. write the function
      4. get the green bar
      5. refactor
      6. write the doc
      7. check that this is what I meant

      Basically I'm just adding the extra step at the end of the TDD cycle, the purpose of writing the doc is to check that the function does what I mean as well as that it does it successfully.

      Oh, by the way Docco works great with .js files too, not just with .coffee ones.

       

      • views
      • Tweet
    • 0
      6 Feb 2012

      Logging in nodejs

      • Edit
      • Delete
      • Tags
      • Autopost

      I needed a way to log messages at an environment-depending granularity, I am deploying my code on heroku, so I already have NODE_ENV set to a value depending on that.

      I've set the granularity depending on that environment variable:

      So that evaluates to "error" if I'm in production or to "debug" if I'm developing. Sure I could've put the logging level in process.env, but I've thought that in this way I do not have to add anything to my configuration, the code adapts to the environment.

      For the sake of completion I'm using TJ Holowaychuk's log.js; for starting the server I use nodemon.

      • views
      • Tweet
    • 2
      1 Feb 2012

      POSTing with @mikeal's request

      • Edit
      • Delete
      • Tags
      • Autopost

      I've had a little problem figuring out how to make POSTs with @mikeal request, so here is how I did it

      As you can see there's nothing strange or difficult, I just could not find a way.

      • views
      • Tweet
    • 0
      10 Jan 2012

      TDD functions addition

      • Edit
      • Delete
      • Tags
      • Autopost

      This post is related to the previous one.

      Well, this deserves a blog post on its own, since I believe the change I made is little in terms of code but huge in terms of the TDD concept it represents.

      I changed the way the thing behaves, if we have a red bar then the red bar stays there until we get a green bar. I believe this is a key concept in TDD, we do not want to leave our development in a red-bar-omg-whats-wrong for too long. As it was before the red would disappear after one second, leaving the developer with the stack trace, yes, but without the emotion-hurting feeling of having that thick red bar under the code.

      Since I'm writing this I'll share something I've thought about a few days ago, while reading Test Driven Development by example from Kent Beck: we strive to get to green because when we get there we are protected by it, being under the green light enables us to refactor and produce changes with a confident state of mind, we have a working condition just behind us, so refactoring errors will be caught. So we could refactor in a more comfortable situation. 

      And along the way I learned how to use progn in emacs lisp, now this is a good coding night end! 

      • views
      • Tweet
    • 0
      9 Jan 2012

      Emacs functions to ease TDD

      • Edit
      • Delete
      • Tags
      • Autopost

      Since I'm learning how to do TDD (using javascript in emacs) I thought it would be a Good Thing to have the red / green bar.

      I'm starting with something really easy really small, not to loose the focus of what I'm doing. For now the combination is C-c C-r, it executes all tests in the current buffer and depending on the result it colors the modeline in red or in green and prints the output of the command. I'm using mocha as my tool, I've hardcoded it, but it could be easily refactored.

      tl;dr

      Of course there are no sanity checks, it's thought to work only on js files written as mocha tests.

      • views
      • Tweet
    « Previous 1 2 3 Next »
    • Search

    • Tags

      • emacs
      • tdd
      • chromebook
      • nodejs
      • bash
      • elisp
      • git
      • ubuntu
      • agile
      • asf
      • cedet
      • classpath
      • coderetreat
      • copy
      • diffuse
      • docco
      • ecb
      • gdcr11
      • gnome
      • java
      • life
      • literateprogramming
      • logging
      • mergetool
      • mikealrequest
      • newjob
      • oop
      • ps1
      • recursion
      • redo
      • review
      • self-improvement
      • smr
      • starterkit
      • startup
      • stayhungrystayfoolish
      • svn
      • tomcat
      • undo
      • xbindkeys
      • xfce
    • Archive

      • 2012 (17)
        • May (1)
        • January (12)
        • January (4)
      • 2011 (17)
        • December (2)
        • November (8)
        • October (2)
        • September (5)
    • Obox Design
  • lazywithclass's posterous

    Passionate developer. Addicted to ah-ha moments. Kendo practitioner.

    2159 Views
  • Get Updates

    Subscribe via RSS
    Twitter