Skip to content

Instantly share code, notes, and snippets.

View Doomd's full-sized avatar
:octocat:
Focusing

Doomd Doomd

:octocat:
Focusing
View GitHub Profile
@Doomd
Doomd / index.html
Last active August 12, 2021 23:20
broofa vs e7 #jsbench #jsperf (https://jsbench.github.io/#80610cde9bc93d0f3068e5793e60ff11) #jsbench #jsperf
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<title>broofa vs e7 #jsbench #jsperf</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/benchmark/1.0.0/benchmark.min.js"></script>
<script src="./suite.js"></script>
</head>
<body>
<h1>Open the console to view the results</h1>
@Doomd
Doomd / geohashes.json
Last active January 10, 2021 20:49
PHP - Create Unique Array of Object by comparing one property
[
{
"offer_nid": "16524",
"offer_lm": "1610224798",
"biz_nid": "73865",
"biz_lm": "1602519728",
"geo": "9xjhn",
"counter": "1"
},
{
@Doomd
Doomd / .beautifyrc.json
Last active January 10, 2021 06:07
VSCode Beautify Config Options I liked (before switching to Prettier even though mostly preferred this) #beautify
// VSCODE settings Dec 2020
{
"beautify.language": {
"js": {
"type": ["javascript", "json"],
"filename": [".jshintrc", ".jsbeautifyrc"]
// "ext": ["js", "json"]
// ^^ to set extensions to be beautified using the javascript beautifier
},
@Doomd
Doomd / days_of_the_week.js
Last active January 9, 2021 22:17
[Javascript Days of the Week Array] #date #time #array #constants
export const daysOfWeek = [
{ i: 0, mf: 6, day: "Sunday", abr: "Sun", rr: "SU" },
{ i: 1, mf: 0, day: "Monday", abr: "Mon", rr: "MO" },
{ i: 2, mf: 1, day: "Tuesday", abr: "Tue", rr: "TU" },
{ i: 3, mf: 2, day: "Wednesday", abr: "Wed", rr: "WE" },
{ i: 4, mf: 3, day: "Thursday", abr: "Thu", rr: "TH" },
{ i: 5, mf: 4, day: "Friday", abr: "Fri", rr: "FR" },
{ i: 6, mf: 5, day: "Saturday", abr: "Sat", rr: "SA" },
]
@Doomd
Doomd / twigextracturi.twig
Last active January 9, 2021 22:07
[Drupal Twig Extract URL from Image HTML tag] #drupal
// input: '<img src="/files/blah/blah/image.png?param=blah" attribute="blah" etc="blah" />'
{{ field_business_bg_export | split('?')[0] | replace({ '<img src="':'' }) | trim }}
// output: '/files/blah/blah/image.png'
@Doomd
Doomd / views-view-unformatted.html.twig
Last active September 5, 2020 04:57
views-view-unformatted.html.twig not working as desired
{# Each Business: #}
{% set rowNum = 0 %} {# MY ATTEMPT TO SYNC THE ROW/ARRAY NUMBERS WITH THE BUSINESS NID LOOKUPS -- DOESN'T WORK #}
{% set bizNid = rows[rowNum].content['#row'].node_field_data_node__field_business_location_nid %}
{# START CARD #}
<div class="card" id="{{ bizNid }}">
{% if title %}
{{ title }}
{% endif %}
id: rooster_node_parent_business
label: "Rooster Migrate Parent Business Content"
migration_group: Rooster
migration_tags:
- Rooster 044
- Rooster Business
- Rooster G1
source:
plugin: url
@Doomd
Doomd / drupal_filenames_by_date.sql
Last active June 2, 2020 19:31
Drupal 7 MySQL query: Join file_managed, node, and file_usage to get a list of IMAGE filenames used by nodes filtered and sorted by date
SELECT fm.fid, fm.filename, /*from_unixtime(fm.timestamp, "%Y-%m-%d") as 'file_date',*/
REPLACE(n.title, ',', ' ') AS titleNoCommas, n.nid, from_unixtime(n.created, "%Y-%m-%d") as 'node_date'
FROM file_managed fm
JOIN file_usage fu ON fm.fid = fu.fid
JOIN node n ON fu.id = n.nid
WHERE fm.filename REGEXP '.*.jpg|.*.jpeg|.*.png|.*.gif' AND created BETWEEN unix_timestamp('2012-01-01') AND unix_timestamp('2017-01-03')
ORDER BY node_date
@Doomd
Doomd / car_makes.md
Last active January 9, 2021 22:12
Automobile Manufacturer/Make/Brands in the United States (for Easy HTML options list) #list

I wanted an easy way to always have an updated list of the Car "Makes" in the United States. It doesn't change that often, but if it does, hopefully this list will auto-update as the data is pulled and parsed from Wikipedia.

Here's a link to the Google Sheet if you want to edit anything: https://docs.google.com/spreadsheets/d/1lBk9CjGCkbMNqzbehkdpxa7VyEDRZjh-5Nx2QcpbvOE/edit#gid=108045673

If you'd like to JSON(ify) this list, here's a good writeup on how to do that: https://www.freecodecamp.org/news/cjn-google-sheets-as-json-endpoint/

And here's a quick and easy options list for a select input of car brands/makes in the United States (as of Jan 2020) that you can easily copy and paste:

@Doomd
Doomd / phoneNumNormalize.html
Last active January 9, 2021 22:10
USA Phone Number Normalizer / Formatter
<!--
// Please realize, that I use parsleyjs.js to validate my entire form, so my form automatically informs the user if their input is off course too much.
// My input validation is very liberal for all USA numbers entered with or without a leading "1"
// Please see https://regexr.com/4qjh5 for DETAILS on the regex match and replacement patterns
// It will allow the following:
// an optional leading "+"
// an optional leading "1" and an optional dash, period or space ("[-.\s]") after the "1"
// an optional "(" or ")" around the area code
// any dashes, periods or spaces "[-.\s]" in between the area-code, 3-digit prefix, and 4-digit numbers
// Philisophically, I think it's best to allow the user to enter the phone number however they prefer (so long as they have 10 or 11 digits, ie: "optional (1) + (XXX) + (XXX) + (XXXX)"