2015-12-07

A reminder for myself of how I use git filter-branch to remove files from git history

It's all about the git "filter-branch" command

To keep things clean, I'll make a new file that contains a space-separated list of files i want to remove:
lets call it files_to_rm and put it on my desktop with the following contents
public/api/docs/dist/css/print.css public/api/docs/dist/css/reset.css

git filter-branch --index-filter "git rm -rf --cached --ignore-unmatch `cat ~/Desktop/files_to_rm`" HEAD

And then after this, you'll need to do a force push of course, because you've altered history.

2015-08-12

"Unsubscribe" vs "Manage Subscription"

This needs to be put out there in hopes that it will help someone make a decision in the future.

I'll cut straight to the fact.  When choosing what wording to put at the bottom of your subscriber emails, choose "Unsubscribe" or "Unsubscribe Now".   DO NOT use only the phrase "Manage Subscription".  This is a shady practice and not cool from a UX perspective.  More than likely the person is pissed off that they somehow landed on your subscription list and they just want to be removed NOW.

Psychologically, when I see "Manage Subscription",  I'm thinking something along these lines: "Oh this shitty company doesn't want to make it so easy to get me removed from their spam list, screw them, now I'm really pissed off".  Is that the feeling you really want generated towards your company?

On the flipside, if I had a company, and I was sending emails to subscribers, I would want to make it extremely easy for people to unsub because I wouldn't want to create that negative feeling towards my company.  I would want to get the unwanting people removed as quickly and easily as possible.

At a lower level of thinking:
If your company isn't doing something that creates real interest in a regular email to subscribers, then you're doing something wrong, and you should not be penalizing the people that want out of your boring crappy spam campaign.

However: If you truly do have options that the person CAN "manage".. then use both links.  One to appease the likely case as described above(the quick unsub), and one for your real subscriber that truly wants to edit the subscription settings.

In summary.. Do to others what you would like to have done to you.  ie: Don't be a dick.

2015-07-02

My thoughts on backbone.js

I don't like many front-end mvc frameworks.  Why? Because they tell me what to do and how to do it.  But, I do like backbone.
To me, backbone feels like a wise old man, who doesn't care what others think about it, and only has time to be concerned with the truly important things in life;  You know, the simple and foundational things, like models and collections and views that don't do much at all without your intervention.  This old man is far too wise to tell you how to use the tools he provides, and despite being bored with life's higher-order redundancies, he gets continual enjoyment out of watching how you use the tools.

2014-01-08

script i use to swap between my laptop display and the hdmi connected monitor

Just putting this here so others can find it.


#!/bin/bash

# i ran `xrandr -q` to discover these values
IN="eDP1"
EXT="HDMI1"

if (xrandr | grep "$EXT" | grep "+")
then
xrandr --output $EXT --off --output $IN --auto
else
  if (xrandr | grep "$EXT" | grep " connected")
    then
    xrandr --output $IN --off --output $EXT --auto
  fi
fi

2013-07-07

Configuring the 2013 Sony Vaio pro 13 with Arch Linux

WARNING: DO NOT PURCHASE THE 2013 SONY VAIO PRO:
See this: http://community.sony.com/t5/VAIO-Hardware-Networking/New-Sony-Vaio-Pro-Wifi-Issue/td-p/143557
Sony should recall these.  The wifi antenna was placed internally right next to components that block the signal.  For example: I can be sitting in the center of a starbucks and not see their wifi network.

I will leave my original blog post that has gathered some attention for the configuration, but I will be attempting to return this laptop, although I expect sony to do nothing due to the size of the company and their shady history.

You will need a usb ethernet adapter for this. The one I have is autodetected and configured by arch installer.

These are the steps I used in order to get up and running on this amazing piece of hardware.  This is me remembering what I did about 36 hours ago, as I type this on my awesome new vaio pro running e17.

I used the dd method of copying the arch install boot image to a thumbdrive and used that to boot.

configure the BIOS
With the laptop OFF, press the assist button, this boots the laptop into the sony efi boot/recovery menu.

Select BIOS setup
Make sure secure boot is off and change the boot method from UEFI to "legacy".
Also set external boot to enabled, and give it higher priority in the boot order.

