r3dux.org

A number-pimping side project from the valleys in *NEW* upside-down flavour.

  • Home
  • ABOUT
  • OLD SITE
  • SEARCH
  • FEEDBACK

William Gibson Sprawl inspired apparel

r3dux | August 22, 2011

For anyone who’s read the Sprawl Trilogy, this will definitely flip your switches:

William Gibson Sprawl inspired T-Shirts

You can buy ‘em on T-Shirts and hoodies and all sorts of stuff over at memetictees.

I think the “Tessier-Ashpool IT Department” and either the “Chatsubo Bar” or “Sprawl Cowboy” shirts would make a fine addition to any geek wardrobe :)

Comments
1 Comment »
Categories
Consumer Whore, Imagery, Literature
Tags
Apparel, Clothes, Sprawl Trilogy, t-shirt, William Gibson
Comments rss Comments rss
Trackback Trackback

How to: workaround .gvfs transport endpoint is not connected errors

r3dux | August 21, 2011

Confirming that a work-around is to manually unmount the ~/.gvfs using:
$ fusermount -u ~/.gvfs

Then close/unmount all opened remote locations in Nautilus and log out and back in, again. This restores the .gvfs-functionality for me.

Source: https://bugs.launchpad.net/ubuntu/+source/gvfs/+bug/212789/comments/6

Works for me in XFCE Thunar too, though I can’t say I ever had this crop up for me under Gnome.

Note: Don’t sudo this command, if you get a permission denied error add your user to the fuse group and try again.


Warning: Be careful with the usermod command – the following line will add the user to the fuse group:

sudo usermod -G fuse <USER-ACCOUNT-NAME>

Unfortunately, it will also remove the user from all other groups. What you instead want to use will be the -a(ppend) switch, giving you:

sudo usermod -a -G fuse <USER-ACCOUNT-NAME>

If you did accidentally remove permissions from your user account (like I did), then reboot into a recovery console (you’re not in the sudoers group anymore!) and run the following as root:

usermod -G <USER-ACCOUNT-NAME>,adm,dialout,cdrom,floppy,audio,dip,fuse,video,plugdev,scanner,sambashare,lpadmin,admin <USER-ACCOUNT-NAME>

The first time you put in your user-account name you are specifying it as the first group your user is a member of (hence the account’s primary group), the rest are the standard Ubuntu groups which you might want to modify as required (i.e. add the vboxusers and any other groups you might be using). You can check the current group membership by running:

groups

or,

groups <USER-ACCOUNT-NAME>

or,

cat /etc/group | more

Tricksy hobbitses…

Comments
No Comments »
Categories
How-To, Linux
Tags
fuse, Gnome, gvfs, XFCE
Comments rss Comments rss
Trackback Trackback

How to: Create and insert SQL DATE or DATETIME objects using PHP

r3dux | August 20, 2011

I was helping a student with a bit of project work the other day and had to create a properly formatted Date object from input provided by some dropdown menus, so in the spirit of only ever solving the same problem once, this is how you go about it… I’ll use MySQL for this example, but if the DATEs or DATETIMEs or whatever you’re using have a slightly different format in your DBMS of choice, then the principle’s the same to generate a compatible object.

MySQL Time Formats

The MySQL DATE type has the format YYYY-MM-DD, so for example today (or at least when I’m writing this post) would be 2011-08-19.

The MySQL DATETIME type has the format YYYY-MM-DD HH:ii:SS, so if it’s 9:36am and 53 seconds into the 19th of August 2011, that would be 2011-08-19 09:36:53.

The formatting of the numbers (i.e. the sequence of digits) is super important, but the dashes and colons are optional. This means that when you’re creating a PHP object to represent a DATE or DATETIME, you could create an object which contains 2011-08-19 or 20110819 etc. and MySQL would accept them as the exact same thing.

Constructing a suitable object in PHP

To create our PHP object, we’re going to use the PHP date and mktime functions. For this example I’m just going to create some variables which hold any date or time values, but in the real world you’d probably get them from a dropdown menu or calendar control.

