Leon.Radley.se
  • Blog
  • Labs
  • Leon Radley @ Google+
  • Leon Radley @ GitHub
  • Leon Radley @ Twitter
03 Mar 2012
  • sublime-text-2
  • textmate-2
  • unix

Sublime Text 2 - rsub

First a little introduction, what is rmate?

I read the blog post about TextMate 2 adding remote editing. By typing rmate myfile on the server, it connects to TextMate 2 via a SSH tunnel making editing a breeze.

Sublime Text 2 now also has this functionality via the rsub plugin (search for rsub via the excellent Package Control) It uses the exact same remote script as TextMate2.

Setup SSH to automatically create the tunnel

In a previous article SSH Tips I wrote about how a couple of lines in a config file can make your life a whole lot easier. The new addition to the ~/.ssh/config file is:

RemoteForward 52698 localhost:52698

As soon as you connect to a server via SSH it will start the remote tunnel.

ssh-copy-rmate

I wanted it to be simple to install the rmate command to the remote server, so I created ssh-copy-rmate. What it does is downloads the latest rmate script from github and via SSH copies it to the file /usr/local/bin/rmate on the server and sets the right permissions.

Since I´m using Sublime Text 2 I also created a clone of the install script called ssh-copy-rsub which names the file on the server to rsub instead of rmate.

Install

  • ssh-copy-rmate if you are using TextMate 2
  • ssh-copy-rsub if you are using Sublime Text 2

and place them in your path or in /usr/local/bin

then run ssh-copy-rsub root@myserver.com

The default is to use the ruby version of the script which requires that you have ruby installed on the server.

If you specify -b (ssh-copy-rsub -b root@myserver.com) it will fetch another version of rmate which doesn't require ruby.

References

  • Sublime Text 2 rsub plugin
  • TextMate 2 rmate feature
  • rmate ruby script
  • rmate shell script
Comments
01 Feb 2012
  • sublime-text-2

Sublime Text 2 - YUI Compressor Plugin

Could't find a plugin for using the YUI Compressor so I wrote one.

The plugin calls the yui-compressor jar file, I've used some settings to avoid putting everything on one single line since most text editors grind to a halt when having to deal with long lines.

java
-jar yuicompressor-2.4.7.jar
--charset utf-8
--preserve-semi
--line-break 150
-o ${file_base_name}-min.${file_extension}

Installation

Use package control http://wbond.net/sublime_packages/package_control and search for YUI Compressor

The source code can be found here: https://github.com/leon/YUI-Compressor

Gettings started

Make sure you have java installed, then open a .js or .css file and press F7 or command + b.

The plugin generates a new file along side the original with the extension .min.js or .min.css

Comments
19 Jan 2012
  • tip
  • unix

SSH Tips

I manage a lot of servers, login in quickly without having to look up passwords or remember which username it was should be simple, I'll show you how simple it can get!.

Below I will give you some tips of how to improve your SSH workflow.

ssh-copy-id is great!

By using ssh-copy-id you connect to the server using secure keys instead of having to use a password.

The syntax of ssh-copy-id is the following:

ssh-copy-id user@server.com

and then it will ask for the password.

it works by copying your public key from ~/.ssh/id_rsa.pub to the servers ~/.ssh/authorized_keys.

And when you then type ssh root@server.com it will first try to connect via secure keys which compares your private key ~/.ssh/id_rsa with the public key you copied with ssh-copy-id before falling back to using passwords.

Generate new key

You can generate your private and public key with the following command:

ssh-keygen -t rsa -b 2048

Simplify further

Now it's time to simplify the ssh command. We still need to specify the user and the host when we connect but by specifying this in the ssh config file we can do away with a lot of typing.

Open the file ~/.ssh/config and put the following in it:

# Stop timing out connections
ServerAliveInterval 300
ServerAliveCountMax 20

# Specify default user
User root

Host myalias
    HostName server.com
    User root

Host myalias2
    HostName server2.com
    User root2

The first is to stop OSX Lion from closing down the connection. (If you don´t specify this, you get Broken pipe syndrome)

I hope this will help you become a better unix hacker :)

Comments
13 Dec 2011
  • mootools

MooTools Carousel

I wrote a 3D carousel in 2006. Back then it was written in the newly released ActionScript 3. But as you all know, flash isn't what all the cool guys use nowadays.

So what I've done is revamp my old code and made it a lot cooler. By using Fx.Spring I could simulate friction.

Try swiping the image. Also try it on the iPad it's touch enabled!

Demo

The tech

By using the new javascript function RequestAnimationFrame I could make it run alot smoother. Otherwise the javascript uses setTimeout(fn, 60) which causes the browser to stall if it can't handle the load.

RequestAnimationFrame handles it differently, it fires your callback whenever your system can handle it.

You also get a bonus, when the browser detects that your tab isn't visible it doesn't fire any RequestAnimationFrame.

Options

options: {
    fps: 20,
    frames: 0,
    autoPlay: true,
    resume: 3000,
    mouse: true,
    inverseMouse: false,
    move: {
        stiffness: 20,
        friction: 10,
        threshold: 0.05
    }
}

Usage

new Carousel('placeholderimageid', 'img/image-sequence{num}.jpg', {
    frames: 36,
    autoPlay: true
});
Comments

Tags

  • sublime-text-2| 2
  • textmate-2| 1
  • mootools| 1
  • tip| 1
  • unix| 2
All content on this site is owned by me, Leon Radley. 2010-2012 ⇪