Skip to content

Instantly share code, notes, and snippets.

// paste this into your console
// Warning: only do this after thoroughly comprehending it because pasting mystery code into your console is bad :p
var doEv=ev=>s=>document.dispatchEvent(new KeyboardEvent(ev,{bubbles:1,keyCode:s.toLowerCase().charCodeAt(0)-32}));
var press=doEv("keydown");
var release=doEv("keyup");
var readGamepad = function() {
if(navigator.getGamepads()[0].axes[1]>.5) { press("s"); } else { release("s"); }
if(navigator.getGamepads()[0].axes[1]<-.5) { press("w"); } else { release("w"); }
class STIXPackage:
def to_xml(self, include_namespaces=True, include_schemalocs=False,
ns_dict=None, schemaloc_dict=None):
# do things
# monkey patch
global __old_to_xml_clobbered_by_stix_edh
__old_to_xml_clobbered_by_stix_edh = stix.core.stix_package.STIXPackage.to_xml
def new_to_xml(self, ns_dict=None, *args, **kwargs):
if ns_dict is None: ns_dict = {}
alert(1)
@apsillers
apsillers / CellTemplate.java
Last active August 29, 2015 14:03
Java BftPD sample cell
/*
Sample code for a "Battle for the Petri Dish" cell
Released under the terms of the WTF Public License
No warranty express or implied is granted, etc, etc.
I just hacked this together very quickly; improvements are welcome, so please fork the Gist if you like.
*/
import java.io.BufferedReader;
@apsillers
apsillers / cell_template.js
Created July 12, 2014 06:46
JavaScript BftPD sample cell
/*
Sample code for a "Battle for the Petri Dish" cell
Released under the terms of the WTF Public License,
No warranty express or implied is granted, etc, etc.
I just hacked this together very quickly; improvements are welcome, so please fork the Gist if you like.
*/
// used in defining cell spec
@apsillers
apsillers / cell_template.py
Created July 11, 2014 22:12
Python BftPD sample cell
#!/usr/bin/python
#
# Sample code for a "Battle for the Petri Dish" cell
#
# Released under the terms of the WTF Public License,
# No warranty express or implied is granted, etc, etc.
#
# I just hacked this together very quickly; improvements are welcome, so please fork the Gist if you'd like to share your improvements.
import sys
@apsillers
apsillers / petri.js
Last active August 29, 2015 14:03
"Battle for the Petri Dish" driver
/*
Node.js implementation of the "Battle for the Petri Dish" driver
Copyright (c) 2014, Andrew P. Sillers
All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.