Skip to content

Instantly share code, notes, and snippets.

View DanH42's full-sized avatar

Dan Hlavenka DanH42

View GitHub Profile
@DanH42
DanH42 / likeAllComments.js
Created September 16, 2016 16:38
Expands collapsed threads and then likes every comment on the current Facebook page
(function expandThreads(){
var count = 0;
var els = document.querySelectorAll('.UFIReplySocialSentenceLinkText, .UFIPagerLink');
console.log("Expanding", els.length, "threads");
for(var i = 0; i < els.length; i++){
if(els[i].innerText.indexOf("Hide") === -1){
els[i].click();
count++;
}
}
@DanH42
DanH42 / addr.json
Last active February 6, 2017 21:52
Dynamic DNS using the CloudFlare API
{}
#!/usr/bin/python
text = '22T189RSNH11T .264749,"OIO""O"O,RSNDLHNLDHDSDSHSDCCCRCCNHNNK.ETFGWU .E0E T6839937643?!,"O'
text += '!RLHDSRSCSDLNCCCCCDNUV1E RCHN2E0E 68495RSNNRSRRLHNCLHDCDSDSDNCCNCCCH,"?,HJQKV"???,DRLCCC'
#text = '68753RCNRLNYYWGGWUFMGKXKXQZKXJZZKK'
register = [1,1,1,1,1,1,1,0]
spoke = 0
spokes = [
@DanH42
DanH42 / markov.php
Last active August 29, 2015 14:17
Markov Science!
<?php
/*
PHP Markov Chain text generator 1.0
Copyright (c) 2008-2010, Hay Kranen <http://www.haykranen.nl/projects/markov/>
Fork on Github: < http://github.com/hay/markov >
License (MIT / X11 license)
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
@DanH42
DanH42 / COBOL-AJAX.js
Last active August 29, 2015 14:07
A COBOL programmer tries to use AJAX
// IDENTIFICATION DIVISION.
// PROGRAM_ID. AJAX_EXAMPLE.
//*
// ENVIRONMENT DIVISION.
//*
// DATA DIVISION.
// WORKING_STORAGE SECTION.
var AJAX = null;
var URL = "EXAMPLE.TXT";
var RESPONSE = "";
@DanH42
DanH42 / led_udp.ino
Last active August 29, 2015 14:06
Read color codes (0-255, ['#', r, g, b, '\n']) from incoming UDP packets and write them out to LEDs, and adjust brightness with ['%', n, '\n']
#include <SPI.h>
#include <Ethernet.h>
#include <EthernetUdp.h>
byte mac[] = {0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED};
IPAddress ip(192, 168, 0, 20);
unsigned int localPort = 8888;
EthernetUDP Udp;
unsigned char packetBuffer[UDP_TX_PACKET_MAX_SIZE];
@DanH42
DanH42 / blackfacebook.css
Last active July 30, 2020 19:14
Changes Facebook from blue to black
/* Top bar */
#blueBarNAXAnchor, ._4f7n, ._2s1x ._2s1y{
background-image: none !important;
background-color: #333 !important;
border-bottom-color: #222 !important;
}#blueBarNAXAnchor:after, ._4f7n:after, ._2s1x ._2s1y:after{
background: none !important;
}
/* Notification Icon */

Keybase proof

I hereby claim:

  • I am DanH42 on github.
  • I am danhlavenka (https://keybase.io/danhlavenka) on keybase.
  • I have a public key whose fingerprint is E68A 615B 6413 29DF 7EE4 3B28 FBB7 F72D E5D8 6AC5

To claim this, I am signing this object:

@DanH42
DanH42 / betterPanTo.js
Created March 10, 2014 17:11
Pan a to a given LatLng if the location is not near the middle of the map (either off-screen or near the edge)
// License: MIT (c) 2014 Dan Hlavenka
function panIfNotClose(map, latLng){
// Calculate the "middle half" of the map
var bounds = map.getBounds();
var center = bounds.getCenter();
var northEast = bounds.getNorthEast();
var southWest = bounds.getSouthWest();
var adjust = {
lat: Math.abs(northEast.lat() - center.lat()) / 2,
lng: Math.abs(northEast.lng() - center.lng()) / 2
@DanH42
DanH42 / cache.php
Last active August 29, 2015 13:56
Simple PHP cache
<?php
$cache = json_decode(file_get_contents("cache.json"), true);
function get($url, $max_age=1){
global $cache;
$hash = crc32($url);
if(isset($cache[$hash])){
if(time() - $cache[$hash] > $max_age)
return cache_add($url, $hash);
return file_get_contents("cache/" . $hash . ".txt");
}else