Friday, September 21, 2012

Ooops - hide it under the carpet!

I've done it. You've done it, too. In fact, many have done it and many will do it, for sure.

Pushed something unwanted to a public git repository by accident.

Well, if you are lucky, you notice it very early. In 10 seconds, usually :)
Damage is done, let's try to undo it - fast.

Solution #1

1) Remove the incriminated commit from the local repo:
git rebase -i

2) Forced push to the remote repo:
git push -f origin +branchname

Solution #2

(works for undoing the last N commit only)
git push -f origin HEAD^:branchname

What's left? Crossing fingers and hope noone has pulled the repo during your manoeuvres :)

Thursday, July 26, 2012

VMware rant

Yet another Evernote-style entry to make sure I won't forget it...

VMware Player on Xubuntu. From time to time it decides to re-compile itself, without the slightest chance to prevent it. Would not be a problem if it ran well but it fails to compile the network modules.

Now I've found what to do:
sudo mv /usr/lib/vmware/modules/binary /usr/lib/vmware/modules/binary.old
sudo vmware-modconfig --console --install-all --appname="VMware Player" --icon="vmware-player"
And it works! There must be a more elegant, geeky solution but this week - I simply do not care!
Thanks, AndreiVajnall!

Wednesday, May 30, 2012

Moving git houses

Lately I've realised (or better, this has been bugging me for months now) that the repository I'm using on repo.or.cz is messed up a little bit. Some branches are merged back to master, some are not, then branched again, etc etc. And the at same time, making these creations more public I'd like to make it more user-friendly and while repo.or.cz provides a nice, stable service, github on the other hand is armed with an issue tracker, a wiki and some more. Yes, it is more shiney and glittery :)

With these two reasons on my mind, I've started 'migrating' the git repository from A to B. The following is a summary what I've done:

Moving houses from repo.or.cz to github, also means cleaning up the repos

  • create github_repo on github website with the web interface: http://github.com/kgkilo/tracks
  • cd ~/WORK
  • git clone github_repo tracks
  • git clone repo.or.cz/myrepo.git oldtracks
so at this point we have 2 directories, one for the new repo and one for the old one
  • cd oldtracks
  • git remote rm origin (just to play safe)

cleaning up what we want to import


  • git filter-branch --subdirectory-filter trackname -- --all
  • mkdir trackname
  • mv * trackname
  • git add .
  • git commit

importing


  • cd ../tracks
  • git remote add old-repo ../oldtracks
  • git co -b trackname
  • git pull old-repo trackname
  • git remote rm old-repo
  • mkdir trackname
  • mv * trackname
  • git add -f trackname
  • git commit -a

cleaning up the new repo


  • git rebase -i origin
  • squash, reword or delete commits (time to remove all the unwanted signs you've left behind earlier...)

final steps


  • git log, git st, git do_everything_to_check_for_sanity.
  • repeat the above... really!
  • git co master
  • git push origin trackname

And now... I can do this for all the branches... :)
NB: the filter-branch step proved to be the most problematic one. It is not git's mistake, it is the result of my own careless, unwanted merges back to master sometimes. Something to get rid of, for sure.

refs:
http://gbayer.com/development/moving-files-from-one-git-repository-to-another-preserving-history/
http://effectif.com/git/move-commit-from-one-branch-to-another
http://zenoga.tumblr.com/post/6751990283/til-convenient-cherry-picking-from-another-git
http://stackoverflow.com/questions/1365541/how-to-move-files-from-one-git-repo-to-another-not-a-clone-preserving-history
also:
http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html
http://stackoverflow.com/questions/67699/how-do-i-clone-all-remote-branches-with-git
http://www.zorched.net/2008/04/14/start-a-new-branch-on-your-remote-git-repository/

Tuesday, March 20, 2012

git svn commit trick

Speed Dreams uses SVN. I prefer git. That leads to git svn.

I've just invented for myself a new trick to use when I want to commit only some of my git commits to the central SVN repo. As often, git branching comes as a life-saver - I make a branch for SVN committing, remove the commits I don't want to push to SVN, do git svn dcommit, switch back to master and delete the temporary branch:
git checkout -b svnci
git rebase -i HEAD~6 (usually that is quite enough)
in rebase: remove the commits I don't want to send to SVN
git svn dcommit
git checkout master
git svn rebase
git branch -d svnci
I still have to learn each day the use of easy branching in git. Maybe put up a poster somewhere "Did you branch something today?" :)

