Skip to content

Instantly share code, notes, and snippets.

View oddjobz's full-sized avatar
😀
Coding!

Gareth Bult oddjobz

😀
Coding!
View GitHub Profile
>>> for doc in people.find():
... print('Name: {name:20} Age:{age:3}'.format(**doc))
...
Name: Fred Bloggs Age: 21
Name: Joe Smith Age: 22
Name: John Doe Age: 19
>>> for doc in people.find():
... print(doc)
...
{'_id': b'58ed69161839fc5e5a57bc35', 'name': 'Fred Bloggs', 'age': 21}
{'_id': b'58ed69211839fc5e5a57bc36', 'name': 'Joe Smith', 'age': 22}
{'_id': b'58ed69301839fc5e5a57bc37', 'name': 'John Doe', 'age': 19}
@oddjobz
oddjobz / pynndb-item-1-3-1.py
Created March 28, 2020 02:08
First example in the PyNNDB Introduction
from pynndb import Database
db = Database('my-database')
people = db.table('people')
people.append({'name': 'Fred Bloggs', 'age': 21})
people.append({'name': 'Joe Smith', 'age': 22})
people.append({'name': 'John Doe', 'age': 19})

Keybase proof

I hereby claim:

  • I am oddjobz on github.
  • I am garethbult (https://keybase.io/garethbult) on keybase.
  • I have a public key ASAfLQU2R-hp4nc0VJAkmEAWddglshrNzWIRJFRtKUPIbQo

To claim this, I am signing this object:

@oddjobz
oddjobz / isinarray.py
Created September 9, 2017 11:30
Code Test: return True if sequence appears in array
def isinarray_str(arr, seq):
return str(seq).strip('[]') in str(arr).strip('[]')
print(isinarray_str([1,2,3,4,5,6], [3,4]))
print(isinarray_str([1,2,3,4,5,6], [3,5]))