Hackintosh iMessage login error fix

February 21, 2013 Leave a comment

Started not long ago iMessage suddenly stopped working on my hackintosh laptop (A 1080p HP 4530s) with the following error when trying to setting iMessage account:

The server encountered an error processing registration. Please try again later.

After struggling for a few weeks (going through the official apple support forum, messing around with firewall, system date/time, and /etc/hosts) I found the solution here (actually this Chimera solution just came out 2 days ago), http://www.tonymacx86.com/336-chimera-2-0-now-available-imessage-login-fix.html

Link for the newest Chimera (2.0.1) is here: http://www.tonymacx86.com/downloads.php?do=file&id=164

Here are the steps (specific to my HP 4530S with HP Probook Installer version 6)

  1. Download and install Chimera 2.0.1
  2. Open the HP Probook installer and install “Graphic glitch fix” under “Optional hardware-specific fixes” if you did not install that when you set up your probook (doesn’t harm to re-install though)
  3. Reboot and enjoy

Note: Step 2 might not apply to you. I did step 2 because I got some choppy black boxes on the screen after upgrading to Chimera 2.0.1.

Using twilio without a public web server howto

October 7, 2012 Leave a comment

Why bother:
Most of the twilio tutorials on how to make phone calls require a twiml url and (optionally) status call back url, which might not be desired because either 1) not easy to set up a publicly accessible web server 2) for security reasons it’s better not to to expose some urls to the public even they are just intended for twilio to access. If your application doesn’t require a status call back check, you can follow this post to use twilio for phone calls without setting up a web server.

Basic concept:
1) prepare a twiml url through twimlet echo call
2) create a twilio service object
3) make a call with the service object using the url in step 1, use null as StatusCallBack
4) get the sid for the call made in step 3)
5) wait for a period of time which is enough for step 3) to finish
6) get the status for the call through sid obtain in step 4

Example code (in PHP):
1) go to https://www.twilio.com/labs/twimlets/echo and put in the following xml code into the textarea:

<Response>
<Say>Testing 123.</Say>
<Hangup/>
</Response>

and save the resulting url for the next step
2)

<?php
define('ACCOUNT_SID', 'your_twilio_account_sid');
define('AUTH_TOKEN', 'your_twilio_auth_token');
// from step 1
define('TWIML', 'http://twimlets.com/echo?Twiml=%3CResponse%3E%0A%3CSay%3ETesting%20123.%3C%2FSay%3E%0A%3CHangup%2F%3E%0A%3C%2FResponse%3E&');
require_once 'Path/To/Services/Twilio.php';

$sleep=30;  // seconds to pause before checking the call status
$from='###'; // nbr verified through twilio
$to='###';  // nbr to call
$tw=new Services_Twilio(ACCOUNT_SID, AUTH_TOKEN);
$opts=array(
	'timeout'=>'8',
);

// make a phone call
$call=$tw->account->calls->create($from, $to, TWIML, $opts);

// get its sid
$sid=$call->sid;

// sleep for some seconds
printf("sleeping for %d seconds now...\n", $sleep);
sleep($sleep);

// now check the call status
$call_check=$tw->account->calls->get($sid);
$status=$call_check->status;
printf( "status for [%s] is %s.",  $sid, $call_check->status );

// todo: do something with the $status

Conclusion:
As you can see from the above code, the trick is to take advantage of the twimlet echo service (basically we are using that to provide a twiml url which is hosted by twilio.com).

Categories: twilio

A few zsh tricks I’ve learned so far

September 30, 2012 Leave a comment