Shut down and boot with the thumbdrive in:
It is very important you don't just boot as-is. You have to press tab and edit the kernel boot parameters. Add libata.force=noncq as a boot parameter.
And a side-note on this: The existing boot parameters looked strange to me because it contained a ../../ at the end of the string, so I placed it somewhere in-between two of the existing parameters that looked "normal" to me.

From here forward I followed the arch install guide as normal until a point.
After some research I decided on ext4 for both my / and /boot partition.
Those are the only partitions I created. There is no need for a /swap partition on this hardware. I used fdisk to do the partitioning and here is a printout of my table(with a 250mb boot partition):
Disk /dev/sda: 128.0 GB, 128035676160 bytes, 250069680 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x9dc83417

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048      514047      256000   83  Linux
/dev/sda2          514048   250069679   124777816   83  Linux

If you just follow the guide, you won't be able to boot because the libata.force setting naturally won't persist to your install.
I used grub, because it's dead simple and just works.
So follow the instructions for grub...
pacman -S grub...
Except BEFORE you generate the grub.cfg you need to edit the /etc/defaults/grub file.
So that's before you run "grub-mkconfig -o /boot/grub/grub.cfg" edit this setting(line 4 for me) in /etc/defaults/grub to contain the libata... parameter:
GRUB_CMDLINE_LINUX_DEFAULT="quiet libata.force=noncq"

Continue with the rest of the guide and you should have a bootable system.

Boot into your install:
You're not done yet!

Install git:
pacman -S git

linux-firmware
UPDATE 2013-08-16 - the arch repo version contains the firmware
get the latest linux-firmware (which as of only a few days ago includes the firmware for this intel 7260 card)
The repo: http://git.kernel.org/cgit/linux/kernel/git/firmware/linux-firmware.git/
rm -rf /lib/firmware
git clone git://git.kernel.org/pub/scm/linux/kernel/git/firmware/linux-firmware.git /lib/firmware


kernel source from iwlwifi
clone the linux kernel source from this repo: http://git.kernel.org/cgit/linux/kernel/git/iwlwifi/iwlwifi.git/

