Wednesday, July 31, 2013

Overwriting local changes with Git

Often I want to delete a file and pull the original back from my git repository. To do this properly you have to checkout the file from the "HEAD" tag.

$ git checkout HEAD <optional file name>
$ git checkout .

Tuesday, July 30, 2013

Pulling cross origin data within JavaScript

It took me a lot longer to figure this out than I thought it would, and the syntax has to be just so, minor changes cause failure due to same origin policy.

Using JQuery this code will allow you to pull data from an external website.
$.ajax({
    url: 'http://domain.com/data-request.php?foo=bar',
    dataType: 'jsonp',
    jsonp: 'jsoncallback',
    timeout: 5000,
    success: function(data, status){
        //data loaded
    },
    error: function(){
        //error loading data
    }
});
Data must be formatted in JSON format. I can't remember the site I found this on, but it gives a lot of detail on what's happening and why.

Friday, July 26, 2013

Using the Linux screen command to detach processes from terminal

A nice simple example based page on how to use the screen command in Linux.

http://www.thegeekstuff.com/2010/07/screen-command-examples/

Allows you to detach and later re-attach to SSH sessions without killing your processes.

Start screen session.
$ screen ./work_on_something.sh
Press CTRL+A and then "d" to detach.

List screen sessions.
$ screen -ls
There is a screen on:
21952.pts-0.debian-7 (07/26/13 23:25:29) (Attached)
1 Socket in /var/run/screen/S-user.

If detached, attach with -r
$ screen -r 21952.pts-0.debian-7

Wednesday, July 24, 2013

Removing invalid proxmox VM listings

The proxmox datacenter view sometimes shows a VM after the VM has been deleted. This is appears to be a bug where the configuration file is not deleted.

To remove the listing from the control panel, on the proxmox server:
# rm /etc/pve/nodes/<server_name>/openvz/<vmid>.conf

Friday, July 19, 2013

Turnkey Linux Service Credentials

I have noticed that several Turnkey Linux containers say the password for logging in is "set at first boot", but have not been able to see any such thing happening.

I found a post that says to use "turnkey" as default password and I'll be darned if it didn't work.

Apache proxy to redmine server

I've been struggling with this for awhile. I have a virtual apache server, and turnkey linux container with redmine running and I want the main server to delegate requests to the /redmine/ folder to the redmine server.

I set up the proxy statements on the primary server, but all the followup requests for css, js, images whatever would be looking back in the main server's root again instead of on the redmine sever.

I had to add the following line to the end of /var/www/redmine/config/environment.rb

ActionController::Base.relative_url_root = "/redmine"


And that did the trick.... I have no idea how rails does whatever it does.

Wednesday, July 17, 2013

Tagging versions in GIT

As stated in the title, I use this blog to remember stuff, so here is yet another GIT tip.

Adding a tag for a given version:

$ git tag -a v1.4 -m 'my version 1.4'

Displaying tagged versions:
$ git tag
v0.1
v1.3
v1.4