Skip to content

Instantly share code, notes, and snippets.

@firelizzard18
firelizzard18 / gist:6326536
Created August 24, 2013 06:56
Objective-C Dictionary with Zeroing Weak References
#import <Foundation/Foundation.h>
@protocol DeallocListener <NSObject>
- (void)objectDidDeallocateForKey:(id)key object:(id)obj;
@end
@interface WeakDictionary : NSMutableDictionary <DeallocListener>
@firelizzard18
firelizzard18 / gist:6911804
Last active December 25, 2015 03:39
clicky
function start() {
var elem = document.createElement('div');
elem.id = 'autoclicker';
elem.style.position = 'absolute';
elem.style.top = '200px';
elem.style.left = '200px';
elem.style['z-index'] = 100000000000;
elem.style.width = '30px';
elem.style.height = '30px';
@firelizzard18
firelizzard18 / gist:6911838
Last active December 25, 2015 03:39
minclicky
function start(){var e=document.createElement("div");e.style.position="absolute";e.style.top="150px";e.style.left="50px";e.style["z-index"]=10;e.style.width="20px";e.style.height="20px";e.style["background-color"]="red";e.innerHTML="AC";e.onclick=toggle;document.body.appendChild(e);window.acint=setInterval(doClick,1);window.acel=e}function toggle(){window.ac=!window.ac;if(window.ac)window.acel.style["background-color"]="darkgreen";else window.acel.style["background-color"]="red"}function doClick(){if(window.ac)fireClick(bigCookie,100,100)}function fireClick(e,t,n){var r=e;var i={x:0,y:0};while(r!=null){i.x+=e.offsetLeft;i.y+=e.offsetTop;r=r.offsetParent}var s=document.createEvent("MouseEvents");s.initMouseEvent("click",true,true,window,1,i.x+t,i.y+n,t,t,false,false,false,false,0,null);if(e.fireEvent){e.fireEvent("on"+etype)}else{var s=document.createEvent("Events");s.initEvent("click",true,false);e.dispatchEvent(s)}}start()
@firelizzard18
firelizzard18 / play.js
Created November 26, 2015 03:49
XKCD 1608 Goggles and Position Tracker
ze.goggles()
var p = $('<div style="position: fixed; left: 0; top: 0; background: black; color: white">')
p.appendTo("body")
var oldOnTick = explorer.opts.onTick
explorer.opts.onTick = function (s) { p.text(Math.floor(s.pos.x) + ", " + Math.floor(s.pos.y)); return oldOnTick.apply(this, arguments) }
Sign up for free
@firelizzard18
firelizzard18 / mc-nbt.py
Last active August 5, 2016 03:01
Dead simple command line NBT editor
#!/usr/bin/env python
# Name: mc-nbt
# Version: 0.1
# Description: Views or edits a Minecraft NBT file
# Author: Ethan Reesor <firelizzard@gmail.com>
# License: DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE <http://www.wtfpl.net/>
# Examples:
# Print entire file:
# mc-nbt FILE
2016-10-10 20:01:55
Full thread dump Java HotSpot(TM) 64-Bit Server VM (25.25-b02 mixed mode):
"pool-11-thread-3" #366 prio=5 os_prio=0 tid=0x0000000022aae000 nid=0x912c waiting on condition [0x000000004cebe000]
java.lang.Thread.State: TIMED_WAITING (parking)
at sun.misc.Unsafe.park(Native Method)
- parking to wait for <0x00000000cc9b8cb0> (a java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject)
at java.util.concurrent.locks.LockSupport.parkNanos(LockSupport.java:215)
at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.awaitNanos(AbstractQueuedSynchronizer.java:2078)
at java.util.concurrent.LinkedBlockingQueue.poll(LinkedBlockingQueue.java:467)
@firelizzard18
firelizzard18 / gist:8b2cdf583b76c55ea40d7ee1edeb68dd
Created October 11, 2016 04:34
forge MC hang stack trace (2)
2016-10-10 21:33:36
Full thread dump OpenJDK 64-Bit Server VM (25.91-b14 mixed mode):
"Netty IO #4" #18 daemon prio=5 os_prio=0 tid=0x00007fdad4029800 nid=0x5f9d runnable [0x00007fdab5dec000]
java.lang.Thread.State: RUNNABLE
at sun.nio.ch.EPollArrayWrapper.epollWait(Native Method)
at sun.nio.ch.EPollArrayWrapper.poll(EPollArrayWrapper.java:269)
at sun.nio.ch.EPollSelectorImpl.doSelect(EPollSelectorImpl.java:93)
at sun.nio.ch.SelectorImpl.lockAndDoSelect(SelectorImpl.java:86)
- locked <0x00000006c3143650> (a io.netty.channel.nio.SelectedSelectionKeySet)
@firelizzard18
firelizzard18 / HttpContextExtensions.cs
Created January 31, 2017 02:25
`HttpContext.IsLocal()`
using System.Net;
using Microsoft.AspNetCore.Http;
// use as you will, at your own risk
namespace Ouranos.Common.AspNetCore
{
// adapted from http://stackoverflow.com/a/41242493
public static class HttpContextExtensions
{
patch-package
--- a/index.js
+++ b/index.js
@@ -31,12 +31,16 @@ function processFile(filePath) {
.then(middleware)
.then(getDefaults)
.then(data => {
+ if (data._draft && !conf.draft) return;
+
// If _layout, render it:
@firelizzard18
firelizzard18 / debsudoku.py
Created July 18, 2018 08:23
Using dpkg to solve Sudoku
#!/usr/bin/python
#
# Needs python 2.5 for the Element Tree module.
from xml.etree import ElementTree
import math
from optparse import OptionParser
def pkg_boilerplate(package, version):
"""Generate the repetitive stuff at the front of a Package stanza