PS: of course I've found I did reinvent the wheel. Damn I hate googling :s I've found an article from 2009 from a Mozilla dev about partial git svn commits: http://fredericiana.com/2009/12/31/partial-svn-dcommit-with-git/
While it is not the same technique, it is very much alike. And then you reach the comments... and *bang* there is my shiney new trick all put down 2 years ago :(((

Wednesday, March 14, 2012

Fun, fun, fun!

Some thoughts about the Bamboo table I've mentioned in the previous post.


The exact name is Bamboo CTH-470 Pen & table. It comes with Windows/OS X software on a CD and the manual resides there, too. But you know, I'm on the Linux side...

I've connected it via the USB port - and nothing happened. The table's LED lit up but no sign in Xubuntu that it had discovered any new hardware. But I was well-educated by that time, I knew I may be facing a 6-hour hard battle: http://ubuntuforums.org/showthread.php?t=1515562
However, the topic starts with a brilliant summary of what one should do, courtesy of user Favux, even though the summary alone may be a huge printing task, too. It also includes a link to download the table's driver for Ubuntu before trying to compile drivers, etc etc. So it boiled down to a simple install from a PPA. Thanks, Lekensteyn! Then I've also found another link about the tables and that description uses Lekensteyn's, too.

After installing from the PPA, and after a reboot, the table simply - worked. I've installed MyPaint and gave the table to my daughter - she could use it in one minute and now produces beautiful drawings each and every day. I did not have to explain the pen's rubber function at all, she just naturally used it once needed. She draws real abstract pictures, quite different from her real pencil drawings that always tell a story. You may think "oh sure the dad brags about her daughter painting" but it is in fact different. I brag about her drawing because that is one thing in life I've never been able to - best so far were stick figures :D

Tuesday, February 28, 2012

Borders, sides, barriers

Well, after 'some' silence - and renaming the blog - let me share what I'm fiddling with these days.

I'd like to build a track that models a temporary endurance track, using a standard, 2 * (2+1) lane motorway somewhere in Europe. That is, 2 lanes for normal traffic and one emergency lane, in both directions. There are some chicanes put up using huge plastic piles, a U-turn to turn onto the same motorway but the other side (other direction), a bridge, etc...
Problem comes when you want to build it in Speed Dreams so that it looks great and works correct, too. Why? Here's a brief introduction.


Tracks in Speed Dreams

In Speed Dreams' track format, you are given arbitrary length track segments, that have:
  • width
  • 2 borders (left and right)
  • 2 sides (left and right) and
  • 2 barriers (left and right).
The width is static, so you define the 'track width' at the beginning of the track description and it does not change from then. It is a limit very hard to live with and we aim to get it changed sometime soon.
The borders are fixed width along each segment, but can change width on the next segment. The border also has 'height', that is the height of the border's outer side - just think of curbs on racetracks and you'll get the picture. If you set height to 0, it will be flat of course.
Here comes the side - that should be the side of the track, like the grass next to the concrete strip on a racetrack. The side can change width linearly from the start to the end for each segment, so you can define  narrow or wide areas next to the tracks easily.
The barriers mean the physical edge of our tracks. There is no life outside the barrier on a Speed Dreams track - this is that farthest you can wander from the track. We use this to put up walls, fences, armco around the track.
Well if you happen to use a 3D editor to change the track's landscape, you can of course define any scenery wwwwwaaaay behind the barrier, but that is only eye-candy - you cannot enter that realm with your car.
Obligatory picture just to make all the lines above useless

All of the above is much better described in Andrew's tutorial, worth checking out.


Chicane ahead!

Now back to the original problem. At first you'd think there is nothing simpler than modelling a motorway: set track width to 3 lanes's width (which I've googled to be 3 * 3.75m usually for Europe), set some 50cm border to mark the transition from asphalt to grass, then use 2 metres of grass on the inside and 20m on the outside, then set up a fence as barrier and you are done.
But we want chicanes to slow the cars down a bit before a U-turn! So technically speaking, the track is about 1.5-2 lanes wide only, goes from one edge of the 3 lanes to the other edge when entering or exiting the chicane. Still we want to use the 'side' for the grass areas and we must have barriers, too:
Motorway with chicanes and the racingline cars will most likely follow

That means we need borders that change their width along the segment's length. In Speed Dreams, our robots use the borders or the sides without any fear, if they seem to be 'good' for driving. So if you set the surfaces of the borders the same as the track, the robots will use the borders when chosing their racing line. If you set the side's surface the same, the robots will drive on the sides, too - but set it to some bumpy or grippy or slippery and the robots will keep away from it. That is ideal for us in this situation, we can use the borders as asphalt and the sides as grass.


Digital technique

Now let's see our next picture:
Digital magic

Sadly enough, borders cannot change width currently, so we have to use a trick somehow. This is what I'm trying now: whenever there is need, I cut the track segment into short pieces (quantate it...), see the ugly lilac lines. Every short segment will have a border with different width (gray lines, black distance markers), this is how I emulate the border width changing. In fact, it is changing, not continuosly but step-by-step, like when you digitize an analogue value (quantate then sample average for the segment).
This is a dirty trick indeed and looks awful when you produce the track and try it in the simulator. However, Speed Dreams uses the track description only to make the cars know where to drive - what you see is a completely different story. The visuals can be edited in a 3D editor like Blender or AC3D and we can get rid of all the jigged borders there. Likewise, you could build a track on an iced lake completely covered with ice and only signposts to signal the track, or in a desert with camels showing the limits...


Does it work?

Soon I'll tell you if I've succeeded or not.
BTW did you like my 6-year-old-level graphics? This is our new toy in the family, a Bamboo table & pen - actually my daughter got it as a birthday present and she can draw beautiful drawings using it. Her dad obviously is not able to do the same :)