This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class Post extends Eloquent | |
{ | |
protected $fillable = array( | |
'title', | |
'slug' | |
); | |
public function setTitleAttribute($value) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SQLSTATE[HY000]: General error: 1 ambiguous column name: id | |
(SQL: select * from "categories" inner join "category_posts" on "categories"."id" = "category_posts"."category_id" where "category_posts"."post_id" = 1 and "id" = 1 limit 1) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM ubuntu:precise | |
# Install all the things! (TODO: Add your favorite text editor here) | |
RUN apt-get update | |
RUN apt-get -y -q install php5-cli sudo php5-curl curl git | |
# Create a user so that everything isn't run as root | |
RUN adduser user; adduser user sudo; passwd -d user | |
# Install composer, and move it to `composer` so it can be used globally |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class RouterThing { | |
/* ... */ | |
function fireController($controllerInstance, $action) { | |
/* ... setup ... */ | |
$before = get_object_vars($controllerInstance); | |
$result = $controllerInstance->$action(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Recursively print out a multidimensional array | |
* prettily. Don't use the `$prefix` parameter. | |
* | |
* @param array $array The array to print | |
* @param string $prefix The prefix (internal) | |
* | |
* @return string The nice tree |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ ./node_modules/.bin/r.js -o name=../node_modules/almond/almond baseUrl=client include=main wrap=true optimize=none out=dist/dist.js | |
Tracing dependencies for: ../node_modules/almond/almond | |
Error: ENOENT, no such file or directory './client/underscore.js' | |
In module tree: | |
main | |
Error: ENOENT, no such file or directory './client/underscore.js' | |
In module tree: | |
main |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*! | |
* Backbone BootstrapForm | |
* Copyright (c) 2012 Clark Fischer <[email protected]> | |
* V0.0.1 | |
* MIT Licensed | |
* | |
* This extension depends on Backbone.FormView.js: | |
* <https://gist.github.com/1831242#file_backbone.form_view.js> | |
*/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
exports.whater = function (req, res) { | |
var format = req.params.format ? req.params.format : req.format; | |
User.findOne({ username: req.params.username }, function (err, doc) { | |
if (err) throw err; | |
if (!doc) { | |
if (format == 'json') { | |
res.json({ error: "no such user"}); | |
} else { | |
res.render('404'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//I copied the hash value exactly from a tracker -- this is a hex | |
//representation of the sha1sum of the info dictionary | |
var bigint = require('bigint'), | |
hash = new Buffer('8ac3731ad4b039c05393b5404afa6e7397810b41', 'hex'), | |
connection_id = new bigint('4497486125440'), | |
buffer = new Buffer(36); | |
/* ( http://www.bittorrent.org/beps/bep_0015.html ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var q = require('q'), | |
guid = 1; | |
function randomDefer() { | |
var defer = q.defer(), id = guid++; | |
console.log("sending %d", id); | |
setTimeout(function () { | |
console.log("resolving %d", id); | |
defer.resolve('hi'); |