Skip to content

Instantly share code, notes, and snippets.

@lucasmcastro
lucasmcastro / mongoloide
Created March 20, 2014 00:40
mongo + pymongo + mongolab
>>> from pymongo import MongoClient
>>> import datetime
post = {"author": "Mike","text": "My first blog post!","tags": ["mongodb", "python", "pymongo"], "date": datetime.datetime.utcnow()}
>>> uri = "mongodb://pyladies:pyladies@dbh16.mongolab.com:27167/series4ladies"
>>> client = MongoClient(uri)
>>> client
MongoClient('dbh16.mongolab.com', 27167)
>>> client.series4ladies
Database(MongoClient('dbh16.mongolab.com', 27167), u'series4ladies')
>>> db = client.series4ladies
@gruber
gruber / Liberal Regex Pattern for All URLs
Last active May 29, 2024 00:03
Liberal, Accurate Regex Pattern for Matching All URLs
The regex patterns in this gist are intended to match any URLs,
including "mailto:foo@example.com", "x-whatever://foo", etc. For a
pattern that attempts only to match web URLs (http, https), see:
https://gist.github.com/gruber/8891611
# Single-line version of pattern:
(?i)\b((?:[a-z][\w-]+:(?:/{1,3}|[a-z0-9%])|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}/)(?:[^\s()<>]+|\(([^\s()<>]+|(\([^\s()<>]+\)))*\))+(?:\(([^\s()<>]+|(\([^\s()<>]+\)))*\)|[^\s`!()\[\]{};:'".,<>?«»“”‘’]))