Leon.Radley.se
  • Blog
  • Labs
  • Leon Radley @ Google+
  • Leon Radley @ GitHub
  • Leon Radley @ Twitter
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| 1
  • mootools| 1
  • tip| 1
  • unix| 1
All content on this site is owned by me, Leon Radley. 2010-2012 ⇪