Skip to content

Instantly share code, notes, and snippets.

View adampatterson's full-sized avatar
:octocat:

Adam Patterson adampatterson

:octocat:
View GitHub Profile
@adampatterson
adampatterson / routes-and-controllers.php
Created October 11, 2016 20:41
Laravel controllers with
<?
/*
I am using route caching that prevents me from using closures, but even then I don't see why I can't choose to pass static information to a controller without using route parameters.
For example, My project has an umber of redirects in it, and rather than loading up 40 domains with redirect DNS entries that only I have access to.
I have a helper controller to do this so that my team may make entries.
I am running 40 unique sites out of one Laravel instance to keep my maintenance low. 40 sites x about 25 redirects is a lot of DNS entries.
*/
gulp.task('cacheBuster', function(cb){
//new Date().getTime()
fs.writeFile('config/cacheBuster.php', '<?php return ' + new Date().getTime() + ';', cb);
});
@adampatterson
adampatterson / Handler.php
Last active April 23, 2019 12:36
Laravel 5.2 custom 500 error page
# /app/Exceptions/Handler.php
# use Symfony\Component\Debug\Exception\FlattenException;
# public function render($request, Exception $e)
$exception = FlattenException::create($e);
$statusCode = $exception->getStatusCode($exception);
if ($statusCode === 404 or $statusCode === 500 and app()->environment() == 'production') {
$this->app['request']->server->set('HTTPS', $this->app->environment() != 'local');
@adampatterson
adampatterson / Console Log ACF
Last active February 24, 2016 05:15
Working with ACF Custom data
<? $data = get_fields();?>
<script>
console.log(<?= json_encode($data) ?>)
</script>
<IfModule mod_mime.c>
# Audio
AddType audio/mp4 m4a f4a f4b
AddType audio/ogg oga ogg
# JavaScript
# Normalize to standard type (it's sniffed in IE anyways):
# http://tools.ietf.org/html/rfc4329#section-7.2
AddType application/javascript js
(function($) {
var o = $( {} );
$.each({
trigger: 'publish',
on: 'subscribe',
off: 'unsubscribe'
}, function( key, val ) {
jQuery[val] = function() {
o[key].apply( o, arguments );
<?
if ( have_posts() ):
echo '<!-- '.$post->post_name.'-->';
if ( is_front_page() ):
get_template_part('templates/content', 'home');
else:
if ( file_exists(get_template_directory().'/templates/content-'.$post->post_name.'.php'))
get_template_part('templates/content', $post->post_name);
else
get_template_part('templates/content', 'page');

Contract Killer

The popular open-source contract for web designers and developers by Stuff & Nonsense

  • Originally published: 23/12/2008
  • Revised date: 15/12/2013
  • Original post

-- Create syntax for TABLE 'extension'
CREATE TABLE `extension` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`extension_name` text NOT NULL,
`extension_slug` varchar(200) NOT NULL,
`extension_type` text NOT NULL,
`repo_name` varchar(200) DEFAULT NULL,
`revision` int(11) DEFAULT '0',
`count` int(11) DEFAULT NULL,
`description` longtext,