Skip to content

Instantly share code, notes, and snippets.

View JacopoDaeli's full-sized avatar
🙈

Jacopo Daeli JacopoDaeli

🙈
View GitHub Profile
@JacopoDaeli
JacopoDaeli / redis-dump-to-gs
Last active October 23, 2017 05:19
Backup Redis to Goolge Cloud Storage
#!/bin/bash
#### BEGIN CONFIGURATION ####
# set dates for backup rotation
NOWDATE=`date +%Y-%m-%d`
# set backup directory variables
SRCDIR='/tmp/gs_backups'
DESTDIR='redis'
@JacopoDaeli
JacopoDaeli / hello-name.js
Last active April 16, 2017 01:56
Say Hello {name} or Hello World.
'use strict'
const express = require('express')
const app = express()
const PORT = process.env.PORT || 3000
function capitalize (str) {
const firstLetter = str.charAt(0) // we can check what's inside here
return `${firstLetter.toUpperCase()}${str.slice(1)}`
@JacopoDaeli
JacopoDaeli / video_to_thumbs.py
Last active May 21, 2018 08:16
Extract frames from the video and creates thumbnails for one of each
import os
import cv2
def run_example():
"""Extract frames from the video and creates thumbnails for one of each"""
# Extract frames from video
print "Extract frames from video"
frames = video_to_frames('/path/to/video')
# Generate and save thumbs
@JacopoDaeli
JacopoDaeli / image_to_thumbs.py
Last active November 29, 2016 05:25
Create thumbs from image
import cv2
def image_to_thumbs(img):
"""Create thumbs from image"""
height, width, channels = img.shape
thumbs = {"original": img}
sizes = [640, 320, 160]
for size in sizes:
if (width >= size):
r = (size + 0.0) / width
@JacopoDaeli
JacopoDaeli / video_to_frames.py
Last active July 6, 2021 13:52
Extract frames from pre-recored video with Python and OpenCV
import cv2
def video_to_frames(video_filename):
"""Extract frames from video"""
cap = cv2.VideoCapture(video_filename)
video_length = int(cap.get(cv2.CAP_PROP_FRAME_COUNT)) - 1
frames = []
if cap.isOpened() and video_length > 0:
frame_ids = [0]
if video_length >= 4:
@JacopoDaeli
JacopoDaeli / ci_pipeline_travis_example.yml
Last active October 15, 2019 10:23
TravisCI setup example for CI pipeline
# Use Dockerized infrastructure
sudo: false
# Use node_js environnement
language: node_js
node_js:
- "6"
# Cache Gcloud SDK between commands
cache:
#!/usr/bin/env python
#
# Converts any integer into a base [BASE] number. I have chosen 62
# as it is meant to represent the integers using all the alphanumeric
# characters, [no special characters] = {0..9}, {A..Z}, {a..z}
#
# I plan on using this to shorten the representation of possibly long ids,
# a la url shortenters
#
@JacopoDaeli
JacopoDaeli / slack_delete.py
Last active January 20, 2016 11:06
Delete Slack files older than 7 days.
#!/usr/bin/env python
import requests
import time
import json
token = ''
#Delete files older than this:
ts_to = int(time.time()) - 7 * 24 * 60 * 60
@JacopoDaeli
JacopoDaeli / redis3-0-3.conf
Last active August 29, 2015 14:26
Custom config for Redis 3.0.3
# Redis configuration file example
# Note on units: when memory size is needed, it is possible to specify
# it in the usual form of 1k 5GB 4M and so forth:
#
# 1k => 1000 bytes
# 1kb => 1024 bytes
# 1m => 1000000 bytes
# 1mb => 1024*1024 bytes
# 1g => 1000000000 bytes
@JacopoDaeli
JacopoDaeli / install-redis.sh
Last active August 29, 2015 14:26
Install Redis on Ubuntu / Debian
#!/bin/sh
# Clone redis from GitHub
# Run make && sudo amke install
# Copy and run this script from redis/utils folder as sudo
die () {
echo "ERROR: $1. Aborting!"
exit 1
}