Skip to content

Instantly share code, notes, and snippets.

View danielcbaldwin's full-sized avatar

Daniel Baldwin danielcbaldwin

View GitHub Profile
#!/usr/bin/env sh
warn() {
echo "$1" >&2
}
die() {
warn "$1"
exit 1
}
@danielcbaldwin
danielcbaldwin / serialize_check.php
Created July 31, 2011 23:33
Function to check if a string is actually serialized data.
/**
* Checks if data is serialized
* @param mixed $data
*/
public function is_serialized($data) {
if (!is_string( $data)) {
return false;
}
$data = trim($data);
<img src="http://lorempixum.com/400/200" alt="" />
@danielcbaldwin
danielcbaldwin / is_mobile.php
Created March 22, 2011 15:27
Piece of code to determine if the client is on a mobile device.
<?php
function is_mobile() {
$mobile_browser = 0;
if(preg_match('/(up.browser|up.link|mmp|symbian|smartphone|midp|wap|phone)/i', strtolower($_SERVER['HTTP_USER_AGENT']))) {
$mobile_browser++;
}
if((strpos(strtolower($_SERVER['HTTP_ACCEPT']),'application/vnd.wap.xhtml+xml')>0) or ((isset($_SERVER['HTTP_X_WAP_PROFILE']) or isset($_SERVER['HTTP_PROFILE'])))) {
$mobile_browser++;
@danielcbaldwin
danielcbaldwin / gist:880041
Created March 21, 2011 19:31
A handy function for PHP that checks if a string is actually something that has been serialized
<?php
/**
* Checks if data is serialized
* @param mixed $data
*/
public function is_serialized($data) {
if (!is_string( $data)) {
return false;
}
<?php phpinfo(); ?>
/**
* Sample jQuery Plugin
*/
(function($) {
function Sample() {};
$.extend(Sample.prototype, {
settings: {
base_url: ''
},
/**
* Sample jQuery Plugin
*/
(function($) {
function Sample() {};
$.extend(Sample.prototype, {
settings: {
base_url: ''
},