Monday, July 15, 2013

Recovering files from a crashed Mac

[Edit]  The original post assume you were running OSX 10.7 (Lion).

OSX 10.8 (Mountain Lion) will not let you boot from a Linux CD (at least not for me).  So now what?

Method 0: Use the terminal for copying files.  If you boot to the recover utilities (which are part of the Mountain Lion disk as a separate partition - boot up with the option key depressed), there's a Utilities pull-down with "terminal".  It's not that bad as long as you know:

- /Volumes/USBXXX/* has the USB drive you plugged in

- /Volumes/MacintoshXXX/* has your hard-drive files you want to recover

- /Volumes/MacintoshXXX/Users/frankbraker_or_whatever_your_username_is/.* has your hidden files and directories (use ls -a to see them)

- /Volumes/MacintoshXXX/Users/frankbraker_or_whatever_your_username_is/* has everything else

- /Volumes/MacintoshXXX/Users/frankbraker_or_whatever_your_username_is/Library/Keychains has your keychain files

- XCode 5.0 automatically generates provisioning… and "of that which we cannot speak, we must remain silent" Ludwig Wittgenstein.

- cp -r sourcepath/* destpath/.  copies directories recursively


For example, this will back up all your .ssh config files:

mkdir /Volumes/USBXXX/.ssh

cp -r /Volumes/MacintoshXXX/Users/frank/.ssh/* /Volumes/USBXXX/.ssh/.


This was all off the top of my head… buyer beware!  :)






//---------------------------------- ORIGINAL POST BELOW ------------------------------

Scenario:  My Mac won't boot anymore and the disk utilities say the disk can't be repaired, and that I should recover all the files that I can before formatting and reinstalling the OS.  But how to recover the files?


Method 1: Firewire

1) Spend money for a Firewire cable.

2) Boot the Mac with the "t" key depressed which puts it into external HD mode

3) Copy files (watch this video if you're interested: http://www.youtube.com/watch?v=bVRx6R6hs9Q


Method 2: Linux boot disk

0) Wonder why you have an OSX installation USB drive, but it can't boot to copy files.  Maybe it does if you know the secret handshake?


1) Plug in an external drive large enough.

2) Boot with a Linux CD.

     a) Before your Mac is toast: burn the CD from here: http://www.linuxmint.com/download.php

     b) After your Mac is toast: while powering up, press the "option" key and select the CD.  I recommend Linux Mint because it doesn't require that much command line knowledge to use effectively.


3) Open a file browser.  If you try to navigate to the Mac drive, it will work until you get to user files (which are "protected").  But you can open folders as admin (in a pull-down menu right clicking on the folder).


4) The file browser works fine for copying, and especially for compressing large folders onto the external drive (because I want .zip rather than .tar or .gz, although those are available too).


Alternatively, once you've opened a folder as admin, open a folder with a terminal (same pull-down menu) - the terminal will be open as admin (red "mint" username), and disabled commands now work:

cp -r folder/* /media/<external drive name such as "4D84-911B">/folder/.

Friday, June 21, 2013

Diffing all files in all subdirectories

Note to self... to diff all the files in all subdirectories in cygwin, type:

$ cd /cygdrive/c/d1

$ dir2=/cygdrive/c/d2; out1=/cygdrive/c/outfile.out; rm "$out1"; for dir1 in $(find . -type d); do ( for file in ${dir1}/*; do echo "${dir1}/${file}">> "$out1"; echo "${dir2}/${file}">> "$out1"; diff "${dir1}/${file}" "${dir2}/${file}" >> "$out1"; done ); done;

based on: http://askubuntu.com/questions/111495/how-to-diff-multiple-files-across-directories

There's probably some fancy tool that does this too, like windiff or something.  This way is pretty noisy.



Tuesday, March 26, 2013

Boring Database Stuff



Database Tables, Primary Keys, Foriegn Keys, and Relationships

Isn't it ugly?  All embedded engineers just hate this crap...  snore!!!!!

Until the lights just came on for me watching this:

This is how Civilization and many online video-games are written!  Set timers for build items and there you go.

So keep those boring database videos coming youtube.

Wednesday, March 13, 2013

The Dark Side of Open Source

2 days ago I ran across this site:

http://programming-motherfucker.com/

I was actually looking for C# tutorials, and this site is related to "Learn <language> The Hard Way".  (Which might be fine - too bad there aren't more Python-tutorial-like websites, which is really the best:

http://www.learnpython.org/

)

Anyways, back to Programming, Motherfucker...  which is now a technical term, so don't be offended.  The "manifesto" part of the page struck me as funny enough to post on my facebook page, then take it down because .. well just because.  And Zed Shaw has written a HUGE number of books.

So last night watched his ACM talk "The Scams That Derail Programming, Motherfucker", which is worth the time if you're sort of interested in the psychology of "community" and manipulation:

http://www.youtube.com/watch?v=c5Xh2Go-jkM

In a nutshell, take good care of yourself, watch out for scams, and learn what you can from everything that's out there without becoming a fanatic.  Oh - and program!  Like the wind!!

Sunday, February 3, 2013

Building a Board Game

I recently created a prototype board game for a game idea I've been working on.  If you are at all interested in this sort of thing, I highly recommend this video about user interface design at Apple:

How to Build an iPhone App that Doesn't Suck

That video changed the whole world for me - because it got me started making a paper model board game that I could play with family and see their reactions, without writing any lines of code.  It's also a lot of fun to cut out paper tiles and apply artwork.

But the real work that precedes the paper model, is the set of rules that makes the game.  I used a spreadsheet for writing out my rules, and could easily generate random board layouts - all of this builds up momentum and generates ideas.

The whole process eventually lead me to some generalizations about both board games and card games (possibly other genres too).  If you look at a well-designed game, you might imagine they used this process:


1) Create Layers

The simplest game I can imagine is to flip a coin: heads I get <something>, tails I don't.  I'll call this "directly dependent attainment".  The attainment of <something> is directly dependent on the coin toss.

Creating layers means adding indirect dependencies for attainment.  [And by naming the indirect dependencies creatively, a story-line is generated.]  So if we replace "flip a coin" with "open a goody hut", the goody hut may have a 50% chance of containing people (versus being empty).  Will the people be friendly or hostile?  It depends on <player stats OR technologies researched OR religion OR the phase of the moon>.

So the simple (and boring) coin toss game becomes interesting as layers of attainment are added - and a story is generated along the way.  I can think of resource combining, exploration, and technologies as these sorts of layers that make a game interesting.


2) Organize Dependencies To Maintain Parallelism

This is really all about story-telling.  Don't believe me?  Listen to that guy talking about his last poker game - or my mom talking my brother's ear off about the Scrabble game she won by 1 point (I almost had her!).  Maintaining parallelism of dependencies makes the story that much more compelling.

If you add several layers of dependencies for the player to create a specific unit (or issue a specific attack, or build a specific building, etc), each layer should contain related elements.  One layer might contain resources (the landscape), another layer contain technologies (the technology tree).  Don't put 1000 lbs of iron in the technology tree - it makes no sense!


3) Organize the Learning Curve

This might be more about presentation than it is game-play.  If the game is deep, can the game elements be organized such that players don't have to know all the rules before they can start?  In this way the game rules themselves are evolving as the game unfolds.


4) Subtlety Creates Depth

Here is where I bang my head against the wall - how are Chess and Go such wonderfully deep games with such simple and few rules?  If you watch or play many chess games, you start to see piece development and piece cooperation as key.  The story becomes more subtle even as it becomes more simple, less contrived.

These are what might be considered the highest art of gaming - a subtle story playing out, which like a good joke, maybe only a few will understand.


You'll find more discussion about game design in an earlier post Patterns and Rules.

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!"