Showing posts with label Git. Show all posts
Showing posts with label Git. Show all posts

Thursday, May 14, 2015

Interview question from hell: "Which text editor do you use?"

About 200,000 years ago - it's not really important when it was - I was in an interview somewhere... also not important where.

And at one point they asked me "which text editor do you use?"


This was apparently a part of the company conversation: "Which text editor?"


----------------


Some other place which I remember quite well, I was asked to "fix my tab settings in my editor" because my code didn't look like everyone else's.

I think I looked at it for about an hour... got a confused feeling "what's there to fix?" and gave up.  And then for the rest of my career at that company I felt deeply guilty that my code's tabs were wrong, and I didn't know how to fix my editor to comply with everyone else's code.


-----------------


"What drives this conversation?"

Well I'm glad you asked.  It just so happens it seems to be driven by merge conflicts which aren't ignoring white space.

And my own personal sloppiness.  You see, I can read a file and mostly ignore the white-space, and somehow my brain parses all that and says "yep that will compile fine" and go my merry way without even a thought given to correcting all the spacing.  But not everyone can do that - or even _should_ do that.


------------------


So I'm trying to come up with a solution.

One solution is to mandate company-wide "everyone shall use whatever editor the star performer coder is using" and then every year after the star performer quits to go work for Google - you can pick a new editor that everyone has to switch to.

This just might be the way to go.


-------------------


But the alternative I'm really wondering about is to let everyone use whatever editor they like - and have an automated process upon check-in which does something like this:

1) Remove all the whitespace in the code
2) Run a "prettify" algorithm that adds spaces or tabs
3) If it added spaces, convert them to tabs


4) Never code in Python...  :)  (sorry...  for Python I think you are stuck mandating a specific editor).


--------------------


Git has check-in hooks that can run automated processes like this, to guarantee whatever sins the editor committed, they will all be erased and the code in the repository will be consistent.  That way any merges between branches won't have any changes that are purely white-space.

git merge -Xignore-space-change would also fix this.

Thursday, November 14, 2013

Unity3d Build Target Switch Avoidance with Git

To avoid the time for a build target switch (which going from OSX to iOS is very long), I recommend duplicating the whole git repository in another directory.  Like this:

./MyProject.git.iOS/MyProject

./MyProject.git.OSXtarget/MyProject

You can run a git clone from a remote, or you can do a git clone from your local hard drive:

Franks-MacBook-Pro:MyProject.git.OSXtarget frank$ git clone ../MyProject.git.iOS/MyProject
Cloning into 'MyProject'...
done.
Checking connectivity... done
Checking out files: 100% (3828/3828), done.
Franks-MacBook-Pro:MyProject.git.OSXtarget frankbraker$ ls
MyProject
Franks-MacBook-Pro:MyProject.git.OSXtarget frankbraker$ cd MyProject/
Franks-MacBook-Pro:MyProject frankbraker$ ls
Assets Heapshots ProjectSettings


If your .gitignore is set up as per HowToSetUp.gitignoreForUnity3D the clone will be missing library files, it will take some time when you first open the project to import assets, and some plugin menus may be missing.  I don't know the deep mojo, but I'll religiously close and reopen, close and reopen again, and the plugin menus eventually show up.

The beauty is, if you make changes here, just check them in, push, and you can pull from your other target repository to get those changes, and the target switch time is much faster.

