The Problem

The default color for active tab on Terminator and Ubuntu terminal is almost indistinguishable. This can be fixed by using another theme, but if you want to use your current theme and only tweak the tab color, read on.

Because Terminator 0.97 still uses GTK2; whereas Ubuntu terminal uses GTK3, they each require a different method to tweak.

The Tweak for GTK2

For Terminator and any other GTK2 applications, you can directly edit the gtkrc file your theme uses.

1
sudo vim /usr/share/themes/<YOUR_THEME>/gtk-2.0/gtkrc

Find the following block:

1
2
3
4
5
style "notebook_bg" {
  bg[NORMAL] = shade (1.02, @bg_color)
  bg[ACTIVE] = shade (0.97, @bg_color)
  fg[ACTIVE] = mix (0.8, @fg_color, shade (0.97, @bg_color))
}

Replace @bg_color in bg[NORMAL] to a color you like, e.g. #FCBC8D.

The Tweak for GTK3

For terminal and any other GTK3 applications, you can edit the gtk.css in your home directory. It is located in #HOME/.config/gtk-3.0/gtk.css. Create one if it’s not there.

Add the following lines to gtk.css:

1
2
3
TerminalWindow .notebook tab:active{
  background-color: #FCBC8D;
}

For the change to take effect, you need to open up a new application.

The default Theos installation, as outlined in this wiki, does not include all iOS headers. The following process installs the necessary headers and patches for OSX Mountain Lion/Mavericks.

  • Follow the official wiki to install theos.
  • Add iphoneheader to theos/include
1
git clone https://github.com/rpetrich/iphoneheaders.git
  • Copy IOSurfaceAPI.h from OSX library
1
cp /System/Library/Frameworks/IOSurface.framework/Headers/IOSurfaceAPI.h theos/include/IOSurface
  • Patch IOSurfaceAPI.h by commenting out two lines
1
2
3
4
5
6
7
8
/* This call lets you get an xpc_object_t that holds a reference to the IOSurface.
Note: Any live XPC objects created from an IOSurfaceRef implicity increase the IOSurface's global use
count by one until the object is destroyed. */
//xpc_object_t IOSurfaceCreateXPCObject(IOSurfaceRef aSurface)
//      IOSFC_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_NA);
/* This call lets you take an xpc_object_t created via IOSurfaceCreatePort() and recreate an IOSurfaceRef from it. */
IOSurfaceRef IOSurfaceLookupFromXPCObject(xpc_object_t xobj)
IOSFC_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_NA);

The Problem

It seems all the tutorial on Octopress deals with setting up a new repository. Recently, I needed to clone the my Octopress repo on a new machine and resume writing there. I thought it would be as simple as git clone, rake setup_github_pages, rake new_post, and rake gen_deploy. However I encourtered the following during deploy

1
2
3
4
5
6
7
8
9
10
To https://github.com/username/username.github.io
 ! [rejected]        master -> master (non-fast-forward)
 error: failed to push some refs to 'https://github.com/username/username.github.io'
 hint: Updates were rejected because the tip of your current branch is behind
 hint: its remote counterpart. Merge the remote changes (e.g. 'git pull')
 hint: before pushing again.
 hint: See the 'Note about fast-forwards' in 'git push --help' for details.

## Github Pages deploy complete
cd -

The Fix

I googled around and found no solution. After digging into the Rakefile, I came up with a manual fix. Basically, you need to create and link the deploy directory to master branch.

First, we clone the repo and switch to the correct branch:

1
2
3
git clone https://github.com/username/username.github.io.git
cd username.github.io.git
git checkout source

Then we need to setup the deploy directory.

1
2
3
4
mkdir _deploy
cd _deploy
git init
git remote add -t master -f origin https://github.com/username/username.github.io.git

Done! Now we can make changes in source branch and use rake gen_deploy as usual.

Since China uses a different coordinate system, the common latitude/longitude coordinates obtained from GPS or iOS CoreLocation service will not map to the correct location in China. The shift is usually 500+ meters, which renders the FindMyFriends app useless. In order to let your (unjailbroken) friends see your true location, your reported location need to be shifted. When they receive your (shifted) location and apply it to a shifted map, the shift effect cancels out and they see your true location in MapView.

FindMyFriends.app reports user location from two places.

  • When the app is in foreground, the app itself reports the location.

  • When the app is in background, aosnotifyd daemon will respond to the location request. (This daemon is also responsible for FindMyiPhone.app location tracking.)

Therefore to fix the location shift, those two places need to be patched.

com.apple.mobileme.fmf1

In FindMyFriends.app, the following function does the reporting:

ServerInteractionController.h:
1
-(void)sendMyLocation:(id)location;

Using theos, we can hook into the method and modify the (id)location.

However, we can fix friends location altogether by hooking the location data structure directly.

1
2
3
4
5
6
7
8
9
10
%hook FMFLocation
- (void)updateLatitude:(id)lat longitude:(id)lng altitude:(id)alt
horizontalAccuracy:(id)acc verticalAccuracy:(id)acc5 course:(id)c speed:(id)s timestamp:(id)ts {
    double nlat,nlng;
    transform([lat doubleValue],[lng doubleValue], &nlat, &nlng);
    NSNumber *olat=[NSNumber numberWithDouble:nlat];
    NSNumber *olng=[NSNumber numberWithDouble:nlng];
    %orig(olat,olng,alt,acc,acc5,c,s,ts);
}
%end

com.apple.aosnotifyd

In aosnotifyd, the following function does the reporting:

AOSFindBaseServiceProvider.h
1
-(void)sendCurrentLocation:(id)fp8 isFinished:(BOOL)fp1 forCmd:(id)fp2 withReason:(int)fp3 andAccuracyChange:(double)fp4;

This can be patched similarly.

Location shift function

For some reason, I will not discuss the detail of the shift function transform(). Basically it does the conversion from WGS-84(GPS) to GCJ-02 coordinates. Google WGS2GCJ for more information.

Source code

You can download and build the cydia tweak from my repository: github.com/weishi/FMFChinaLocationPatch