ubuntu on thinkpad x1 carbon 4th gen (2016)

2018-10-14

I picked up a used Thinkpad X1 Carbon 4th Gen (2016) on Craiglist a little over a week ago for $400 and I’m super pleased with it so far. Ubuntu 18.04 works pretty great out of the box, but with a few extra tweaks it’s even better.

Power Management

You’ll want to install tlp for power management first, as powertop will show you right away that most of the hardware isn’t power optimized out of the box. After doing the below, I’m getting about 6 hours (normal use with brightness around 60%) from a battery that only holds 80% of designed capacity.

sudo add-apt-repository ppa:linrunner/tlp
sudo apt-get update
sudo apt install tlp tlp-rdw tp-smapi-dkms acpi-call-dkms
sudo tlp start

Running sudo tlp-stat will give you a bunch of info; sudo tlp-stat -b is likely all you’ll care about.

You can also control the percentage the battery will charge to and the percentage threshold for charging to begin. If you keep your laptop plugged in a lot, you may want to consider setting the charge threshold to 75% and the max charge to 80% to prolong battery life with sudo tlp setcharge 75 80 BAT0. If you’re planning on needing more juice (e.g. getting on a plane), you can quickly revert to 100% charge with sudo tlp fullcharge. tlp docs say it should revert to the 75/80 profile on restart, but that doesn’t seem to work for me.

Fingerprint Reader

The Validity Sensors fingerprint reader on this model isn’t yet supported by the libpam-fprintd driver, however there is a forked version from Marco Trevison that gets the job done. If you already tried the main libpam-fprintd driver, just make sure you remove it and any PPA’s before doing the below.

sudo add-apt-repository -u ppa:3v1n0/libfprint-vfs0090
sudo apt update
sudo apt install libpam-fprintd

99% of the time I use either my right index finger or my right thumb, so to enroll fingeprints for those just run:

fprintd-enroll -f "right-index-finger" "$USER"
fprintd-enroll -f "right-thumb" "$USER"

If you’d rather enroll everything you can simply do:

for finger in {left,right}-{thumb,{index,middle,ring,little}-finger}; do fprintd-enroll -f "$finger" "$USER"; done

If you want to use your fingerprint instead of your password when you use sudo, you’ll want to run sudo pam-auth-update and use the ncurses interface to select “Fingerprint authentication.” Enrolling a fingerprint for your user should automatically enable fingerprint authentication as an option for logging into Ubuntu, but you can double that it’s enabled by opening “Users” in “Settings” and make sure “Fingerprint Login” is set to “Enabled”.

brushing the dust off

2018-10-13

Well, it’s been a little awhile, but I’m finally reviving this blog. To start, I ditched Tumblr and migrated to GitHub Pages powered by Jekyll. Jekyll has an importer, but it’s pretty naive. All the reblogs from Tumblr are broken and none of the images came along with the posts (though they were downloaded into a directory for me). Not a huge deal, I plan to just go back and slowly delete all the reblog posts since most are broken anyways and I’ll manually add the images on the whopping four imported posts that had them.

The below is a tl;dr on how to migrate from Tumblr to GitHub Pages for those familiar with Docker and Jekyll (at least a little bit). It’s 2018, so I assume everyone has at least played with Docker by now, but if you’re late to the party then I highly recommend Dive Into Docker.

  1. Create a new Jekyll site
  2. cd into the directory
  3. Import your Tumblr posts
  4. Setup GitHub Pages.

git branching model

2014-02-19

This has been my guide for Git branching for my projects.

A condensed version with some of my own additions:

Main Branches

Origin should have two main repo’s, “master” and “dev” (“develop”, “development”, whatever you prefer).

master is always stable, production ready.  Pull Requests should be to dev branch.  Features (discussed below) should also be pushed to dev before before a release to master/production.

Features

Feature branches should be merged into dev with –no-ff so everything is packaged together.

Start by creating your feature branch with git checkout -b myfeature dev

After work is done and you’re feature is ready:

  1. git checkout dev
  2. git merge –no-ff myfeature
  3. git branch -d myfeature
  4. git push origin dev

Releases

Cutting a release consists of grabbing the dev branch at a certain point and merging that into master.

  1. git checkout -b release_name dev
  2. Update a version file and commit if one exists
  3. git checkout master
  4. git merge –no-ff release_name
  5. git tag -a release_name_or_number
  6. git checkout dev
  7. git merge –no-ff release_name
  8. git branch -d release_name

Hotfixes

Hot/bugfixes can be done on master, just be sure to also merge and push to dev.

  1. git checkout -b hotfix_name master
  2. git checkout master
  3. git merge –no-ff hotfix_name
  4. git tag -a release_name_or_number
  5. git checkout dev
  6. git merge –no-ff hotfix_name
  7. git branch -d hotfix

Keeping local branches up to date

  1. git checkout dev
  2. git pull origin dev
  3. git checkout your_local_branch_name
  4. git merge dev

Merge Conflicts

DiffMerge is a good visual tool. Here’s how to set it up.

Reverting a Merge

http://git-scm.com/blog/2010/03/02/undoing-merges.html

This is when doing a merge for your features makes a lot of sense because you can easily rollback an entire feature with git revert -m 1 merge_sha

cap deploy refreshing local cache fails

2014-02-07

If you’re trying to cap deploy and getting

fatal: Not a git repository (or any of the parent directories): .git

during the “refreshing local cache to revision …” step on OSX, try deleting the /tmp/caches/<project-name> directory on your Mac and retry the deploy.

Kudos to http://www.outofcph.dk/2009/05/capistrano-deployment-with-git-failing-periodically/

s3 no gps icon when using an app that uses gps

2013-07-23

If you have a Samsung Galaxy S3 and you aren’t getting a GPS lock and a GPS icon does not show in the notifications area when using an app that uses GPS (e.g. Google Maps or GPS Status & Toolbox). Try the below.  Worked for me on an AT&T S3 (stock 4.1.1 rooted), not sure about other models/carrier versions:

  1. Dial *#197328640#
  2. Select [1] UMTS
  3. Select [6] Common
  4. Select [6] NV REBUILD
  5. Select [1] NV REBUILD
  6. Wait 30 seconds
  7. Reboot phone