Skip to content

Instantly share code, notes, and snippets.

Jamie York ziadoz

View GitHub Profile
@ziadoz
ziadoz / composer.json
Created Aug 29, 2012
Advanced Composer Examples (PHPMailer from zip, local repository)
View composer.json
{
"require": {
"phpmailer/phpmailer": "5.2.1"
},
"repositories": [
{
"type": "package",
"package": {
"name": "phpmailer/phpmailer",
"version": "5.2.1",
@ziadoz
ziadoz / .bash_profile
Last active Oct 9, 2015
Web Development Setup (Bash, SSH, Ruby)
View .bash_profile
# Bash Profile
# File: ~/.bash_profile
# Set $WEB_DIR and $SCRIPTS_DIR to the appropriate directories.
export PATH="./vendor/bin:$PATH"
export EDITOR=nano
export WEB_DIR="/var/www/vhosts"
export SCRIPTS_DIR="~/.web"
@ziadoz
ziadoz / FooController.php
Created Sep 5, 2012 — forked from igorw/FooController.php
Silex convention-based controllers
View FooController.php
<?php
// src/Foobar/Controller/FooController.php
namespace Foobar\Controller;
class FooController
{
public function helloAction($request)
{
@ziadoz
ziadoz / mobile.js
Created Sep 10, 2012
jQuery Mobile User Agent Detection
View mobile.js
$.extend({
isMobile: function() {
return navigator.userAgent.match(/Android|webOS|iPhone|iPod|iPad|BlackBerry/i) !== null;
}
});
@ziadoz
ziadoz / gist:3692801
Created Sep 10, 2012
Bash Users with Different Primary Group
View gist:3692801
sudo useradd -m -d /home/<username> -s /bin/bash -k /etc/skel -g <primarygroup> -G sudo <username>
sudo passwd <username>
sudo deluser <username>
chsh -s /bin/bash <username>
@ziadoz
ziadoz / chromcast-bgs.js
Last active Oct 12, 2015
Download Google ChromeCast Backgrounds with CasperJS
View chromcast-bgs.js
/**
* Command: casperjs chomecast-bgs.js [DIR] [START] [END]
* Examples: casperjs chomecast-bgs.js ~/Downloads/Chromecast
* casperjs chomecast-bgs.js ~/Downloads/Chromecast 25
* casperjs chomecast-bgs.js ~/Downloads/Chromecast 25 35
*
* Note: [DIR] (Required) The directory to download. This must exist, it won't be created.
* [START] (Optional) Start is the image number to start from, incase the script fails and needs to be restarted.
* [END] (Optional) End is the image number to finish at, if you only want a specific range of images.
*/
@ziadoz
ziadoz / fizzbuzz.php
Last active Dec 10, 2015
The Fizz Buzz problem solved in PHP.
View fizzbuzz.php
<?php
// http://content.codersdojo.org/code-kata-catalogue/fizz-buzz/
foreach (range(1, 100) as $i) {
$x = '';
$x .= ($i % 3 === 0 ? 'Fizz' : '');
$x .= ($i % 5 === 0 ? 'Buzz' : '');
echo $i . ' ' . (empty($x) ? $i : $x) . "\n";
}
@ziadoz
ziadoz / index.html
Last active Dec 10, 2015
HTML5 Webcam / CSS3 Image Filter Experiment
View index.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Image from Webcam</title>
<style type="text/css">
video { display: block; margin: 0 auto; border: 10px solid #ccc; }
.button { margin: 10px auto; padding: 10px; background: #ccc; color: white; text-align: center; width: 200px; cursor: pointer; }
#container,
@ziadoz
ziadoz / checklist.class.php
Last active Dec 11, 2015
Perch Checkbox List Field Type
View checklist.class.php
<?php
/**
* Checklist Field Type.
*
* File: PERCH_PATH/addons/fieldtypes/checklist/checklist.class.php
* Usage: <perch:content id="features" type="checklist" label="Features" options="Feature 1, Feature 2, Feature 3" />
* @author Jamie York
**/
class PerchFieldType_checklist extends PerchAPI_FieldType
{
@ziadoz
ziadoz / ternary.php
Last active Dec 11, 2015
PHP Ternary (Left/Right Associative)
View ternary.php
#!/usr/bin/env php
<?php
// Left associative ternary.
// Output: T
echo (true ? 'True' : false ? 'T' : 'F') . "\n";
// This is essentially the same as above.
// Output: T
echo ((true ? 'True' : false) ? 'T' : 'F') . "\n";
You can’t perform that action at this time.