Skip to content

Instantly share code, notes, and snippets.

@JesseObrien
JesseObrien / gist:2729069
Created May 19, 2012 04:21
One-liner to install sublime on linux
mkdir /home/$USER/sublime2 && curl http://c758482.r82.cf2.rackcdn.com/Sublime%20Text%202%20Build%202181%20x64.tar.bz2 | tar jxv -C /home/$USER/sublime2 && echo "export PATH=\$PATH:/home/\$USER/sublime2/Sublime\ Text\ 2/" >> ~/.bashrc && exit
@JesseObrien
JesseObrien / resque_bootstrap.php
Created December 4, 2012 17:19
Resque bootstrap for Laravel 3
<?php
// Bootstrap the laravel environment for our resque workers.
require 'paths.php';
require path('sys').'core.php';
Laravel\Bundle::start(DEFAULT_BUNDLE);
\Autoloader::directories(array(
path('app').'workers',
@JesseObrien
JesseObrien / resque_worker.sh
Last active October 13, 2015 13:58
Resque worker with Laravel bootstrapper
#!/bin/sh
cd vendor/chrisboulton/php-resque
# Replace MyAppName with whatever you want to name this queue
QUEUE=MyAppName APP_INCLUDE=../../../resque_bootstrap.php ENV=local php resque.php
@JesseObrien
JesseObrien / exampleworker.php
Created December 4, 2012 17:54
Example Resque worker for Laravel
<?php
class ExampleWorker
{
// Resque looks for the "perform" function to "run" the worker, without it the worker won't run
public function perform()
{
// All of your code should go here
// Don't hesitate to split the work into smaller parts
@JesseObrien
JesseObrien / exampletask.php
Created December 4, 2012 18:03
Artisan task to run a job in Resque with Laravel
<?php
class ExampleTask_Task
{
public function run()
{
// You can pass arguments into the worker as payload
$args = array('name' => 'John Smith');
Resque::enqueue('MyAppName', 'ExampleWorker', $args);
echo "Resque job queued.\n";
@JesseObrien
JesseObrien / folders.txt
Last active September 24, 2019 03:48
Example composer package and file structure.
# Package Folder/File Structure
- src/
- PackageName/
- PackageName.php
- PackageClass.php
- PackageLib.php
- Subfolder/
- OtherLib.php
- tests/
- composer.json
@JesseObrien
JesseObrien / OtherLib.php
Last active December 10, 2015 22:08
Describing how to namespace your files properly in composer.
<?php # /src/PackageName/Subfolder/OtherLib.php
namespace PackageName\Subfolder;
class OtherLib
{
}
@JesseObrien
JesseObrien / gist:4499408
Created January 10, 2013 04:15
Example composer.json.
{
"name": "organization/packagename",
"description": "A package for the ages.",
"authors": [
{
"name": "Main Author",
"email": "main.author@example.com"
},
{
"name": "Other Author",
@JesseObrien
JesseObrien / todo.php
Created January 23, 2013 16:25
Basic controller for todo list
<?php
class Todo_Controller extends Base_Controller
{
public $restful = true;
/**
* Show the list of all items
*/
public function get_index()
data:text/html, <style type="text/css">#e{position:absolute;top:0;right:0;bottom:0;left:0;font-size:12pt;}</style><div id="e"></div><script src="http://d1n0x3qji82z53.cloudfront.net/src-min-noconflict/ace.js" type="text/javascript" charset="utf-8"></script><script>var e=ace.edit("e");e.setTheme("ace/theme/solarized_dark");e.getSession().setMode("ace/mode/php");</script>