Archives 2005 - 2019

Install Oracle Java on Ubuntu the easy way

published Apr 19, 2014 04:59   by admin ( last modified Apr 19, 2014 04:59 )

I cannot vouch for the quality or integrity but my guess is that it is legit.

 

sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java7-installer


Read more: Link - 10 Things To Do After Installing Ubuntu 14.04 Trusty Tahr To Get A Near Perfect Desktop ~ Web Upd8: Ubuntu / Linux blog


Om: A ClojureScript interface to Facebook's React

published Apr 19, 2014 01:25   by admin ( last modified Apr 19, 2014 01:25 )

Note to self:

ClojureScript interface to Facebook's React

 

A clojurescript interface to a javascript library

 


A python script to download videos from video sites, including youtube

published Apr 12, 2014 02:20   by admin ( last modified Apr 19, 2014 01:27 )

Update: Did not work that well on my Ubuntu 13.10; seems to have hard coded names for stuff that have other names on Ubuntu.

Requires package libav-tools on Ubuntu 13.10 .

 

youtube-dl is a small command-line program to download videos from YouTube.com


Read more: Link - youtube-dl


MoviePy - video editing from python

published Apr 12, 2014 02:15   by admin ( last modified Apr 13, 2014 02:15 )

Impressive demos, including picture in picture. Uses ffmpeg and numpy.

 

 


Read more: Link - MoviePy — MoviePy 0.2 documentation


How to find out your OpenSSL version

published Apr 08, 2014 04:30   by admin ( last modified Apr 08, 2014 04:33 )

Summary:

Type

openssl version

With the recent disclosure of the long standing heartbleed bug, it is a god idea to check what version of openSSL you are actually running. Just type openssl on the command line followed by the word "version". According to this page, the versions that are compromised are

  • OpenSSL 1.0.1 through 1.0.1f (inclusive)

OpenSSL cheat sheet


Tunneling of VNC over ssh in one command

published Mar 27, 2014 03:35   by admin ( last modified Jan 03, 2015 12:53 )

Well actually two, but you stick them in one file that gets executed in bash:

ssh -fN  -L 5900:localhost:5900 remotserver.example.com
vncviewer -encoding tight -quality 5 localhost:0

 

The -N switch prevents commands to be sent to the remote host, the -f switch allows the terminal to come back and prompt for a vnc password that is triggered by the second line.

Warning: Haven't figured out how to exit cleanly. However the top rated answer here might do the trick:

Bash script to setup a temporary SSH tunnel - Stack Overflow
 


A reasonable setting for low bandwidth VNC over SSH

published Mar 27, 2014 03:30   by admin ( last modified Mar 27, 2014 03:30 )

Tightvnc used in this case:

vncviewer -encoding tight -quality 5 localhost:1

Making a python 2.4 virtualenv buildout on Ubuntu 10.4 & Debian 7 as of 2014-03

published Mar 16, 2014 11:20   by admin ( last modified Mar 18, 2014 01:05 )

It gets harder and harder to install a python 2.4 buildout on Ubuntu and Debian. Basically, the different scripts involved will try to execute code that is not compatible with python 2.4 at every step of the way. I need python 2.4 for some old Plone 2.5 sites. Here is what I did to get it running this time, tested both on Ubuntu 10.4 and Debian 7:

Use a separate virtualenv script, so do not rely on the one installed in the system which is made for another python version. Instead download a standalone script of some vintage:

wget --no-check-certificate https://raw.github.com/pypa/virtualenv/1.7.2/virtualenv.py

Setup the virtual environment like so:

python2.4 virtualenv.py .

It will crash when trying to install setuptools, but by then it has installed python.

Now you should have a working python.

Time to install a setuptools that actually works. Version 1.4.2 works (somewhat selected at random, you can try newer ones if you like). That version is not linked from the https://pypi.python.org/pypi/setuptools page, but with some detective work it can be found at:

https://pypi.python.org/packages/source/s/setuptools/setuptools-1.4.2.tar.gz

Download and unpack it and install it in the old-fashioned way:

./bin/python setuptools-1.4.2/setup.py install

Time to install easy_install. Download the script from:

http://peak.telecommunity.com/dist/ez_setup.py

Then install easy_install with:

./bin/python ez_setup.py

Time to install zc.buildout:

./bin/easy_install zc.buildout==1.4.4

In your buildout.cfg file, you must also pin setuptools to the version you have installed. Otherwise, you guessed it, zc.buildout will download and fail to run a newer incompatible version of setuptools:

[versions]

setuptools = 1.4.2

And there you go:

./bin/buildout

 

 

 

 


A free web/blog site with tables?

published Mar 05, 2014 09:35   by admin ( last modified Mar 05, 2014 12:00 )

I had the need for a quick and easy way to publish a table on some free web publishing service. The table must be easy to edit. However finding a free blog site or web publishing site where you can add tables in the wysiwyg editor turned out to be not that easy. In fact I have not found one yet:

 

