Skip to content

Instantly share code, notes, and snippets.

View motin's full-sized avatar

Motin motin

View GitHub Profile
@motin
motin / install-phundament4-sakila.sh
Last active August 29, 2015 14:07
phundament4-sakila-test
#!/bin/bash
set -x
set -o errexit
if [ ! -d "sakila-db" ]; then
wget http://downloads.mysql.com/docs/sakila-db.tar.gz
tar -xvf sakila-db.tar.gz
fi
@motin
motin / _bootstrap.php
Created July 17, 2014 10:36
Yii unit test _bootstrap for codeception
<?php
$_SERVER['SCRIPT_FILENAME'] = 'index-test.php';
$_SERVER['SCRIPT_NAME'] = '/index-test.php';
$_SERVER['REQUEST_URI'] = 'index-test.php';
// change the following paths if necessary
$yiit=dirname(__FILE__).'/../../../vendor/yiisoft/yii/framework/yiit.php';
require_once($yiit);
$main=require(dirname(__FILE__).'/../../../app/config/main.php');
<?php
/**
* Runs the command.
* @param array $args the command-line arguments.
* @return integer the return code.
* @throws CException if the mysqldump binary cannot be located or if the actual dump fails.
*/
public function run($args)
{
list($action, $options, $args) = $this->resolveRequest($args);
@motin
motin / Identity.php
Last active January 2, 2016 19:28
Example environment bootstrap files for any php project
<?php
namespace neam\envbootstrap;
class Identity
{
static public function brand()
{
@motin
motin / package.json
Created December 4, 2013 10:58
Example casperjs script. Run from cli: casperjs --params='{"url":"http://foobar.com/"}}' theprogram.js
{
"author": "",
"name": "",
"version": "0.0.0",
"dependencies": {
"xtend": "> 0.0.0",
"utils": "> 0.0.0"
},
"devDependencies": {}
}
<?php
class ActiveRecord extends CActiveRecord
{
// Hard code source language to en for now. TODO: Be able to choose and store source language
public $source_language = 'en';
public function behaviors()
{
@motin
motin / Photo.php
Last active December 29, 2015 07:58
<?php
class Photo extends CActiveRecord {
/**
*
* Save a file into multiple formats on S3
* @param unknown_type $filename
* @param unknown_type $id
* @param unknown_type $type
*/
@motin
motin / OwnerBehavior.php
Created November 20, 2013 22:48
Behavior to automate setting the "owned by user" attribute to the currently logged in user id upon creation of a record. Revive of OwnerBehavior from https://github.com/schmunk42/p3extensions/commit/aa990c986fabd4ab5932ee504b593b230238ccac
<?php
// Owner Behavior by thyseus <thyseus@gmail.com>
// Assuming a dataset is "owned" by a user, we need to set the id
// of the current logged in user when saving the dataset automatically.
// Optional, a "last updated by" column can save the user that last updated
// the dataset. The Owner will never be touched.
class OwnerBehavior extends CActiveRecordBehavior {
<?php
use Codeception\Util\Stub;
trait IndexActionTrait
{
public function actionIndex()
{
return "foo";
}
}
@motin
motin / Y18n.php
Last active December 28, 2015 14:29
Simple wrapper to easily use different message sources in Yii
<?php
class Y18n
{
/**
* Wrapper for Yii::t() for static messages
*/
public static function st($category, $message, $params = array(), $source = null, $language = null)
{
$source = 'staticMessages';