Skip to content

Instantly share code, notes, and snippets.

@sn
sn / gist:1336372
Created November 3, 2011 12:24
Detecting Internet Explorer with PHP
<?php
$is_ie = (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') === false)? FALSE : TRUE;
?>
@sn
sn / mio.rb
Created November 4, 2011 09:12 — forked from macournoyer/mio.rb
mio
#!/usr/bin/env ruby
# mio -- minimalist language inspired by Io for your own careful
# and private delectation w/ friends of the the family,
# if you want to.
# usage:
# mio # starts the REPL
# mio mio_on_rails.mio
# (c) macournoyer
module Mio
class Error < RuntimeError
@sn
sn / gist:1352657
Created November 9, 2011 19:32
Subtracting days from todays date in Ruby
# 1209600 is the amount of seconds in 14 days
d = Time.new - 1209600
@sn
sn / gist:1352832
Created November 9, 2011 20:12
Nifty way to see what has changed in your GIT repo
git whatchanged --since="yesterday"
git whatchanged --oneline --since="1 week"
@sn
sn / gist:1574791
Created January 7, 2012 13:51
Creating Heroku app using the Cedar Stack
heroku create <app name> --stack cedar
@sn
sn / gist:1921824
Created February 27, 2012 06:06
Counting lines of code on a POSIX system
wc -l `find . -iname "*.php"`
@sn
sn / gist:2006978
Created March 9, 2012 15:24
Create new product in Mooblr API
<?php
/**
* Add a new product to the system
*
* @param string $sku
* @param float $cost
* @param string $name
* @param string $desc
* @param float $markup
* @param int $categories_id
@sn
sn / gist:2942076
Created June 16, 2012 17:50
Installing PHPUnit with MAMP PRO on OSX
1) Open up the terminal
2) Don't use version of PEAR that came with OS-X, use the one that came with MAMP (/Applications/MAMP/bin/php/php5.3.6/bin/pear)
3) Upgrade PEAR:
/Applications/MAMP/bin/php/php5.3.6/bin/pear channel-update pear.php.net
/Applications/MAMP/bin/php/php5.3.6/bin/pear channel-update upgrade pear
If you receive the following error: `Notice: unserialize(): Error at offset 276 of 1133 bytes in Config.php on line 1050`,
delete the PEAR config file found here: /Applications/MAMP/bin/php/php5.3.6/conf/pear.conf
4) Register the channels:
@sn
sn / gist:5808571
Created June 18, 2013 19:38
Scaling IMG elements proportionally in responsive UI's
img {
width:auto;
max-width:100%;
height:auto;
}
@sn
sn / gist:6bac786fd175f471b64e
Last active August 29, 2015 14:11
Kirby Nginx configuration file for site running on PHP FastCGI
server {
listen 80;
listen [::]:80;
root /var/www/site;
index index.php index.html index.htm;
server_name _;
autoindex on;
access_log off;
# Kirby Specific Directories