start new:
tmux
start new with session name:
tmux new -s myname
""" | |
Convert a MongoDB ObjectID to a version-1 UUID. | |
Python 2.7+ required for datetime.timedelta.total_seconds(). | |
ObjectID: | |
- UNIX timestamp (32 bits) | |
- Machine identifier (24 bits) | |
- Process ID (16 bits) | |
- Counter (24 bits) |
/* | |
Notes: | |
Despite Scala's appearances, it is, in fact, a Statically Typed language. | |
It has just eliminated a great deal of the "type vomit" people are used | |
to seeing in Statically Typed languages (e.g. C, C++, Java). It often | |
can infer the type on its own. It also combines functional and | |
object-oriented programming paradigms in a fashion that feels similar | |
to Python. | |
*/ |
When hosting our web applications, we often have one public IP
address (i.e., an IP address visible to the outside world)
using which we want to host multiple web apps. For example, one
may wants to host three different web apps respectively for
example1.com
, example2.com
, and example1.com/images
on
the same machine using a single IP address.
How can we do that? Well, the good news is Internet browsers
Magic words:
psql -U postgres
Some interesting flags (to see all, use -h
or --help
depending on your psql version):
-E
: will describe the underlaying queries of the \
commands (cool for learning!)-l
: psql will list all databases and then exit (useful if the user you connect with doesn't has a default database, like at AWS RDS)import com.github.fge.jsonschema.core.report.ProcessingMessage | |
import scala.collection.JavaConversions._ | |
import com.fasterxml.jackson.databind.JsonNode | |
import com.github.fge.jsonschema.main.JsonSchemaFactory | |
import org.json4s._ | |
import org.json4s.jackson.JsonMethods._ |
#!/usr/bin/env python | |
#-*- coding:utf8 -*- | |
# sources | |
# 1. https://gist.github.com/tell-k/4943359#file-paramiko_proxycommand_sample-py-L11 | |
# 2. https://github.com/paramiko/paramiko/pull/97 | |
# info: http://bitprophet.org/blog/2012/11/05/gateway-solutions/ | |
# local -> proxy-server -> dest-server | |
# ~/.ssh/config | |
# | |
# Host proxy-server |
val s3Paths = "s3://yourbucket/path/to/file1.txt,s3://yourbucket/path/to/directory" | |
val pageLength = 100 | |
val key = "YOURKEY" | |
val secret = "YOUR_SECRET" | |
import com.amazonaws.services.s3._, model._ | |
import com.amazonaws.auth.BasicAWSCredentials | |
import com.amazonaws.services.s3.model.ObjectListing | |
import scala.collection.JavaConverters._ | |
import scala.io.Source |