Wordpress.com

 

no wysiwyg tables. There are plugins for wordpress that have this, but they are not available at wordpress.com, at least not for free.

Tumblr.com

 

no wysiwyg tables

Livejournal.com

 

no wysiwyg tables and has peculiar ideas about password security and annoying captchas

blogspot.com

 

no wysiwyg tables

blogetery.com

 

Is supposed to have some wordpress plugins, which ones they are is not listed, but signup does not work whether using Firefox or Chrome from Ubuntu, so it will remain a mystery.

angelfire.lycos.com

 

has a table "plugin" but it disappears when you try to click it in Google Chrome or Firefox

notehub.org

 

has markdown publishing, but does not support the markdown table format

 


Running a GUI application on your Linux machine as a different user

published Jan 11, 2014 03:45   by admin ( last modified Mar 23, 2015 02:08 )

Update 2015-03-23: It seems that the program get privileges to both accounts. If I start Firefox with it, it can read both from my account's files and the the account that sox runs it as.

sux seems to do the job. If you are on Ubuntu:

 

sudo apt-get install sux

 

sux other_user_name gui_program_to_run

 

You may need to include the full path to the program you want to run, e.g. if is a Windows program to be run under wine

sux other_user_name wine /path/to/program

 

Haven't tried without full path though.


When the newfangled buttonless touchpads make right click difficult in Ubuntu

published Jan 03, 2014 11:19   by admin ( last modified Jan 03, 2014 11:19 )

There is a "hidden" setting in Gnome that allows you to use two fingers on the touchpd (trackpad) to emulate right click (context click). Read more here:

 

http://askubuntu.com/questions/331605/simulate-right-click-in-laptop


How to get python 2.4 to compile on a new Debian

published Dec 31, 2013 03:40   by admin ( last modified Dec 31, 2013 03:52 )

The instructions are for Ubuntu, but the user appociappo's instructions worked like a charm on Debian 7. It contains a patch to setup.py, and flags for the C compiler and loader:
 Link - [ubuntu] compile python 2.4 and 2.6 on 12.04 x86_64

Furthermore, if you are using bootstrap.py for e.g. a Plone buildout, this bootstrap.py seems to work:

http://blog.fourdigits.nl/python-2.4-bootstrapping


Making adjustments to a non functioning ubuntu install

published Dec 17, 2013 10:55   by admin ( last modified Dec 17, 2013 10:55 )

Boot with a live CD or live USB. Assuming that your install is availableat /dev/sda1, then, quoted from:

http://askubuntu.com/questions/112957/display-works-fine-in-livecd-but-not-in-full-installation

 

sudo mkdir -p /media/ubuntu
sudo mount /dev/sda1 /media/ubuntu

Then you need to mount the proc, dev, and sys filesystems into your new environment:

sudo mount --bind /dev /media/ubuntu/dev
sudo mount --bind /proc /media/ubuntu/proc
sudo mount --bind /sys /media/ubuntu/sys

Finally, chroot into it:

sudo chroot /media/ubuntu

Now edit /etc/default/grub, uncommenting out the line

GRUB_GFXMODE=640x480

and then run

sudo update-grub

Trying to understand the Bitcoin script walk-through

published Dec 15, 2013 05:55   by admin ( last modified Dec 16, 2013 04:54 )

There is a script walk-through at the bitcoin wiki. It is not all that easy to understand, since it could be formatted and presented better. I show here the current table as it looks on the Wiki, and then further down my hopefully improved version. Here is what the original looks like:

Checking process:

Stack Script Description
Empty. <sig> <pubKey> OP_DUP OP_HASH160 <pubKeyHash> OP_EQUALVERIFY OP_CHECKSIG scriptSig and scriptPubKey are combined.
<sig> <pubKey> OP_DUP OP_HASH160 <pubKeyHash> OP_EQUALVERIFY OP_CHECKSIG Constants are added to the stack.
<sig> <pubKey> <pubKey> OP_HASH160 <pubKeyHash> OP_EQUALVERIFY OP_CHECKSIG Top stack item is duplicated.
<sig> <pubKey> <pubHashA> <pubKeyHash> OP_EQUALVERIFY OP_CHECKSIG Top stack item is hashed.
<sig> <pubKey> <pubHashA> <pubKeyHash> OP_EQUALVERIFY OP_CHECKSIG Constant added.
<sig> <pubKey> OP_CHECKSIG Equality is checked between the top two stack items.
true Empty. Signature is checked for top two stack items.

So, in order to understand this, there are a couple of things that are kind of obscure in that table, namely:

  • In the column "Stack" the top of the stack is the last item, which means that since the text wraps in the field, if there are multiple lines, the bottom-most item is at the top of the stack
  • In the column "Script", it is actually the same script in all rows, just less and less of it.
  • The comments seem to be written as to what the state is before the script part executes

 

It might be cleaner to do like this instead:

  • Let the topmost item in the "Stack" cell in a row, be at the top of the stack, and number them.
  • Only write the part of the script that is executed in a row. List entire script before the table for clarity
  • Description should descibe what happens when the code in the row, operates on the stack in the row

Then it becomes like this:

Checking process:

Entire script is:

<sig> <pubKey> OP_DUP OP_HASH160 <pubKeyHash> OP_EQUALVERIFY OP_CHECKSIG

Stack Script Description
Empty. <sig> <pubKey> scriptSig and scriptPubKey are pushed onto the stack.
  1. <pubKey>
  2. <sig>
OP_DUP Top stack item is duplicated.
  1. <pubKey>
  2. <pubKey>
  3. <sig>
OP_HASH160 Top stack item is hashed.
  1. <pubHashA>
  2. <pubKey>
  3. <sig>
<pubKeyHash> Constant pubKeyHash is pushed onto the top of the stack,.
  1. <pubKeyHash>
  2. <pubHashA>
  3. <pubKey>
  4. <sig>
OP_EQUALVERIFY Equality is checked between the top two stack items. If not equal, script returns false and transaction is invalidated
  1. <pubKey>
  2. <sig>
OP_CHECKSIG .Signature is checked for the two remaining stack items.
true Empty.  

 


Being logged in on XMPP chat with same nick from several places

published Dec 11, 2013 02:14   by admin ( last modified Dec 11, 2013 02:14 )

If you use different devices for your XMPP chat, it can be a chore to have different nicks just so that you do not get kicked out or blocked when you log in from device number 2.

Newer versions of ejabberd (13.10 tested) allows this by default, however the old version (2.1.2) shipped with Ubuntu 10.4 does not. Openfire did not allow it in the version I tested, and it seems that it is not possible.


Vagrant, a way to configure virtual machines

published Dec 01, 2013 11:50   by admin ( last modified Dec 01, 2013 11:50 )

Just a note to self:

 

Create and configure lightweight, reproducible, and portable development environments.


Read more: Link - Vagrant


Format a USB stick on Ubuntu

published Nov 05, 2013 02:30   by admin ( last modified Nov 05, 2013 02:32 )

Taken from: Link - How to format a USB flash drive? - Ask Ubuntu

 

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

 


An HTML Wysiwyg editor that can edit divs?

published Oct 31, 2013 11:35   by admin ( last modified Oct 31, 2013 12:06 )

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.

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.

 

 


My git cheat sheet

published Oct 30, 2013 09:05   by admin ( last modified Jun 15, 2015 04:38 )

Pulling, fetching & merging

I want to track a new remote branch

Check what branches are available at remote:

git remote show origin

Then do:

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

git fetch

and then compare the branches with

git diff HEAD...origin

I want to merge in another branch, how do I pull down the new stuff in that branch without switching to it?

Do :

git merge origin/other_branch

while being in your branch.

A

git pull --all

followed by a a

git merge other_branch

won't work. "git pull --all" fetches all tracked remotes and updates them, but only merges new updates on your current branch. So even if other branches are updated locally, HEAD hasn't moved in them and from merge's point of view the updates aren't there.

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:
http://stackoverflow.com/questions/4911794/git-command-for-making-one-branch-like-another

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

-or-

git branch -d master
git checkout incoming
git -b master

-or-

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.

Pushing

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.

See:
http://stackoverflow.com/questions/6157730/why-cant-i-push-to-this-bare-repository

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

git push

, 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

Undoing stuff

How do I revert unstaged files to last commit?

git checkout -- .

How do I unstage a file?

git reset HEAD filename

How do i undo my last commit?

Most drastic

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

Least drastic

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.

See: http://stackoverflow.com/questions/927358/how-to-undo-the-last-git-commit

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.

git submodule

You can use sub modules in a fruitful way if you’re on git 1.8.2 or later:

http://stackoverflow.com/questions/9189575/git-submodule-tracking-latest/9189815#9189815

http://www.vogella.com/articles/Git/article.html#submodules

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. So does newer versions of Ubuntu.

If you are on an older Ubuntu, use:

sudo add-apt-repository  ppa:git-core/ppa

from: https://launchpad.net/~git-core/+archive/ppa

Adding a submodule to a repository

git submodule add -b branch <url> dirname
git submodule add -b master ssh://git@git.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 to to remove a submodule

This seems quite involved, but I have successfully done so, following these instructions:

Remove a Submodule within git

Other

How do I add an empty directory in git?


You can’t. Commit 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


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.


When the bootstrap.py won't work because of distribute/setuptools conflicts

published Oct 16, 2013 10:55   by admin ( last modified Oct 16, 2013 10:55 )



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


Read more: Link - setuptools - How to solve pkg_resources.VersionConflict error during bin/python bootstrap.py -d - Stack Overflow