Skip to content

Instantly share code, notes, and snippets.

desc_text = self.redis.hmget(key + '_description', getattr(self, featurename))[0]
print "Query %s for %s and get %s.\n" % (key + '_description', getattr(self, featurename), desc_text )
print "is text not none? %s" % (desc_text is not None)
if desc_text is not None:
featurevalue = json.loads(desc_text)
print "load %s as json and get %s\n" % (desc_text, featurevalue)
print "so %s is now %s\n" % (featurename+'_description', featurevalue)
setattr(self, featurename + '_description', featurevalue)
@morgajel
morgajel / gist:7fa8b232a9f05c711e3b
Last active October 28, 2023 09:49
Mass Layer Gimp Python Fu scripts
align multiple layers to the center of an image in gimp
layer = gimp.image_list()[0].layers[0]
image = gimp.image_list()[0]
for layer in gimp.image_list()[0].layers :
x = (image.width - layer.width) / 2
y = (image.height - layer.height) / 2
layer.set_offsets(x, y)
@morgajel
morgajel / gist:ba49f6edf1e86edda17b
Created September 27, 2014 21:54
Road drawing algorithm in JS

I have two coordinates on a plane, ranging from 100 > x > -100 and 100 > y > -100.

I need to draw a road that:

  • starts at point A
  • contains z number of "stops" along the way that may drift from a direct line
  • never overlaps itself
  • ambles near (but not exactly) [0,0]
  • ambles to point B
@morgajel
morgajel / foo.json
Created September 17, 2014 13:49
/_cluster/health?pretty=true
{
"cluster_name" : "elasticsearch",
"status" : "yellow",
"timed_out" : false,
"number_of_nodes" : 1,
"number_of_data_nodes" : 1,
"active_primary_shards" : 261,
"active_shards" : 261,
"relocating_shards" : 0,
"initializing_shards" : 0,
env ▶ morgajel ▶ linwider ▶ ~ ▶ multiverseminer ▶ feature/test-refactor ▶ $ ▶py.test
======================================================================================== test session starts ========================================================================================
platform linux2 -- Python 2.7.6 -- py-1.4.23 -- pytest-2.6.1
plugins: cov
collected 54 items
tests/test_account_context.py ..
tests/test_admin.py ....
tests/test_craft.py .....
tests/test_login.py .......
.
├── config.py
├── config.py.sample
├── config.py.test
├── data
│   ├── accounts.json
│   ├── items.json
│   └── planets.json
├── db_migrate.py
├── import_data.py
class Character(db.Model):
""" Character is the actual in-game PC."""
name = db.Column(db.String(64), primary_key=True, nullable=False)
class Item(db.Model):
""" Primary table with all the goodies. """
name = db.Column(db.String(64), primary_key=True)
# I want several characters associated with an account, and a single character to be the "active character"
# The result should look something like this:
# bob= Account(name='bob')
# conan = Character(name='Conan')
# beowulf = Character(name='Beowulf')
# bob.characters=[conan, beowulf]
# bob.active_character=conan
@morgajel
morgajel / gist:bac295a962c8f8318239
Created August 31, 2014 22:23
helpful stacktrack
INFO [alembic.migration] Context impl PostgresqlImpl.
INFO [alembic.migration] Will assume transactional DDL.
Traceback (most recent call last):
File "./db_migrate.py", line 15, in <module>
manager.run()
File "/home/morgajel/multiverseminer/env/local/lib/python2.7/site-packages/flask_script/__init__.py", line 412, in run
result = self.handle(sys.argv[0], sys.argv[1:])
File "/home/morgajel/multiverseminer/env/local/lib/python2.7/site-packages/flask_script/__init__.py", line 383, in handle
res = handle(*args, **config)
File "/home/morgajel/multiverseminer/env/local/lib/python2.7/site-packages/flask_script/commands.py", line 216, in __call__
2014-08-26 21:34:59,148 INFO sqlalchemy.engine.base.Engine BEGIN (implicit)
2014-08-26 21:34:59,150 INFO sqlalchemy.engine.base.Engine SELECT count(%s) AS count_1
FROM "user"
2014-08-26 21:34:59,150 INFO sqlalchemy.engine.base.Engine ('*',)
127.0.0.1 - - [26/Aug/2014 21:34:59] "GET /admin/userview/ HTTP/1.1" 500 -
Traceback (most recent call last):
File "/home/morgajel/flask-admin/env/lib/python2.7/site-packages/flask/app.py", line 1836, in __call__
return self.wsgi_app(environ, start_response)
File "/home/morgajel/flask-admin/env/lib/python2.7/site-packages/flask/app.py", line 1820, in wsgi_app
response = self.make_response(self.handle_exception(e))