Archive for the ‘food for thought’ Category

Work and martial arts

Monday, May 10th, 2010

Funny how, when I’m busy, I stop updating this blog, isn’t it.

I’m learning a good amount on HTTP, Perl (specifically CGI) and working on using TDD with Ruby/Rails: it’s a mindset.

Regarding martial arts, sensei helped me figure out that my punches are all wrong, and the issue has been traced to lower back muscles. Thankfully, I’ve got tons of subway time now, so I can practice standing. For those of you who don’t study martial arts… That last sentence is not a joke.

On an unrelated note: I always enjoy the fact that ‘martial arts’ is commonly mistyped as ‘marital arts’. I knew the two were similar (*grin*), but some sentences are downright hilarious.

Inter-array permutations in Ruby

Thursday, December 17th, 2009

I don’t really have a better name for this. It’s also not completely clean, but it works. I had, almost a year ago (362 days ago), written a blog post about lexicographic permutations. That was about permutations of elements within one array.
Someone on ruby-forum asked about permutations between multiple arrays. I found something in C#, which I was happy to transcribe to Ruby and tweak a little.

def array_permutations array, index=0
  # index is 0 by default : start at the beginning, more elegant.
  return array[-1] if index == array.size - 1 # Return last element if at end.
  result = []
  array[index].each do |element| # For each array
    array_permutations(array, index + 1).each do |x| # Permute permute permute
      result << "#{element}, #{x}"
    end
  end
  return result
end

So, we get this:

