This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Run this Lambda function inside a VPC with a MongoDB instance inside it. | |
# Set up security groups to allow the function to communicate with the MongoDB endpoint | |
# NAT service or NAT instance is required because the function need to access AWS KMS, which an external endpoint | |
# Set four environment variables for the function containing the details required for the MongoDB endpoint uri | |
# I used the Bitnami MongoDB install from the AWS Marketplace | |
import boto3 | |
import os | |
from base64 import b64decode |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @param realDate your real date -> dd/MM/yyyy | |
* */ | |
public static String controlDateWithTimestamps(String realDate) { | |
try { | |
Long currentTimestamp = System.currentTimeMillis() / 1000; | |
DateFormat formatter2 = new SimpleDateFormat("dd/MM/yyyy"); | |
Date messageDate = (Date) formatter2.parse(realDate); | |
Long messageTimestamp = messageDate.getTime() / 1000; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* This code is licensed under the terms of the MIT license | |
* | |
* Deep diff between two object, using lodash | |
* @param {Object} object Object compared | |
* @param {Object} base Object to compare with | |
* @return {Object} Return a new object who represent the diff | |
*/ | |
function difference(object, base) { | |
function changes(object, base) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
def supersample(clip, d, nframes): | |
""" Replaces each frame at time t by the mean of `nframes` equally spaced frames | |
taken in the interval [t-d, t+d]. This results in motion blur.""" | |
def fl(gf, t): | |
tt = np.linspace(t-d, t+d, nframes) | |
avg = np.mean(1.0*np.array([gf(t_) for t_ in tt]),axis=0) | |
return avg.astype("uint8") | |
return clip.fl(fl) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# a bit of a hack | |
# by Cormac Relf - cormacrelf.com - @cormacrelf | |
# Opens the url on the clipboard in Safari | |
# by opening Google Chrome with an x-callback-url | |
# that takes you to the same url in Safari. | |
# I guess you could just open it in googlechrome:// | |
import webbrowser |