Skip to content

Instantly share code, notes, and snippets.

View DanielCoulbourne's full-sized avatar

Daniel Coulbourne DanielCoulbourne

View GitHub Profile
@DanielCoulbourne
DanielCoulbourne / AlpineVueHackAdaptor.js
Last active May 27, 2024 22:33
Vue loves to strip all the content out of template tags, even if those tags are within a `v-pre`. This breaks many AlpineJS features that rely on templates like `x-if` and `x-for`.
let copyContentsIntoTemplateTags = (templates, selector) => {
document
.querySelectorAll(selector)
.forEach((element, index) => {
element.replaceChildren();
element.content.prepend(templates[index]);
});
}
let copyContentsOutOfTemplateTags = (selector) => {
@DanielCoulbourne
DanielCoulbourne / StateSynth.php
Created May 15, 2024 14:16
A Livewire Synth for Verbs States
<?php
namespace App\Livewire\Synths;
use Livewire\Mechanisms\HandleComponents\Synthesizers\Synth;
use Thunk\Verbs\State;
class StateSynth extends Synth
{
public static $key = 'VrbSt';
<?php
namespace Tests\Feature;
use Illuminate\Support\Collection;
use Tests\TestCase;
class DealCardsTest extends TestCase
{
protected function genrateShuffledDeck($include_jokers = false)
@DanielCoulbourne
DanielCoulbourne / melvor-combat.js
Created September 4, 2021 02:09
Melvor Idle Auto-Combat Script
let eat = () => { document.getElementById('combat-footer-minibar-eat-btn').click(); console.log('Eating Food! - Current HP:' + getCurrentHP())}
let loot = () => { document.getElementById('combat-btn-loot-all').click(); console.log('Looting!')}
let jump = () => { loot(); document.getElementById('combat-slayer-task-jump').click(); console.log('Switching Task! - New Task: ' + getAssignment())}
let run = () => { document.getElementById('combat-btn-run').click(); alert('Ran away. Re-stock your food.')}
let foodValue = 110
let getCurrentHP = () => parseInt(document.getElementById('combat-player-hitpoints-current-1').innerText)
let getFoodQuantity = () => parseInt(document.getElementById('combat-food-current-qty-1').innerText)
hs.grid.setGrid('10x4')
hs.grid.setMargins({x=10, y=10})
hs.grid.HINTS={
{ 'F1', 'F2', 'F3', 'F4', 'F5', 'F6', 'F7', 'F8', 'F9', 'F10' },
{ '1', '2', '3', '4', '5', '6', '7', '8', '9', '0' },
{ 'Q', 'W', 'E', 'R', 'T', 'Y', 'U', 'I', 'O', 'P' },
{ 'A', 'S', 'D', 'F', 'G', 'H', 'J', 'K', 'L', ';' },
{ 'Z', 'X', 'C', 'V', 'B', 'N', 'M', ',', '.', '/' },

Keybase proof

I hereby claim:

  • I am danielcoulbourne on github.
  • I am coulb (https://keybase.io/coulb) on keybase.
  • I have a public key ASCYdI3fojRlNN70-0EzA9YLDJONt_OdexOdApY5miDpPAo

To claim this, I am signing this object:

@DanielCoulbourne
DanielCoulbourne / Resource.js
Created June 16, 2017 20:04
ES6 Resource Client
/***
*
* EXAMPLE USAGE
*
* Resource.index('users')
* Resource.store('users', { email: 'daniel@tighten.co' })
* Resource.show('users', 1)
* Resource.update('users', { id: 1, email: 'daniel.coulbourne@gmail.com' })
* Resource.destroy('users', 1)
*
@DanielCoulbourne
DanielCoulbourne / gitwords.sh
Created March 24, 2017 20:00
Count the number of usages of a given first word in your git commits.
#!/bin/bash
email="$email"
echo "Most used first words in this repo:";
echo $(git log --format=%s --author=$email | cut -d' ' -f1) | tr ' ' '\n' | sort | uniq -c | sort -r
{% for the_quiz in post.quiz %}
{% set quiz_obj = TimberPost(the_quiz) %}
<h3>Take the {{quiz_obj.title}} Quiz</h3>
{% for the_question in quiz_obj.get_field('question') %}
{% if loop.index is even %}
<div class="row">
{% endif %}
<div class="col-md-6">
<p><span>{{loop.index}}.</span>{{the_question.question}}</p>
<form>