Skip to content

Instantly share code, notes, and snippets.

View crittermike's full-sized avatar

Mike Crittenden crittermike

View GitHub Profile
@crittermike
crittermike / block.sh
Created July 19, 2017 14:07
Block IP address via IPTABLE (works on Digital Ocean)
sudo iptables -A INPUT -s [IPADDRESSHERE] -j DROP
@crittermike
crittermike / gist:7734b582324a4fb4ea4b6098b838e31e
Created July 17, 2017 19:12
Create a weird scrolling navigation thing with Slick slider for jQuery
// Note that this is strange and horrible, but it works.
jQuery('.slick-slider-2').on('init', function(event, slick) {
jQuery(this).find('.slick-dots li:eq(0)').addClass('asg-slick-active');
jQuery(this).find('.slick-dots li:eq(1)').addClass('asg-slick-active-next');
jQuery(this).find('.slick-dots li:first-child').before('<li class="asg-slick-active-prev"></li>');
jQuery(this).find('.slick-dots li:last-child').after('<li></li>');
});
jQuery(".slick-slider-2").slick({
@crittermike
crittermike / container.sh
Created June 30, 2017 18:08
Opening shell/cli prompts inside containers with Outrigger
# Open the actual running container
docker exec -it PROJECTNAME_local_www sh
# Run the command in a throwaway container
docker-compose -f build.yml run --rm cli
@crittermike
crittermike / settings.common.php
Last active June 28, 2017 15:17
Disable caching for local Drupal 8 development
<?php
$settings['container_yamls'][] = DRUPAL_ROOT . '/sites/development.services.yml';
$settings['cache']['bins']['render'] = 'cache.backend.null';
$settings['cache']['bins']['dynamic_page_cache'] = 'cache.backend.null';
@crittermike
crittermike / import.php
Last active April 15, 2025 18:49
Importing Drupal 8 config programmatically
<?php
// Import arbitrary config from a variable.
// Assumes $data has the data you want to import for this config.
$config = \Drupal::service('config.factory')->getEditable('filter.format.basic_html');
$config->setData($data)->save();
// Or, re-import the default config for a module or profile, etc.
\Drupal::service('config.installer')->installDefaultConfig('module', 'my_custom_module');
@crittermike
crittermike / docker-compose.yml
Last active July 11, 2018 10:22
Simple docker-compose.yml for Grav CMS. Put this in the Grav root and run `docker-compose up`.
version: '3.1'
services:
www:
container_name: gravtest_www
image: outrigger/apache-php:php71
network_mode: "bridge"
environment:
DOCROOT: /var/www
volumes:
@crittermike
crittermike / docker-compose.yml
Created June 6, 2017 16:24
Examples of volumes in docker-compose.yml
volumes:
# Just specify a path and let the Engine create a volume
- /var/lib/mysql
# Specify an absolute path mapping
- /opt/data:/var/lib/mysql
# Path on the host, relative to the Compose file
- ./cache:/tmp/cache
@crittermike
crittermike / context.php
Created June 2, 2017 18:14
(Drupal 7) List blocks being rendered by the Context module into a given region
<?php
// Grab an instance of the "Block Reaction" plugin.
$context_reaction = context_get_plugin('reaction', 'block');
// Run the block_list() function to find the blocks being rendered
// into the region you specify.
$context_blocks = $context_reaction->block_list('REGIONNAME');
// Now make sure that we reset the static cache for the block list in case
@crittermike
crittermike / text.md
Last active May 30, 2017 13:12
Description of hardware vs. operating system vs. applications from the book "Show Stopper!" by G. Zachary

Picture a wealthy English household in the early 1900s. Think of a computer—the hardware—as a big house, the family’s residence. The house consists of plumbing and lighting, bricks and mortar, windows and doors—all manner of physical things and processes.

Next, imagine computer software as the people in the house. The household staff, living downstairs, provide a whole range of services at once. The butler stands by the door, the driver washes the car, the housekeeper presses the linen, the cook provides meals and bakes cakes, the gardener rakes the leaves from the lawn. And this activity, which seemingly happens of its own accord, is coordinated by the head of the household staff. Such is the life of the downstairs dwellers, who in a certain sense exist in the background.

Then consider the people upstairs. They are the whole reason for the toil of the people downstairs. The husband desires a driver not simply for peace of mind but because he wishes to travel. The wife employs a cook, so her family

<div id="widget-container"></div>
<script type="text/javascript">
// First grab the `view` param from the query string, if it exists
var reg = new RegExp( '[?&]' + 'view' + '=([^&#]*)', 'i' );
var paramSearch = reg.exec(window.location.search);
var param = paramSearch ? paramSearch[1] : '';
// Then build the JS file
var js = document.createElement("script");