Skip to content

Instantly share code, notes, and snippets.

View robdecker's full-sized avatar

Rob Decker robdecker

View GitHub Profile
@robdecker
robdecker / 1.md
Last active February 22, 2022 14:17
[Composer commands] #composer #d8
@robdecker
robdecker / 1.md
Last active November 26, 2021 08:35
[Fix Sequel Pro import error] #macos #sql

When I upload a database to Sequel Pro, I often get this 'file read error':

An error occurred when reading the file, as it could not be read in the encoding you selected (Autodetect - Unicode (UTF-8)).

Sequel Pro file read error

To solve this, delete all the tables and try again with encoding 'Western: Mac OS Roman'.

Sequel Pro encoding fix

For a quick local server:

npm install browser-sync --save-dev

In package.json:

"scripts": {
  "server": "browser-sync start --directory --server --files '*.js, *.html, *.css'"
}

1. Using parseInt() - slow

parseInt() parses a string and returns a whole number. Spaces are allowed. Only the first number is returned.
This method has a limitation though. If you parse the decimal number, it will be rounded off to the nearest integer value and that value is converted to string. One might need to use parseFloat() method for literal conversion.

myString = '129' 
console.log(parseInt(myString)) // expected result: 129

a = 12.22

Sans jQuery

Events

// jQuery
$(document).ready(function() {
  // code
})
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"
@robdecker
robdecker / 1.md
Created December 8, 2019 04:50
[Cheat Sheets & examples] #d8
@robdecker
robdecker / 1.md
Last active May 19, 2021 21:31
[Show outdated projects] #composer
@robdecker
robdecker / README.md
Last active May 1, 2021 22:01
[Sass folder structure best practices] #sass
@robdecker
robdecker / how-to-get-youtube-video-id.md
Last active March 30, 2021 22:14 — forked from jakebellacera/how-to-get-youtube-video-id.md
[Learn how to get the ID of any YouTube video] #video #youtube

How to get the ID of any YouTube Video

This article walks you through how to get the ID of any YouTube video.

How to get a YouTube video ID from a youtube.com page URL

You may be watching the video or just happened to visit a link to a video. The video ID will be located in the URL of the video page, right after the v= URL parameter.