direnv is one of the coolest tools ever

0

I’ve always loved the idea of self contained environments but coming from doing perl and c/c++ a long time ago, I’ve never been able to really pull it off. It wasn’t until I encountered virtualenv for python that I finally got this working properly. I had encountered rvm’s gemsets before that, but they always seemed finicky at best.

I started to have complex vim configs, and bash rcs that tried to look at what directory you were in / file you were editing, and change configs accordingly. It never worked well. EditorConfig and vim-editorconfig helped a lot with that. No longer had to have really confusing vim configs. I could specify per project editor settings. I can’t wait till its more uniformly adopted.

That left bash configs though. Enter DirEnv. Its solved the second half for me. Makes all those configurations per project. A simple direnv edit . inside your project directory will open up $EDITOR. This lets you specify all kinds of things about that project. Anything you can do in bash you can do here. It works best with env variables but can do other things. I love the layout functions though.

layout node

adds node_modules/.bin to your path

layout python

Creates a new virtualenv and adds it to your path.
..etc

It makes it easy to work with heroku based apps as well. They do all your configurations as environment variables, its pretty easy to add a bunch of export statements to your direnv and emulate the same thing.

I’ve just submitted a simple patch to add layout perl. This makes local::lib so much easier to use per project.

I have to give Philip Nelson credit for letting me know about this toolset. Its changed how I develop applications. He and I disagree on exactly how to use it, but no matter how you do, it helps out.

Bash prompt linewrap with colors issues

So I’ve been fighting with trying to make a custom color prompt for a while now.

I’ve recently found out about tput to output color codes. That combined with local variables meant prompts became easier to read.

  local BG_RED=$(tput setab 1)

We started to create a custom prompt here for the team. Had all the info needed at a quick glance. Everything was good except long lines didn’t wrap properly. Ctrl+r would just get nutty.

So, after a lot of research and reading various forum posts, I found out that color codes should be wrapped in “\[...\]“. So example:

  local BG_CYAN=$(tput setab 6)
  local FG_GREEN=$(tput setaf 2)
  local RESET=$(tput sgr0)

  export PS1="\[${BG_CYAN}${FG_GREEN}\]\u@\h \[${RESET}\]$"

Note the \[ and \] wrapping the codes. This allows bash to properly figure out the length of the line. Note: I just grabbed random colors, I suspect this example looks bad.

I did find a slight exception

For the TITLEBAR (putty/xterm/screen) support:

case $TERM in
xterm*|rxvt*)
TITLEBAR="\[33]0;\u@\h:\w07\]"
;;
screen*)
TITLEBAR="\[33k\u$\h\]"
;;
*)
TITLEBAR=''
;;
esac

The \[ and \] should wrap the entire block as everything inside is considered part of the control code.

Feb 1st, 2014 – An unique milestone

This will be one of my rare non tech posts on this blog (I think).

As of today, Feb 1st, 2014, It has been now 10 years since my last relationship ended with the infamous words “You can still date me if you want”.

I’ve brought it up with friends, mostly because it’s a weird kind of rare milestone. Most people then ask how I feel about it. It’s taken a while to figure out what to say. I only recently realized it was almost 10 years (sometime in December maybe). I was talking to a friend about school and came across some old albums and realized when things last ended. I feel like being single has not really been a big deal in my life.

Now some people have gone along the lines “have you tried dating?” or “Are you ready now?”. I think that just highlights people don’t really understand. I’ve never avoided it. I even tried online dating several times. Online dating really isn’t for (someone like) me. It puts a lot of pressure on the first encounter. I’m well aware that many meet people from online dating sites and go on to stay friends, but I don’t think that’s the norm. I know when I tried I always tried to made it clear that I was happy enough even just to make new friends but I’m also aware of how many horrible people that frequent on those sites. After meeting and/or chatting with people, I realized it’s not the venue for me. I like getting to know people instead of instantly the comfortable way.

So how do I feel about being single for so long? Overall I don’t think I regret it. Sure there are times when that’s not true, but they pass pretty quickly. It’s usually the moments when you realize you are the only person in a room that hasn’t paired up with someone. I would say none of the people I hang out with regularly has ever held that against me, but it does come up from time to time.

So is my status ever going to change? Who knows. I’m really happy where the path of life has taken me so far. I have some amazing friends. Met some amazing people. I love my job. I’m going to continue to go out, do things, meet new people if I can, and who knows, one day I might find that someone special, but I would never want to force it. It’s not who I am.

