Skip to content

Instantly share code, notes, and snippets.

View m4tthumphrey's full-sized avatar
🏂
Working...

Matt Humphrey m4tthumphrey

🏂
Working...
View GitHub Profile
<?php
date_default_timezone_set('Europe/London');
$dayInterval = new DateInterval('P1D');
$startDate = new DateTime('2013-07-01');
$duration = null;
if (isset($_GET['duration'])) {
$duration = $_GET['duration'];
<?php
set_time_limit(0);
$fields = array(
'id',
'name',
'first_name',
'middle_name',
'last_name',
# Backup and Swap Files
.*.sw?
*.bak
*~
# Komodo
*.komodoproject
.komodotools
# PHPStorm
@m4tthumphrey
m4tthumphrey / Config.php
Created April 23, 2013 13:37
One of the worst parts of Magento. Truly hilarious. It checks that a URL returns the string 'MAGENTO' and nothing else as a way to check that it has been installed to the correct place. Impossible to test.
<?php
protected function _checkUrl($url, $secure = false)
{
$prefix = $secure ? 'install/wizard/checkSecureHost/' : 'install/wizard/checkHost/';
try {
$client = new Varien_Http_Client($url . 'index.php/' . $prefix);
$response = $client->request('GET');
/* @var $responce Zend_Http_Response */
$body = $response->getBody();
#!/usr/bin/env bash
apt-get -y update
apt-get -y install build-essential zlib1g-dev libssl-dev libreadline6-dev libyaml-dev
cd /tmp
wget ftp://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.3-p392.tar.gz
tar -xvzf ruby-1.9.3-p392.tar.gz
cd ruby-1.9.3-p392/
./configure --prefix=/usr/local
make
make install
var a = [];
function addPart(part) {
someFunction('blah', function(var) {
alert(a.length); // correct value: 0, 1, 2
a.push(part);
});
}
function init()
{
class Product < ActiveRecord::Base
belongs_to :company
has_many :features,
:class_name => 'ProductFeature',
:source => :product_feature,
:include => :feature
attr_accessible :description,
:name,
class Feature < ActiveRecord::Base
has_many :product_features
has_many :products, :through => :product_features
attr_accessible :name
end
class PermittedParams < Struct.new(:params, :user)
def topic
params.require(:topic).permit(*topic_attributes)
end
def topic_attributes
[:name].tap do |attributes|
attributes << :sticky if user && user.admin?
attributes << {posts_attributes: {:"0" => post_attributes}}
end
@m4tthumphrey
m4tthumphrey / error
Last active December 10, 2015 12:28
Exception
NoMethodError
Error
undefined method `id' for nil:NilClass
/home/gitlab/gitlab/app/models/project.rb:104:in `find_with_namespace'
/home/gitlab/gitlab/app/workers/post_receive.rb:9:in `perform'