Skip to content

Instantly share code, notes, and snippets.

async function supportsImgType(type) {
// Create
//
// <picture>
// <source srcset="data:,x" type="{type}" />
// <img />
// </picture>
//
// (where "data:,x" is just a minimal URL that is valid but doesn't trigger network)
let img = document.createElement('img');
@Fuxy22
Fuxy22 / bash_aliases.sh
Last active November 7, 2021 01:36
Bash Script functions to Manage /etc/hosts file for adding/removing hostnames.
# remove specified host from /etc/hosts
function removehost() {
if [[ "$1" ]]
then
HOSTNAME=$1
if [ -n "$(grep $HOSTNAME /etc/hosts)" ]
then
echo "$HOSTNAME Found in your /etc/hosts, Removing now...";
sudo sed -i".bak" "/$HOSTNAME/d" /etc/hosts
@schatterjee4
schatterjee4 / AEMDevResources
Created November 21, 2017 06:02 — forked from MikeNats/AEMDevResources
Adobe Experience Manager Resources for Developers
Documentation
-------------
AEM: http://docs.adobe.com
Recent updates: https://docs.adobe.com/docs/en/aem/recent-documentation-updates.html
AEM Docs daily changes: http://adobedocsdiff.headwire.com/sitediff/
API References
anonymous
anonymous / app.dockerfile
Created January 2, 2017 11:02
FROM php:7.0.4-fpm
RUN apt-get update && apt-get install -y libmcrypt-dev \
mysql-client libmagickwand-dev --no-install-recommends \
&& pecl install imagick \
&& docker-php-ext-enable imagick \
&& docker-php-ext-install mcrypt pdo_mysql
# editorconfig.org
root = true
[*]
indent_style = space
indent_size = 4
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
@kuckmc01
kuckmc01 / AEM-Touch-UI-Tab-Dialog-sample.xml
Last active April 23, 2021 22:20
AEM Touch UI Tab Dialog sample that has placeholders for adding tab content
<?xml version="1.0" encoding="UTF-8"?>
<jcr:root xmlns:sling="http://sling.apache.org/jcr/sling/1.0"
xmlns:cq="http://www.day.com/jcr/cq/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0"
xmlns:nt="http://www.jcp.org/jcr/nt/1.0" jcr:primaryType="nt:unstructured"
jcr:title="Compare Products Services" sling:resourceType="cq/gui/components/authoring/dialog"
mode="edit" helpPath="style-guide.html#compare-rows-services">
<content
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/foundation/container">
<layout
@refo
refo / remove-leading-slash
Created June 5, 2015 13:27
javascript - Remove leading slashes
'/example/string/'.replace(/^\/+/g, '');
// Should remove all leading slashes and return 'example/string/'
var mediaJSON = { "categories" : [ { "name" : "Movies",
"videos" : [
{ "description" : "Big Buck Bunny tells the story of a giant rabbit with a heart bigger than himself. When one sunny day three rodents rudely harass him, something snaps... and the rabbit ain't no bunny anymore! In the typical cartoon tradition he prepares the nasty rodents a comical revenge.\n\nLicensed under the Creative Commons Attribution license\nhttp://www.bigbuckbunny.org",
"sources" : [ "http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4" ],
"subtitle" : "By Blender Foundation",
"thumb" : "images/BigBuckBunny.jpg",
"title" : "Big Buck Bunny"
},
{ "description" : "The first Blender Open Movie from 2006",
"sources" : [ "http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/ElephantsDream.mp4" ],
@floriankraft
floriankraft / JcrQueryLibrary.md
Last active April 5, 2024 14:09
Some useful JCR queries (XPATH, SQL2) for AEM/CQ development.

SQL2

All nodes with a specific name

SELECT * FROM [nt:unstructured] AS node
WHERE ISDESCENDANTNODE(node, "/search/in/path")
AND NAME() = "nodeName"

All pages below content path

@un33k
un33k / sed cheatsheet
Created August 22, 2011 13:28
magic of sed -- find and replace "text" in a string or a file
FILE SPACING:
# double space a file
sed G
# double space a file which already has blank lines in it. Output file
# should contain no more than one blank line between lines of text.
sed '/^$/d;G'