It’s the second day since I installed zsh onto my Mac OSX Lion (the exact procedures work on Mountain Lion as well) and I couldn’t help to sharing a few tips that I’ve learned so far:
1. Find all .pdf files under current directory
ls **/*.pdf

2. Go to folder ~/Documents/things/2nd_backup, current folder is ~
cd D/t/2, followed by Tab, autocompletion will change the command into
cd ~/Documents/things/2nd_backup

3.stop a process without running ps
kill, followed by space, tab
If you already know part of the process name, simply, for example
kill ht, Tab (intend to kill running htop process), if htop is the only one that matches ht, command will be automatically converted to
kill pid_of_htop, pretty neat, isn’t it?

4. change default theme from robbyrussell to gentoop The reason I did the switch is because robbyrussell lacks the indication if a user runs “sudo -s” to become root (given the user is given the privilege) and I happened to be a Gentoo fan.
Find the following line in ~/.zshrc and change robbyrussel to gentoo
ZSH_THEME=”robbyrussell”

[UPDATE 10:05PM EDT, 9/30/2012]
I found robbyrussell to be very attractive so I decided to tweak it a bit so it will indicate sudoer status:
vi ~/.oh-my-zsh/themes/robbyrussell.zsh-theme
add “%# ” to the end of PROMPT setting:
PROMPT='%{$fg_bold[red]%}➜ %{$fg_bold[green]%}%p %{$fg[cyan]%}%c %{$fg_bold[blue]%}$(git_prompt_info)%{$fg_bold[blue]%} % %{$reset_color%}%# '
With this change I can easily find out if I am running shell as normal user (%) or root (#), see the screenshot below:

Categories: zsh

Mac OS X Lion zsh installation with brew guide

September 30, 2012 2 comments
brew install zsh
cd $HOME
git clone https://github.com/robbyrussell/oh-my-zsh.git .oh-my-zsh
sudo chsh -s /usr/local/bin/zsh yourusernamehere
cp ~/.oh-my-zsh/templates/zshrc.zsh-template ~/.zshrc

Since I am a git nut, I fell in love with zsh right away after I saw the following when I was testing the auto-completion feature of zsh (glad the default zshrc.zsh-template has git enabled in the plugins setting):

The big yellow X means there are changes under current repository, “exp” in red is the name of the current branch. Once I committed the changes, the big yellow X sign disappeared. In other words I don’t even need to type git status to check if current repository is clean – can’t stop loving this feature.

Credits:
http://seletz.github.com/blog/2012/01/06/switch-from-bash-to-zsh/

Categories: zsh

Array min, max with Coffeescript

September 19, 2012 Leave a comment

Quite simple actually:


Array::max=->
  Math.max.apply(null, this)

Array::min=->
  Math.min.apply(null, this)

a=[6, 5, 17, -3, 4.5]
console.log a.max()
console.log a.min()

Outputs:
17
-3

Categories: coffeescript, Programming

Yet another must have node.js module – underscore-cli

September 12, 2012 Leave a comment

If you love underscore.js and happen to be a CLI nut, you should not miss out underscore-cli, see

https://npmjs.org/package/underscore-cli

for details, or simply install via (assuming you are already using node.js)

sudo npm install -g underscore-cli

Test Drive:
curl https://api.github.com/users/midnightcodr|underscore print --color

Categories: javascript, node.js

Calling initialization function only once with this js trick

September 12, 2012 Leave a comment

There are times when an initialization function in a js object needs to be called only once. Here’s one of the solutions I came up with. When F.paint() is called, a check on the initialization tag (need_init) is performed. need_init remains undefined until init() is called for the first time.

The code:

var F=(function() {
	var self=this;

	var init=function() {
		console.log('Initialized.');
		self.need_init=false;
	}
	return {
		paint: function() {
			if(typeof self.need_init==='undefined') {
				init();
			}
			console.log('Now I am ready to paint.');
		}
	};
})();

F.paint();
F.paint();
F.paint();

Output from the above example:
Initialized.
Now I am ready to paint.
Now I am ready to paint.
Now I am ready to paint.

Enjoy coding.

Categories: javascript, Programming

Dualboot Mountain Lion + Ubuntu 12.04 LTS on the same hard drive howto

September 4, 2012 Leave a comment

Shortly after Mountain Lion was released I did a clean installation onto my HP 4530S and have been very happy with the result, but I am also a huge Ubutu fan and I’ve been dual booting Ubuntu 12.04 LTS through a SD card on the same machine. All was working fine except I don’t like the Ubuntu booting speed (it’s one of those 95MB/s 16GB Sandisk SD cards, fast on the paper but it takes over 30-second to boot into Ubuntu) so I decided to dual boot ML and Ubuntu from the same hard drive (Agility 3 SATAIII 120GB, http://www.ocztechnology.com/ocz-agility-3-sata-iii-2-5-ssd.html) and it turned out to be not very difficult.

What is needed:
1) ML Unibeast installation disk
2) HP Installer (Or Multibeast if on non-HP4530s systems)
3) Ubuntu installation disk

Steps:
1) Re-partition hard drive ML installation, when I did the ML installation, I started with 1-partition scheme as I was not planning for dual-booting. To re-size the ML partition is a piece of cake (I was amazed how Mac OS X can handle this so well, online resize the OS drive, looking at you Window$), just launch disk utility -> click on the hard drive, click the + sign, adjust the divider, click on the new partition and adjust the size through its size from the text field if needed. The new partition will be created as free space and no other changes are required. Hit Apply.
2) Reboot with Ubuntu installation disk, choose “Something else” when asked how to install, create a ext4 / partition and a 2GB swap partition (adjust the sizes if you want, I have 8GB of RAM so I am not worried about swap that much). My root partition is created as /dev/sdb3, when it comes to boot loader installation, make sure you choose this as where GRUB would be installed, if you choose the wrong partition, first partition, for example, you will need to do some extra work to fix it.
3) Once Ubuntu is installed, reboot with Unibeast, make sure to choose the hard drive ML installation when Chimera menu comes up. Log in to ML and install Chimera again from HP installer (or Multibeast).
4) Shutdown, remove Unibeast installation disk, power up, when Chimera boot logo appears, hit any key you will see the Ubuntu partition along with the original ML partition.

Note: This post is created after I successfully dual boot into the newly installed Ubuntu 12.04 LTS. Cheers.

Install node.js on Raspberry PI in two simple steps

July 24, 2012 13 comments

[ Updated Jan 20, 2013 ] Check out my git repository https://github.com/midnightcodr/rpi_node_install if you are interested in putting newer version of node to raspberry pi (tested with 0.8.14, os runs raspbian)

1) Install the newest wheezy image onto the sd card (currently 2012-07-15-wheezy-raspbian.zip) from http://www.raspberrypi.org/downloads

2)

sudo apt-get install nodejs npm

, press y, Enter when prompted, you will get node.js (v0.6.19) and npm (1.1.4) installed in a few minutes, which should be the easiest way to get node.js and npm up and running on RP.

Note: If you want newer version of node.js you might want to check this out: http://www.raspberrypi.org/phpBB3//viewtopic.php?f=34&t=9929, I have tested the method described in this post in the previous release of wheezy (http://www.raspberrypi.org/archives/1435) and I assume it should work with the current image as well.

Categories: node.js, raspberry pi

Install Postgres on Mac OS X Lion with homebrew howto

July 20, 2012 3 comments

1) This is the easiest part, simply

$ brew install postgres

2) this step is not obvious but you can’t move on without it (would be nice if brew can automate this step too :D)

$ initdb /usr/local/var/postgres

3) add /usr/local/bin to $PATH if it’s not already there, one way to do that is

$ echo 'export PATH=/usr/local/bin:$PATH' >> ~/.bash_profile && . ~/.bash_profile

without this step you will end up using /usr/bin/psql, which is installed by default in Lion, while trying to access db, which would give you the following error:

psql: could not connect to server: Permission denied
Is the server running locally and accepting
connections on Unix domain socket “/var/pgsql_socket/.s.PGSQL.5432”?

[added 7/26/2012]
3.5) start postgres server

pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log start

4) access postgres db

psql postgres your_username

or

psql postgres `whoami`

assuming your_username is the one who runs step 2

5) if everything’s ok you should be able to see

psql (9.1.3)
Type “help” for help.

postgres=#

type \q to exit

6) if you want to create your first db, do (under system shell, not postgres) a

createdb mydb

and access it through

psql mydb your_username

Note: your_username in command psql is optional if the shell user is the creator of the db to be accessed, that is, you can simply type psql postgres or psql mydb to access the dbs.

Enjoy.

References:
http://archives.postgresql.org/pgsql-general/2009-09/msg00990.php
http://nextmarvel.net/blog/2011/09/brew-install-postgresql-on-os-x-lion/ (didn’t use the method describe in this post but use the PATH method instead)
http://www.postgresql.org/docs/9.0/static/tutorial-createdb.html

Categories: lion, mac osx, postgresql