<?PHP
	// Create variables to store 1:15pm and 28 seconds on the 20th of August 2011
	// NOTE: If you don't enclose your values with apostrophes or quotes, then things will go wrong because
	// single digit values need the leading zeroes, for example the 08 below will turn into 8, and then
	// the whole thing's broken. See the bottom of this post for an alternative padding method for numbers.
	$theYear   = '2011'; // YYYY
	$theMonth  = '08';   // MM
	$theDay    = '20';   // DD
	$theHour   = '13';   // HH
	$theMinute = '15';   // ii
	$theSecond = '28';   // SS
 
	// Create an object suitable for insertion into a MySQL DATE field
	// The date 'YmD' parameters mean: year as YYYY, month as MM w/ leading zeroes, day as DD w/ leading zeroes
	// Full PHP date parameters can be found at: http://php.net/manual/en/function.date.php
	// The format of mktime is: hour, minute, second, month, day, year
	// Full PHP mktime parameters can be found at: http://php.net/manual/en/function.mktime.php
	$sqlDate = date('Ymd', mktime(0, 0, 0, $theMonth, $theDay, $theYear));
 
	// Create an object suitable for insertion into a MySQL DATETIME field
	// The date 'YmdHis' means: Ymd as above, hours as HH w/ leading zeroes, minutes as ii w/ leading zeroes, ss as seconds w/ leading zeroes
	$sqlDateTime = date('YmdHis', mktime($theHour, $theMinute, $theSecond, $theMonth, $theDay, $theYear));
 
	// Now you've got your DATE or DATETIME object, sling 'em in your database with something like this...
	$dbConn = mysql_connect("localhost", "root", "") or die("It is a good day to die!: " . mysql_error()); // Default WAMP settings
 
	// Choose the database to work with
	mysql_select_db("MyLovelyDatabase", $dbConn) or die("It is a good day to fail to connect to your DB!: " . mysql_error());
 
	// Create the insert statement
	$sqlStatement = "INSERT INTO TestTable (someDate, someDateTime) VALUES ('$sqlDate', '$sqlDateTime')";
 
	// Execute the statement
	$result = mysql_query($sqlStatement, $dbConn);
 
	// Display result of the statement. If this is 1 then the insertion was successful, otherwise it wasn't
	echo "Statement executed and gave the following result: " . $result;
 
	// Shut down the connection to the database
	mysql_close($dbConn);
?>

Which when we then take a look at the database shows us:

DateTime Database Record

Result!

Automatically padding out numerical data with leading zeroes

If you need to work directly with numerical data (as opposed to strings), then you can use the following function (written by matrebatre over on the str_pad page) to pad out your data:

<?PHP
	function padNumber($theNumber, $numDigits)
	{
		// str_pad format: value, desired number of characters, what to pad with, where to place the padding
		return str_pad((int) $theNumber, $numDigits, "0", STR_PAD_LEFT);
	}
 
	$value = 5;
	$paddedValue = padNumber($value, 1); echo $paddedValue . "<br/>"; // 5
	$paddedValue = padNumber($value, 2); echo $paddedValue . "<br/>"; // 05
	$paddedValue = padNumber($value, 3); echo $paddedValue . "<br/>"; // 005
?>

Done & dusted.

Comments
No Comments »
Categories
Coding
Tags
DATE, DATETIME, DBMS, MySQL, Object, PHP, SQL, TIMESTAMP
Comments rss Comments rss
Trackback Trackback

Bruno Mars – The Lazy Song

r3dux | August 19, 2011

I’m not a big fan of this song, but my wife put me on to it because she knows I’ve got a lot of time for Leonard Nimoy – and fair play, the video made me laugh, so maybe you’ll like it too =D

YouTube Preview Image

Cool by association…

Comments
No Comments »
Categories
Humour, Music
Tags
Bruno Mars, Cool by association, Leonard Nimoy, The Lazy Song
Comments rss Comments rss
Trackback Trackback

A new life awaits you on the off-world colonies

r3dux |

The news that Ridley Scott is going to be directing a brand new Blade Runner movie completely blind-sided me this morning, and I’m yet to pick my jaw up off the floor. I love Blade Runner – it’s my favourite film of all time, and I’m sure I must have watched it like 20 times. I loved the Philip K. Dick book, I really enjoyed the K. W. Jeter extensions, I finished the PC adventure game multiple times so I could see all the different endings… So yeah, bit of a fan, then. To find out they’re making a new movie, and that Ridley Scott’s at the helm has officially just made my year =D

If you don’t know what you’re missing, check out the Blade Runner Final Cut (2007) trailer below:

YouTube Preview Image

Surely more of this has got to be A Good Thing =D

P.S. If you like the music in the trailer, it’s Death is the Road to Awe by Clint Mansell.

Comments
No Comments »
Categories
Imagery, Literature
Tags
Blade Runner, Film, Movie, Replicant, Ridley Scott
Comments rss Comments rss
Trackback Trackback

« Previous Entries Next Entries »

Translate

Categories

Archives

Tags

3D ActionScript ActionScript 3.0 Adobe AI Ballarat Bash C++ Class Convert CS4 Effect Error Film Flash GLSL Gnome Hack How-To install Jaunty Java Kinect Linkage Linux Mash-Up Microsoft Motion OpenGL Particle Problem PS3 Remix Retro script Slides Sound Systems Texture Ubuntu Video VirtualBox Wii Windows XBox

Gamercard

OpenR3dux

Misc.

Flattr this

RSS Feed

r3dux twitter feed



“Prepare not the path for the child; prepare the child for the path.”

rss Comments rss valid xhtml 1.1 design by jide powered by Wordpress get firefox