(Lets hope this comes across as positive as I wanted)

Capistrano3 – Deploying with internal git server

To set the scene. New team has been using capistrano to deploy some of its apps (all internal/behind our firewall). So new POC project comes along. Nothing sensitive but needs to be publicly accessible. I get very excited because this is the first time I’ve setup capistrano from scratch. I follow the getting started guide. Deploy to internal test. No problem there. Go to deploy to the amazon box (Go Free Tier) and fail… Riiight, can’t talk to our git server.

So spend a while scouring the internet for how to solve this problem. Can I just SCP? Its not that important right now. Hrm. That doesn’t seem to work reliably. Lots of solutions, none of which seem very clear and/or work with cap3. So I give up searching. This should be easy right? Just setup a remote tunnel. I open a new window, create  tunnel, edit my config, and bang. Deployed. Yay!

But wait, this is going to get annoying fast. Plus others will have to do that manual process as well. How do I automate this? Scour the internet for a while. Again, no real automation and/or doesn’t work with cap3.

Well fine, I always need the excuse to learn more about ruby, so start digging into the code. Its using pre-existing open source modules so it shouldn’t be that hard. After a bunch of learning, and giving up, I decided to skip on the nice clean solution and just start overriding some things.

So here it is, config/deploy/production in all its glory:

YAOIRPG

tl;dr – http://yaoirpg.halkeye.net is now live again

Yet Another Online Interaction Role Playing Game was a project a group of us at BCIT put together. It was for some of internet studies course (Yea I’m that old / It hadn’t been updated yet). Evan, the guy who named it, was also someone who spent a lot of time online and really enjoyed the idea of an acronym that people probably wouldn’t get.

So YAOIRPG was born. We had to do lots of paperwork. Project Docs, Design Docs, ETC ETC. But we found everyone loved playing it. I actually got killed several times while I was trying to demo the game to the class. It was fully multiplayer. Not bad for a school project. We were not expected to finish it, just document the process. There was only one other team that manged to get something demoable (I think), and they had a simple app that transferred files.

Anyways, it came up in conversation recently, mostly because I still tell the story that the teacher was heard saying he loved yaoi and we in the know at the time were so amused by this.

I realized the code wasn’t backed up, so I dug through some of my old hard drives, found the code and an old DB dump and this morning through a lot of trial and error (And actually minimal work) got it running in a recent version of php and mysql.

http://yaoirpg.halkeye.net now lives on heroku where it should forever run. Backed up to bitbucket ’cause I’m pretty ashamed of the code :D

2013 In Review.

