Skip to content

Instantly share code, notes, and snippets.

View stevelacey's full-sized avatar
🚀
Shipping

Steve Lacey stevelacey

🚀
Shipping
View GitHub Profile
@stevelacey
stevelacey / robot.js
Created December 3, 2012 18:51
SteveBot
//FightCode can only understand your robot
//if its class is called Robot
var Robot = function(robot) {
};
Robot.prototype.onIdle = function(ev) {
var robot = ev.robot;
robot.ahead(100);
<?php
namespace Application\BaseBundle\Doctrine\Listener;
use Doctrine\ORM\Event\LoadClassMetadataEventArgs;
class InheritanceMapping
{
protected $mappings;
@stevelacey
stevelacey / .htaccess
Created January 9, 2013 17:27
WordPress 8==> Symfony2
# web/blog/.htaccess (wordpress core resides in web/blog/wordpress)
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /blog/
# Redirect wordpress dir
RewriteRule ^wordpress/?$ . [R=301,L]
@stevelacey
stevelacey / CatalogParamConverter.php
Created March 7, 2013 10:59
/** * @route("/{permalink}", name="category", requirements={"permalink": ".+"}) */
<?php
namespace WiredMedia\CatalogBundle\Request\ParamConverter;
use Sensio\Bundle\FrameworkExtraBundle\Request\ParamConverter\DoctrineParamConverter;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\ConfigurationInterface;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use Symfony\Component\HttpFoundation\Request;
use Doctrine\Common\Persistence\ManagerRegistry;
@stevelacey
stevelacey / spamhaus.php
Created June 27, 2013 10:53
Spamhaus checker
<?php
$linode = array('server-name' => '1.2.3.4');
$rackspace = array('server-name' => '1.2.3.4');
foreach (array('linode' => $linode, 'rackspace' => $rackspace) as $stack => $servers) {
foreach ($servers as $server => $ip) {
$data = file_get_contents(sprintf('http://www.spamhaus.org/query/ip/%s', $ip));
echo sprintf('%s (%s) - %s', $server, $stack, $ip), PHP_EOL;
@stevelacey
stevelacey / deploy.rb
Last active December 20, 2015 23:08
WordPress Capistrano deploy.rb
# Project
set :application, "ProjectName"
set :repository, "git@github.com:changeme/#{application}.git"
set :db_dev, "database_name_dev"
# Tasks
## Standard
<?php
class Post extends \WPUF_Add_Post {
function __construct() {
remove_shortcode('wpuf_addpost');
add_shortcode('wpuf_addpost', array($this, 'shortcode'));
}
function post_form($post_type) {
$reflection = new \ReflectionMethod('WPUF_Add_Post', 'post_form');
@stevelacey
stevelacey / survey-completion.js
Last active May 10, 2024 15:02
JS automation of survey completion (with weighting)
function blam(sentiment) {
var sentiment = sentiment || null;
$('input:text, textarea').each(function() {
$(this).val('Generic ' + sentiment + '\'ve input!');
});
$('.question:contains("Email") input:text').val('fake@simpleweb.co.uk');
$('.date-picker').val('October 08, 2014');
{
"auto_complete_commit_on_tab": true,
"color_scheme": "Packages/RailsCasts Colour Scheme/RailsCastsColorScheme.tmTheme",
"detect_slow_plugins": false,
"dictionary": "Packages/Language - English/en_GB.dic",
"draw_minimap_border": true,
"ensure_newline_at_eof_on_save": true,
"file_exclude_patterns":
[
"._*",
@stevelacey
stevelacey / deploy.rb
Created March 27, 2014 16:10
Capistrano 3 tasks for pushing/pulling a Postgres db
set :user, "my-ssh-user"
set :db, YAML::load(IO.read("config/database.yml")) # assumes rails
namespace :db do
desc "Push database"
task :push do
run_locally do
db = fetch(:db)
env = fetch(:rails_env)
server = fetch(:server)