Skip to content

Instantly share code, notes, and snippets.

View JeffreyWay's full-sized avatar

Jeffrey Way JeffreyWay

View GitHub Profile
@JeffreyWay
JeffreyWay / example.feature
Created April 27, 2014 21:58
Quick scenario example. Think from the point of view of the benefactor.
Given I have an account
When I reset my password
Then I should receive an email with password reset instructions
<?php
/**
* @Get("/")
*/
public function home() {
return 'home page';
}
<?php
/**
* @Middleware("auth")
*/
class Admin {
// ...
}
return gists.map(function(gist) {
return newGist(gist);
});
// Becomes:
return gists.map(gist => newGist(gist))
<?php
require 'Envato_marketplaces.php';
$Envato = new Envato_marketplaces();
$c = $Envato->collection(877517); // replace with collection id (see url on collection page)
foreach($c as $item) : ?>
<li>
<a href="<?php echo $item->url . '?ref=yourUsername';?>">
<?php echo $item->item; ?>
@JeffreyWay
JeffreyWay / slimtohtml
Created September 7, 2011 19:06
Using Slim in Simple PSD -> HTML Type Projects
# This assumes that you've installed and are familiar with Slim: http://slim-lang.com/
# Open ~/.bash_profile (if you're a Mac user), and add the following function.
function slimtohtml() {
slimrb -p $@.slim > $@.html
}
# Save it, restart Terminal (or: source ~/.bash_profile), and convert.
# The following line will look for a file called test.slim in the root of your directory, convert it, and save as test.html
slimtohtml test
<?php
$someVar = 'some value';
add_action('admin_init', function() {
# I want access to $someVar in here, and don't want it to be a global.
# Is there a way to pass $someVar into the callback as a local variable?
});
@JeffreyWay
JeffreyWay / gist:1268154
Created October 6, 2011 18:12
Lookups instead of Switch
<?php
# Instead of
$name = 'Jeff';
switch ($name) {
case 'Jeff':
echo "I'm Jeff";
break;
case 'Joe':
// Bad
$('a').click(function() {
$(this).hide();
$(this).css('color', 'red');
$(this).show();
alert('something else');
$(this).hide();