Disable OSX Lion from re-opening saved app state

If you are like me, hate to see all closed files or tabs coming back after re-opening applications in Lion, you won’t be pissed any more.

Basically, Lion saves every single thing you do in every single applications in ~/Library/Saved Application State. This is where the problem rises. Every applications will look at this saved state while opening up and will try to restore back to the same right before you closed, which I find this behavior annoying.

To fix it: You have 2 choices,
1. disable write-access to this directory, by using chmod command. This will disable in every apps or by each app depending on which directory you are changing.
2. disable savedState per application by using command

defaults write [application_name] NSQuitAlwaysKeepsWindows -bool false

where application_name will look like following:-
>> com.microsoft.Word for Microsoft Word
>> com.apple.Safari for Safari
>> com.google.Chrome for Chrome

Example, to disable saved state for Microsoft Word, do as following:-
defaults write com.microsoft.Word NSQuitAlwaysKeepsWindows -bool false

You can find by open ~/Library/Saved Application State and look at the name. Unfortunately, Lion also keeps ~/Library hidden too. You can fire up terminal and type open Library to open ~/Library in Finder and go through quickly.

To revert action: just use the same command with -bool true

Popularity: 1% [?]

afpd on Debian

afp share

When you are on #OSX regularly, CIFS/SMB is not that good option. What you would need to do so is installing afpd and bonjour. Obviously, they won’t name as they are in Apple product. Their package names are netatalk and avahi consecutively. Installation is as easy as one regular apt-get.

Setting up both at the same time, then we would configure later.

# apt-get install netatalk avahi-daemon libnss-mdns

After installation, we need to configure a bit for both service.

afpd — what we are going to do now is to disable legacy Apple File protocol back in pre #OSX time which we don’t need.
# vim /etc/default/netatalk

 # enable new service
CNID_METAD_RUN=yes 
AFPD_RUN=yes 
# disable legacy service 
TIMELORD_RUN=no
A2BOOT_RUN=no
ATALKD_RUN=no
PAPD_RUN=no

All you need to do is making sure if these values are assigned correctly. Next, we have to declare sharepoint. You can append to these new settings to the end of this file.
# vim /etc/netatalk/AppleVolumes.default

/your/path VolumeName allow:@groupname options:usedots,upriv

Example:
You can do a share by username.

~/ "$u" allow:myusername options:usedots,upriv

For Time Machine, you can do this; it might be a good idea to limit volume size before Time Machine takes over the whole drive by using volsizelimit:100000 in MB; 100000 = 100GB

/home/username/TimeMachine "TimeMachine" allow:myusername options:usedots volsizelimit:100000

Restart netatalk to see the change
# /etc/init.d/netatalk restart

For more info: http://linux.die.net/man/5/applevolumes.default

Avahi (Bonjour)
Next, we need to do help setting up bonjour or avahi. A setting file is /etc/nsswitch.conf which is belong to mDNS (mDNS comes helping hostname resolution.) we need to enable mdns module by add “mdns” to hosts: line as following:

hosts: files mdns4_minimal [NOTFOUND=return] dns mdns4 mdns

Last but not least, we customize how any device see afpd. Create a new file named /etc/avahi/services/afpd.service and paste this in.

<?xml version="1.0" standalone='no'?><!--*-nxml-*-->
<!DOCTYPE service-group SYSTEM "avahi-service.dtd">
<service-group>
 <name replace-wildcards="yes">%h</name>
 <service>
 <type>_afpovertcp._tcp</type>
 <port>548</port>
 </service>
 <service>
 <type>_device-info._tcp</type>
 <port>0</port>
 <txt-record>model=MacPro</txt-record>
 </service>
</service-group>

You can change model to something else which change icon you will see on #OSX client side. AppleTV, iMac, MacPro, Xserve, MacBook, MacBookPro, MacBookAir, Macmini, etc.

Restart avahi-daemon to see the change

# /etc/init.d/avahi-daemon restart

Popularity: 1% [?]

MacJournal to Evernote

I was a short-period Evernote user after OneNote took over by all features and everything many years ago. However, once I moved to Mac OSX, I had yet to find a right tool as OneNote alternative. Although VMWare Fusion 4 has been improved over the years, why on Earth I have to keep Windows running wasting my memory at all time.

