jorgenmodin.net - Blog
Just a note to self:
Create and configure lightweight, reproducible, and portable development environments.
Read more: Link - Vagrant
sudo fdisk -l
It will show all the volumes. My stick was at /dev/sdb1 .
Change /dev/sdb1 if the USB stick isn't there and enter its correct address.
If the USB stick is at /dev/sdb1, unmount it with:
sudo umount /dev/sdb1
Then format it with fat32 like so:
sudo mkfs.vfat /dev/sdb1
Oftentimes, I'd like to edit a div in Wysiwyg mode. But the Wysiwyg editors that I use (TinyMCE and CKEditor) do not seem to show divs in an easy way. They do show tables, with borders and all, and I assume the same could be done for divs.
I'd like to see where the divs are, be able to create a div, preferrably by selecting a piece of text and do a "wrap in div" command or some such. And I want to be able to select a div in Wysiwyg mode, and edit its CSS classes.
I guess you could go through their source code and model a div editing capability on the table editing capability.
Hmm, I just realized that showing the divs is just a matter of editing the CSS for the edit view. Half the problem solved.
- For version 4.2 of CKEditor there seems to be a plugin called Div Container Manager .
- Also one called Show Blocks
Div container manager looks promising, but I am not entirely sure of how to integrate it into my CMS, Plone. Just including the file does not work, and additionally adding "div" to the Plone toolbar configuration does not work either.
For TinyMCE there is visualblocks.
Pulling, fetching & merging
I want to track a new remote branch
Check what branches are available at remote:
git remote show origin
git fetch origin remote_branch_name:local_branch_name
There are differences between my branch and the remote branch, but I want to see what would be merged in, before doing a pull
Do a fetch first
and then compare the branches with
git diff HEAD...origin
How do I merge in a branch so that everything in the incoming branch takes precedence?
In subversion you can do “theirs-full” as a merging strategy. You used to be able to do that in git too, but it has been deprecated and outright removed. Here is one way of doing a theirs-full. You simply move to the incoming branch, branch it into a temporary branch, switch to master and merge that one into yours
git checkout -b temporary origin/incoming git merge -s ours master # ignoring all changes from master git checkout master git merge temporary # fast-forward to tmp HEAD git branch -D temporary # deleting tmp
See more at:
If you want the incoming branch to completely take over, there are a couple of ways of doing that. Assuming the incoming branch is called “incoming”, and that you are on the “master” branch:
git reset --hard incoming
git branch -d master git checkout incoming git -b master
git checkout -f -b master incoming
Before you do any of the above you may want to create a branch for your old work, or it is effectively rendered inaccessible. Note that any files from your original master not present in incoming, will be ignored.
How do I initialize a remote repository with my stuff and make my local repository track the remote?
$ git remote add origin git@gitserver:/opt/git/project.git $ git push origin master
How do I push to a fresh remote repository?
If the remote repository is fresh and does not have any branches in it, it does not know where to store your stuff, even if you are on master. Use:
git push --all
It will create the necessary branches on remote and effectively copy all your branches over, including the one that you are on.
I have created/edited tags, but "git push" does not seem to include them
git does not push tags to remote servers unless you specify that explicitly
git push --tags
...for all tags.
git push <tagname>
...for a named tag
I made a new branch locally, and I want to push it to remote
You need to use
git push -u origin branchname
It will also set up your local branch to track the remote one.
Do not just do a
, because that will push master to master on remote, even if you are on your new local branch.
git push --all
should work too, if you want to push all branches to remote.
Where are the remotes?
git remote -v
shows you what you’ve got
A local branch can track a remote branch. git clone automatically sets up this
How do I unstage a file?
git reset HEAD filename
How do i undo my last commit?
Undo your last commit and bring your workspace and staging area back to the state of the last commit:
git reset --hard HEAD~1
if you want to keep your workspace as it is now:
git reset HEAD~1
if you only want to undo the commit but keep both your index (staging area) and your work space as they are now:
git reset --soft HEAD~1
Any of these resets will erase your most recent commit from the commit history! There are ways of getting it back but it is a bit of work.
Aborting a merge when you are in the middle of it
Hit Ctrl-c to exit the merge tool dialog
If your git is 1.7.4 or newer:
git merge --abort
If your git is older than 1.7.4:
git reset --merge HEAD
git clean -f
(but this latter will remove all untracked non-ignored files, may not be want you wanted, however you should had made sure of a clean state before the merge, and then its cool)
One would have thought that git stash would help here, but you cannot stash merge conflicts, so it is not an option
My editor removed a file by mistake, how do I get it back and/or
I want to revert a file to last commit
You may see it staged for deletion. Then do a checkout to the branch you are already on, for that particular file:
git checkout -- file_that_was_deleted
It works without the “--”, but since your file name may correspond with a branch name it is best to put “--” in.
You can use sub modules in a fruitful way if you’re on git 1.8.2 or later:
How do I get a version of git that is 1.8.2 or newer?
Github and bitbucket already run by default on newer versions
If you are on Ubuntu, use:
sudo add-apt-repository ppa:git-core/ppa
Adding a submodule to a repository
git submodule add -b branch <url> dirname git submodule add -b master ssh://email@example.com/srv/git/awesome_lib.git awesome_lib
When cloning a repository that has a submodule :
When you clone the parent repository, the submodule does not get cloned into its sub directory. For that you have to do:
git submodule init git submodule update
How do I add an empty directory in git?
You can’t. Put an empty .gitkeep file in there and it works though.
git add --patch
Allows for staging just parts of a file, good when you want to make a commit that does not fix two or more things at once.
git add -u will add all changed files it knows about to the staging area, from where you issue the command and recursively downwards. In other words, if you do git add -u in a subdirectry, only changes within that subdirectory will be staged.
Tell bootstrap to use an earlier zc.buildout version Run bootstrap.py with the -v option, forcing it to stick to a specific, earlier version: $ bin/python bootstrap.py -d -v 2.1.1
Bookmarked for further reading.
The Definitive Guide to Angular on Mobile
It can be a boon to post on Facebook from your Android phonegap/cordova app. You can actually use the https scheme to post through the user's browser, but then he needs to login there. It is also possible to communicate with the Facebook app via the fb:// protocol, but you cannot post stories or any other kind of updates that way (anymore).
There is however a plugin for Phonegap to use Facebook, and it seems to work, and you can post from the app to Facebook. The instructions for it worked out A ok for me, just follow it step by step, but with the following caveats:
Don't use Phonegap 2.8.0 or 2.7 (2.8.1 works though)
In Phonegap 2.7 they removed some deprecated interfaces, that the Facebook plugin for Phonegap uses. They then put those deprecated interfaces back in 2.8.1. So if you - like me - were on 2.8.0 or if you are on 2.7, you are on the versions that do not work. (Disclaimer, I have not tested the 3.x series or anything pre 2.8). it is possible to use the new interfaces as outlined in the blog post linked above, but when it came down to lines in the plugin as:
this.fba.success(new PluginResult(PluginResult.Status.OK), this.fba.callbackId);
...it started to become a bit hairy, and not clear to me what that actually does, or how to replace it. With 2.8.1 you don't need to worry about that.
It is "facebook-js-sdk.js", not "facebook_js_sdk.js" as it is written in the index.html file currently.
On Linux the key you need to make a hash out of, is in "~/.android/"
In the Facebook documentation, they only give examples for OSX and Windows. On Linux you need to write:
keytool -exportcert -alias androiddebugkey -keystore ~/.android/debug.keystore | openssl sha1 -binary | openssl base64
After these changes, I was able to post on my wall from an Android emulator. I have not tried with an exported apk yet, for that you need to make a hash as above but from the keystore you use to sign your apks with.
So I went to the Microjs site and found a dozen or so libraries that handled events. They seemed to fall into three categories:
- Libraries only interested in the DOM. I wanted something a bit more abstract, decoupled from the DOM.
- Libraries that modify the objects they are operating on. This seemed to me to not be very transparent, and I would need to come up with objects. Since it is a mobile application I need to persist stuff through the create/pause/resume/destroy lifecycle, and i do not want to end up with some objects - that have data that is persisted - also have some state related to what events they emit or listen to, while others objects may be loaded from script with no memory of this
- So, the third group uses a dedicated central object, that just emits nice clean text messages. These libraries seem to be classified as doing the pubsub pattern or mediator pattern. This I believe is what I want.
Candidates in group 3 so far are:
A light utility class to help implement the Mediator pattern
Read more: Link - Mediator.js
This blog post will be amended and expanded later.
I want a graphical overview of what files are unknown to git, which are known and has changed, and which ones are staged. I also want to be able to add (stage) files, commit files, and also unstage files.
I have a cheat sheet with the following stuff in it, but would like to have it supported in the GUI:
|Separate staged, unstaged, unedited and unknown files||Y||Y|
|track a new remote branch|
see what would be merged in, before doing a pull (i.e. a
|initialize a remote repository with my stuff and make my local repository track the remote|
|push to a fresh remote repository|
|I made a new branch locally, and I want to push it to remote|
|undo my last commit|
|Aborting a merge when you are in the middle of it|
|revert a changed or deleted file to its last commit|
|handle submodules as they are defined in recent versions of git (1.8.2 and higher)||N||Y|
Found a page that details some of the offerings:
So a quick test for the basic level:
git-cola - seems to do a lot of the things I want. Distinguishes between tracked and untracked files, shows which files have edits in them. double click to stage file, the best one so far
giggle - does not seem to do much, it does not distinguish between files with changes in them and not, has a context menu for committing any file, wheter changed or not. May be more for inspecting and analyzing.
git-gui - Lumps all files into a long messy list, with no distinction between tracked and untracked files
© 2013 Unheap.