Skip to content

Instantly share code, notes, and snippets.

@Tim-Otte
Tim-Otte / htmlTagConverter.php
Last active January 9, 2024 21:20
With this script you can convert a string with html tags into an array of html tags with tag name, attributes, inner text and child tags
<?php
define('HTML_REGEX_PATTERN', '/<([a-zA-Z]+)(?:\s([a-zA-Z]+(?:=(?:".+")|(?:[0-9]+))))*(?:(?:\s\/>)|(?:>(.*)<\/\1>))/');
function isHtmlTag($text) {
return preg_match(HTML_REGEX_PATTERN, $text);
}
function hasHtmlTag($text) {
return preg_match_all(HTML_REGEX_PATTERN, $text);
@kylefox
kylefox / attachment-utils.js
Created October 17, 2018 15:58
Convert Base64 data URLs to File objects for Trix attachments
window.AttachmentUtils = (function() {
var BASE64_MARKER = ';base64,';
var Utils = {
// Takes a file size (in bytes) and returns a human-friendly string representation.
humanFileSize: function(size) {
if(size < 1) return "0 bytes";
// http://stackoverflow.com/a/20732091
@joshbuchea
joshbuchea / semantic-commit-messages.md
Last active May 16, 2024 17:23
Semantic Commit Messages

Semantic Commit Messages

See how a minor change to your commit message style can make you a better programmer.

Format: <type>(<scope>): <subject>

<scope> is optional

Example

@ayamflow
ayamflow / gist:b602ab436ac9f05660d9c15190f4fd7b
Created May 9, 2016 19:10
Safari border-radius + overflow: hidden + CSS transform fix
// Add on element with overflow
-webkit-mask-image: -webkit-radial-gradient(white, black);
@michaeldeboeve
michaeldeboeve / jQuery stop animation on scroll.js
Last active September 7, 2020 12:51
jQuery: Stop animation when user scrolls
$(window).on('mousewheel', function() {
$('html, body').stop();
});
@matteotrap
matteotrap / wpml
Last active April 12, 2024 22:38
WPML - Active Languages list
<?php
$languages = icl_get_languages();
foreach($languages as $l){
$langs[] = '<li><a href="'.$l['url'].'">'.$l['native_name'].'</a></li>';
}
echo join('', $langs);
?>
@manastungare
manastungare / css-compress.php
Created May 7, 2012 00:23
On-the-fly CSS Compression
<?php
/**
* On-the-fly CSS Compression
* Copyright (c) 2009 and onwards, Manas Tungare.
* Creative Commons Attribution, Share-Alike.
*
* In order to minimize the number and size of HTTP requests for CSS content,
* this script combines multiple CSS files into a single file and compresses
* it on-the-fly.
*
@keeguon
keeguon / countries.json
Created April 5, 2012 11:11
A list of countries in JSON
[
{name: 'Afghanistan', code: 'AF'},
{name: 'Åland Islands', code: 'AX'},
{name: 'Albania', code: 'AL'},
{name: 'Algeria', code: 'DZ'},
{name: 'American Samoa', code: 'AS'},
{name: 'AndorrA', code: 'AD'},
{name: 'Angola', code: 'AO'},
{name: 'Anguilla', code: 'AI'},
{name: 'Antarctica', code: 'AQ'},
@jakebellacera
jakebellacera / ICS.php
Last active April 19, 2024 09:06
A convenient script to generate iCalendar (.ics) files on the fly in PHP.
<?php
/**
* This is free and unencumbered software released into the public domain.
*
* Anyone is free to copy, modify, publish, use, compile, sell, or
* distribute this software, either in source code form or as a compiled
* binary, for any purpose, commercial or non-commercial, and by any
* means.
*