Skip to content

Instantly share code, notes, and snippets.

View hicay's full-sized avatar

Salih Caglar Ispirli hicay

View GitHub Profile
@ianmas-aws
ianmas-aws / mongoDBWriter_lambda.py
Created March 28, 2017 07:43
Example Lambda Fuction for pushing event data into a MongoDB database
# 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
/**
* @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;
@Yimiprod
Yimiprod / difference.js
Last active May 10, 2024 16:49
Deep diff between two object, using lodash
/**
* 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) {
@Zulko
Zulko / moviepy_motion_blur.py
Last active December 10, 2022 07:03
Motion blur in MoviePy.
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)
@cormacrelf
cormacrelf / OpenURL.py
Created January 20, 2013 13:35
open url in safari from pythonista
# 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