Skip to content

Instantly share code, notes, and snippets.

View daverogers's full-sized avatar
🤘

Dave Rogers daverogers

🤘
View GitHub Profile
@daverogers
daverogers / example.vue
Created November 5, 2024 10:11
Wrap Highlighted Input Text With Quotes
<script setup>
// i always wanted a way to mimic IDEs in web forms, where i can wrap highlighted text with quotes
// or any other characters you'd typically want to wrap (parens, backticks, curly brackets, etc)
// this can be easily adjusted to accomodate any/all characters you want to wrap with
// (i just happened to be implementing this in a Vue project, but you can use it in vanilla js)
const keydown = (event) => {
const input = event.target;
const selectionStart = input.selectionStart;
@daverogers
daverogers / UniqueForGenerator.php
Created April 17, 2024 21:22
uniqueFor Modifier - Faker PHP
<?php
use Faker\Generator;
use Faker\Provider\Base;
use Faker\UniqueGenerator;
/**
* The default UniqueGenerator groups by the method name called,
* this class allows a custom tag to be specified instead
*
@daverogers
daverogers / kebab-case.php
Last active March 12, 2023 11:33
Laravel's `Str::kebab()` format is basically just `Str::snake()` with the hyphen delimiter, but the downside being when you have groups of capitalized letters it'll hyphenate in between each of them instead of just before the first of the group. This isn't always desirable, like in some column name format styles...
<?php
// default Laravel output
Str::of('TableID')->kebab();
// result: 'table-i-d'
// my way, grouping by capital letters
Str::of('TableID')
@daverogers
daverogers / roundrobin.php
Created November 4, 2021 15:29
PHP Round Robin
<?php
// evenly distribute colors across $return keys
$colors = [ 'red', 'blue', 'green', 'pink' ];
$return = [ 0,1,2,3,4,5,6,7,8,9 ];
foreach($return as $i => $loop) {
$return[$loop] = $colors[$i % count($colors)];
}
@daverogers
daverogers / Copy As JIRA Table
Created October 5, 2016 07:50
Copies Sequel Pro result into JIRA's table format. Save with the Bundle Editor (as new Copy bundle).
#!/usr/bin/php
<?php
/*
* COPY AS JIRA TABLE by @daverogers
* Copies Sequel Pro result into JIRA's table format. Save with the Bundle Editor (as new Copy bundle).
*
* Thanks to @jakob-stoeck for his example Gist!
*/

Keybase proof

I hereby claim:

  • I am daverogers on github.
  • I am daverogers (https://keybase.io/daverogers) on keybase.
  • I have a public key whose fingerprint is 3E60 69FA 897B 97EF 1C7C 4949 0400 4D9C 54CB 0F66

To claim this, I am signing this object:

@daverogers
daverogers / footer.js
Created April 12, 2013 22:41
Assign "active" class to navbar item based on current page URL with jQuery