Skip to content

Instantly share code, notes, and snippets.

@domdoescode
domdoescode / mobile.php
Created November 12, 2012 13:31
Stupidly basic mobile detection =\
<?php
$mobileType = new stdClass();
//Detect special conditions devices
$mobileType->iPod = stripos($_SERVER['HTTP_USER_AGENT'],"iPod");
$mobileType->iPhone = stripos($_SERVER['HTTP_USER_AGENT'],"iPhone");
$mobileType->iPad = stripos($_SERVER['HTTP_USER_AGENT'],"iPad");
if(stripos($_SERVER['HTTP_USER_AGENT'],"Android") && stripos($_SERVER['HTTP_USER_AGENT'],"mobile")) {
$mobileType->android = true;
} elseif (stripos($_SERVER['HTTP_USER_AGENT'],"Android")){
$mobileType->android = false;
var stylus = require('stylus')
, nib = require('nib')
, uglify = require('uglifyjs')
function processStylus(input, cb) {
fs.readFile(input.src, function (err, data) {
if (err) return cb(err)
@domdoescode
domdoescode / AbstractRememberMeServices.php
Created June 18, 2012 12:10
Changes to Remember Me service for Symfony 2.0.7, dealing with multiple authentication providers
<?php
namespace Symfony\Component\Security\Http\RememberMe;
use Symfony\Component\Security\Core\Exception\AuthenticationException;
use Symfony\Component\Security\Core\User\UserInterface;
use Symfony\Component\Security\Core\Authentication\Token\RememberMeToken;
use Symfony\Component\Security\Http\Logout\LogoutHandlerInterface;
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
use Symfony\Component\Security\Core\Exception\UnsupportedUserException;
@domdoescode
domdoescode / gist:2703752
Created May 15, 2012 17:59
Re-installing ElasticSearch on Ubuntu 10.04
cd ~
sudo rm -Rf /usr/local/share/elasticsearch
sudo /usr/local/share/elasticsearch/bin/service/elasticsearch remove
sudo rm /usr/local/bin/rcelasticsearch
wget https://github.com/downloads/elasticsearch/elasticsearch/elasticsearch-0.19.3.tar.gz -O elasticsearch.tar.gz
tar -xf elasticsearch.tar.gz
rm elasticsearch.tar.gz
sudo mv elasticsearch-* elasticsearch
sudo mv elasticsearch /usr/local/share
@domdoescode
domdoescode / symfony2-git-boilerplate.sh
Created May 30, 2011 21:21
Creating a Symfony2 project, git init, and adding html5-boilerplate default awesome (in twig format)
#!/bin/bash
SYMFONY="Symfony_Standard_Vendors_2.0.0BETA3.tgz"
APPLICATION_ROOT="/var/www"
REMOTE_IP="127.0.0.1"
DB_HOST="localhost"
DB_DRIVER="pdo_pgsql"
DB_USER="test"
DB_PASSWORD="test"
echo "Please enter the company name and project name (in the format CompanyName ProjectName)"