#diary

These days work is extremly boring.

Before our team had dark era, after that it seemed going well for a moment but I’m not sure what specific things caused this feeling again.

I sit down and tried to think logically to find out the reason, why I’m not motivated, why I feel boring, why I get so tired everyday? Is it related to my personal life? Or is it because I’m already in the holiday mood? Is it because the evaluation? I kept asking myself questions to break down the negtive feelings into separate parts so that I can find each solution. But I couldn’t make it, I found myself hard to stay rational, because the more I asked myself, the more cleary I can see the answer.

The answer is simple, I don’t believe the guy. I don’t believe we’re gonna make it, to be specifically, his goal, his ambition, judging by the way how we worked. I don’t know every detail stories about it, but I think I’ve made the judgement subconsiously. My friend mentioned the same thing at yesterday’s lunch, totally different story but I think it inspired me somehow, “I’ve made the judgement”. The feeling from subconsious is hard to deal with, hard to change, it’s based on the self expierences and observations in quite a log time.

The project itself of course has potential, I never doubt that. I’m not saying he is a bad person neither. And I absolutely have resoponsibilities, how I participated the project, how I interacted with the team, etc. It just he as a leader, I’ve found myself hard to follow him.

#sublimetext

If you find yourself typing these kind of similar codes very often, and want a snippet to save your time, this is it.

@topic = Topic.find(params[:topic_id])
@car_item = CarItem.find(params[:car_item_id])
@user = User.find(params[:id])

It maps the variable name to its model name by converting the first character or the character after a underscore to uppercase, which is a convention in Rails framework.

Demo Video

The Snippet

I put it and named as SublimeText/Packages/User/Snippets/model_find.sublime-snippet.

<snippet>
  <content><![CDATA[
@${1} = ${1/^(.)|_(.)/\U\1\2/g}.find(params[:${2:${1}_}id])
]]></content>
  <tabTrigger>mf</tabTrigger>
  <scope>meta.rails.controller</scope>
</snippet>

So now I just have to hit mf -> tab to trigger it.

SublimeText Document

Here I’m using the Substitutions feature of SublimeText 2 snippet.

The substitution syntax has the following syntaxes:

  • ${var_name/regex/format_string/}
  • ${var_name/regex/format_string/options}

e.g.

Original: ${1:Hey, Joe!}
Transformation: ${1/./=/g}

# Output:

      Original: Hey, Joe!
Transformation: =========
#diary

We use our phones every day. They have a modern name “Smart Phone”, as it can do much more tasks compared to the old one. I’ve been using iPhone for over 3 years now. And since yesterday, I started not to use it, you probably wonder why but I got some personal issues so maybe this is one of the actions I have to take.

Anyway, here is the interesting things I found that I can’t do without a phone based on these 2 days of experience. So many surprises.

  • I have to find a clock alarm, the physical item, to get myself up at morning.
  • I feel so boring when I’m on a train. I can’t check Twitter, Facebook or any RSS newsletters. I can’t read my kindle book either.
  • I was in the mood of cooking, and I realized, “Oh, I don’t have a kitchen timer.” Then after I cooked, I couldn’t take a picture.
  • Yes I can’t take a picture whenever and wherever I want like before, my phone is the only camera.
  • I can’t check-in in foursquare when I enter a cafe or restaurant, to keep log of my life.
  • I can’t track my running records, although I have a fixed route so I know exactly how many kilometers I’ve run but still I can’t keep those data.
  • I can’t block the noise by putting earphone, to be specific here, a noisy child cries loudly, rolled on the floor said to his parents that he wants juice, right in the center of a shopping center, he is totally guilty and not innocent. I have to say the f**k words and hold myself try not to kill him.
  • I don’t know the time when I’m out. I have a watch but I don’t have the habit to wear it…
  • I can’t access to the Internet, when I want to search a place, I have to do the research in my laptop before moving.
  • I can’t keep tracking my expenses. I’m using an app to do that, now if I really want to continue, maybe I have to input the amounts in some kind of Excel-like interface…
  • I can’t take a note, I don’t carry a notebook and a pen with me, I was using Evernote or Apple’s native Notes app to do this thing.
  • And of course, I can’t contact to any friends by calling or sending text messages.
  • And at work, when my boss asked, “hey, this thing seems not work in smartphone browser, go check it”, “OK, damn it! I don’t have a phone…”. Really funny.

