Skip to content

Instantly share code, notes, and snippets.

View hirasso's full-sized avatar
👋

Rasso Hilber hirasso

👋
View GitHub Profile
@nathansearles
nathansearles / isAutoplaySupported.js
Last active December 13, 2022 11:06
Test if HTML5 video autoplay is supported
// isAutoplaySupported(callback);
// Test if HTML5 video autoplay is supported
isAutoplaySupported = function(callback) {
// Is the callback a function?
if (typeof callback !== 'function') {
console.log('isAutoplaySupported: Callback must be a function!');
return false;
}
// Check if sessionStorage exist for autoplaySupported,
// if so we don't need to check for support again
@datchley
datchley / es6-eventemitter.js
Last active June 7, 2021 03:40
A straight forward EventEmitter implemented in Javascript using ES6
let isFunction = function(obj) {
return typeof obj == 'function' || false;
};
class EventEmitter {
constructor() {
this.listeners = new Map();
}
addListener(label, callback) {
this.listeners.has(label) || this.listeners.set(label, []);
@bhwebworks
bhwebworks / Redirect specific WordPress pages or posts to https.php
Last active December 12, 2017 00:14
Redirect specific WordPress pages or posts to https
/**
* Redirect specific pages or posts to https
*
* This code assumes the page/post ID to make https is 7000.
* You will need to change that ID to match your site.
*
* @link http://blackhillswebworks.com/?p=5088
*/
add_action( 'template_redirect', 'bhww_front_end_ssl_template_redirect', 2 );
var Bar1 = base => class extends base {
componentWillMount(){
super.componentWillMount();
console.log('Bar1');
}
};
var Bar2 = base => class extends base {
componentWillMount(){
super.componentWillMount();
@danielpquinn
danielpquinn / svg-rounded-rectangle-path.js
Last active February 17, 2025 10:54
Draw SVG Rounded Rectangle Path
/**
* Get path data for a rounded rectangle. Allows for different radius on each corner.
* @param {Number} w Width of rounded rectangle
* @param {Number} h Height of rounded rectangle
* @param {Number} tlr Top left corner radius
* @param {Number} trr Top right corner radius
* @param {Number} brr Bottom right corner radius
* @param {Number} blr Bottom left corner radius
* @return {String} Rounded rectangle SVG path data
*/
@lordspace
lordspace / array2attribs
Created July 21, 2014 08:58
Here is a PHP class that allows you to create HTML attributes from a php array. If you pass the second parameter the key will be prefixed with 'data-' prefix so they can be access via jQuery later.
Class HTML_Util {
/**
* Usage: HTML_Util::array2attribs();
* @param array $attributes
* @param bool $make_them_data will prefix each key with 'data-' prefix so it's acessible via $('#elem').data();
* @return string
* @see http://stackoverflow.com/questions/18081625/how-do-i-map-an-associative-array-to-html-element-attributes
*/
public static function array2attribs($attributes = array(), $make_them_data = 0) {
$pairs = array();
@nateswart
nateswart / com.nateofnine.FlaggedEmailToReminder.plist
Created January 9, 2014 03:54
plist to run this AppleScript every minute via launchd
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Disabled</key>
<false/>
<key>Label</key>
<string>com.nateofnine.FlaggedMailToReminders</string>
<key>Program</key>
<string>/usr/bin/osascript</string>
/**
* Redirect WordPress front end https URLs to http without a plugin
*
* Necessary when running forced SSL in admin and you don't want links to the front end to remain https.
*
* @link http://blackhillswebworks.com/?p=5088
*/
add_action( 'template_redirect', 'bhww_ssl_template_redirect', 1 );
@jfloff
jfloff / mamp.md
Last active February 13, 2025 01:03
How to get MAMP to work with SSL ... Yes really.

First of all you need to be able to run MAMP in port 80. This is a "heat check" if you don't have any process jamming http ports. You can check it like this:

sudo lsof | grep LISTEN

If you do happen to have any process with something like this *:http (LISTEN), you are in trouble. Before with adventure check if it isn't MAMP itself (yeah, you should close that beforehand)

ps <pid of that process>

If you don't see MAMP, you are in good hands, I have just the thing for you: