This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def exec_code(code, inputs, outputs): | |
"""Execute the provided code given the inputs, return a dictonary of the outputs. | |
Keyword arguments: | |
code -- the python code to run. | |
inputs -- a dictionary of variable/initial values. | |
outputs -- the list of output variables to preserve from the run. | |
""" | |
for variable, value in inputs.items(): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Requires: | |
- pi-gpio | |
- gpio-admin | |
This snippet is intended to be the hello world equivalent for working | |
with the raspberry pi gpio with node.js. This simply flashes an LED | |
connected to pin 7 based on the duration. | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// loading jQuery on a site that doesn't have jquery for fun and ... hmmm profit?. | |
(function (jQueryURL) { | |
function loadSuccess() { | |
eval(this.responseText); | |
console.log("jQuery loaded."); | |
} | |
function loadFailed(event) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from cachetools import TTLCache | |
from sched import scheduler | |
cache = TTLCache(maxsize=128, ttl=5) | |
runner = scheduler() | |
cache["abc"] = 42 | |
def display_cached_value(cache_key): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from ctypes import * | |
class Point(Structure): | |
_fields_ = [ | |
("x", c_float), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from ctypes import c_int, Structure | |
from inspect import getsource | |
from struct import pack_into, unpack_from | |
# Create 2 buffers, one smaller than the other for | |
# demonstration purposes. | |
buff1 = bytearray(64) | |
buff2 = bytearray(32) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from random import choice | |
t = "" | |
s = " ▁▂▃▄▅▆▇█" | |
z = 0 | |
for i in range(5000): | |
z += choice([-1, 1]) | |
if z < 0: | |
z = z + 2 | |
elif z >= len(s): | |
z = z - 2 |