Skip to content

Instantly share code, notes, and snippets.

View vincentorback's full-sized avatar
🌻

Vincent Orback vincentorback

🌻
View GitHub Profile
@vincentorback
vincentorback / get-id.php
Last active November 29, 2021 09:53
Get ID from videos embedded from YouTube and Vimeo
<?php
function getElementAttribute ($attribute, $html) {
if (preg_match('/' . $attribute . '="([^"]+)"/', $html, $match)) {
return $match[1];
}
return false;
}
@vincentorback
vincentorback / README.md
Last active February 2, 2021 14:30
Swedish counties, municipalities, districts. Svenska län, kommuner och distrikt.

Sweden JSON / Sverige JSON

Swedish counties, municipalities and districts in JSON format.
Svenska län och kommuner och distrikt i JSON format.

Data

Downloaded from SCB 13 jan 2021.

@vincentorback
vincentorback / .deploy
Created September 7, 2020 08:50
Github Action - Deploying Bedrock WordPress website
name: Build and deploy
on:
push:
branches: [master]
pull_request:
branches: [master]
jobs:
build:
@vincentorback
vincentorback / undeletable-wordpress-pages.php
Last active August 31, 2020 14:45
Undeletable WordPress pages
<?php
function restrict_post_deletion ($post_ID) {
$restricted_pages = [
get_option('page_on_front'),
123,
666
];
if (!current_user_can('administrator') && in_array($post_ID, $restricted_pages)) {
@vincentorback
vincentorback / remove_node_modules.sh
Last active July 10, 2020 15:10
delete all node_modules directories
# Test
find . -name "node_modules" -type d -prune -print | xargs du -chs
# Remove
find . -name "node_modules" -type d -prune -print -exec rm -rf "{}" \;
/**
* detect IE
* returns version of IE or false, if browser is not Internet Explorer
*/
function detectIE() {
var ua = window.navigator.userAgent;
// Test values; Uncomment to check result …
// IE 10
@vincentorback
vincentorback / visibilitychange.js
Created March 15, 2020 18:54
Handle visibilitychange better
function handleHidden (callbackHidden, callbackVisible) {
var browserPrefixes = ['moz', 'ms', 'o', 'webkit']
var isVisible = true // internal flag, defaults to true
// get the correct attribute name
function getHiddenPropertyName (prefix) {
return (prefix ? prefix + 'Hidden' : 'hidden')
}
// get the correct event name
@vincentorback
vincentorback / truncate.css
Last active March 31, 2020 20:31
Truncate text with PHP and CSS
/**
* Text truncation
*
* Prevent text from wrapping onto multiple lines, and truncate with an
* ellipsis.
*
* 1. Ensure that the node has a maximum width after which truncation can
* occur.
* 2. Fix for IE 8/9 if `word-wrap: break-word` is in effect on ancestor
* nodes.
@vincentorback
vincentorback / cart.less
Last active December 27, 2018 12:51
Hide empty Squarespace cart, until a product is added.
.Cart {
transition: 300ms;
}
.Cart[hidden] {
display: inline-block;
opacity: 0;
visibility: hidden;
}

Keybase proof

I hereby claim:

  • I am vincentorback on github.
  • I am wincent95 (https://keybase.io/wincent95) on keybase.
  • I have a public key whose fingerprint is 5226 9E7E 2E44 8C51 A353 F1FF E3A0 C36B 4994 F81B

To claim this, I am signing this object: