Skip to content

Instantly share code, notes, and snippets.

Hazel Fidecaro hipsterjazzbo

Block or report user

Report or block hipsterjazzbo

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View Collection::group_by().php
<?php
public static function group_by(Array $objects, $group_by_property)
{
$grouped_objects = [];
foreach($objects as $object)
{
$property_value = $object->{$group_by_property};
View deploy.sh
#!/bin/bash
# Fergus Staging Deploy Script
# Update git to staging
cd /var/www/fergus_internal_demo;
#!/bin/bash
function bgtext {
echo -e $(tput setab 24)" $1"$(tput sgr0);
View gist:b33d14ad9ff8970cd632
<?php
//TODO get URL from parameters and authenticate it with an expiring hash/timestamp
$url = 'http://traffic.libsyn.com/atpfm/atp95.mp3';
// Forward these headers from original request
$requestHeaders = [];
if (isset($_SERVER['HTTP_USER_AGENT'])) $requestHeaders[] = 'User-Agent: ' . $_SERVER['HTTP_USER_AGENT'];
if (isset($_SERVER['HTTP_RANGE'])) $requestHeaders[] = 'Range: ' . $_SERVER['HTTP_RANGE'];
View gist:e9e4ee4f8cab765c0638
<?php
$myStarSign = "Gemini";
if ($myStarSign == "Taurus") {
echo "Me too!";
} elseif ($mystarsign == "nah") {
echo "your dumb!";
} else {
echo "Too bad so sad...";
View gist:54e06d4ef79c61f2a19b
<?php
/**
* Pass in a number and get it back as a string with an ordinal suffix (1 -> 1st, 2 -> 2nd etc)
*/
function addSuffix($number)
{
if ($number == 1) {
return $number + 'st';
} elseif ($number == 2) {
View gist:e033f437d81d25cb9265
<?php
// One means "Assign this value to this variable"
$number = 1; // This one is an integer (whole number)
$anotherNumber = "1"; // This one is a string
// Two means "Are these the same value?"
if ($number == $anotherNumber) {
// This will be true
}
@hipsterjazzbo
hipsterjazzbo / ajax.php
Created Mar 16, 2011
A CodeIgniter controller to enable dynamic AJAX access to models from views.
View ajax.php
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Ajax extends CI_Controller {
function __construct()
{
parent::__construct();
}
/**
View tweets.php
<?php
$query = 'weekendhacker';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://search.twitter.com/search.json?q=$query");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$json = curl_exec($ch);
$tweets = json_decode($json);
@hipsterjazzbo
hipsterjazzbo / is_cached
Created Jul 28, 2011
Check is client is cached in the DB
View is_cached
public function is_cached($client_id)
{
$query = $this->db->select('id')->where('client_id', $client_id)->get('clients');
if($query->num_rows() == 0) {
return false;
}
return true;
}
View less-sucky.php
<?php
// option 1
$config['admin']['example'] = array(
'table' => 'tbl_example',
'name' => 'Example',
'fields' => array(
'field_1' => 'Field 1 Title',
'field_2' => 'Field 2 Title',
'field_3' => 'Field 3 Title'
You can’t perform that action at this time.