Friday, August 2, 2013

LESS Mixins!

I find that I often use LESS  If you do front end web development, and don't use LESS you are missing out.  In short, it let's you nest CSS, create CSS functions, gives you CSS variables, and do math in your CSS (and much more).

It can turn this:
Into this:

Now, that might not look great right now, but it will save you time in the long run. I will probably write a post at a later point about the magic of LESS, however for now, I figured I'd just post a few of my favorite mixins (think of them like functions) that I use on the daily.

As I do more, I'll add them , just look for the LESS tags

Thursday, August 1, 2013

Killing X11 in linux

Recently my father in law bought me a Raspberry Pi for my birthday, super sweet!  I've always tooled around with linux, however never got serious about it.  As I started playing with it, I found that using the default OS (the NOOBS) was slowing me down and I just wanted a command line.  I have 2 options at this point

  1. SSH
  2. Kill window manager, and just get to the command line.
I opted for #2.  However how the hell do you do that without restarting (you know, cause I'm lazy) I figure you start it by saying 'startx' perhaps you kill it by 'stopx'.  No dice.  I went on and tried some other things, none of which worked.  Eventually I consulted my linux friend and he told me to try hitting 'ctrl+alt+F1'  Sure enough, that killed it and there I am on just the command line!

TL;DR:  
startx - starts X11
'ctrl+alt+F1' - kills X11

Long time no post....

So I've realized I don't really post here that much... That's fine, I don't have much to say.  However I'm going to try to post more of my "Gee how do I do X... oh like this, great" moments here.  Hopefully they help others.

Tuesday, February 5, 2013

PHP 5.4, Memcached and Windows 7


Recently I was asked to get memcached working with PHP 5.4.8 on my Windows 7 64 bit machine at work, took a while and some looking around, but I was able to get it working successfully.  Below are the steps which I took to get it to work.  Hopefully this helps someone else in the future.

Assumptions:

  1. You have apache, php 5.4 installed.  my directories are as follows:
    c:\etc\php
    c:\etc\apache
  2. You are an admin on your machine... If you aren't get access.
  3. I'm using Windows 7, 64 bit
  4. In reading this you realize that this is what has worked for ME, I can't promise that it will work for you, nor do I take any responsibility for any of the files below.  They didn't break my machine, but who knows what they will do to yours. Use at your own risk
Let's get down to business! 
  1. Download this http://code.jellycan.com/files/memcached-1.2.6-win32-bin.zip
  2. Unzip here: c:/etc/memcahced
  3. Right click ->; properties ->; compatibility ->; run as admin
  4. Go to command line:
    c:\etc\memcached\memcached.exe –d install
  5. If window throws an error saying that it is missing or can not find "MSVCR71.dll" do the following, else go to #6
    1. Download this: http://www.box.net/shared/jn252o074v
    2. Copy file to c:\windows\system32
    3. Try #4, if it works, great go to #6, 
    4. Didn’t work huh? Ok, move file to c:\windows\system and try again.
    5. Still didn't work? I've heard going placing in C:\windows\sysWOW64 works... but I haven't tried that.
  6. Go to services.msc, start service (find where it says memcached, right click and hit 'start')
  7. Confirm everything is proper by going to regedit and making sure you have this:
    HKEY_LOCAL_MACHINE/SYSTEM/CurrentControlSet/Services/memcached
    to access regedit open a run window and type 'regedit'
  8. Raise memory limit (if you want):
    c:\etc\memcached\memcached.exe –d runservice –m 512
  9. Download PHP .dll (now as I've said earlier, this is only for php 5.4): http://windows.php.net/downloads/pecl/releases/memcache/3.0.6/php_memcache-3.0.6-5.4-ts-vc9-x86.zip
  10. Unzip contents to c:\etc\php\ext
  11. Add the following to php.ini
    extension=php_memcache.dll
  12. Restart server
  13. Add this to a test page:
//Create a new instance of memCached
$memcache = new Memcache;

//Of course you can use "localhost" instead of the IP if you want
$memcache->connect('127.0.0.1', 11211) or die ("Could not connect");

//Get the version, cause why not
$version = $memcache->getVersion();
echo "Memcache's version: $version
\n";

//Make some object
$tmp_object = (object) null;
$tmp_object->;someString = 'Testing...';
$tmp_object->;someInt = 9083202;

//Get the contents of the memcache
$get_result = $memcache->;get('key');
echo "-- Data currently in the cache:
\n";
var_dump($get_result);

//set the memcache
$memcache->set('key', $tmp_object, false, 15) or die ("Failed to save data at the server");

echo "
\n-- Data is stored in the cache, will expire in 15 seconds
\n";
//Get the contents of the memcache
$get_result = $memcache->;get('key');
echo "-- Data currently in the cache:
\n";
var_dump($get_result) ;


Now, assuming you have no errors, you are good to go!  Hope this helped!