I also noticed push wants to push to your local drive (which didn't work for me).  I had to set up a remote as in the original target's git directory.

Tuesday, December 18, 2012

Worlds Cheapest Git Server Pt. 2


Here it is!  To install git, run "apt-get install git" (while online of course, which for me meant hooking up ethernet cables and a television at the local library).  "Wheezy" is the raspberry pi ported version of Debian, which has ssh pre-installed (although with strange defaults that I haven't worked through - it doesn't quite do keyphrases as expected right now).

Wheezy also comes with Scratch (an educational programming system for children) - worth checking out.

After setting up accounts, permissions and repositories, and Git Extensions on my Windows machine, and git-scm for Mac http://git-scm.com/download/mac, and turning on meta-files in Unity and following the other Unity documentation, it works!  Hurray!

[Somewhere in the process git asked if I wanted Windows-Unix line-terminator conversions, which I answered "no conversion" and that seems to work fine so far.]

Also, not only does it work - it works well.  There's some latency when checking out a 500MB repository for the first time, but it isn't bad.  I will have to put some mileage to see about making minor code changes and checkin/checkout waits.

The other downside - if the house burns down, so does the git server!  So it's either make a fire-proof housing for the server, or store it off-site when not in use.



Total cost:
Raspberry pi (Newark): $35
(but look at my previous post and you might get a better coupon price before January 30th or so)

Power Supply (Newark): $7

Newark shipping: $10

SanDisk 32GB SD-card (Newegg): $35 + free shipping
http://www.newegg.com/Product/Product.aspx?Item=9SIA12K0AT5024

Total: $52


Optional (really could have lived without this, since can use any t.v. screen, and after ifconfig to get IP address, just ssh remotely for setting up):

HDMI to DVI cable (Newegg): $7 + free shipping
http://www.newegg.com/Product/Product.aspx?Item=N82E16812576006






Also - to do a git push, you have to set up a git bare repository on the server.  Something like this:

pi@raspberry ~ mkdir myRepoDir

pi@raspberry ~ cd myRepoDir

pi@raspberry ~ git init --bare

Now from your client you can push to ssh://pi@192.168.0.100/~/myRepoDir (or whatever the IP of the raspberry is), and the repository is set up.  Now any other machine can pull from ssh://pi@192.168.0.100/~/myRepoDir.



Thursday, November 8, 2012

Worlds cheapest Git server

Yesterday I looked at Git.  This is a version control written by Linus Torvalds, and I'm not going to pretend I'm an expert.  However, github (https://github.com/) seems to be the favored place for open-source repositories.

Great!  What if I want to keep my code private?  Github allows private repositories for $7/month.

This might be a competitive price to Amazon Web Services (http://aws.amazon.com/) - although for the CPU bandwidth, it's more cost-effective to build a machine from scratch (I'm assuming their prices haven't gone down significantly since I last tried them about a year ago).  It's certainly competitive to Linodes which go for $19/mo and up.

So how cheap can you build a PC for nowadays?

If you're not in ANY hurry - take a look at the quite awesome Raspberry Pi:

http://www.alliedelec.com/lp/120626raso/

Turnaround is months from placing the order, unfortunately.

You'll need a power supply and SD Card - which will run a total cost under $60.  For small projects that you want to keep private and quickly set up a git server, this looks like the right way to go.  There are also rumors of an Android build for Raspberry Pi, and those GPIO lines... something about them calls out "make something!"

Thursday, September 13, 2012

Patterns and Rules

Here's a good link:

http://www.gamasutra.com/view/feature/132649/the_case_for_game_design_patterns.php?print=1


While the author is talking about "Game Design Patterns", it brings up a progression of Design Pattern discussion:

http://www.slideshare.net/JoshuaKerievsky/a-timeless-way-of-communicating-alexandrian-pattern-languages

Perhaps most well known among software engineers is the "Gang of Four" Design Patterns book.  Whenever I've heard the term "patterns", I've assumed this was the usage.  Not true!  Design Patterns seem to have originated in architecture, with applications in gardening, theme park design - not just software.

The progression for game design continues to "The 400 Project", which is deliberately a list of "rules" rather than patterns, as discussed in the GDC presentations:

http://www.finitearts.com/Pages/400page.html


This is all fine.  It provides a great framework and vocabulary for discussion.  These are recipe books in architectural and experiential domains.


[Edit:  What I'm wondering now, is how to put wieners, rocks, paper and scissors to good use!]

[Edit: For GoF patterns, this also looks like a good discussion: http://www.oodesign.com ]