Skip to content

Instantly share code, notes, and snippets.

View aledalgrande's full-sized avatar

Alessandro Dal Grande aledalgrande

View GitHub Profile
@aledalgrande
aledalgrande / lambda_start
Created June 18, 2022 23:00
Gymnastics needed to instrument Next.JS on Netlify
#!/bin/bash
# make this file executable before pushing: chmod +x lambda_start
args=("$@")
export NODE_OPTIONS='--require ./tracing.dist.js'
exec "${args[@]}"
@aledalgrande
aledalgrande / git_store_gpg_password.sh
Last active May 7, 2017 08:38
I'm tired of typing my GPG password for Git, so I save it in the keychain
brew install gpg2 pinentry-mac
brew link --overwrite gnupg2
git config --global gpg.program gpg2
echo "pinentry-program /usr/local/bin/pinentry-mac" >> ~/.gnupg/gpg-agent.conf
echo "export GPG_TTY=$(tty)" >> ~/.bash_profile
# open new terminal, commit and save your pass in keychain, yay!
@aledalgrande
aledalgrande / gist:b3cb880058bfd95ebe8e
Last active November 22, 2017 20:02
Flatten your iTunes folder keeping artist names in the filename with Ruby: change /Volumes/Backup/iTunes to whatever destination folder you want
ruby -e 'require "fileutils";Dir.glob("./**/*").reject { |d| File.directory?( d ) }.map { |f| [f, "/Volumes/Backup/iTunes/#{File.dirname(f).gsub(/([^\.])\//, "#{$1}-")}-#{File.basename(f)}"] }.map { |f| FileUtils.cp(f[0], f[1], verbose: true) }'
@aledalgrande
aledalgrande / gist:0690830224e92c0c21ca
Last active October 13, 2015 20:56
base64 string
AABmLmYyzTRmNgA4zTiaOWY6MzsAPGY8zTwzPZo9AD5mPs0+Mz+aPwAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
@aledalgrande
aledalgrande / rotations.h
Last active August 29, 2015 14:06
Fast 90°, -90°, 180° rotations
// rotate 90° CW: flip the transpose on Y
inline void rotate90CW(cv::Mat& input)
{
cv::flip(input.t(), input, 1);
}
// rotate -90° CW: flip the transpose on X
inline void rotate90CCW(cv::Mat& input)
{
cv::flip(input.t(), input, 0);
@aledalgrande
aledalgrande / home_controller.rb
Created August 10, 2014 02:03
Sidekiq notification
# app/controllers/home_controller.rb
class HomeController < ApplicationController
def index
@news = News.get_recent
@notifications = current_user.notifications
end
end
@aledalgrande
aledalgrande / article.rb
Created August 10, 2014 01:50
Sidekiq Elasticsearch
# app/models/article.rb
class Article < ActiveRecord::Base
include Elasticsearch::Model
# include Elasticsearch::Model::Callbacks
after_update :update_elasticsearch_index
def update_elasticsearch_index
ElasticSearchWorker.perform_async(Article, id)
@aledalgrande
aledalgrande / Gemfile
Last active August 29, 2015 14:05
Sidekiq video upload
# Gemfile
gem 'sidekiq'
@aledalgrande
aledalgrande / Gemfile
Created August 9, 2014 00:17
Redis example
# Gemfile
gem 'redis', '~> 3.0.1'
gem 'hiredis', '~> 0.4.5'
# ps ax | grep 3306
28723 pts/1 Sl 0:00 /usr/sbin/mysqld --basedir=/usr --datadir=/var/lib/mysql --user=mysql --pid-file=/var/lib/mysql/mysqld.pid --skip-external-locking --port=3306 --socket=/var/lib/mysql/mysql.sock
28930 pts/1 Sl 0:00 /usr/sbin/mysqld --basedir=/usr --datadir=/var/lib/mysql --user=mysql --pid-file=/var/run/mysqld/mysqld.pid --skip-external-locking --port=3306 --socket=/var/lib/mysql/mysql.sock
29096 pts/1 R+ 0:00 grep 3306
# ls /var/lib/mysql/mysql.sock
ls: cannot access /var/lib/mysql/mysql.sock: No such file or directory
# service mysql stop
Shutting down service MySQL done
# ps ax | grep 3306