Jun
23
You’re Going to Suck
Filed Under creativity, life, recommendations | 1 Comment
Merlin Mann on Doing Creative Work; The Sound of Young America
Merlin Mann is an amazing speaker, and I’ve always found his talks inspirational. His theories have helped me through a ton of tough spots.
Jun
23
Simple way to “page” an Array in Ruby
Filed Under Software, ruby, technology | Leave a Comment
Unless you have ultra simplistic needs, (and are using Rails) I always recommend using the fantastic will_paginate plugin for paginating ActiveRecord, and even non-ActiveRecord collections! But, if you have a basic need to to page an array, you could open up the Array class and add this method:
class Array def page(pg, offset = 10) self[((pg-1)*offset)..((pg*offset)-1)] end end
This is a beautiful little method that adds #page to all arrays, and can be utilized like this:
my_array = [1,2,3,4,5, ... ,20,21,22,23,24,25] my_array.page(1) #=> [1,2,3,4,5,6,7,8,9,10] OR my_array.page(1, 5) #=> [1,2,3,4,5]
Feel free to use this if you like it!
Jun
23
Haml & Sass Bundles for TextMate
Filed Under Software, creativity, recommendations, ruby, technology | Leave a Comment
At Caring.com, we write our view templates using Haml and Sass (with Chris Eppstein’s Compass CSS Framework). It was a little strange to get used to at first, especially coming from tag-based/ERB-style frontend templating, but I have found that it is surprisingly straightforward, and succinct. TextMate, which is a fabulous text editor for rails and ruby, has two bundles that I use constantly that make my life easier (code coloring especially) in both Haml and Sass.
I am writing this blog post to share the bundles I use everyday with you, and so that I can remember where they live, for myself.
For Sass integration I use this bundle by seaofclouds:
git clone git://github.com/seaofclouds/sass-textmate-bundle.git "Ruby Saas.tmbundle"
For Haml integration, I use the “official” one provided by MacroMates (the creators of TextMate):
svn co "http://macromates.com/svn/Bundles/trunk/Bundles/Ruby Haml.tmbundle"
Clearly, you need to have both Subversion and Git installed to install these plugins, however you may be able to travel to github and download a zip file if need be.
Jun
20
Jun
18
PageSlide Plugin for jQuery
Filed Under Software, creativity, javascript, technology | 2 Comments
I’ve been working with Mr. Scott Robbins on his fantastic jQuery PageSlide plugin for the last few weeks. It has been a lot of fun, we’ve moved the project off of google code completely, and today have released version 1.1 of PageSlide on Github. version 1.1 is essentially a complete re-write touting a ton of new/awesome features, here is a list from the README:
- Choose slide direction (left or right)
- Custom width slides
- Modal slides
- unobtrusive
- Mutiple slide definitions on the same page
- Fully supported with IE7+, FireFox 2+, Safari 2+
- Minified version included!
I am very excited about this plugin, and will be using it in some of my projects very shortly! If you like the project, please “watch it” on Github and tweet about it and stuff while you’re at it :)
Get jQuery PageSlide here, it works with jQuery 1.26 and up!
EDIT: Live demo can be found here: http://derekperez.com/jquery-pageslide/demo/
Mar
17
It has been a busy month. In less than thirty days, my life has completely changed, for the better. I’ve moved back to the south bay, from the east bay and am now currently living centrally in Menlo Park, right next to the train station. I had about a week to pack/move/unpack before I started my new fantastic job as web engineer for growing startup, Caring.com, in San Mateo.
Caring, Inc is a website dedicated to helping senior/elder caregivers and provides a wealth of resources for the caregiving community. At first, it seemed like a demographic/product that someone like me wouldn’t be too interested in, but I am very happy about the fact that I not only get to work on a fantastic team building a (suprisingly) complex CMS, but I am also making a difference in people’s lives. This is my way of changing the world today.
Caring from an engineering perspective is very cutting edge. We are a very very agile shop (our COO is a board member of the Agile Group or whatever they call themselves these days), we do stories, (real) scrums, sprints, and all that scrumy goodness. I am really into this workflow. I’ve worked for previous employers who don’t really understand how these tenents work together. Its very interesting, engineering is not the only agile team, the WHOLE company is agile, very neat!!
I love Menlo Park so far. Fantastic food, everything is walking distance, the train is right outside my door, perfect! I’ve never had such a perfect commute/living situation, everything (amazingly) just fell into place perfectly. I am also neighbors with my brother here which is hilarious, we have a walkie-talkie system setup, currently. The cats are also quite happy with my new place, much more socialble, less bitey.
I’ve also been doing a lot of research lately on scalability and some new software development techniques that I will definitely be writing more about very soon, so keep posted if you are interested in things like say, CouchDB.
Mar
4
Everything is Amazing, Nobody is Happy
Filed Under Uncategorized | 1 Comment
Feb
17
A Late Valentine For All My Readers
Filed Under Uncategorized | Leave a Comment
Thanks for reading, readers. I’ll be posting more insightful things later.
Feb
9
Fibonacci
Filed Under Software, ruby, technology | 1 Comment
Thanks so much everyone for submitting your Fibonacci examples! One of the reasons why I asked everyone to do this is because it gives me (and all of us) a chance to learn about different approaches and different languages. So, in case you haven’t figured it out, it was sort of a trick question.
Fibonacci is generally very fast, unless you are over-architecting the solution. Let me show you what I mean:
def fibo(n) (!(n>2)) ? n : fibo(n-1)+fibo(n-2) end 37.times do |i| puts "n=#{i} => #{fibo(i)}" end
This was my first attempt. Its a beautifully complex execution of the algorithm, using recursion. However, notice that I am not storing any of the values that I am calculating? That causes the processor to go crazy around time 30. This would be what I call a classic example of over-architecting a simple problem.
But its cool right? :)
Here is my faster, smarter, more performant version:
$fibs = []; def fibo_calc(n) (!(n>2)) ? n : fibonacci(n-1)+fibonacci(n-2) end def fibonacci(n) if $fibs[n] return $fibs[n] else x = fibo_calc(n) $fibs[n] = x return x end end 37.times do |i| puts "n=#{i} => #{fibonacci(i)}" end
This is much much much faster, and can hit 30,000 iterations without missing a beat. The cooler thing too is that I can mix up the 30,000 integers that its calculating for, and it can run a “shortcut” using the array. Very cool.
So that was my nerd realization of the month. Of course, there are a billion ways to skin an algorithm, but sometimes the most concise or technically interesting way, is the slowest.
Feb
3
Nerd Challenge: Fibonacci Fun!
Filed Under Software, technology | 17 Comments
Lately, I’ve been studying algorithms, just for fun, because I am hardcore like that. Also, I’ve been very excited to test the speed/performance of the newly released and stable Ruby 1.9.1. I have been waiting patiently for the release, it is full of great new things like a modern VM, massive integer performance tweaks, language readability improvements, and full unicode support.
So I decided to do some masturbatory benchmarking, using Fibonacci! Also, did you know that Ruby has a builtin benchmarking framework?
Fibonacci is not a very difficult algorithm, though I learned a lot about what to do (and not do) when it comes to writing this sort of code in Ruby. (and any language for that matter)
So here is the challenge, write your best Fibonacci Sequence algorithm in any language you choose, discuss the pros/cons of your implementation, and speed of execution. Also, its mandatory that your algorithm calculates a minimum of 36 sequences deep, extra points if you get to 30,000 in less than 5 seconds.
In a few days, I will post how I did it in Ruby. I don’t really have a prize lined up or anything, maybe I will come up with something. At the very least, you’ll have bragging rights.
keep looking »