söndag 27 oktober 2013

edit remote application in Eclipse

http://stackoverflow.com/a/4216878/517457

RSE may already be included in your current Eclipse installation. To check in Eclipse Indigo go to Window > Open Perspective > Other... and choose Remote System Explorer from the Open Perspective dialog to open the RSE perspective.
To create an SSH remote project from the RSE perspective in Eclipse:
  1. Define a new connection and choose SSH Only from the Select Remote System Type screen in the New Connection dialog.
  2. Enter the connection information then choose Finish.
  3. Connect to the new host. (Assumes SSH keys are already setup.)
  4. Once connected, drill down into the host's Sftp Files, choose a folder and select Create Remote Project from the item's context menu. (Wait as the remote project is created.)
If done correctly, there should now be a new remote project accessible from the Project Explorer and other perspectives within eclipse. With the SSH connection set-up correctly passwords can be made an optional part of the normal SSH authentication process. A remote project with Eclipse via SSH is now created.

måndag 16 september 2013

SEO redirects 101

http://moz.com/blog/save-your-website-with-redirects

Jquery form plugin

http://jsfiddle.net/KvXK4/1/

http://stackoverflow.com/a/12954102

http://stackoverflow.com/a/12650849

http://stackoverflow.com/a/8191682

http://www.playframework.com/documentation/1.2.7/routes#anamecontenttypesSettingcontenttypesa

lördag 14 september 2013

Virtualbox, to copy the image to another computer

http://jen3ral.wordpress.com/2009/03/02/copying-a-virtualbox-virtual-machine-onto-another-host-computer/

To copy the image to another computer:
  1. Close VirtualBox if it’s running.
  2. Go to your home folder and enable show hidden files through the View menu.
  3. Find the .VirtualBox folder, go to the HardDisks folder and copy the .vdi file you want to use.  In my case  I burned the file to a DVD because we have so many people who will be needing to save this in their home directory.
  4. Now go to the other host computer you want to use that .vdi file on and open VirtualBox if you’ve never opened it on the new host machine before.  This will create the .VirtualBox folder.  Then paste it in the same place (user’s home directory -> show hidden files -> .VirtualBox -> HardDisks).  You might need to create the HardDisks folder yourself.
  5. Edit the permissions of the file in order for it to work.  All I did was right-click on it after moving the file over and give read & write permissions to the owner, which should have your username there.  You can change the permissions to the group and others sections if needed later, but that wasn’t necessary for me.
Once you’ve copied the disk image you need to create a new machine and register that hard disk with VirtualBox on the target host machine:
  1. From the VirtualBox window click the New button.  This will open the New Virtual Machine Wizard.
  2. VM Name and OS Type – Give it a name and pick the type & version of the virtual machine OS.
  3. Memory – Just leave it as the default.  You can change it later if you notice any problems.
  4. Virtual Hard Disk – This is where you select the hard disk you copied in to the home directory earlier.  So click on existing and when the Virtual Media Manager window comes up choose to Add.  It should take you to the correct folder so just select the image file and click open, then select.
  5. You’re done, it’ll take you back to the main window with the new virtual machine you just created based off the existing image file.
If you notice things running slowly you can shut down the machine, go to settings, and change the base memory allocation.  It’ll be screaming at you in red or orange text if you’ve allocated too much.

onsdag 11 september 2013

ref: http://stackoverflow.com/a/1052246/517457


Figured it out.
Turns out Internet Explorer chokes if you use anything other than "javascript" in the language attribute of the script tag.
I was using version numbers appended onto javascript in the language attribute, which was causing IE not to load prototype.js

tisdag 10 september 2013

Extend JQuery UI dialog

ref: http://stackoverflow.com/a/17763712

var defaults = {
  autoOpen: false,
  draggable: false,
  resizable: false,
  closeOnEscape: true,
  modal: true,
  height: 'auto',
  width: 200,
  position: ['top', 150]
};
and then use $.extend with the specific options you want to override:
$('.detail-view').dialog($.extend({}, defaults, {
  width: 600
}));
$('.forgotpass').dialog($.extend({}, defaults, {
  width: 400
}));
You could encapsulate this in a function:
function createDialog(selector, options) {
    $(selector).dialog($.extend({}, defaults, options));
}

createDialog('.detail-view', {
  width: 600
});
createDialog('.forgotpass', {
  width: 400
});
Or of course if it's just width:
function createDialog(selector, width) {
    $(selector).dialog($.extend({}, defaults, {width: width}));
}

createDialog('.detail-view', 600);
createDialog('.forgotpass', 400);

JQuery form plugin issue < IE10

https://github.com/malsup/form/issues/302

and

https://drupal.org/node/1675794

even better actually, use chromeframe


<meta http-equiv="X-UA-Compatible" content="chrome=1">

Add This slows page loading and the solution

The solution is to load AddThis script in asynchronous mode. This would prevent AddThis from loading other assets except the initial script. After loading this initial script your website will break connection with the AddThis server and load itself further. When your website’s DOM has fully loaded, you can call the init() function of AddThis to resume loading of AddThis assets.
To do this, just add the following parameters to your script call
async=1&domready=1
So, instead of the following code:
1<script type="text/javascript" src="http://s7.addthis.com/js/250/addthis_widget.js#pubid=xa-4f3e33c72b9a4e40"></script>
Use this one (change the pubid parameter to your pubid):
1<script type="text/javascript" src="http://s7.addthis.com/js/250/addthis_widget.js#pubid=xa-4f3e33c72b9a4e40&async=1&&domready=1"></script>
And then call the init() function right before closing the body tag
1<!-- Call for AddThis init() function -->
2<script>
3    function initAddThis()
4     {
5          addthis.init()
6     }
7     initAddThis();
8</script>
You’ll see that your AddThis widget is loading faster than before. Of course there could be other reasons that might be slowing down your website. You should look at them separately.