I tried a lot of alternatives: OneNote on VMWare Fusion — Unity view of course, MarsEdit, OmnifocusCircusponies Notebook, Journler, MacJournal, Springpad (webapp), Catch (webapp.) As a result, MacJournal it was by its simplicity for months. However, lacking of synchronization sucked big time, esp. with all mobile devices. Then there was an underdog option showing up again. Evernote. At least this piece of software was built with cloudsync in mind.

Well, this time, after couple years w/o using EverNote, I could say that it’s been vastly improved. It’s still far from OneNote counterpart, but this is all you can get on OSX. The question left is how to move all data in MacJournal to Evernote?

Like everybody else. I googled for a solution; I found a script which gave me an error, at least for me. Suddenly I thought of why we have to complicate life this much. So I decided to select all my journal entry, drag them all and drop into Evernote!

Boom! it works! way too easy, right? it works beautifully also. Evernote will show up tons of windows when it completely grabs each journal, but you can always wait a bit and close them all at once with cmd+q. After reopening Evernote, you would more than happy.

note: downside — tag doesn’t come along, but there is always a search, right?

Popularity: 1% [?]

FreeNAS 8 – cave man can do it

It’s FreeNAS. It’s easy. Set it and forget it with full fledge NAS you can’t find anywhere else. Well, it might not have DRBD, but for home/personal or even small business should be able to cope with rsync easily.

At least, this version makes me happy. My SS4200 comes alive w/ port multiplier; it just lives up to its potential.

Kernel log speaks louder than anything.

+pmp0 at siisch1 bus 0 scbus1 target 15 lun 0
+pmp0: < Port Multiplier 0325197b 000e > ATA-0 device
+pmp0: 300.000MB/s transfers (SATA 2.x, NONE, PIO 8192bytes)
+pmp0: 300.000MB/s transfers (SATA 2.x, NONE, PIO 8192bytes)
+pmp0: 15 fan-out ports
+ada1 at siisch1 bus 0 scbus1 target 1 lun 0
+ada1: ATA-8 SATA 2.x device
+ada1: 300.000MB/s transfers (SATA 2.x, UDMA5, PIO 8192bytes)
+ada1: Command Queueing enabled
+ada1: 1907729MB (3907029168 512 byte sectors: 16H 63S/T 16383C)
+ada2 at siisch1 bus 0 scbus1 target 0 lun 0
+ada2: ATA-8 SATA 2.x device
+ada2: 300.000MB/s transfers (SATA 2.x, UDMA6, PIO 8192bytes)
+ada2: Command Queueing enabled
+ada2: 1907729MB (3907029168 512 byte sectors: 16H 63S/T 16383C)
+ada3 at siisch1 bus 0 scbus1 target 3 lun 0
+ada3: ATA-8 SATA 2.x device
+ada3: 300.000MB/s transfers (SATA 2.x, UDMA6, PIO 8192bytes)
+ada3: Command Queueing enabled
+ada3: 1907729MB (3907029168 512 byte sectors: 16H 63S/T 16383C)
+ada4 at siisch1 bus 0 scbus1 target 2 lun 0
+ada4: ATA-8 SATA 2.x device
+ada4: 300.000MB/s transfers (SATA 2.x, UDMA5, PIO 8192bytes)
+ada4: Command Queueing enabled
+ada4: 1907729MB (3907029168 512 byte sectors: 16H 63S/T 16383C)

Thanks, FreeBSD guys enabling this feature. Thanks, FreeNAS folks developing nice-and-easy NAS.

Popularity: 3% [?]

Thai font for webOS

Well, after HP dumped #webOS device w/o caring how many languages those devices can read. We, as a user, are supposed to be on our own then.

Here is fonts you need to replace, Arial & Prelude families. These are sorta main fonts in webOS. Actually you can replace only Prelude for webOS 2.x or older, but likely you need both for webOS 3.

What I have done? You definitely can copy any font w/ Thai character and rename to Prelude for all webOS 2.x or below. restart Luna once. It will work. However, I just like to have Prelude as it was. I only add Thai characters to that font. So as in this Arial.

How can you replace these fonts? there are many possible ways to do so, but I guess you have to have some sort of shell, XTerm preferably, and surely you probably need to have Preware first. Then you should be able to simply copy this font over the original one.

root@Touchpad: /var/home/root# cp /media/internal/newfont/* /usr/share/fonts/

Once you copy these over, restart Luna once. All set =) If you need anything else, just give me a shout in comment =)

