Skip to content

Instantly share code, notes, and snippets.

from PIL import Image
from PIL import ImageDraw
import lazyopt
import random
import os
this_dir = os.getcwd()
images_dir = os.path.join(this_dir,'images')
@neyer
neyer / hokey_pokey.py
Last active August 29, 2015 14:01
hokey pokey: an algorithm for a dance
def hokey_pokey(self):
for appendage in [ "left_hand",
"right_hand",
"left_foot",
"right_foot",
"whole_head"] :
self.put_in(getattr(self,appendage))
self.take_out(getattr(self,appendage))
self.shake_about(getattr(self,appendage))
# it's not really recursive.
@neyer
neyer / lava_flow_fixed
Last active August 29, 2015 14:06
fixed lava flow check
# fixed way
def check_for_flow(self):
if self.terrain_type == 'grass':
return False
neighbors = engine.metagrid.get_neighbors(self.pos)
flow_dirs = []
for direction in ORDINALS:
@neyer
neyer / lava_flow_bad
Created September 8, 2014 01:13
bad lava flow code
def check_for_flow(self):
if self.terrain_type == 'grass':
return False
neighbors = engine.metagrid.get_neighbors(self.pos)
did_flow = False
for direction in ORDINALS:
these_neighbors = neighbors.get(direction) or {}
ground_neighbor = these_neighbors.get(LAYER_GROUND)
@neyer
neyer / rearranging images
Last active August 29, 2015 14:06
rearranging images
from PIL import Image
i = Image.open('static/images/dudes/sheep-2.png')
new_image = Image.new(i.mode, (256,256))
size_per_image = 128
real_image_size = 64
# for changing old sheep with spacing to new sheep
def map_portion(x_num, y_num):
start_x = x_num*size_per_image + 32
# from a post
"message_tags": {
"9": [
{
"id": "849191185199284",
"name": "Mark Chandler",
"type": "user",
"offset": 9,
"length": 13
{"meta":{},"content":{"sites":[{"title":"javascript - Get website's favicon with JS - Stack Overflow","url":"https://stackoverflow.com/questions/2057636/get-websites-favicon-with-js","timestamp_ms":1646504705389},{"title":"Chrome extensions: Local storage - DEV Community","url":"https://dev.to/paulasantamaria/chrome-extensions-local-storage-1b34","timestamp_ms":1646504706970},{"title":"javascript localStorage in extension at DuckDuckGo","url":"https://duckduckgo.com/?q=javascript+localStorage+in+extension&t=brave&ia=web","timestamp_ms":1646504708178},{"title":"Migrating from background pages to service workers - Chrome Developers","url":"https://developer.chrome.com/docs/extensions/mv3/migrating_to_service_workers/","timestamp_ms":1646504709302},{"title":"Samples - Chrome Developers","url":"https://developer.chrome.com/docs/extensions/mv3/samples/","timestamp_ms":1646504712334},{"title":"javascript - Get website's favicon with JS - Stack Overflow","url":"https://stackoverflow.com/questions/2057636/get-website
{"meta":{},"content":{"sites":[{"title":"javascript - Get website's favicon with JS - Stack Overflow","url":"https://stackoverflow.com/questions/2057636/get-websites-favicon-with-js","timestamp_ms":1646504705389},{"title":"Chrome extensions: Local storage - DEV Community","url":"https://dev.to/paulasantamaria/chrome-extensions-local-storage-1b34","timestamp_ms":1646504706970},{"title":"javascript localStorage in extension at DuckDuckGo","url":"https://duckduckgo.com/?q=javascript+localStorage+in+extension&t=brave&ia=web","timestamp_ms":1646504708178},{"title":"Migrating from background pages to service workers - Chrome Developers","url":"https://developer.chrome.com/docs/extensions/mv3/migrating_to_service_workers/","timestamp_ms":1646504709302},{"title":"Samples - Chrome Developers","url":"https://developer.chrome.com/docs/extensions/mv3/samples/","timestamp_ms":1646504712334},{"title":"javascript - Get website's favicon with JS - Stack Overflow","url":"https://stackoverflow.com/questions/2057636/get-website
{"meta":{},"content":{"sites":[{"title":"javascript - Get website's favicon with JS - Stack Overflow","url":"https://stackoverflow.com/questions/2057636/get-websites-favicon-with-js","timestamp_ms":1646504705389},{"title":"Chrome extensions: Local storage - DEV Community","url":"https://dev.to/paulasantamaria/chrome-extensions-local-storage-1b34","timestamp_ms":1646504706970},{"title":"javascript localStorage in extension at DuckDuckGo","url":"https://duckduckgo.com/?q=javascript+localStorage+in+extension&t=brave&ia=web","timestamp_ms":1646504708178},{"title":"Migrating from background pages to service workers - Chrome Developers","url":"https://developer.chrome.com/docs/extensions/mv3/migrating_to_service_workers/","timestamp_ms":1646504709302},{"title":"Samples - Chrome Developers","url":"https://developer.chrome.com/docs/extensions/mv3/samples/","timestamp_ms":1646504712334},{"title":"javascript - Get website's favicon with JS - Stack Overflow","url":"https://stackoverflow.com/questions/2057636/get-website
{"meta":{},"content":{"sites":[{"title":"javascript - Get website's favicon with JS - Stack Overflow","url":"https://stackoverflow.com/questions/2057636/get-websites-favicon-with-js","timestamp_ms":1646504705389},{"title":"Chrome extensions: Local storage - DEV Community","url":"https://dev.to/paulasantamaria/chrome-extensions-local-storage-1b34","timestamp_ms":1646504706970},{"title":"javascript localStorage in extension at DuckDuckGo","url":"https://duckduckgo.com/?q=javascript+localStorage+in+extension&t=brave&ia=web","timestamp_ms":1646504708178},{"title":"Migrating from background pages to service workers - Chrome Developers","url":"https://developer.chrome.com/docs/extensions/mv3/migrating_to_service_workers/","timestamp_ms":1646504709302},{"title":"Samples - Chrome Developers","url":"https://developer.chrome.com/docs/extensions/mv3/samples/","timestamp_ms":1646504712334},{"title":"javascript - Get website's favicon with JS - Stack Overflow","url":"https://stackoverflow.com/questions/2057636/get-website