Ubuntu: Check Release Version
This is very useful. If you need to know what version of Ubuntu you are running use the following command...
lsb_release -a
Hope this helps.
will byers stan first human second
Lint Roller? I Barely Know Her
art blog(derogatory)
No title available
styofa doing anything
he wasn't even looking at me and he found me

titsay

Andulka
wallacepolsom

⁂
d e v o n
One Nice Bug Per Day

PR's Tumblrdome

❣ Chile in a Photography ❣
Misplaced Lens Cap

Janaina Medeiros
Sweet Seals For You, Always
Game of Thrones Daily
occasionally subtle

izzy's playlists!
seen from United States

seen from United States
seen from Italy

seen from Greece
seen from United States

seen from Sweden
seen from Israel
seen from Israel
seen from United States
seen from United States

seen from Russia

seen from United States

seen from United States

seen from United States

seen from United States
seen from United States
seen from United States
seen from United States

seen from United States

seen from United States
@robdwaller-blog
Ubuntu: Check Release Version
This is very useful. If you need to know what version of Ubuntu you are running use the following command...
lsb_release -a
Hope this helps.
Ubuntu: How to Delete Your Mail Files
I had a problem the other day where my server exploded because it ran out of disk space. I added some more and rebooted it and things were fine.
However I later found out the problem was caused by a large and growing mail file. So I needed to find out how to remove all the data from the relevant file so it didn't cause the problem again.
And it turns out it is really simple...
> /var/mail/[~Username~]
This will basically truncate the file without removing it.
Hope this helps.
Linux Command Line: View Disk and Directory Size
This is a very quick one, but if you want to check the disk space or directory size of your Linux server you use the following commands...
// View disk space in human readable format df -h // View directory size in human readable format du -hs /path/to/folder
Hope this helps.
My Chromebook Review
I have had my Samsung Chromebook for about two weeks now and I thought I'd give it a review. Especially given my friend @adriannabarro wanted to know what my thoughts were.
So first off, I have to admit, I think my Chromebook is f*ck*ng awesome -- I love it. It is exactly what I want a laptop to be. It's light, fast, cheap and really easy to use. It is basically everything that Windows 8 isn't.
But for the sake of balance I will outline what is good and what is bad. We'll begin with bad so we can finish on a high...
Your Chromebook will not replace your Mac or Windows machine yet.
It's different so it will take a while to get used to.
Heavy lifting dev work isn't easy and neither CodeAnywhere nor Cloud9IDE are good enough replacements for a proper dev environment.
There is no FTP App nor Git App that I can find.
Zip files and other non-standard files are a no, no. Basically the file management system needs some work.
You can only edit documents offline, not spreadsheets nor presentations.
The Good...
It is lightening fast -- loads up in seconds.
It's lightweight and small so you can do work anywhere.
For doing all your online stuff it is amazing.
It's got some great apps like Secure Shell and Remote Desktop.
There are plenty of apps for writing code like SourceKit and CodeAnywhere which both synch with your Dropbox.
All of Google's standard tools like Docs and Callendar are great but I especially like Google Hangouts.
In addition a couple of points I will make about the two main criticisms of Chromebooks -- their power and their need for internet access. I have not had any problems with either. You have to open a lot of stuff before performance is compromised. And as a very mobile developer I have not ever had a problem getting an internet connection.
And if you're wondering how I do my dev work on my Chromebook. Currently I do my code in SourceKit and do the heavy lifting stuff by remote desktopping into my Windows machine. So it is possible.
Overall there are some weaknesses but I feel that with a few improvements Chromebooks and their competitors will be the future of mobile work.
Ping on Linux
Ok this is a random one I didn't know until yesterday and I had all the issues with the StatusPeople/Twitter IP block.
Turns out if you want to run a ping command on Linux you need to define how many times you want it to occur. Otherwise it will continue indefinitely...
//Windows ping twitter.com //Linux ping -c 5 twitter.com
Basically you just add "-c n" to the command to define the count and it will work the same as it does on Windows.
Hope this helps.
jQuery: Improve API Calls With an Event, Request, Class Structure
First of all happy new year to all of you, I hope you enjoyed the holiday season.
Anyway I'm going to share with you a simple way to improve the structure of your jQuery code. It's what I call the Event, Request, Class Structure. And I find it particularly useful when dealing with API or server requests in jQuery.
I'm sure some of you will have seen something similar or know of something better. But this is for the many coders who still use procedural jQuery when making server requests. Just take a look at OpenCart as a prime example.
We all know this kind of jQuery event, request and response set up...
$('#button').bind('click',function(e){ e.preventDefault(); var inp1 = $('#input1').val(); $.ajax({ type: 'GET', url: 'http://example.com/API/GetData', dataType: 'json', data: 'inp='+inp1, cache: false, success: function (result) { //Do something with the response alert(result); } }); });
This works fine, but it means the event, request and response handling are all done in the same place. In addition every time you make a request you have to type out the same $.ajax bullshit over and over again. So your code becomes a clutter and or 'soggy'...
So how can we improve things? Well we can use an Event, Request, Class Structure or something similar. And if you're cool with MVC you going to get the idea pretty quickly.
Basically we split out our events into one file, we then create a request class with routing features and finally create a set of classes for handling the responses...
So let's create an events file called events.js...
$(document).ready(function(){ //Instantiate your requests class srv = new Server(); $('#button1').bind('click',function(e){ e.preventDefault(); var inp1 = $('#input1').val(); //Call the request method srv.Request('GET','json','/API/RequestOne','inp='+inp1,'ClassOne_ResponseOne'); }); $('#button2').bind('click',function(e){ e.preventDefault(); var inp2 = $('#input2').val(); srv.Request('POST','json','/API/RequestTwo','inp='+inp2,'ClassTwo_ResponseTwo'); }); });
Above you will see we just instantiate our request class, called Server() in this instance. It's request method is passed standard $.ajax variables plus a route string at the end.
The route string contains the class and the method we want the response handled by, separated by an underscore.
Next we create our request class (server.class.js) for handling and routing all our requests...
function Server() { this.Request = function(type,response,url,data,route) { $.ajax({ type: type, url: url, dataType: response, data: data, cache: false, success: function (result) { //Split route into class and method var cm = route.split('_'); //Class var c = cm[0]; //Method var m = cm[1]; //Instantiate our class by adding it to the window. var myclass = new window[c](); //Call the class' method and pass it the relevant data myclass[m](result); } }); } }
The above is just a simple way of instantiating a class and method based on a string. Very similar to the way it is done in PHP MVC. And of course the important bit is the bit after 'success' and I explain this in more detail in a previous post...
I hope you can see where this is going. The final task is to create our classes for handling the results. So let's create responses.class.js...
function ClassOne { this.ResponseOne = function(result) { alert(result); } } function ClassTwo { this.ResponseTwo = function(result) { alert(result); } }
See simple. We can now handle our responses in whatever way we want.
The above code can be extended to become as complicated as you want. I've even built a version that handles file uploads which I'll share at a later date.
The benefits of the above approach should be obvious. It will keep your code DRY; It will be better structured so it is easier to debug; And you will be able to produce code quicker.
I hope you find it useful, but please don't think I believe my way is the best way or the only way. If you know of improvements or better ways please share them with me.
HTML Base Tag: Is it a Good Idea?
I've been developing a website for a company recently using a well known CMS when we had one of those cross domain jQuery issues.
You know the one, where you try and make a request from one sub-domain to another and JavaScript has a little spasm.
However in this case we shouldn't have had a problem as the issue related to the http:// and http://www. domains and we were using relative URLs.
So I did a little investigating, checked the DNS set up, etc but had no idea what the problem was.
Anyway after a few hours of Googling I stumbled across a post that mentioned the HTML <base> tag -- which was a new one to me...
As w3schools says the base tag is used to set the base URL for all relative URLs on a page...
The <base> tag specifies the base URL/target for all relative URLs in a document.
There can be at maximum one <base> element in a document, and it must be inside the <head> element.
So I checked the CMS and it turns out it was using said tag. The base URL was set to http://example.com. So when we accessed the site via http://www. it was making jQuery requests to http:// -- hence the cross-domain load issue.
Anyway I fixed my problem by commenting out the tag. But I can't work out why you would use the base tag -- especially given the issue I highlighted above.
If anyone can tell me why the base tag is a good idea please let me know. It will be much appreciated.
Convert From PuTTY to Google Secure Shell
Before I tell you how to convert from PuTTY to Google Secure Shell. Let me tell you why I'm using Secure Shell. And if you're not interested scroll down a bit...
As a developer I've been thinking for a while about how I become a truly mobile dev -- AKA ParaDev... Basically I've been thinking how I get myself in a position where I can work anywhere and on any device.
And this is why I became quite excited by Windows 8, the Surface Tablet and the new Windows Phones. But after installing Windows 8 on my laptop all I can say is I'm thoroughly disappointed.
Windows 8 feels like what happens when a group of talented developers have a really good idea but need to get it signed off by finance and marketing... It's so close, yet so very, very far...
So this has left me in a bit of a pickle. Windows 8 is simply a write off, I don't ever want to become a Mac user and I don't think I'm ready for Linux -- just yet... So the only option left is Google -- and they've just released their new Chrome Books.
But the obvious question is, can I dev on a Chrome Book? Well, I did a little research and the answer is just about... With a combination of Cloud9, Git Hub and Secure Shell you can.
It may not be perfect but Android phones and tablets are pretty solid and one can only hope as the Chrome OS user base grows so will its features.
Anyway Secure Shell is pretty amazing. It's a SSH Client in your browser which you can use anywhere and on any tool with Chrome installed. It's only in Beta at the moment, but it works really well. You can read up about it on it's FAQ page and join the Google Group to ask any questions you have.
The only problem I had was that you can't use a PuTTY generated PPK key to access your server. What you need is a separate public (.pub) and private key. Now not being an experienced Linux Bod I was left wondering how I could get my PuTTY generated PPK Key working with Secure Shell.
And after much head scratching, manually splitting out the keys, swearing at the computer, searching the web, wondering about new users with new keys, etc, etc... I realised the obvious answer.
You can use PuTTYgen to covert your PPK file into the separate files you need. You just have to import your PPK file -- go Conversions > Import. And then as the Image shows click Conversions > Export OpenSSH key and you have what you need. It's so obvious and easy it does make me feel very stupid...
But either way I hope this info helps.
Execute SQL File Using MySQL Source
Haven't posted in bloody ages but need to jot this one down as I use it all the time.
You can execute a SQL file in command line using the following code...
mysql> use [table]; mysql> source /Path/To/File.sql
Works great for uploading files.
jQuery: Tumblr Scroll Top Button
So for my site StatusPeople.com I wanted to add a scroll top button -- like the one on Tumblr.
I scratched my head a bit and had a play around and here is what I came up with...
//Bind scroll event to window $(window).bind('scroll',function() { var v; //Get the scroll position v = $(this).scrollTop(); //If scroll position is greater than 400px add button if (v>400) { if (!$('#topbutton').length) { var div = $('<div/>'); div.attr('id','topbutton'); div.text('Top'); div.hide(); div.appendTo('body').fadeIn(1500); } } else { //If button exists and scroll position is less than 400px remove button if ($('#topbutton').length) { $('#topbutton').fadeOut(1000,function(){ $(this).remove(); }); } } }); function ScrollTo(id,time,minus) { $('html, body').animate({ //Scroll to the top of any page element scrollTop: $(id).offset().top-minus }, time); } //Button click event, remember it's dynamic so we use live to bind the event $('#topbutton').live('click',function() { //Scroll page back to top of page ScrollTo('body',1500,0); });
It's pretty straight forward. We just add or remove the scroll button based on the scroll position. And if the the top button is clicked the page scrolls up and the button disapears.
Let me know your thoughts and I hope you find it useful.
MySQL Optimisation and Performance: This is really good for noobs or part time SQL coders.
How to Route a JavaScript Class and Method With a String
As normal I'm very busy at the mo so very little blogging recently. However this is quite important so I thought I'd share it.
If you want to route a JavaScript Class and Method via a string like you do with a PHP MVC framework this is how you do it.
Pass a string string to your route class...
var ClassMethodString = 'Class_Method'; var Data = 'Any data you wish to pass to your method.'; var Route = new Route(); Route.Process(ClassMethodString)
Then split your class method string and instantiate it...
function Route() { this.Process = function(ClassMethodString,Data) { //Split String var cm = ClassMethodString.split('_'); var c = cm[0]; var m = cm[1]; //Instantiate Class var myclass = new window[c](); //Call Method myclass[m](Data); } }
We instantiate our class by adding it to the window object and then we can instantiate our method in the same way.
It's pretty simple and its advantage should be clear. I'm currently using it to set up a simple routing system for jQuery's $.ajax method so I can pass all my server requests through a single method.
Hope you like it and find it useful.
My First jQuery Plugin
I haven't published anything in ages as I have been v busy with @StatusPeople. But thought I'd quickly share my first jQuery plugin script...
<div id="holder"></div> <div id="holder1"></div> <script type="text/javascript"> (function($) { $.fn.fillHolder = function(options) { var defaults = { message: 'Hello World!!' } var opts = $.extend({},defaults,options); return this.each(function(){ $(this).html(opts.message); }); } })(jQuery); </script> <script type="text/javascript"> $('#holder').fillHolder({message:'Party Time!!'}); $('#holder1').fillHolder(); </script>
Let me know what you think. I hope you like it. Also this is a good tutorial to get started with jQuery plugins...
I bloody love Paul Scholes. I would have loved to see him play at Euro 2012.
Stop Britain Funding Argentina
What Austerity?