ps. well, FYI, I did put Thai character of TH SarabunNew into webOS’s Arial and Thonburi’s into Prelude.

note: due to excessive spamming, I couldn’t approve real people comments in time. I have to delete spams in database instead. If you guys which have a problem are still around, let me know again. Sorry for inconvenience. I think I’ll move to #Disqus avoiding this issue as soon as possible.

Popularity: 8% [?]

Multiple Profiles — A hero after Google Apps has transitioned

I don’t know if anyone is in on the same boat as me. Back then, I was on both Google Apps mail and Gmail at the same time. However, once Google decided to change Google Apps account to be more like normal Google account. Things get rough; I have to use Firefox for one account and Chrome for the other. Yeah, it’s a pain in the butt. However, I just discovered that Chrome has such a nice feature called “Multiple Profiles.” Basically, it lets you have different sets of session and else on different windows and of course they provide a nice touch identifying each profile by avatar on top-right of each window.

First, you have to enable “multiple profiles” flag by go to about:flags, find Multiple Profiles and enable it. Then you have to restart your Chrome once. There you go!
Multiple Profiles -- Google Chrome

Popularity: 2% [?]

Too many connections on MySQL server

If you are new to administrate all your web and database server and wonder how you can tweak to their best, you are just like me. My job was to build a webapp in order to handle roughly 10 grand of users, and this app was database-driven one. Its database is about 15GB with 25M records and is growing steadily. Well, traffic is also growing twice a month, approx. 8,000 visits; 260,000 pageviews a day as of now, according to Google Analytics. It’s relatively small if you compare to all giant sites these days. However, it’s not as easy as it seems once you are a coder, but have to manage all these things too. I’ll try to share as much information as I could as time goes by.

After I tweaked on coding side, e.g. indexing, using cache, bla bla bla, as much as I know. I have faced some weird issue that database server was down randomly while it didn’t even eat up all memory or frequently an popular “Too many connections” popping up. After googling for a while, I found that it could relate to several things: maximum connection on MySQL itself which is 100 as a default; maximum open files which is depending on OS; or simply out of memory. In my case, it surely is not memory issue, since top/free confirmed me about that. Then I have changed both maximum connection on MySQL and maximum open files on Linux:-

in /etc/my.cnf, you have to add another line setting this:

[mysqld]
max_connections = 250 # or whatever

This would set new maximum connection limit for the database server, but it doesn’t guarantee if it can handle that–that’s also OS and memory related. After this change, restart MySQL daemon once to see the change.

For maximum open files, you can check by ulimit -n, if it’s over MySQL maximum connections, you can skip this part. If not, heading to /etc/security/limits.conf, and you can simply add:-

* hard nofile 2048
* soft nofile 2048

If you are using SSH, you have to restart sshd once for new setting. So far, I’m happy with the new role and having fun tweaking it. If you have any suggestion, please share!

Popularity: 1% [?]

Colorizing VIM

The more you use vim, the further you are from all other text editors. However, when you get your new box ready, vim is likely not to enable syntax color by default. You can choose to do that individually or for everyone. If you decide to let other manage this on their own, you can just create ~/.vimrc or you can opt for system wide setting in /etc/vim/vimrc.

in /etc/vim/vimrc, you will find:-

" syntax

on which mean it’s commented out. What you have to do is uncomment it, save, and try. For ~/.vimrc, you can just touch that file and type syntax on or you can just do:

$ echo 'syntax on' > ~/.vimrc

That should do it.

Popularity: 2% [?]

Mac OSX and CIFS/SMB relationship

After I had a problem transferring file over CIFS with my Macbook Pro, there are a lot of issues: stopping copying, missing files in a destination although successful operation. That was frustrated and surely I can’t give up on Samba just yet. I even have to do rsync or cp to get expectable outcome from such a simple task. By the way, after stumble across threads, KBs, I found the solution that make me happy for couple weeks so far.

Here is what I was looking for Mac OSX 10.5, 10.6: About named streams on SMB-mounted NAS

What you have to do is pretty simple, enabling named streams on Mac OS X client–yeah my machine! By opening up Terminal and type as following:-

echo "[default]" >>  ~/Library/Preferences/nsmb.conf
echo "streams=yes" >> ~/Library/Preferences/nsmb.conf

That is enabling named streams as a default for all smb connection. This makes my day indeed — not worrying if copying works as it should or not.

Popularity: 2% [?]