Sunday, July 7, 2013

git install --windows


There are two competing Git packages for Windows: a Cygwin-based Git and msysGit. I will describe how to install the msysGit package

Run the installer (Git-1.8.4-preview20130916.exe  at the time of writing) :
  • explorer integration : simple context menu (I haven't tried the cheetah one)
  • Use git Bash only (at least for starters) - see here for a hack
  • Configure line endings : that's a complicated one. Bottom line : choose Checkout as-is, Commit as-is and be sure to setup a .gitattributes file in all of your repos. I will blog about this soon.
First of all, on installing, if not on english windoz, you will have the nasty surprise of having the GUI display in your locale. That's plain a pain - and easily fixed : delete C:\Program Files (x86)\Git\share\git-gui\lib\msgs\*.msg file(s). Read on all the gory details

Recent versions of git won't allow you  to commit without telling who you are :
git config --global user.name "Firstname Lastname"
git config --global user.email "your_email@youremail.com"
At some point you may need to setup an editor for git - I use notepad++ and a guide for setting this up is here. Essentially you need to issue :

git config --global core.editor C:/path_with_no_spaces/npp.bat

where npp.bat:

#!/bin/sh
"c:/Program Files/Notepad++/notepad++.exe" -multiInst "$*"

notice the Unix like syntax. Alternatively you may just issue :

git config --global core.editor "'C:/Program Files/Notepad++/notepad++.exe' -multiInst -notabbar -nosession -noPlugin"

Explanation for the flags (you probably only need -multiInst - see here) - another post by VonC with similar info.

At some other point you may need to setup a merge tool - see here for various tools, and here for more up to date info on p4merge.

Git - First-Time Git Setup for more info - I'd say to add these commands in a script and also to dump your %USERPROFILE%/.gitconfig into dropbox and link to it from there

Finally if you are annoyed by the gc popup disable it thusly (but be sure to understand what it is about)

Worth noting : .gitignore, .gitattributes etc start with a dot - you can't create them in explorer - do this in git Bash (for instance) :

$ echo "*.class" >> .gitignore
Another complicated point is to set up the SSH keys (if you want to push without entering your username/pass. You may leave it for now). From here :

Go to Start > Git Gui >

Click the "Generate Key" button.This will generate your public and private OpenSSH keys. You will be prompted to enter an optional passphrase. If you do, then you will be prompted to enter the passphrase each time you try to push to github - so you may wish to leave it blank. Once generated, Git GUI will store your private and public keys in your %USERPROFILE%/.ssh directory. You may wish to back up these keys to somewhere secure. Git GUI will now display your public key. Enter this to your github (or other) account (in github is under Settings > SSH Keys).

Here are some very useful links :

An Illustrated Guide to Git on Windows - really nice demo (with screens) of using the Gui and Bash to commit, branch, push etc. Start from here (I just found the contents)

Basic docs :

Git - Book - be sure to read at least Git - Basic Branching and Merging.
Git Reference - nice minimal site
Git User’s Manual (for version 1.5.3 or newer) - da manual

Couple of links on specific topics - must read :

Git for Computer Scientists - the data structures !
A successful Git branching model - branching done right

More docs tutorials etc :

The Git Parable - lol
Everyday GIT With 20 Commands Or So - quick reference
Git Magic - Preface - and another one
A tour of git: the basics - yet another
Git Immersion - step by step
The Thing About Git - why the index
Git For Windows Developers
A few of my Git tricks, tips and workflows

2013.11.02 20.53 UTC

Friday, May 3, 2013

Java 6 file IO - installment 5678657



Primer
The not so standard idiom - see an answer there for varargs close() method. And another answer with useful info.

On closing only the outermost buffer : consider (also a bug) -  I actually commented on this here and here

Comparison of the :

final Resource resource = acquire();
try {
    use(resource);
} finally {
    resource.release();
}
 
pattern (see also other answers there - a wealth of info) to the traditional : 

Resource resource = null;
try { 
    resource = acquire();
    use(resource);
} finally {
    if(resource != null) resource.release();
}

(also in DB code)
And a question concerning multiple wrapped streams
 
Btw At what point does wrapping a FileOutputStream with a BufferedOutputStream makes sense,
in terms of performance? with interesting links to source
 
Advanced
Execute around idiom - Skeet - read in your free time, still escapes me.
class Compensation - well that's a good one ! Unfold the try finally block ! Comments like in the Skeet answer apply.


WIP : 2013.05.25 19.12 UTC

Monday, April 15, 2013

EL - JSTL samples


Suppose you want to select the first element of a List to print it. Easy
 <c:out value="${myList[0]}" />  
It can get complicated if you have not a list but a map, with numeric keys - see here.

What about comparing strings :
 <c:if test = "${user.role == 'ADMIN'}">  
Comparing the above two for selecting an option in a drop down :
 <option value="${role}" ${role == selectedRole ? 'selected' : ''}>${role}</option>  
Notice this wont work with xhtml. See here for escaping quotes.


TBC

Posted2013.04.15 13.23 UTC



Sunday, March 17, 2013

Android - AlarmManager samples


'Cause of BookmarksOverflow...

First things first - why you should be using an Alarm and not a service

Btw it is impossible to have anything run on install of the app (see comments here) - and LocalBroadcastManager is not applicable here.

Intent resolution

Your first constructor will only work for a BroadcastReceiver registered in the manifest. If you specify a component, Android will attempt to deliver to that component, ignoring your action. 

Cf : Intents can be divided into two groups:

    Explicit intents designate the target component by its name (the component name field, mentioned earlier, has a value set). Since component names would generally not be known to developers of other applications, explicit intents are typically used for application-internal messages — such as an activity starting a subordinate service or launching a sister activity.

    Implicit intents do not name a target (the field for the component name is blank). Implicit intents are often used to activate components in other applications.

Android delivers an explicit intent to an instance of the designated target class. Nothing in the Intent object other than the component name matters for determining which component should get the intent.

Apparently this component must be declared in some manifest :

The name of the component that should handle the intent. This field is a ComponentName object — a combination of the fully qualified class name of the target component (for example "com.example.project.app.FreneticActivity") and the package name set in the manifest file of the application where the component resides (for example, "com.example.project"). The package part of the component name and the package name set in the manifest do not necessarily have to match. 

Flags
Much needed Clarification on the docs for PendingIntent.FLAG_CANCEL_CURRENT
And on FLAG_UPDATE_CURRENT

Last edited : 2013.03.30 14.45 UTC

Wednesday, February 27, 2013

Skyrim mods I use

WIP - I hope to eventually play some quest mods

  • SkyUI - well yes, obviously
  • Bag of Holding - a cheat, sure :)
  • Unread Books Glow - I wrote about my dislike for the literary part of elder scrolls (I'm not fifteen anymore unfortunately) but I like skillbooks. And this one colors them bright red

Saturday, October 13, 2012

git remind


And I will begin with :
git checkout revision/branch path/to/file
for checking out into the working tree a particular version of a particular file. So :
git checkout HEAD path/to/file
would revert all changes in file relative to the last commit index.

Push a local branch to a different remote branch :

git push -v -u remote_repo local_branch:remote_branch
as in git push -v -u origin github:master. -v is verbose -u is to set the local tracking the remote branch. Add -n for dry-run.
Push all branches/tags up to the remote repo :

git push --all
git push --tags

From here. Don't be in a hurry though - make sure you really want to push everything.

See all commits  messages in a range between commits abc... and def... affecting a single file :

git log oldhash..newhash -- path/to/inspect
 notice the 2 dots.

Ah - the subject of gitignore - this merits a post but for starters here is the syntax.
See all files that have the assume unchanged bit set :
git ls-files -v
I use the msgit gui to stage/commit separate lines/hunks. If ever interested in how one can do this via console (which sounds like an absolute chore) here is a great post about that.

Free private git repos are sought after. I went for assembla for a (school) project were I needed many (>5) people - but I'd go for bitbucket (I like the UI better). Github unfortunately does not offer private for free. Anyway - from the previous post I got two links describing how one could set up a git repo on their Dropbox account.

Links :

Git Reference
For windoz : http://nathanj.github.com/gitguide/tour.html

2013.09.21 19.01 UTC