git clone git://git.kernel.org/pub/scm/linux/kernel/git/iwlwifi/iwlwifi.git
UPDATE(2013-07-21): kernel source
Use the mainline kernel 3.11-rc5
Linus merged in the iwlwifi repo. https://www.kernel.org/
(You'll still have to do the next part)

UPDATE - 2013-09-13 - Support for this CPU is finally in the linux repo as of 2013-09-12 (https://github.com/torvalds/linux)

DONT COMPILE YET, first you'll need to edit one line in this file: drivers/cpufreq/intel_pstate.c

This is very important, without doing this your cpu will be stuck at 800mhz.

Here is my diff, real simple, just add a single line(or make sure it's there... hopefully this makes it's way to mainline soon)


diff --git a/drivers/cpufreq/intel_pstate.c b/drivers/cpufreq/intel_pstate.c
index 07f2840..1ce506a 100644
--- a/drivers/cpufreq/intel_pstate.c
+++ b/drivers/cpufreq/intel_pstate.c
@@ -522,6 +522,7 @@ static const struct x86_cpu_id intel_pstate_cpu_ids[] = {
        ICPU(0x2a, default_policy),
        ICPU(0x2d, default_policy),
        ICPU(0x3a, default_policy),
+       ICPU(0x45, default_policy),
        {}
 };

Ok, now you are prepared to compile.
pre-compile checklist:
- clone the github repo kernel
- /lib/firmware is updated and contains iwlwifi-7260-7.ucode
- cloned the linux source from the iwlwifi repo
- downloaded the current mainline kernel
- edited the intel_pstate.c file

an annoyance here is since you're booted into a kernel that does not contain the haswell support, you will be running at 800mhz, and thus compilation will take long.

Now you'll be following the arch directions on how to compile your own kernel from source. The arch documentation for this is great.
https://wiki.archlinux.org/index.php/Kernels/Compilation/Traditional

I will leave the rest to you... or my future self referring back to this.

Also, I want to give credit to two blogs that helped guide me in the right direction in all of this:

Nick Brackley's blog: http://www.nicksplace.com.au/
and
https://spicious.com/sony-vaio-pro-11-with-ubuntu.html

Thanks guys!

I hope I didn't miss anything.  I will edit this if I did.

update:
ok, it's been a few days, and I've been monitoring the cpu with i7z.
I'm posting this little update to say I've notice that when I put the laptop to sleep(close the lid), and wake it up again, the CPU seems to be frozen at 2.9..Ghz.
I will be looking into this soon, and posting what I find, if anything useful.

update 2:
I've been reading quite a bit about the stuck turbo mode situation.  It seems it isn't the only problem.  Apparently the cpu should also be able to idle as low as 800mhz.  Currently(ignoring the sleep/wake turbo-mode bug), my cpu sits idle at 1800mhz and turbos properly up to 3ghz.  I don't think I will do anything here.  I'm almost always near an outlet to stay plugged in, if this temporary bug causes my battery life to be less amazing.  I'm getting at least 4 hours(real-life usage) anyway.
Doing a bit more research this weekend; perhaps the kernel pstate/governors can be disabled altogether and let the cpu manage itself?  I don't have a lot of knowledge of this area of tech, but I wish to learn.

update 3:
external monitor/hdmi sound - works perfect!
see: https://wiki.archlinux.org/index.php/Xorg#Multiple_monitors.2FDual_screen
and of course for sound I'm using pulseaudio, and I use pavucontrol to control pulse settings

boot speed test, see for youself how fast this beast is:


update 4:
the wireless driver is now included in the mainline kernel 3.11-rc2.
I've updated the blog post, but also noting it here.

update 5:
Another thing I realize I should post is that I have been unable to get the built-in microphone to work.
I simple get pavucontrol reporting the internal microphone as "unavailable".  I'll be looking at this more this week, and will update if I can get it working.

update 6(2013-08-16):
I've got to the point where I compile every new kernel rc.  Still waiting for intel pstate support to be baked in to the kernel and I still haven't figured out how to get the internal mic working.  Those two things are all that remain for 100% support.
At the moment I plug in a headset I use for my phone, and the mic on that works through the combined headsest/mic port.
I have a kernel config that has been working very well.
Posting it here for public consumption, but don't criticize too hard, I haven't been customizing kernels for very long.
https://s3.amazonaws.com/elouisyoung/.config

update 7 (2013-09-13)
Yesterday I noticed Linus pulled in a commit that enabled haswell support(finally).  No more need to add the CPU id, as described above.  So I have struck the irrelevant portions of the blog post.
Support is looking good now, although I have never got the internal mic to do anything other than show "Unavailable" in pulse audio.

update 8 (2013-10-13)
The mic finallly works with current master branch kernel.  This leaves only the wifi problem.  Well it's a hardware design failure on sonys part so I will be doing whatever I can to return this laptop to Frys when the new samsung ativ 9 is on the shelf.  Screw you sony for not doing a recall for the wifi failure.

2013-06-25

my configuration for minitest in a rails project

Here I want to document my minitest configuration because I think it is elegant and if this helps anyone, then I am very happy.

spec/spec_helper.rb


unless @no_env
  ENV['RAILS_ENV'] = 'test'
  require File.expand_path('../../config/environment', __FILE__)
end

require 'minitest/autorun'
require 'minitest/spec'
require "minitest/pride"

# if this file was executed directly
if __FILE__ == $0
  $LOAD_PATH.unshift('spec')
  Dir.glob('./spec/**/*_spec.rb') { |f| require f }
end


test group in my Gemfile


group :test do
  gem 'minitest'
end


spec/models/foo.rb


standard rails model spec.

require_relative '../spec_helper'

describe Foo do
  # specs here
end


spec/lib/foo_module.rb


example spec for a lib that doesn't require the rails env

require_relative '../spec_helper'
require_relative '../../lib/foo_module.rb'
@no_env = true

describe FooModule do
  # spec for module that is decoupled from the rails env
end
The best thing here is having no reliance on rake. The spec files and the helper will be called directly with ruby.
Examples:
"ruby spec/spec_helper.rb" - will run all specs
"ruby spec/lib/foo_spec.rb" - will just run that spec

And vim makes this easy when editing a spec file I just run "!ruby %" to run that spec file
A final note: I realize "ruby spec/spec_helper.rb" is a bit much to type, so of course I simply made a zsh alias called "specs" for it.

2013-02-06

Ubuntu ruby and rails development setup script

I've been configuring ubuntu for ruby and rails development for a while now, so I started maintaining a bash script to help in the process, here's the github link:

At the time of posting I have been running this on ubuntu 12.10

https://github.com/ELouisYoung/init-ubuntu

Feel free to take a peek.  There's still some stuff specific to me in there, so edit it before running.

Foe SEO purposes I will paste the current version of the script here:


#! /bin/bash
#
#  Written from scratch by Eric Young
#  Do whatever you want with it.
#

echo "executing with $SHELL"
echo "Installing git..."
sudo apt-get install -y git

#create .files directory so we can check if it's empty or not
DOTFILES="$HOME/.files"
mkdir -p $DOTFILES

if [ "$(ls -A $DOTFILES)" ]
then
  echo "You already have the .files, lets see if there's an update"
  cd $DOTFILES
  git pull --rebase
else
  echo "You dont have the .files, lets clone the repo"
  cd $DOTFILES
  git clone git@github.com:ELouisYoung/dotfiles.git .
fi

#make symlinks
SYMFILES=( .tmux.conf .vimrc .gitconfig .zshrc .gemrc )

for SYMFILE in ${SYMFILES[@]}
do
  echo "Working on $SYMFILE --"
  if [ -e "$HOME/$SYMFILE" ]
  then
    "echo that file already exists, is it a symlink?"
    if [ -L "$HOME/$SYMFILE" ]
    then
      echo "Yep, it's a symlink, assuming it's what you want"
      echo "You already have $SYMFILE symlinked, doing nothing"
    else
      echo "Nope, it's a not a symlink, backing it up and linking the sym from .files"
      echo "Your pre-existing $SYMFILE file is being moved to ~/$SYMFILE.moved"
      mv "$HOME/$SYMFILE" "$HOME/$SYMFILE.moved"
      ln -s "$HOME/.files/$SYMFILE" $HOME
    fi
  else
    echo "$SYMFILE was not linked, doing it now"
    ln -s "$HOME/.files/$SYMFILE" $HOME
  fi
done

#purge the undesirables
sudo apt-get purge -y -qq\
 libreoffice* thunderbird pidgin

sudo apt-get install -y\
 vim-gnome\
 tmux\
 xclip\
 build-essential\
 openssl\
 libreadline6\
 libreadline6-dev\
 libmagickwand-dev\
 libterm-readkey-perl\
 curl\
 zlib1g\
 zlib1g-dev\
 libssl-dev\
 libyaml-dev\
 libsqlite3-dev\
 sqlite3\
 libxml2-dev\
 libxslt-dev\
 autoconf\
 libc6-dev\
 ncurses-dev\
 automake\
 libtool\
 bison\
 pkg-config\
 zsh\
 openjdk-7-jdk\
 vlc\
 htop\
 postgresql\
 postgresql-server-dev-9.1\
 libpq-dev\
 ia32-libs\
 libcurl4-gnutls-dev\
 gitk\
 chromium-browser\
 chromium-codecs-ffmpeg-extra\
 redis-server\
 exuberant-ctags\
 ack\
 dnsmasq\
 mongodb


#rbenv
if [ -d "$HOME/.rbenv" ]
then
  echo "You already have rbenv"
else
  git clone git://github.com/sstephenson/rbenv.git "$HOME/.rbenv"
fi

#heroku toolbelt
if [ -e "/usr/local/heroku/bin/heroku" ]
then
  echo "You already have the heroku toolbelt"
else
  echo "Installing heroku toolbelt, will ask for password"
  wget -qO- https://toolbelt.heroku.com/install.sh | sh
fi

#vim Vundle prep
if [ -d "$HOME/.vim/bundle/vundle" ]
then
  echo "You already have Vundle, doing nothing, assuming you have set it up"
else
  echo "PRESS ENTER WHEN VIM EXECUTES"
  git clone https://github.com/gmarik/vundle.git ~/.vim/bundle/vundle
  vim +BundleInstall +qall
fi