Skip to content

Instantly share code, notes, and snippets.

View jeremydouglass's full-sized avatar

Jeremy Douglass jeremydouglass

View GitHub Profile
@monkstone
monkstone / data.yml
Last active November 27, 2017 21:22
Reading and Writing YAML with jruby-complete.jar
---
bubbles:
- xpos: 20
ypos: 50
diameter: 200
emotion: happy
- xpos: 80
ypos: 60
diameter: 210
emotion: sad
@g-io
g-io / Vividict.py
Last active May 10, 2018 12:31
Python autovivified nested dictionary
class Vividict(dict):
"""
dict class which allows to set deeply nested values. Any nested dict will get autovivified.
Note that using defaultdict is more performant, so in case of huge datasets revert to that one.
However using this class and not 'closing' it after setting values might result in undesired behavior:
When accessing a value which is not set, no KeyError is thrown, instead it's autovivified into an empty Vividict.
To guarantee this doesn't happen but KeyError is thrown, dictify() needs to be called to transform the data structure
into regular dicts.
@genekogan
genekogan / ascii-art-rnn
Created August 18, 2018 16:23
generated text from an LSTM (char-rnn-tensorflow) trained on ascii art scraped from https://www.asciiart.eu/
This file has been truncated, but you can view the full file.
.:'
..:'
.;'
.;!;
.;;;;,;;,;;,,,.
.,;;;'''''';;..,;;;,;
`'',CC;;;;;;'.....;;;.
:.............,'`...;;;;;;;.............;;\. ::::::::::
;;;;;;..,,,...,,..........;' :::::::::::;;;;;;;;;'..
:::::::::::' :: `'':::::......,,,;::::::::::::::::'
@shenwei356
shenwei356 / nested_dict.py
Created November 3, 2015 06:50
different implemention of nested dict in Python
#!/usr/bin/env python
# different implemention of nested dict in Python
from collections import defaultdict
# from: http://stackoverflow.com/questions/635483/what-is-the-best-way-to-implement-nested-dictionaries-in-python
class AutoVivification(dict):
def __getitem__(self, item):
try:
return dict.__getitem__(self, item)
@qguv
qguv / solarized-dark.css
Last active April 5, 2021 04:50 — forked from nicolashery/solarized-dark.css
Solarized theme for Jekyll, updated to reflect toned-down line numbers
/* Solarized Dark
For use with Jekyll and Pygments
http://ethanschoonover.com/solarized
SOLARIZED HEX ROLE
--------- -------- ------------------------------------------
base03 #002b36 background
base01 #586e75 comments / secondary content
@bertobox
bertobox / list-styles-for-markdown.css
Created August 28, 2012 20:31
Easy list style types for Markdown
.lower_roman+ol, .lower_roman+ul {list-style-type: lower-roman;}
.upper_roman+ol, .upper_roman+ul {list-style-type: upper-roman;}
.lower_alpha+ol, .lower_alpha+ul {list-style-type: lower-alpha;}
.upper_alpha+ol, .upper_alpha+ul {list-style-type: upper-alpha;}
.lower_greek+ol, .lower_greek+ul {list-style-type: lower-greek;}
.lower_latin+ol, .lower_latin+ul {list-style-type: lower-latin;}
.upper_latin+ol, .upper_latin+ul {list-style-type: upper-latin;}
.none+ol, .none+ul {list-style-type:none;}
.disc+ol, .disc+ul {list-style-type:disc;}
.circle+ol, .circle+ul {list-style-type:circle;}
@wrunk
wrunk / jinja2_file_less.py
Last active September 19, 2023 15:05
python jinja2 examples
#!/usr/bin/env/python
#
# More of a reference of using jinaj2 without actual template files.
# This is great for a simple output transformation to standard out.
#
# Of course you will need to "sudo pip install jinja2" first!
#
# I like to refer to the following to remember how to use jinja2 :)
# http://jinja.pocoo.org/docs/templates/
#
@gornostal
gornostal / Unicode.md
Created November 22, 2015 10:15
Python 2.7. Unicode Errors Simply Explained

Python 2.7. Unicode Errors Simply Explained

I know I'm late with this article for about 5 years or so, but people are still using Python 2.x, so this subject is relevant I think.

Some facts first:

  • Unicode is an international encoding standard for use with different languages and scripts
  • In python-2.x, there are two types that deal with text.
    1. str is an 8-bit string.
  1. unicode is for strings of unicode code points.
@atduskgreg
atduskgreg / PWindow.pde
Last active November 15, 2023 13:29
Example of creating a Processing sketch with multiple windows (works in Processing 3.0)
class PWindow extends PApplet {
PWindow() {
super();
PApplet.runSketch(new String[] {this.getClass().getSimpleName()}, this);
}
void settings() {
size(500, 200);
}
@magicznyleszek
magicznyleszek / jekyll-and-liquid.md
Last active January 12, 2024 03:46
Jekyll & Liquid Cheatsheet

Jekyll & Liquid Cheatsheet

A list of the most common functionalities in Jekyll (Liquid). You can use Jekyll with GitHub Pages, just make sure you are using the proper version.

Running

Running a local server for testing purposes: