Skip to content

Instantly share code, notes, and snippets.

View passion4code's full-sized avatar

Jason Rose passion4code

View GitHub Profile
@passion4code
passion4code / cors.js
Last active November 9, 2015 21:25
actionhero CORS initializer
// initializers/cors.js
"use strict";
var util = require('../lib/utility');
exports.cors = function(api, next){
api.log('CORS Origin Header Control', "debug");
var cors_filter = function(connection, actionTemplate, next){
@passion4code
passion4code / LocaleListener.php
Created March 12, 2014 21:11
Change Symfony's default routing locale reference to use %default_locale%
<?php
namespace Acme\Bundle\AcmeBundle\EventListener;
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
use Symfony\Component\HttpKernel\KernelEvents;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\RequestContextAwareInterface;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
/**
{
"discussion" : {
"comments" : {
"comments" : [
{
"id" : "0001",
"downVotes" : 0,
"upVotes" : 0,
"message" : "Turkey meatloaf capicola tongue shankle. Shankle tongue pork chuck, rump leberkas tenderloin shoulder sirloin beef ribs pastrami salami corned beef.",
"parentCommentId" : null,
@passion4code
passion4code / gist:3790011
Created September 26, 2012 19:24
git - remove merged branches
git branch --merged | grep -v "\*" | xargs -n 1 git branch -d
@passion4code
passion4code / fizzbuzz.php
Created October 11, 2011 15:08
fizzbuzz for php
<?php
for($i=1;$i<=100;$i++){
$mod_3 = $mod_5 = false;
if($i%3 == 0){
echo 'fizz<br>';
$mod_3 = true;
}
if($i%5 == 0){
echo 'buzz<br>';
<?php
public function view($techGuideid = null) { //details page for tech-guide
// $params = array(
// 'conditions' => array(
// 'TechGuideline.id' => $techGuideid,
// //'TechGuideline.is_active' => 1,
// ),
// 'fields' => array('User.first_name', 'User.last_name ', 'Technology.id', 'Technology.title', 'TechGuideline.id', 'TechGuideline.user_id', 'TechGuideline.title', 'TechGuideline.content', 'TechGuideline.created', 'TechGuideline.comments_count'),
// 'joins' => array(
<?php
class TestsController extends AppController{
var $uses = array();
function promises_get(){
if(isset($this->params['named']['auth_token'])) $this->authToken = $this->params['named']['auth_token'];
if(isset($this->params['named']['modified'])){
$this->__send('promises/get',array('modified' => $this->params['named']['modified']));
}elseif($this->params['named']['promise_request_id']){
$this->__send('promises/get',array('promise_request_id' => $this->params['named']['promise_request_id']));
<?php
class Person extends AppModel{
public $hasMany = array('PromiseRequest','PromiseResponse');
public $hasOne = array('PersonInfo');
public function beforeSave(){
//check for accounts with the same info
$found_person = null;
if(isset($this->data['Person']['email'])){
@passion4code
passion4code / css.php
Created May 18, 2011 19:31
CSS File Merge and Caching
<?php
define('DS',DIRECTORY_SEPARATOR);
$base_path = $_SERVER['DOCUMENT_ROOT'].DS.'app'.DS.'webroot'.DS;
$files = array(
<?php
echo ($this->Paginator->sortKey() == 'LessonPlan.favorite_count') ? $this->Paginator->sortKey(): $this->Paginator->sort(__('Favorites',true),'favorite_count',array('direction' => 'desc'));
echo ($this->Paginator->sortKey() == 'LessonPlan.created_at') ? $this->Paginator->sortKey() : $this->Paginator->sort(__('Date',true),'created_at',array('direction' => 'desc'));
//both returns '0'