Skip to content

Instantly share code, notes, and snippets.

View JacopoDaeli's full-sized avatar
🙈

Jacopo Daeli JacopoDaeli

🙈
View GitHub Profile
@JacopoDaeli
JacopoDaeli / keynote-code-highlighting.md
Last active August 29, 2015 14:22
Code highlighting for Keynote presentations.

Step 0:

Get Homebrew installed on your mac if you don't already have it.

Step 1:

Install highlight. Run brew install highlight (this brings down Lua and Boost as well).

Step 2:

@JacopoDaeli
JacopoDaeli / install-iojs.sh
Last active August 29, 2015 14:26
Install io.js on Ubuntu / Debian
IOJS_VERSION=v2.5.0
IOJS_DIR=$HOME/.iojs
iojs_install() {
iojs_setup
iojs_download
iojs_assemble
iojs_teardown
}
@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
}
@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 / 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
#!/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 / 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:
@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 / 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_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