Skip to content

Instantly share code, notes, and snippets.

View cleaver's full-sized avatar
💭
git push --force

Cleaver Barnes cleaver

💭
git push --force
View GitHub Profile
@cleaver
cleaver / 10.ex
Created December 12, 2023 19:03
Advent of Code 2023, Day 11 - Elixir
import AOC
import InputHelpers
aoc 2023, 11 do
@moduledoc """
https://adventofcode.com/2023/day/11
"""
@row_coord 0
@column_coord 1
@cleaver
cleaver / useWindowPosition.ts
Created August 22, 2023 20:30
React hook for window resize + vertical scroll
import { useEffect, useState } from 'react';
export function useWindowPosition() {
const [windowSize, setWindowSize] = useState({
width: 0,
height: 0,
scrollY: 0,
});
function handleResize() {
@cleaver
cleaver / .zshrc
Created December 7, 2022 17:05
Defer initializing nvm - speed up terminal login for zsh
# adapted from: https://www.growingwiththeweb.com/2018/01/slow-nvm-init.html
if [ -s "$HOME/.nvm/nvm.sh" ] && [ ! "$(whence -w __init_nvm)" = "__init_nvm: function" ]; then
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/bash_completion" ] && . "$NVM_DIR/bash_completion"
declare -a __node_commands=('nvm' 'node' 'npm' 'yarn' 'gulp' 'grunt' 'webpack')
function __init_nvm() {
for i in "${__node_commands[@]}"; do unalias $i; done
. "$NVM_DIR"/nvm.sh
unset __node_commands
@cleaver
cleaver / pixel_meter
Last active November 15, 2020 20:16
Making VU meter type display with Neopixel ring.
#include <Adafruit_NeoPixel.h>
// Which pin on the Arduino is connected to the NeoPixels?
// On a Trinket or Gemma we suggest changing this to 1:
#define LED_PIN 13
// How many NeoPixels are attached to the Arduino?
#define LED_COUNT 24
#define HUE_STEP 512;
@cleaver
cleaver / laravel-sql-debug.php
Last active November 16, 2015 16:19
Laravel: debug SQL statements
<?php
use Illuminate\Support\Facades\Event;
use Illuminate\Support\Facades\Log;
Event::listen("illuminate.query", function($query, $bindings, $time, $name){
$this->output($query);
$this->output(json_encode($bindings));
// Or, send to log:
Log::sql($query."\n");
Log::sql(json_encode($bindings)."\n");
@cleaver
cleaver / redis-settings.php
Created October 29, 2015 18:16
Drupal Redis cache settings
$conf['redis_client_interface'] = 'PhpRedis';
// environment variable: MY_REDIS_HOST
$conf['redis_client_host'] = getenv(‘MY_REDIS_HOST');
$conf['lock_inc'] = 'sites/all/modules/contrib/redis/redis.lock.inc';
$conf['path_inc'] = 'sites/all/modules/contrib/redis/redis.path.inc';
$conf['cache_backends'][] = 'sites/all/modules/contrib/redis/redis.autoload.inc';
$conf['page_cache_without_database'] = TRUE;
$conf['page_cache_invoke_hooks'] = FALSE;
// Use if connecting to Redis by socket