ref:
http://techwelkin.com/slow-addthis-reason-and-solution#.Ui7RjaydnLY

tisdag 11 juni 2013

Break anchor inside table cells


http://stackoverflow.com/a/5889731

example:

td a { word-break: break-all;}

söndag 6 januari 2013

router control dd-wrt

http://lifehacker.com/5791208/run-your-home-network-like-a-coffee-shop

lördag 5 januari 2013

Backup Windows client to linux server

http://blog.dmitryleskov.com/small-hacks/pushing-files-from-windows-to-linuxunix-hosts-with-cwrsync/

lördag 29 december 2012

play framework jpa join two tables

http://stackoverflow.com/a/7873969/517457

Every time you have a field names "xxxId" in an entity, and "xxxId" is the ID of another entity, you did something wrong. The point of JPA is to manipulate objects, and associations between objects using object references or object collections.
Your tbl_lookup_user_major looks like a join table to me. Such a join table means that you have a many-to-many (or one-to-many, is one of the IDs is unique) between Major and User. So, your Major entity should have the following field :
@ManyToMany
@JoinTable(...) // details omitted
private Set<User> users;
And your JPA query should look like
select m from Major m
inner join m.users user
where user.id = :userId

torsdag 27 december 2012

limit bandwidth on dd-wrt router

http://markmaunder.com/2011/01/26/how-to-reliably-limit-the-amount-of-bandwidth-your-room-mate-or-bad-office-colleague-uses/



tisdag 25 december 2012

reload .bashrc after changes

http://askubuntu.com/a/152463

Please place those lines -
export PATH=$PATH:/to/path/play
, in .bashrc file in your user directory and restart the system OR just execute the following command:
source ~/.bashrc

onsdag 5 december 2012

Getting the response header

http://stackoverflow.com/a/2444499/517457


$(document).ready(function() { 
    $("[name='submit']").click(function() { 
        $.ajax({
            type: "POST",
            data: $(".form-signup").serialize(),
            url: "external.asp", 
            success: function(output, status, xhr) { 
              alert(xhr.getResponseHeader("Content-Length"));
            },
            error: function(output) {
              $('.sysMsg').html(output);
            }
        }); 
    }); 
});

söndag 25 november 2012

upgrade or downgrade java version ubuntu/linux

http://www.webupd8.org/2012/01/install-oracle-java-jdk-7-in-ubuntu-via.html

To add our PPA and install the latest Oracle Java 7 in Ubuntu (supports Ubuntu 13.04, 12.10, 12.04, 11.10, 11.04 and 10.04), use the commands below:
sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java7-installer

After the installation finishes, if you wish to see if it was successful, you can run the following command:
java -version
It should return something like this:
java version "1.7.0_04"
Java(TM) SE Runtime Environment (build 1.7.0_04-b20)
Java HotSpot(TM) Server VM (build 23.0-b21, mixed mode)

The package installs all the Java binaries, so you can also try "javac -version" which should return "javac 1.7.0_04" and so on (the "_04" part of the version can be different because I'm constantly updating the PPA with the latest Oracle Java 7 version).

If for some reason, the Java version in use is not 1.7.0, you can try to run the following command:
sudo update-java-alternatives -s java-7-oracle

Update: the Oracle Java 7 (JDK & JRE) PPA is now available for Ubuntu 12.10 Quantal Quetzal and 13.04 Raring Ringtail.

Update 2: the installer now requires you accept the Oracle license before the installation begins. This is only required once. If for some reason you need the installation to be automated, you can run the following command to automatically accept the Oracle license:
sudo echo oracle-java7-installer shared/accepted-oracle-license-v1-1 select true | sudo /usr/bin/debconf-set-selections



Removing Oracle Java 7


If you don't want to use Oracle Java (JDK) 7 anymore and want to go back to OpenJDK, all you have to do is remove the Oracle JDK7 Installer and the previous Java (OpenJDK, etc.) version will be used:
sudo apt-get remove oracle-java7-installer

tisdag 18 september 2012

TinyMCE in JEditable


$.fn.tinymce = function(options){
   return this.each(function(){
      tinyMCE.execCommand("mceAddControl", true, this.id);
   });
}
function initMCE(){
   tinyMCE.init({
        mode : "textarea",
        theme : "advanced",
        ... // YOUR CUSTOMIZATION
      });
}

initMCE();

$.editable.addInputType('mce', {
   element : function(settings, original) {
      var textarea = $('<textarea id="'+$(original).attr("id")+'_mce"/>');
      if (settings.rows) {
         textarea.attr('rows', settings.rows);
      } else {
         textarea.height(settings.height);
      }
      if (settings.cols) {
         textarea.attr('cols', settings.cols);
      } else {
         textarea.width(settings.width);
      }
      $(this).append(textarea);
         return(textarea);
      },
   plugin : function(settings, original) {
      tinyMCE.execCommand("mceAddControl", true, $(original).attr("id")+'_mce');
      },
   submit : function(settings, original) {
      tinyMCE.triggerSave();
      tinyMCE.execCommand("mceRemoveControl", true, $(original).attr("id")+'_mce');
      },
   reset : function(settings, original) {
      tinyMCE.execCommand("mceRemoveControl", true, $(original).attr("id")+'_mce');
      original.reset(this);
   }
});
 
In your JEditable initiation make it of type mce. So:


    $(".edit").editable('ajax/save.php?editnotetext', {
        type
: 'mce',
       
... // etc
   
});
 





http://stackoverflow.com/a/5969896/517457