Everyone else has started to do this. I’ve been working on it for a week now for my own reasons. I apologize in advance. Overall I’d say 2013/30 has been an amazing year. (Posting it to the rarely used blog so I don’t have to copy and paste all the text cross social networks.

* Lost like 40 pounds, really gotta work at doing more (Esp since I seem to be finally gaining weight again :(). Got heavily into using the slow cooker which helped a lot with this.
* New job at telus seems to be going amazing so far (I especially can’t wait for any of the prototypes my team are playing with to make it out to the public)
* Awesome friends, especially the new ones i’ve made this year (Reconnecting with noggery, Yvonne, Raine, Katrina, Meeting Roslyn, Justin, and recently Annie. Loads more people I probably forgot it was this year)
* Best birthday in years (lots of room for improvement so can only go up from here)
* Had lots of run doing redditgifts. It keeps giving me big anxiety, but it helps me learn to deal with it in a controlled way, so yay!
* Raine/Alex wedding, Yvonne/Eric wedding
* Salty Stories launched. Didn’t do as well as I had hoped, but it launched I can say I’m an app developer now.
* Nigel (airg Ireland) and Brian (Blizzard) moving away. Boooo
* I’ve had a lot of fun with kickstarter, only real complaint so far is the ouya. I still think pebble should win kickstarted of the year award.
* Went to some events by myself (Including an awesome wedding and a gentlemen hecklers show).
* Started to GM/Run Games.
* Generally focus more on the good, try to get less caught up on the bad.
* Pebble

So much more. Lets see if 2014 can be even better.

Things I wish I had done but didn’t:
* Post more to the blog. I meant to while I was job hunting. Started to clean up older posts thinking I might convert to octopress. Then I just didn’t finish ’cause I spent too long trying to track down old broken image links.
* Finish Projects (See above). When they are personal projects I tend to do the learning/prototype stuff, but not follow through enough. Made a couple android apps. Went “yea, I totally can do it” but didn’t finish the polishing steps as they are just for me.

Oh! Some automated 2013 things:
* https://www.vizify.com/gavin-mogan/twitter-video
* https://plus.google.com/107775609316541886610/posts/VMKeoGGpRNb

Renaming batch of files (with spaces) in linux

I rename a lot of files. Often by hand as it’s just easier. I’ve tried various combinations of find -print0 | xargs -0, and find -exec, without much luck.

Just So I have reference on what does work:

find -type f | while read file; do echo mv \"$file\" \"$(echo $file | sed -e 's/^Old Content/New Content/')\"; done | sh

Yea I could probably drop the echo mv, and the |sh, but it feels safer to do a dry run

Updating WordPress Plugins Helper

I decided a while ago to put pull all the plugin source codes for this wordpress install directly from subversion. This makes it easier when files need manual patching or more likely, a file gets deleted.

So I created this little helper script that I can use to do a mass update when I get too out of date.

https://gist.github.com/halkeye/6288018

Android and SNES? Oh my!

So a while ago (Dec 2012, so only a couple months :D) I posted a little picture of a setup I got working with my nexus 7.


I promised I would document how I did it for others, and so I’ll  best to explain what / how I got it working but it’s been a long time since I did any sort of technical writing, so bear with me.

So what do you need? This is what I used, this is by no means the only way.

  1. Gamepad (I used one of the snes gamepads I bought from a local game store. There are tons of tutorials online on how to convert an old snes controller to a usb one)
  2. MicroUSB OTG Adapter – As linked
  3. Android Device that has OTG support. I know my Galaxy Nexus and Nexus 7 both support them.
  4. I used USB/BT Joystick Center in the end. Its pretty expensive, has some sort of online DRM (but seems to work offline, just can’t edit joysticks). I’ve heard you can do it with root/this app, but this is what I used for my un-rooted tablet. There is a demo version available that lets you test compatibility before spending the money.
  5. A “game” you want to run. I use SNESDroid for that

All in all I would say it’s not exactly a hard process. Joystick Center is expensive and a very dev-ie UI but it’s quite simple once you figure it out. It is essentially a tool to make drivers for your usb gamepad for your android device. It seems to do a good job at that.

Once you get everything hooked up and Joystick center installed and running, you need to make sure it finds the gamepad. It’s a bit finicky, especially if you have other USB apps installed. Once you have the app running and find the device you see something like:

 

Next you need to select that device. When that is done, you’ll see another row. This row confused me the most. It’s not that important other than the driver button on the left hand side. Once you’ve clicked/tapped the driver button, you’ll come across a screen kind like:

This would be the most important screen. It took me a few trues and a few videos to figure everything out but it’s actually quite simple.

First you’ll want to add your directional support. Since my gamepad has a dpad, I added a “stick” control. This is the second button on the right side of the big + indicator on the left side of the screen (confusing no?). My gamepad also has 8 buttons so I added 8 of those (first button next to +).

Now for each “feature” you will select them once at a time and configure it. It does’t matter at all which order you added/do things in.

First I selected my stick. On your gamepad move the dpad/control stick around. For every light / box that changes (from on to off or whatever) highlight it. I ended up having 16 boxes selected. After selecting move the dpad around again, you should see the stick box move around properly. Make sure to try out all directions.

Next comes the easy buttons. Select a button. Press a button on the gamepad repeatedly. Highlight any boxes that change. Repeat for next button.

By the time you are all done, any time you press an existing button or move the dpad, it should jump to the properly button in app. If that’s all correct, hit back. I would press “Exp” on the main screen to save your configs, but so far mine has never gone away.

Now fire up your game. For me SNES droid has the ability to remap keys. So I go into the settings and map each button press to a key.

So there you have it, now you can play games with your gamepad on your android device.

 

 

From what I read, you can actually use the app to map buttons to actual key presses, so its possible to play regular games, but I never exactly figured out how to do that (not needed for snes).

How to change from mate-terminal to xfce4-terminal

Mostly for my own purposes

mateconftool-2 --set /desktop/mate/applications/terminal/exec --type string "xfce4-terminal"

I’m not a big fan of mate terminal, seems to hurt my eyes, like xfce better, so this still makes the “launch terminal” shortcut work, but launch a different terminal.

Probably should switch it to use the debian standard “x-terminal-emulator”

Go to Top