I’m not sure where I’m going, but there was not just negative “findings” about this. I found myself have time to think about something normally I would not to because I must be checking not-that-important tweets or just trying to use the phone to kill the time. Any tasks/ideas/todos comes to my mind, I have to keep it there, into my mind stack. And trust myself if this thing is important I won’t forget about it.

I wrote this post doesn’t mean I like this idea and try to convince any of you to do the same crazy-seems-nonsense thing. But by doing this, it reminds me how my social/technical life has changed within 3 years, how great iPhone it is to make life easier.

I’m sure I can go back, live without a phone completely if I really want to. I can find lots of alternative tools, I still miss paperback books, sometimes I still want to grab a pen to take notes or just skitch some ideas to the paper. But when it comes to keep connections with friends or family, it’s still very convenient when we keep our phones in our pockets.

#rails capistrano

I’m not familiar with capistrano at all, I kind of use it in daily base but what I’m capable of is just the one major command: ca deploy, heh that’s all I got.

Capistrano Callback Order

If you like me always get confused by the callback orders, image is really gonna help you out.

Capistrano Task explanation

Capistrano recipes: deploy is brief explanations of each task, same in the source code I think, highly recommend you go through them once.

Another good resource is capistrano recipes source code

task :update do
  transaction do
    update_code
    create_symlink
  end
end

Like this :update task is easy to guess: run update_code and create_symlink in a transaction.

#recommend diary

About the video

Original url

It’s the video about a speech DHH presented 2010 at Stanford. It’s very inspring, good to know about the insight of these things, I just randomly listed:

  • why VC is a time bomb
  • why it’s good to spend your own money for your own business
  • how to work as a startup
  • how to manage your time
  • stories about Rails and Basecamp then 37signals company
  • what kind of company is a smart company
  • etc…

I wish I could have watched this when I was still in school. But maybe then I wound’t understand the essence of many things. Anyway highly recommend. The video is about 1 hour long but the speech itself is maybe less than 20 or 25 minutes I think. After that was Q&A session and it’s still quite good.

About Japanese Way of (Time) Management

This is my thought, as well as my complains about the topic, you can ignore this if you’re not interested in.

I’m not sure if it’s the majority or just among old guys who happen to be the managers or board members or whatever high postion, higher than you, the people I’ve met tend to think that working hard, say 50 or 60 hours a week is just normal. And not do themselves stick to this principle, they also ask you to do the same thing. It doesn’t mean they’re terrible human beings, actually usually there’s nothing wrong with their personalities or characters, it’s just the way they’ve been educated, been expeirenced by their managers when they were young.

But my argument is, our industry is different, different from old days, it calls for creative, we need passions, need to be motivated. Not even mention how many flaws or damages or consequences it will cause if you force your employees to just work more. Here I quote DHH’s speech:

I think there’s just a lot of misconception out there about how hard you must work. I’m sure this was true in the industrial age when you were hammering on stuff. If you hammered for another five hours, you would produce another 10 widgets and you can sell those widgets. If you’re working in stuff like software or anything else that doesn’t require your personal labor in manufacturing widgets which is basically none. None of this stuff matters.

Wow it ended up longer artcies than I expected, maybe I should refactor this to another post =_=;

#git

Sometimes it’s common that we tracked some files in the git repository first but later decided not to. For instance in rails application it could be database.yml file. So you added database.yml to .gitignore but when you changed something in that file, git will still show you.

Solution

  1. First added files you don’t want to track to .gitignore
  2. Then use either method 1 for single file, or method 2 for folders below.

method 1: git update-index –assume-unchanged

git update-index --assume-unchanged config/database.yml

This works very well with single file, I’m not sure but maybe it doesn’t support folder.

Method 2: git rm -r –cached

# This removes everything from the index
git rm -r --cached .

# This will only add files not listed in the .gitignore
git add .
# then commit it
git commit -m ".gitignore is now working"

git - .gitignore file not ignoring - Stack Overflow

#rails

Short note

  • rake assets:precompile
  • config.serve_static_assets = true # on production.rb
  • rails s -e production

That’s all.

config.serve_static_assets

When you run rake middleware you’ll see use ActionDispatch::Static in the development mode but not in production mode.

In normal case, you should not set that to true unless for trying production mode on local machine. As the comment on the source code suggested:

Disable Rails’s static asset server (Apache or nginx will already do this)