Archive for August 2010


strace for Mac OS X

August 13th, 2010 — 11:16pm

In Leopard it’s called dtrace, but it’s simpler if you just call dtruss

Here is the manual:

NAME
dtruss – process syscall details. Uses DTrace.
-
SYNOPSIS
dtruss [-acdeflhoLs] [-t syscall] { -p PID | -n name | command }
-
DESCRIPTION
dtruss prints details on process system calls. It is like a DTrace ver-
sion of truss, and has been designed to be less intrusive than truss.
Of particular interest is the elapsed times and on cpu times, which can
identify  both  system calls that are slow to complete, and those which
are consuming CPU cycles.
Since  this  uses  DTrace,  only  the  root  user  or  users  with  the
dtrace_kernel privilege can run this command.
-
OPTIONS
-a     print all details
-b bufsize
dynamic  variable  buffer  size.  Increase  this  if  you notice
dynamic  variable  drop  errors.  The  default  is  ”4m”  for  4
megabytes per CPU.
-c     print system call counts
-d     print relative timestamps, us
-e     print elapsed times, us
-f     follow children as they are forked
-l     force printing of pid/lwpid per line
-L     don’t print pid/lwpid per line
-n name
examine processes with this name
-o     print on-cpu times, us
-s     print stack backtraces
-p PID examine this PID
-t syscall
examine this syscall only
-
EXAMPLES
run and examine the “df -h” command
# dtruss df -h
examine PID 1871
# dtruss -p 1871
examine all processes called “tar”
# dtruss -n tar
run test.sh and follow children
# dtruss -f test.sh
run the “date” command and print elapsed and on cpu times,
# dtruss -eo date
-
FIELDS
PID/LWPID
Process ID / Lightweight Process ID
RELATIVE
relative  timestamps  to  the start of the thread, us (microsec-
onds)
ELAPSD elapsed time for this system call, us
CPU    on-cpu time for this system call, us
SYSCALL(args)
system call name, with arguments (some may be evaluated)
-
DOCUMENTATION
See the DTraceToolkit for further documentation under the  Docs  direc-
tory. The DTraceToolkit docs may include full worked examples with ver-
bose descriptions explaining the output.
-
EXIT
dtruss will run forever until Ctrl-C is hit, or if a command  was  exe-
cuted dtruss will finish when the command ends.
-
AUTHOR
Brendan Gregg [Sydney, Australia]
-
SEE ALSO
procsystime(1M), dtrace(1M), truss(1)

Comment » | Bash Shell

Bathroom Remodeling

August 13th, 2010 — 11:15pm

2008-11
We bought this house in Nov 2008. I am Japanese and taking bath has been just my part of my life. However, we fall in love with this house so much that we accepted fact that the house only had Shower in Master. We were thinking… well, bathtub can be easily installed! We can knock down the closet and place shower there and place bathtub where current shower stall is.

2010-01
So yeah… about one year has passed. We got estimate from a few contractors and I was like wow… placing bathtub is not so cheap especially in our case, major pluming work was involving. First we got estimate from homeDepot. They told me it will be like $30K. Then we met a couple of contractors – both were like $13k or so… because of the limited space we have, I have to pick small bathtub and of course, smaller shower…. I just didn’t see the value paying that much to have small bathtub with smaller shower space… Long story short, I decided that steam sauna is what I want…
1) Greener – it use much less water than bath
2) Don’t have to sacrifice on shower space
3) and a lots of benefit – just google “steam sauna benefit”

old bathroom

Old Bathroom

2010-08
We found one company called Bath-Pro who we feel we can trust and offers very reasonable price. The construction was finally started on Aug 9th.

2010-08-09 [Day 1]
They did demo

Bathroom Remodeling Day 1

Bathroom Remodeling Day 1

2010-08-10/11 [Day 2 & 3]
They placed bench and soffit ceiling so that they can tile the ceiling.

Bathroom Remodel Day 3

Bathroom Remodel Day 3

2010-08-10/11 [Day 4~]
I got too excited about design and forgot to check some critical thing.. Permit. My husband thought that they are professional so he assumed that they already got permit for this construction. But I wasn’t sure so I checked with them… they told me it is up to home owner… We requested Permit from city. Phew… good thing we checked with them. If you google “bathroom remodiling permit”, you will see all kinds of helpful information. We decided that getting Permit is right thing to do especially installation of Steam Sauna involves running electric cable etc…

2010-12-11

So they are still in process of getting permit right… Though good thing we asked them to go ahead get a permit. Because the way they were going to install steam unit actually violates the city code. So now that they have to re-draw some of the plan and re-submitting to the city… Though there are slight improvement since the last time.

1. they installed floor (it was carpet before)

2. they installed steam generator (which needs to be moved to outside in order to meet city code)

3. We did some upgrade by ourselves. Mirror, faucet and light. We really like how it turned out.

Bath Room Pic 2010-12-11

Some floor and New Mirror & Faucet

2010-12-28
Project Manager came back with City Permit and change of plan. According to the City of Goodyear, steam generator needs to have at least one foot of space from each wall and installing underneath of the bench didn’t meet the criteria.

Again, I am so glad to take time to get City Permit before we move forward with this project. It cost us $350 and very long period of time but I think it is worth it. So now the steam generator is installed above the steam shower room.

2010-12-30
Yey! FINALLY, we have wall in the bathroom. We haven’t had wall for let’s see… about 4 months. Now our power bill should be better…

2011-01-05
Installing KERDI paper to cover the space between DensShield (Tile Backer that has built in moisture barrier)

2011-01-11

Some more tiles has been installed.

Space between tile and wall...

Space between tile and wall...

woo, more tiles!

