Skip to content

Instantly share code, notes, and snippets.

View robdecker's full-sized avatar

Rob Decker robdecker

View GitHub Profile
var parser = document.createElement('a');
parser.href = "http://example.com:3000/pathname/?search=test#hash";

parser.protocol; // => "http:"
parser.hostname; // => "example.com"
parser.port;     // => "3000"
parser.pathname; // => "/pathname/"
parser.search;   // => "?search=test"
parser.hash; // => "#hash"

Sans jQuery

Events

// jQuery
$(document).ready(function() {
  // code
})
@robdecker
robdecker / debug.twig
Last active January 19, 2021 18:50 — forked from zakiya/debug.twig
[Debugging Twig in Drupal] #d8 #twig
{# ~ Core ~ #}
{# {{ dump() }} #}
{# {{ dump(page) }} #}
{# ~ Devel~ #}
{# {{ kint()}} #}
{# {{ kint(page)}} #}
{# {{ devel_dump(page) }} #}
{# {{ devel_breakpoint() }} #}
@robdecker
robdecker / debug.php
Last active January 19, 2021 18:50 — forked from zakiya/debug.php
[Debugging php in Drupal] #d8
<?php>
function myfunction($app) {
// ~~ Core.
// debug($app);
// dump($app);
// var_dump($app);
// ~~ Devel + kint library + settings
// dpr($app);
// kint($app);
@robdecker
robdecker / youtube_id_regex.php
Created May 7, 2020 20:56 — forked from ghalusa/youtube_id_regex.php
[Extract the YouTube Video ID from a URL in PHP] #php
<?php
// Here is a sample of the URLs this regex matches: (there can be more content after the given URL that will be ignored)
// http://youtu.be/dQw4w9WgXcQ
// http://www.youtube.com/embed/dQw4w9WgXcQ
// http://www.youtube.com/watch?v=dQw4w9WgXcQ
// http://www.youtube.com/?v=dQw4w9WgXcQ
// http://www.youtube.com/v/dQw4w9WgXcQ
// http://www.youtube.com/e/dQw4w9WgXcQ
// http://www.youtube.com/user/username#p/u/11/dQw4w9WgXcQ
@robdecker
robdecker / php-get-vimeo-video-id-from-url.php
Last active May 7, 2020 20:58 — forked from anjan011/php-get-vimeo-video-id-from-url.php
[Get Vimeo Video ID from URL in PHP] #php
<?php
/**
* Get Vimeo video id from url
*
* Supported url formats -
*
* https://vimeo.com/11111111
* http://vimeo.com/11111111
@robdecker
robdecker / 1.md
Last active April 18, 2020 20:21 — forked from bzerangue/_verify-repair-permissions-disk.md
[Mac OS X Utilities via Terminal] Verify and Repair: Disk Permissions AND Disk / Software Update / TimeMachine #macos

List, mount, etc

List disks

diskutil list

Mount ISO

hdiutil mount ~/Downloads/name_of_file.iso

@robdecker
robdecker / vanilla-js-cheatsheet.md
Last active April 8, 2020 22:02 — forked from thegitfather/vanilla-js-cheatsheet.md
[Vanilla JavaScript Quick Reference / Cheatsheet] #js
@robdecker
robdecker / export_vscode_extesions.md
Last active January 28, 2020 19:47 — forked from joseluisq/export_vscode_extesions.md
[How to export your VS Code extensions from terminal] #macos

How to export your VS Code extensions from terminal

Note: Unix-like systems only.

  1. Export your extensions to a shell file:
code --list-extensions | sed -e 's/^/code --install-extension /' > my_vscode_extensions.sh
@robdecker
robdecker / Breadcrumbs.php
Last active October 17, 2019 19:49 — forked from jonpugh/Breadcrumbs.php
[Add Taxonomy Term to a Node's Breadcrumb in Drupal 8] #d8
<?php
// src/Breadcrumbs.php
namespace Drupal\modulename;
use Drupal\Core\Breadcrumb\BreadcrumbBuilderInterface;
use Drupal\Core\Routing\RouteMatchInterface;
use Drupal\Core\Breadcrumb\Breadcrumb;
use Drupal\Core\Link;