Skip to content

Instantly share code, notes, and snippets.

Avatar
🚑
Git problems? Better Call Luca

Andrew Luca iamandrewluca

🚑
Git problems? Better Call Luca
View GitHub Profile
@iamandrewluca
iamandrewluca / find-duplicated-ids.js
Created Jun 29, 2020
Will search and mark duplicated IDs on a page #bookmarklet
View find-duplicated-ids.js
javascript: void ((function() {
/* More bookmarklets at https://gist.github.com/iamandrewluca/61feacf07bc4f2f50e70f986c2e9b2d2 */
document.querySelectorAll('[id]').forEach(el => {
const specificIds = document.querySelectorAll(`[id="${el.id}"]`);
if (specificIds.length > 1 && specificIds[0] === el) {
console.log('Duplicate id ' + el.id);
specificIds.forEach(element => {
element.style.outline = '5px solid red';
});
alert('duplicate found');
@iamandrewluca
iamandrewluca / headings-out-of-order.js
Last active Jun 29, 2020
Will outline headings out of order in a page (from https://twitter.com/Una/status/1277652897606635523) #bookmarklet
View headings-out-of-order.js
javascript: void ((function() {
/* More bookmarklets at https://gist.github.com/iamandrewluca/61feacf07bc4f2f50e70f986c2e9b2d2 */
const styles = document.createTextNode(`
/* Headers out of order (i.e. h2 before h1, etc.) */
/* Result: dotted blue outline */
/* https://twitter.com/Una/status/1277652897606635523 */
h2 ~ h1,
h3 ~ h1,
h4 ~ h1,
h5 ~ h1,
@iamandrewluca
iamandrewluca / speak-selected-text.js
Last active Jun 18, 2020
Will speak any select text from page #bookmarklet
View speak-selected-text.js
javascript: void ((async () => {
/* More bookmarklets at https://gist.github.com/iamandrewluca/61feacf07bc4f2f50e70f986c2e9b2d2 */
let interval = 500;
const intervalId = setInterval(() => {
interval += 500;
if (interval > 5000) { return; }
if (window.speechSynthesis.getVoices().length !== 0) {
clearInterval(intervalId);
@iamandrewluca
iamandrewluca / shrug.js
Last active Jun 18, 2020
Random Shrug text emoji #bookmarklet
View shrug.js
javascript: void(function() {
/* More bookmarklets at https://gist.github.com/iamandrewluca/61feacf07bc4f2f50e70f986c2e9b2d2 */
const all = [
"¯\\_(ツ)_/¯",
"¯\\(ツ)/¯",
"ʅ(ツ)ʃ",
"乁(ツ)ㄏ",
"乁(ツ)∫",
"ƪ(ツ)∫",
"¯\\_₍ッ₎_/¯",
@iamandrewluca
iamandrewluca / open-localhost.js
Last active Jun 18, 2020
Open any URL with host as localhost:3000 #bookmarklet
View open-localhost.js
javascript: void((function () {
/* More bookmarklets at https://gist.github.com/iamandrewluca/61feacf07bc4f2f50e70f986c2e9b2d2 */
/**
* Add your own mappers, first found will be used
* @type {{host: string, startsWith: string}[]}
*/
const hostMapper = [
{ startsWith: 'https://example.org', host: 'localhost:3000' },
{ startsWith: 'https://example.org/admin', host: 'localhost:3001' },
];
@iamandrewluca
iamandrewluca / request-picture-in-picture.js
Last active Jun 18, 2020
Request picture in picture on first found video that is playing #bookmarklet
View request-picture-in-picture.js
javascript: void ((function() {
/* More bookmarklets at https://gist.github.com/iamandrewluca/61feacf07bc4f2f50e70f986c2e9b2d2 */
/** @type {NodeListOf<HTMLIFrameElement>} */
const iFrames = window.document.querySelectorAll('iframe');
/** @type {Document[]} */
const allDocuments = [
window.document,
...Array.from(iFrames)
.map(i => i.contentDocument)
@iamandrewluca
iamandrewluca / password-toggler.js
Last active Jun 18, 2020
Toggle password inputs to text back and forth #bookmarklet
View password-toggler.js
javascript: void ((function() {
/* More bookmarklets at https://gist.github.com/iamandrewluca/61feacf07bc4f2f50e70f986c2e9b2d2 */
const passwordInputs = document.querySelectorAll('[type="password"], [data-password-bookmark-toggled]');
Array.from(passwordInputs).forEach(e => {
if (e.getAttribute('data-password-bookmark-toggled')) {
e.removeAttribute('data-password-bookmark-toggled');
e.setAttribute('type', 'password');
} else {
e.setAttribute('data-password-bookmark-toggled', true);
e.setAttribute('type', 'text');
@iamandrewluca
iamandrewluca / generate-password.js
Last active Jun 18, 2020
Generate a password in browser #bookmarklet
View generate-password.js
javascript: void((function() {
/* More bookmarklets at https://gist.github.com/iamandrewluca/61feacf07bc4f2f50e70f986c2e9b2d2 */
const upAlpha = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
const lowAlpha = 'abcdefghijklmnopqrstuvwxyz';
const digits = '0123456789';
const specialChars = '!@#$.+';
const defaultSettings = confirm('Default settings');
const includeUpAlpha = defaultSettings ? true : confirm('Include: ' + upAlpha + ' ?');
const includeLowAlpha = defaultSettings ? true : confirm('Include: ' + lowAlpha + ' ?');
@iamandrewluca
iamandrewluca / duplicate-id-finder.js
Last active Apr 6, 2020
Find and mark elements with on page which have duplicate IDs
View duplicate-id-finder.js
javascript: void ((function() {
const ids = document.querySelectorAll('[id]');
Array.from(ids).forEach(el => {
const id = document.querySelectorAll(`[id="${el.id}"]`);
if (id.length > 1 && id[0] === el) {
console.log('Duplicate id ' + el.id);
Array.from(id).forEach(fel => {
fel.style.outline = '5px solid red';
});
alert('duplicate found');
View yellowpages.md.java
import org.apache.commons.csv.CSVFormat;
import org.apache.commons.csv.CSVPrinter;
import org.apache.commons.csv.CSVRecord;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;
import java.io.*;
import java.net.*;
You can’t perform that action at this time.