2011-01-11
Oh wow, this is pretty! Now the grout between tiles and steam controller is installed. Pebble floor and wall. I can’t wait to get in this beautiful steam shower!

steam controller and grout are installed

steam controller and grout are installed

2011-01-19

2010-01-19 pic

corner pieces are installed. now it is rounded!

2011-01-24

Glass are installed and looks nice. Quality of the glass are better than expected. Very contemporarily looking. They put extra whole on side-wall. I wonder how they are going to fix…?

Glass Door is in

Glass Door is in

2010-01-24 b

Glass Door Installed.

2010-01-24-c

oops... they placed hole on wrong place... how they are going to fix?

2011-08-24

So we have been enjoying this Steam Room for a while. I just love it. I don’t miss taking bath at all. I use Steam every single day even when outside is 112 degree.
Everything turns out to be okay. I have no complain about final product. The whole on the side-wall was filled and I can’t tell where was the whole :) So it is all good.

Shower Heads

Rain Shower head for my husband and Handheld is for me and kids!

Steam is on!

Steam is on!

Floor

Floor

Full Shower Image

Full Shower Image

Comment » | Home Improvement

Home Solar – Lease or Purchase

August 6th, 2010 — 5:19am

I have read great things about SolarCity and Sungevity – I believe they are the two leading solar leasing company at the time of writing.

I got estimate form both companies. They do lease very differently…

SloarCity ask you for some down payment then low monthly fee for 20 years regardless of power company you are with.

Sungevity on the other hand requires No down payment. This is probably the only way to go if you have no cache. No down payment and you can go green. Sugevity also wants “inflation rate” to be added every year. So my monthly payment will increase 2.5% every year. This isn’t too bad considering recent energy rate increase.

Both SolarCity and Sungevity will give you “Performance Guarantee” with lease option – meaning that if Solar System generates less than what they projected, they will pay you. Also maintenance is included. So going Solar not only help our planet but also save us money guaranteed!!!! At this point I just could not find any reason why we don’t want to go Solar.

Before we decide to go with this lease option I wanted to see what purchase option would be… Lease make Solar system VERY affordable but after 10/20 years, it is not yours… You end up paying about $20K and you will be given option to purchase at the end of the lease.

So I wanted to see what Purchase option might look like. I reviewed some discussion about Solar lease vs purchase. Both side has valid point. Some says lease is scam… but I don’t think so… Yes you end up paying more money than purchase option but there are many people out there who just cannot come up with cache. Though in my research, if you have cache, purchase is the definitely the way to go.

Purchase option with Sangevity and SolarCity weren’t so fascinating. I think this is because they are trying to promote lease option more than purchase option.

I got quote from American Solar Electric. After the Rebate and Federal Credit, I will end up paying something like $8500. I am going to get quote from other company and see but my mind has almost decided. I will go with purchasing option.

I was listening to NPR this morning saying that my power company lost millions of revenue due to energy efficient rebate etc… so they will increase rate again in 2012 or 2014 (can’t remember) so again, it just no brainer… having own power generator is the way to go.

Comment » | Green Living

Latin 1 to UTF-8

August 5th, 2010 — 7:35am

Long story short, I was doing some screen scraping on web application. My web app use Latin 1 and target is using UTF-8. So I had a few issues to resolve in order for it to work…

1. Display Issue: If target site has beyond ascii character, it wasn’t displaying correctly. To resolve this was easy. I walk through the characters and replaced with html encode if character code is higher than base ascii….(yes i know… the scripting language that I use doesn’t offer nice libraries…)

2. Posting Issue: This was the pain one… because my web app use Latin 1, anything higher than ascii is translated as HTML Encoding. So to post to UTF-8 site, there are 2 steps involving. (1) Convert HTML Encoded character to Unicode (2) Convert Unicode to URL Encode
2.1. Convert HTML Encoded character to Unicode: This is very simple. Basically use this regenx pattern “&#[0-9]{3.5};” to look for HTML Encoded character and extract numeric only and wrap with command to convert it to character (for instance in php it is chr).

2.2. Convert Unicode to URL Encode: Now that you have Unicode prepared, all you have to do is to do url-encoding! (and no, the scripting language i use doesn’t offer native solution. and yes, I have plan to switch scripting language. so this is for person like me who stuck with language that offers very limited set of libary)
2.2.1. My First Attempt: use curl –data-urlencode option. Please note that this was added in version 7.18.0. If you are Mac user like me, you can install/upgrade curl using MacPorts or you can download source from here and install. Unfortunately I could not use this option… because there is one restriction to this – “content cannot contain = or @ symbols, as that will then make the syntax match”.
2.2.2.My Second Attempt: Relies on Shell… Now this is almost always works! I decided to use php rawurlencode. Calling like this from terminal works like a charm.

$ php -r “echo rawurlencode(‘ξακσλξ’)

Issue the command via plugin to execute shell command did not work. It is not unicode supported so it end up returning url encode of ??????
I contacted plugin vendor and he is planning to release unicode support soon… so until then somehow

My co-worker found this article: http://akameng.com/web/php_utf_unicode_convertor. Ooooo, this shows the formula to how to convert this using integer division and multiplication without using bitwise operation. This article also explains this formula.
If ud <128 (7F hex) then UTF-8 is 1 byte long, the value of ud.

If ud >=128 and <=2047 (7FF hex) then UTF-8 is 2 bytes long.
byte 1 = 192 + (ud div 64)
byte 2 = 128 + (ud mod 64)

So as a final product (for now) I have code like this:

$ php -r “echo rawurlencode(chr(206).chr(190).chr(32).chr(32).chr(195).chr(169).chr(110).chr(100));”

I am done for now.

Comment » | PHP

Back to top