first = ['one', 'two']
second = ['three', 'four']
third = 'five', 'six']
result = array_permutations [first, second, third]
=> ["one, three, five", "one, three, six", "one, four, five", "one, four, six", "two, three, five", "two, thre
e, six", "two, four, five", "two, four, six"]

Magic!

——
Edit – of course, my solution is hackish, and someone came up with a quicker and more elegant solution:

def fancy_array_permutation array
  return array[0] if array.size == 1
  first = array.shift
  return first.product( fancy_array_permutation(array) ).map {|x| x.flatten.join(" ")}
end

This gives the same result as above.

Why do I study martial arts?

Saturday, October 3rd, 2009

I am watching Rocky III and IV (the only ones I really like), and the driving theme is the power of the human spirit. Rewatching it now, I see a lot of other ideas. They’re not particularly hidden, but I never really noticed them before. This started to make me think about my choices.
(more…)

Christopher Moore’s Lamb

Saturday, June 27th, 2009

Well, I just finished the book. Apparently I do that with a lot of books – finish them at the wee hours of the morning.
“Alright.. I have half the book left to go.. I’ll pick it up tomorrow.”
“Alright.. I’ve got a quarter of the book left to go…”
“Well, only 35 pages…”

So, it’s 2:30 am and in less than 8 hours I have to be beating up little kids.
Raven recommended Lamb by Christopher Moore.

I was really happy to have picked it up, and enjoyed reading about Jesus Christ as a child, and then as things evolved, I first really liked reading about the eastern religions. Then I realized things didn’t fit. Some things about which I’m too young and stupid to have a sense of humor (like chronology and History) weren’t right. There were some absolutely terrible puns.
Then it hit me that this idea of his wasn’t really new – I’d read something quite similar in one of Aleister Crowley’s books : Meditation Give it a read.

In the end, all the magic was gone from the book, and while I did enjoy the way it was written, and how well everything is put together, and how believable everything is.. It had become just a story.

I don’t know what to think of the fact that I didn’t get any new spiritual concepts from this book; I was kinda hoping I’d get something new. On a personal note, as I’ve thought and written somewhere before, I think now’s the time for me to -do-.. Enough with the theorizing.

Thankfully, there’s an epilogue in which Christopher Moore explains that he had to play with History and chronology, as well as scriptures and accepted “knowledge”, to get things to fit the way he wanted them. It’s not perfect and he apologizes.
There’s even a second epilogue, because I bought a special edition (looks neat!), and he explains how he did it all, his trip to Israel, his thoughts during the trip…

Overall, I must admit, I’d probably recommend the book – it makes one smile, definitely -, but the epilogues really gave me a lot of respect for the author. And that was before he self-proclaimed a “not particularly devout Buddhist with Christian tendencies”.

Two videos – a change in the world?

Tuesday, March 31st, 2009

Those two videos have been brought to my attention within maybe two weeks of each other, and I hate thinking of random coincidences.. So here they are, together so I can find them again in several years.
Playing for change: Stand by me
Where the hell is Matt?

The first one fills my heart with a warm feeling – the song was recorded by all these people around the world simultaneously (or so they say, but it sure is well edited in any case).
The second one brings tears to my eyes, I’m not sure why.. I’ll let you guys watch it

Who follows who?

Thursday, March 26th, 2009

In the past couple of weeks, I’d gotten to spar progressively harder with a blue belt who is twice my age, but has been in dojos where sparring and self-defense were more important than kata. As a result, I consider him somewhat dangerous to spar with.. And, well, I let myself get caught up. I stopped being the watcher..
I hid behind the excuse that I was just sparring as hard as he wanted to spar, and so it just escalated.
Yesterday I took a different approach; I resolved to work on what I wanted to work, which turns out to be distance/range evaluation and shifting.. And I sparred at half-speed. He followed my speed, only speeding up a little as he got into it. I did not.
I asked him after sparring what he thought of the first minute or so of sparring with me, and he said he didn’t remember much.. But it enlightened me to hear “At first, I always take a few seconds to see if we’re going hard or soft, and then I get going”.
Here I was, thinking I was following him, and here he was, thinking he was following me! It sure is a good thing I took a step back from the vicious cycle.

(Lexicographic) Permutations in Ruby

Saturday, December 20th, 2008

Taking the code from this other blog … It’s pretty elegant Ruby!

I won’t waste your time repeating what the guy wrote in his blog – you’re welcome to go read it. I just felt that I should help spread a little this elegant implementation of the standard permutation algorithm, fixing a small bug within it in the process. If, like me, you have issues understanding how to use this, well – you have to use this function and call a block of code on it. It runs the block of code on each permutation it finds.

def permutations array
  if array.size < 2
    yield array
  else
    array.each do |element|
      permutations(array.select() {|n| n != element}) \
      {|val| yield([element].concat val)}
    end
  end
end

Can You See With Your Tongue?

Monday, December 1st, 2008

Can You See With Your Tongue? | Senses | DISCOVER Magazine.

This is an amazing article – a scientist who managed to make people react to light-based input without using their eyes. The human brain is … limitless within its limits ? It’s definitely worth the read.

An old-school 6th dan

Tuesday, November 4th, 2008

Yesterday evening a man who trained about as long as sensei came to train with us. Black obi, rather frayed to white. He’d trained a long time under his uncle, and then ~15 years under sensei’s sensei. He’d taken a break for a while, so he was a bit out of shape, but his mindset, his attitude, his devotion were 100% into everything he did – an important lesson which I forget all too often.

He left, very happy to have joined us. I hope we’ll see him again.

Hurt my mid-back…

Tuesday, April 8th, 2008

    I don’t know how I did it, but at some point during my empty hand class, I hurt my back. Think of a line going horizontally across the middle of the back (under the shoulderblades), and you have it. I didn’t stay for weapons past my bo class and went home. I was OK during my sword class, which means either I wasn’t paying attention, or I wasn’t using those muscles..

It got worse in the evening, to the point where I was walking slowly, and I couldn’t help but play with it a little — forced to use momentum generated by other muscles in order not to feel pain. Sunday was better but still careful, and Monday I considered not going to work but I felt good enough not to let it stop me. Training on Monday night made it pretty much all go away.

It’s very interesting to be in pain, when it’s not constant and excruciating (because that just sucks), you can explore better your body’s workings.