Change name of imported type (aliasing)
The goal is to make code more productive and clean in cases where multiple classes with same name must be used in code. It should relief a developers frustration in that
.:' | |
..:' | |
.;' | |
.;!; | |
.;;;;,;;,;;,,,. | |
.,;;;'''''';;..,;;;,; | |
`'',CC;;;;;;'.....;;;. | |
:.............,'`...;;;;;;;.............;;\. :::::::::: | |
;;;;;;..,,,...,,..........;' :::::::::::;;;;;;;;;'.. | |
:::::::::::' :: `'':::::......,,,;::::::::::::::::' |
--- | |
bubbles: | |
- xpos: 20 | |
ypos: 50 | |
diameter: 200 | |
emotion: happy | |
- xpos: 80 | |
ypos: 60 | |
diameter: 210 | |
emotion: sad |
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. | |
version: '2' | |
services: | |
myapp: | |
build: . | |
container_name: "myapp" | |
image: debian/latest | |
environment: | |
- NODE_ENV=development | |
- FOO=bar | |
volumes: |
import java.util.Iterator; | |
import java.util.NoSuchElementException; | |
// Introduction: | |
// | |
// This is an example class meant to illustrate several differen concepts: | |
// * The use of type parameters (i.e. Java generics) | |
// * Implementing an iterator over some collection, in this case an array | |
// * Implementing the Iterable interface, which enables your collection | |
// to work with the Java simple for loops, i.e. (for String s : list) |
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:
str
is an 8-bit string.unicode
is for strings of unicode code points.class PWindow extends PApplet { | |
PWindow() { | |
super(); | |
PApplet.runSketch(new String[] {this.getClass().getSimpleName()}, this); | |
} | |
void settings() { | |
size(500, 200); | |
} |
#!/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) |
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 a local server for testing purposes: