Skip to content

Instantly share code, notes, and snippets.

View earthday47's full-sized avatar

Wes Jones earthday47

View GitHub Profile
@earthday47
earthday47 / THEMENAME.theme
Last active September 16, 2022 16:32
Drupal 9 - Collapsible Facets Blocks
<?php
/**
* Implements template_preprocess_block() for facet blocks.
*/
function THEMENAME_preprocess_block__facet_block(&$variables) {
$facet = $variables['content'][0]['#facet'];
if ($facet->getActiveItems()) {
$variables['details_open'] = TRUE;
@earthday47
earthday47 / update_curl.sh
Last active July 17, 2019 15:39 — forked from fideloper/update_curl.sh
Update curl on Ubuntu 14.04
#! /usr/bin/env bash
# Install any build dependencies needed for curl
sudo apt-get build-dep curl
# Get latest (as of Feb 25, 2016) libcurl
mkdir ~/curl
cd ~/curl
wget http://curl.haxx.se/download/curl-7.65.2.tar.bz2
tar -xvjf curl-7.65.2.tar.bz2
{
"workbench.startupEditor": "newUntitledFile",
"workbench.colorTheme": "One Dark Pro",
"workbench.iconTheme": "material-icon-theme",
"window.zoomLevel": 1,
"typescript.check.npmIsInstalled": false,
"editor.tabSize": 2,
"editor.insertSpaces": true,
"editor.acceptSuggestionOnEnter": "smart",
"explorer.confirmDragAndDrop": false,
@earthday47
earthday47 / loch-ness-monster.txt
Created September 27, 2018 13:06
Loch Ness monster ASCII art
_..--+~/@-@--.
_-=~ ( . )
_-~ _.--=.\ \''''
_~ _- \ \_\
= _= '--'
' = .
: : '=_. ___
| ; '~--.~.
; ; } |
= \ __..-...__ ___/__/__
@earthday47
earthday47 / razer-turret.sh
Last active June 15, 2017 13:22
Lower mouse sensitivity for Razer Turret in Linux (Ubuntu and Linux Mint)
#!/bin/bash
# Sets the deceleration constant for Razer Turret.
deceleration_constant=2.5
name="Razer Razer Turret Dongle"
for id in $(xinput --list | awk -F= "/$name.*pointer/ {print \$2}" | cut -f1)
do
xinput --set-prop $id "Device Accel Constant Deceleration" $deceleration_constant
done
@earthday47
earthday47 / custom.mail.inc
Created January 25, 2017 16:18
Drupal 7 - Custom email interface class. Allows HTML email messages.
<?php
/**
* HTML mail backend.
*/
class CustomMailSystem implements MailSystemInterface {
/**
*
* @param $message
* A message array, as described in hook_mail_alter().
@earthday47
earthday47 / myst4memories_solution.rb
Created December 13, 2016 20:20
An attempt to apply mathematical logic to Myst IV Revelation's insane memory puzzles. Turns out the permutations are on the order of 10^55, but this script will run the moves that produce the solution.
class Place
attr_accessor :name
attr_accessor :phrases
attr_accessor :left_place
attr_accessor :right_place
def initialize(name, initial_phrases)
@name = name
@phrases = initial_phrases
@left_place = nil
@right_place = nil
@earthday47
earthday47 / gist:b1bd053d180813e83daf
Last active August 29, 2015 14:13
Statamic - get latest blog post and display link (outside of Statamic)
<?php
$latest_title = '';
$latest_link = '';
$blog_posts = array();
// change this depending on your installation location and folder name
foreach (glob(dirname(__FILE__) . '/statamic/_content/01-blog-entries/*-*-*.md') as $blog_filepath) {
$pathinfo = pathinfo($blog_filepath);
$blog_posts[$pathinfo['filename']] = $blog_filepath;
}
@earthday47
earthday47 / yii-parse-csv-quotes_failed.php
Created June 13, 2014 13:44
Failed attempt at parsing a CSV file that has new line characters within quotes. They should be all one field.
<?php
$file = Yii::app()->params->uploadedDynamicsCsvFile;
$handle = fopen($file, 'r');
$row = array();
$field_data = ''; // field contents buffer
$carry = 0; // row has even/odd quotes; carry bit
while (!feof($handle)) {
$contents = fgets($handle);
@earthday47
earthday47 / 0-no_css3_columns_split.js
Created November 1, 2011 20:39
split list into two columns with jQuery
/**
* Find all lists, and if there's more than 10 list items, split it.
* Requires the Modernizr library for the check.
*/
$('.content ul').each(function(){
if ($(this).children('li').length > 10) {
// if CSS3 columns is allowed, add a css class.
if (Modernizr.testAllProps('columnWidth') && Modernizr.testAllProps('columnGap')) {
$(this).addClass('two-column-list');
} else {