Skip to content

Instantly share code, notes, and snippets.

View lucahammer's full-sized avatar
💭
Cleaning code.

Luca Hammer lucahammer

💭
Cleaning code.
View GitHub Profile
'''
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
@lucahammer
lucahammer / fbcomment2clipboard.js
Created August 9, 2018 13:18
Copy first names of all visible users to clipboard
javascript:(function()%7B%2F*https%3A%2F%2Fhackernoon.com%2Fcopying-text-to-clipboard-with-javascript-df4d4988697f*%2Fconst%20copyToClipboard%20%3D%20str%20%3D%3E%20%7Bconst%20el%20%3D%20document.createElement('textarea')%3Bel.value%20%3D%20str%3Bel.setAttribute('readonly'%2C%20'')%3Bel.style.position%20%3D%20'absolute'%3Bel.style.left%20%3D%20'-9999px'%3Bdocument.body.appendChild(el)%3Bel.select()%3Bdocument.execCommand('copy')%3Bdocument.body.removeChild(el)%3B%7D%3Bvar%20names%20%3D%20%5B%5D%3B%20for%20(var%20item%20of%20document.querySelectorAll(%22.UFICommentActorName%22))%7Bnames.push(item.innerText.split(%22%20%22)%5B0%5D)%7D%3BcopyToClipboard(names.join('%2C'))%7D)()
javascript:(function(){
/*https://hackernoon.com/copying-text-to-clipboard-with-javascript-df4d4988697f*/
const copyToClipboard = str => {
const el = document.createElement('textarea');
el.value = str;
el.setAttribute('readonly', '');
el.style.position = 'absolute';
el.style.left = '-9999px';
@lucahammer
lucahammer / typomarklets.js
Last active April 3, 2018 08:08
Typo Bookmarklets
// Copy a zero width whitespace to the clipboard
// Adds a element to the document, selects it, adds it to the clipboard and removes it
// Source: https://stackoverflow.com/questions/5046972/copy-text-to-clipboard-from-bookmarklet
javascript:!function(a){var b=document.createElement("textarea"),c=document.getSelection();b.textContent=a,document.body.appendChild(b),c.removeAllRanges(),b.select(),document.execCommand("copy"),c.removeAllRanges(),document.body.removeChild(b)}("​");
// Add Proper Quotation Marks
// Adds quotations marks around selected text
// Source https://stackoverflow.com/questions/40584878/how-to-create-a-js-bookmarklet-to-insert-fixed-text-at-cursor-position
javascript:(function(a){a.value=a.value.slice(0,a.selectionStart)+"„"+a.value.slice(a.selectionStart,a.selectionEnd)+"“"+a.value.slice(a.selectionEnd);})(document.activeElement);
@lucahammer
lucahammer / contacts-to-list.js
Created March 30, 2018 15:35
add all Facebook contacts to a list
// Create new List
// Choose Manage List -> Edit List
// Scroll to bottom of friends.
// Execute code
var friends = document.querySelectorAll('.friendListItem');
for (var i = 0; i < friends.length; i++) {
friends[i].click();
}
// collect all links to remove the apps
var delete_links = document.querySelectorAll('#delete-link');
//click all collected links
for (var i = 0; i < delete_links.length; i++) {
delete_links[i].click();
}
//wait five seconds for the confirmation boxes to load
//and click all confirmation boxes to remove the apps
Play the first html video faster (eg. on Facebook): javascript:(function(){document.getElementsByTagName('video')[0].playbackRate += 0.5})();
Play the first html video slower: javascript:(function(){document.getElementsByTagName('video')[0].playbackRate -= 0.5})();
@lucahammer
lucahammer / mastoviz.py
Last active February 12, 2024 11:29
Mastodon Network visualization (for use with Gephi)
'''
Replace base_url, access_token and user_id
'''
import requests
base_url = 'https://vis.social/api/v1/'
# https://takahashim.github.io/mastodon-access-token/
access_token = '###'
# which followers to visualize
@lucahammer
lucahammer / add-to-list.py
Created December 20, 2017 12:54
Quick script to add Twitter IDs or usernames to a Twitter list.
import tweepy;
consumer_key = 'KEYHERE'
consumer_secret = 'SECRETHERE'
access_token = 'TOKENHERE'
access_token_secret = 'TOKESECRETHERE'
auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
auth.set_access_token(access_token, access_token_secret)
api = tweepy.API(auth)
Ein paar Excel-Formeln, die ich immer wieder beim Auswerten von Tweets nutze.
=DATUM(RECHTS(H2,4),MONAT(DATWERT(1 & TEIL(H2,5,3))),TEIL(H2,9,2))
=ZEITWERT(TEIL(H2,12,8))
=DATUM(RECHTS(H2,4),MONAT(DATWERT(1&TEIL(H2,5,3))),TEIL(H2,9,2))+ZEITWERT(TEIL(H2,12,8))
=WENN(IDENTISCH(TEIL(F2,1,2),"RT"),"RT","Tweet")
=WENN(IDENTISCH(TEIL(E2,1,1),"@"), "Reply", WENN(IDENTISCH(TEIL(E2,1,2),"RT"),"RT","Tweet"))
=WENN(ISTZAHL(SUCHEN("dieblauen",F2)),"vorhanden","nicht vorhanden")
Facebook
@lucahammer
lucahammer / map.js
Last active July 24, 2017 18:08
plot long/lat csv to map with p5.js
//Loosly based on https://github.com/CodingTrain/Rainbow-Code/blob/b22fb09f6eb3e403c3efff370dab42c104a33d35/CodingChallenges/CC_57_Earthquake_Viz/sketch.js
var clat = 0;
var clon = 0;
var ww = 1024;
var hh = 512;
var zoom = 1;
var tweets;