Skip to content

Instantly share code, notes, and snippets.

View c3ry5's full-sized avatar

Cerys Williams c3ry5

  • London, United Kingdom
View GitHub Profile
@c3ry5
c3ry5 / aem.cq.getRequest.js
Last active March 15, 2023 04:39
Get request using the AEM sightly Javascript use api
"use strict";
use(function() {
var url = this.api,
getRequest = new org.apache.commons.httpclient.methods.GetMethod(url),
client = new org.apache.commons.httpclient.HttpClient(),
status = new org.apache.commons.httpclient.HttpStatus(),
inputStream;
console.log("Retrieving data from " + url);
try {
var statusCode = client.executeMethod(getRequest);
@c3ry5
c3ry5 / getVideoId.js
Last active November 3, 2020 10:53
Regex Map/loop for getting the video id from youtube, vimeo, vine and instagram
getVideoId = {
siteMap : {
"youtube" : {
r : /(youtu\.be\/|youtube\.com\/(watch\?(.*&)?v=|(embed|v)\/))([^\?&"'>]+)/,
id : 5
},
"vimeo" : {
r : /https?:\/\/(?:www\.)?vimeo.com\/(?:channels\/(?:\w+\/)?|groups\/([^\/]*)\/videos\/|album\/(\d+)\/video\/|)(\d+)(?:$|\/|\?)/,
id : 3
},
@c3ry5
c3ry5 / macsetup.sh
Last active September 5, 2019 15:19
# Ask for the administrator password upfront.
sudo -v
# Keep-alive: update existing `sudo` time stamp until the script has finished.
while true; do sudo -n true; sleep 60; kill -0 "$$" || exit; done 2>/dev/null &
# Apps
apps=(
java
docker
body {
background: #000;
}
.countdown {
background: #000;
color: #fff;
display: table;
margin: 0 auto;
text-align: center;
font-family: arial;
var guid = function() {
var nav = window.navigator;
var screen = window.screen;
var guid = nav.mimeTypes.length;
guid += nav.userAgent.replace(/\D+/g, '');
guid += nav.plugins.length;
guid += screen.height || '';
guid += screen.width || '';
guid += screen.pixelDepth || '';
@c3ry5
c3ry5 / SaveforWebSP.jsx
Last active January 10, 2019 16:08
A script to export images in photoshop with max with and file size
//SaveforWebSP.jsx
var docRef = activeDocument;
var outputFolder = docRef.path;
var segments = app.activeDocument.name.split(".");
segments.splice(segments.length - 1, 1);
var docName = segments.join(".");
var fileName = prompt("Please Enter a file name without extension?", docName);
var safeFileName = fileName.replace(/[^A-Z0-9]+/ig, "_");
@c3ry5
c3ry5 / Dockerfile
Created December 19, 2018 11:45
Basic Docker Setup for php & MySql with the dependancies for Xenforo
FROM php:7.1.2-apache
RUN apt-get update && \
apt-get install -y libfreetype6-dev libjpeg62-turbo-dev libpng12-dev && \
docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ && \
docker-php-ext-install gd
RUN docker-php-ext-install mysqli
@c3ry5
c3ry5 / detect-webapp.js
Last active November 4, 2018 11:27
detect if the website has been saved as a webapp
const webappDetect = () => ("standalone" in window.navigator) && window.navigator.standalone;
@c3ry5
c3ry5 / ga-error-tracking.js
Last active November 4, 2018 11:27
crossbrowser tracking js errors using google analytics
window.onerror = (message, filename, lineno, colno, error) => {
function stack() {
return (`${(error.stack).replace(/(\r\n|\n|\r)/gm," ")} in ${navigator.userAgent}`)
}
function nostack() {
return (`${message} on line ${lineno} for ${filename} in ${navigator.userAgent}`)
}
@c3ry5
c3ry5 / read.cookie.js
Last active November 4, 2018 11:26
Read and write cookies