Skip to content

Instantly share code, notes, and snippets.

View 4-x's full-sized avatar
🦥

Alexander Shoup 4-x

🦥
View GitHub Profile
console.log("hello world");
@4-x
4-x / clear-intervals.js
Last active June 19, 2017 14:42
Hacky script for clearing all intervals in javascript
function clearIntervals() {
var last_interval_id = window.setInterval("", 9999);
for (var i = 1; i < interval_id; i++) {
window.clearInterval(i);
}
}
@4-x
4-x / css-mouse.js
Created June 22, 2017 20:16
Provide mouse movement data to CSS variables
function addCSSMouse() {
window.root = document.querySelector(':root');
document.addEventListener('mousemove', function(evt){
// between -1 and 1
var x = ((evt.clientX - (window.innerWidth / 2)) / window.innerWidth * 2).toFixed(2);
var y = ((evt.clientY - (window.innerHeight / 2)) / window.innerHeight * 2).toFixed(2);
root.style.setProperty('--mouse-x', x + 'px');
root.style.setProperty('--mouse-y', y + 'px');
});
}
@4-x
4-x / list-commas.css
Last active July 3, 2017 19:30
Adding commas to items in an unordered list without a comma on the final list item
li:not(:last-child)::after {
content: ",";
}
@4-x
4-x / nodelist-array.js
Last active September 21, 2022 00:39
Get page elements in an array instead of a NodeList
// updated 2022_9_20 - felt cute; might delete later
// Array.from
const elements1 = Array.from(nodeList);
// spread syntax
const elements2 = [...nodeList];
// THE OLD WAYS
// call slice method on a nodelist
@4-x
4-x / cors-echo-proxy.php
Created May 19, 2018 19:36
Simple PHP page for bypassing CORS. Takes URL as parameter: `/cors-echo-proxy.php?ANY_URL`
<?php
header("Access-Control-Allow-Origin: *");
function curl_get_contents($url)
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_URL, $url);
@4-x
4-x / unstyle.js
Created July 28, 2022 00:58
Strip CSS (external, embedded, and inline)
var stylesheets = document.querySelectorAll('link');
stylesheets.forEach(function (sheet) {
sheet.parentNode.removeChild(sheet);
});
var inlineStylesheets = document.querySelectorAll('style');
inlineStylesheets.forEach(function (sheet) {
sheet.parentNode.removeChild(sheet);
});
document.querySelectorAll('*').forEach(function (element) {
element.style = '';
@4-x
4-x / ch.css
Last active September 5, 2023 21:15
Pure CSS experiments in chess board layout
/*
CSS grid layout can be used for stacking pieces on squares
Grid position is not animatable, so the FLIP technique would
be required
*/
.white-player {
grid-template-areas:
'a8 b8 c8 d8 e8 f8 g8 h8'
'a7 b7 c7 d7 e7 f7 g7 h7'
'a6 b6 c6 d6 e6 f6 g6 h6'
@4-x
4-x / getAllSelectors.js
Last active November 10, 2022 03:13
get array of all unique selectors on page
const selectorsArr = (()=>{
const allElements = document.querySelectorAll('*')
const tags = new Set()
const classes = new Set()
const ids = new Set()
allElements.forEach(el=>{
tags.add(el.tagName)

Details HTML disclosure element in Github-flavored Markdown

As long as <style> and <script> tags are stripped from markdown documents rendered on Github, the details element is the only interactivity available in Github-flavored Markdown documents.

Summary Extended description.