Skip to content

Instantly share code, notes, and snippets.

View jhancock532's full-sized avatar
๐Ÿ˜„
Hello world!

James Hancock jhancock532

๐Ÿ˜„
Hello world!
View GitHub Profile
@jhancock532
jhancock532 / manifest.json
Last active October 16, 2020 09:36
Mozilla Firefox twitter extension that draws attention to your presense in reality as you scroll. Read the blog post at http://www.jameshancock.art/webcam-presence/
{
"manifest_version": 2,
"name": "Phasing Presence Twitter Extensino",
"version": "1.0",
"description": "A Twitter extension that draws attention to your presense in reality as you scroll.",
"icons": {
"48": "icons/icon-48.png",
@jhancock532
jhancock532 / content-aggregation.js
Created October 18, 2020 16:26
Mozilla Firefox extension that visualises the ghost of the tweets we've scrolled past.
//Don't use HTML2Canvas as part of a browser extension. Just don't. Trust me.
//For more information, see the bottom of the FAQ's at http://html2canvas.hertzen.com/faq
setTimeout(function tick() {
let timelineContainers = document.querySelectorAll('[aria-label="Timeline: Your Home Timeline"]');
let tweets = timelineContainers[0].children[0].children;
let timeline = timelineContainers[0].children[0];
for (let i = 0; i < tweets.length; i++){
@jhancock532
jhancock532 / dadaArtistsOnDada.art.js
Last active November 11, 2020 20:39
How to get Dada artists on dada.art
var img = new Image;
img.crossOrigin = "Anonymous";
img.onload = function () {
ctx_final.drawImage(img, 0, 0, img.width * 0.64, img.height * 0.69);
}
img.src = 'https://res.cloudinary.com/dvxmjunfv/image/upload/v1605120751/Photos/Dada_artists__group_photograph__1920__Paris.jpg';
@jhancock532
jhancock532 / QuaternionSlerpExample.js
Created November 27, 2020 23:04
How to animate a smooth camera angle transition in Three.js, without causing the camera to spin around itself several times.
let time = {t: 0};
const positionToLookAt = new THREE.Vector3(10, 10, 10);
const startQuaternion = camera.quaternion.clone(); //set initial angle
camera.lookAt(positionToLookAt);
const endQuaternion = camera.quaternion.clone(); //set destination angle
camera.quaternion.copy(startQuaternion);
new TWEEN.Tween(time)
.to({t: 1}, 1000) //duration in milliseconds
@jhancock532
jhancock532 / pointInPolygon.js
Created December 28, 2020 12:01
JavaScript function to check if a point is in a polgyon
function pointInPolygon(point, vs) {
// Taken from https://github.com/substack/point-in-polygon
// Nice explainer at https://observablehq.com/@tmcw/understanding-point-in-polygon
// ray-casting algorithm based on
// http://www.ecse.rpi.edu/Homepages/wrf/Research/Short_Notes/pnpoly.html
let x = point[0], y = point[1];
let inside = false;
for (let i = 0, j = vs.length - 1; i < vs.length; j = i++) {
@jhancock532
jhancock532 / emoji.js
Last active February 6, 2025 01:27
A lot of popular emojis in a JavaScript array.
let emojis = ['๐Ÿ’˜','๐Ÿ’','๐Ÿ’–','๐Ÿ’—','๐Ÿ’“','๐Ÿ’ž','๐Ÿ’•','๐Ÿ’Ÿ','โฃ๏ธ','๐Ÿ’”','โค๏ธ','๐Ÿงก','๐Ÿ’›','๐Ÿ’š','๐Ÿ’™','๐Ÿ’œ','๐ŸคŽ','๐Ÿ–ค','๐Ÿค','โค๏ธโ€','๐Ÿ”ฅ','โค๏ธโ€','๐Ÿฉน','๐Ÿ’ฏ','โ™จ๏ธ','๐Ÿ’ข','๐Ÿ’ฌ','๐Ÿ‘๏ธโ€๐Ÿ—จ๏ธ','๐Ÿ—จ๏ธ','๐Ÿ—ฏ๏ธ','๐Ÿ’ญ','๐Ÿ’ค','๐ŸŒ','โ™ ๏ธ','โ™ฅ๏ธ','โ™ฆ๏ธ','โ™ฃ๏ธ','๐Ÿƒ','๐Ÿ€„๏ธ','๐ŸŽด','๐ŸŽญ๏ธ','๐Ÿ”‡','๐Ÿ”ˆ๏ธ','๐Ÿ”‰','๐Ÿ”Š','๐Ÿ””','๐Ÿ”•','๐ŸŽผ','๐ŸŽต','๐ŸŽถ','๐Ÿ’น','๐Ÿง','๐Ÿšฎ','๐Ÿšฐ','โ™ฟ๏ธ','๐Ÿšน๏ธ','๐Ÿšบ๏ธ','๐Ÿšป','๐Ÿšผ๏ธ','๐Ÿšพ','๐Ÿ›‚','๐Ÿ›ƒ','๐Ÿ›„','๐Ÿ›…','โš ๏ธ','๐Ÿšธ','โ›”๏ธ','๐Ÿšซ','๐Ÿšณ','๐Ÿšญ๏ธ','๐Ÿšฏ','๐Ÿšฑ','๐Ÿšท','๐Ÿ“ต','๐Ÿ”ž','โ˜ข๏ธ','โ˜ฃ๏ธ','โฌ†๏ธ','โ†—๏ธ','โžก๏ธ','โ†˜๏ธ','โฌ‡๏ธ','โ†™๏ธ','โฌ…๏ธ','โ†–๏ธ','โ†•๏ธ','โ†”๏ธ','โ†ฉ๏ธ','โ†ช๏ธ','โคด๏ธ','โคต๏ธ','๐Ÿ”ƒ','๐Ÿ”„','๐Ÿ”™','๐Ÿ”š','๐Ÿ”›','๐Ÿ”œ','๐Ÿ”','๐Ÿ›','โš›๏ธ','๐Ÿ•‰๏ธ','โœก๏ธ','โ˜ธ๏ธ','โ˜ฏ๏ธ','โœ๏ธ','โ˜ฆ๏ธ','โ˜ช๏ธ','โ˜ฎ๏ธ','๐Ÿ•Ž','๐Ÿ”ฏ','โ™ˆ๏ธ','โ™‰๏ธ','โ™Š๏ธ','โ™‹๏ธ','โ™Œ๏ธ','โ™๏ธ','โ™Ž๏ธ','โ™๏ธ','โ™๏ธ','โ™‘๏ธ','โ™’๏ธ','โ™“๏ธ','โ›Ž','๐Ÿ”€','๐Ÿ”','๐Ÿ”‚','โ–ถ๏ธ','โฉ๏ธ','โญ๏ธ','โฏ๏ธ','โ—€๏ธ','โช๏ธ','โฎ๏ธ','๐Ÿ”ผ','โซ','๐Ÿ”ฝ','โฌ','โธ๏ธ','โน๏ธ','โบ๏ธ','โ๏ธ','๐ŸŽฆ','๐Ÿ”…','๐Ÿ”†','๐Ÿ“ถ','๐Ÿ“ณ','๐Ÿ“ด','โ™€๏ธ','โ™‚๏ธ','โšง','โœ–๏ธ','โž•','โž–','โž—','โ™พ๏ธ','โ€ผ๏ธ','โ‰๏ธ','โ“๏ธ','โ”','โ•','โ—๏ธ','ใ€ฐ๏ธ','๐Ÿ’ฑ','๐Ÿ’ฒ','โš•๏ธ','โ™ป๏ธ','โšœ๏ธ','๐Ÿ”ฑ','๐Ÿ“›','๐Ÿ”ฐ','โญ•๏ธ','โœ…','โ˜‘๏ธ','โœ”๏ธ','โŒ','โŽ','โžฐ','โžฟ','ใ€ฝ๏ธ','โœณ๏ธ','โœด๏ธ','โ‡๏ธ','ยฉ๏ธ','ยฎ๏ธ','โ„ข๏ธ','#๏ธโƒฃ','*๏ธโƒฃ','0๏ธโƒฃ','1๏ธโƒฃ','2๏ธโƒฃ','3๏ธโƒฃ','4๏ธโƒฃ','5๏ธโƒฃ','6๏ธโƒฃ','7๏ธโƒฃ','8๏ธโƒฃ','9๏ธโƒฃ','๐Ÿ”Ÿ','๐Ÿ” ','๐Ÿ”ก','๐Ÿ”ข','๐Ÿ”ฃ','๐Ÿ”ค','๐Ÿ…ฐ๏ธ','๐Ÿ†Ž','๐Ÿ…ฑ๏ธ','๐Ÿ†‘','๐Ÿ†’','๐Ÿ†“','โ„น๏ธ','๐Ÿ†”','โ“‚๏ธ','๐Ÿ†•','๐Ÿ†–','๐Ÿ…พ๏ธ','๐Ÿ†—','๐Ÿ…ฟ๏ธ','๐Ÿ†˜','๐Ÿ†™','๐Ÿ†š','๐Ÿˆ'
@jhancock532
jhancock532 / sitemap-generator.py
Created March 17, 2022 16:27
Sitemap Generator for Django Pattern Library Pages
# Please adapt the file paths according to your project conventions.
import glob
import re
base_url = "http://localhost:8000/pattern-library/render-pattern/patterns"
# /render-pattern/ loads the pattern in full page view without the pattern library UI
pattern_libray_pages = glob.glob('**/patterns/pages/**/*.html', recursive=True)
@jhancock532
jhancock532 / pa11yConfigGenerator.py
Created April 5, 2022 08:23
Generates a pa11y.config.js file for a Django pattern library site
import glob
import re
base_url = "http://localhost:8000/pattern-library/render-pattern/patterns"
pattern_libray_pages = glob.glob('**/patterns/pages/**/*.html', recursive=True)
config = """module.exports = {
defaults: {
standard: "WCAG2AAA",
@jhancock532
jhancock532 / Glob to Import Convertor for Sass Updates
Created May 16, 2022 15:52
If you're importing scss files in your project using a glob, this snippet will rename and output the new imports. WIP draft
import glob
import os
scss_files = glob.glob('**/patterns/**/*.scss', recursive=True)
main_scss = ""
working_dir = os.getcwd()
for file in scss_files:
@jhancock532
jhancock532 / alert.js
Created January 16, 2023 11:03
Alert
alert("Hello world!");