Skip to content

Instantly share code, notes, and snippets.

@lfbittencourt
lfbittencourt / fps-converter.sh
Last active January 23, 2024 13:57
120 to 60 FPS converter using ffmpeg
#!/bin/bash
for file in *.MP4; do
echo "Processing $file..."
output="${file%.MP4}-60fps.mp4"
ffmpeg -i "$file" -movflags use_metadata_tags -filter:v fps=60 "$output"
done
@lfbittencourt
lfbittencourt / display-errors.php
Created October 25, 2016 12:38
Display every single error in PHP
<?php
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
@lfbittencourt
lfbittencourt / .htaccess
Last active January 12, 2019 13:39
Force non-www SSL version of a site
<IfModule mod_rewrite.c>
RewriteEngine On
# Force non-www
RewriteCond %{HTTP_HOST} ^www\.foo\.com$ [NC]
RewriteRule ^(.*)$ https://foo.com/$1 [L,R=301]
# Force SSL
RewriteCond %{HTTP_HOST} ^foo\.com$ [NC]
RewriteCond %{SERVER_PORT} ^80$
@lfbittencourt
lfbittencourt / redis.sh
Created July 21, 2015 18:35
Install Redis and Redis PHP extension on Ubuntu
# Installs extra packages
sudo apt-get update
sudo apt-get -y install build-essential tcl8.5
# Installs Redis
# http://redis.io/topics/quickstart
# https://www.digitalocean.com/community/tutorials/how-to-install-and-use-redis
# https://realguess.net/2014/07/19/non-interactive-redis-install/
PORT=6379
CONFIG_FILE=/etc/redis/6379.conf
@lfbittencourt
lfbittencourt / .htaccess
Created April 5, 2018 18:58
Loads production assets in case files don't exist locally
<IfModule mod_rewrite.c>
RewriteEngine On
# Try production domain if file doesnt exists
RewriteCond %{HTTP_HOST} !^foo\.com [NC]
RewriteCond %{REQUEST_FILENAME} !-f [NC]
RewriteRule ^uploads/.*$ http://foo.com/$0 [L,NC]
</IfModule>
@lfbittencourt
lfbittencourt / SimpleCrypt.php
Created March 23, 2018 19:55
Simple reversible hashing class
<?php
class SimpleCrypt
{
protected static $factor = 2 / 3 / 5 / 7 / 11 / 13 / 17 / 19 / 23 / 29;
public static function crypt($value)
{
$hash = ceil($value / self::$factor);
@lfbittencourt
lfbittencourt / SimpleApi.php
Last active December 4, 2017 13:09
Simple REST API abstraction
<?php
class SimpleApi
{
private $baseUrl;
public function __construct($baseUrl)
{
$this->baseUrl = $baseUrl;
}
@lfbittencourt
lfbittencourt / clear_tags.rb
Last active March 21, 2017 11:03
This Ruby script removes all local and remote tags in a single-line way, so you don't need supply your credentials several times. Optionally, you can remove only tags greater than a specific version.
#!/usr/bin/env ruby
# Only tags >= min_tag will be removed.
min_tag = '0.0.0'
tags = `git tag`.split(/\s+/).select do |t|
Gem::Version.new(t) >= Gem::Version.new(min_tag)
end
`git tag -d #{tags.join ' '}`
`git push origin #{tags.map { |t| ':' + t }.join ' '}`
@lfbittencourt
lfbittencourt / prettify-json.sh
Created March 14, 2017 17:49
Prettify JSON from curl
curl foo bar | python -m json.tool
@lfbittencourt
lfbittencourt / .htaccess
Created February 7, 2017 13:11
Force SSL/https without redirect loop
<IfModule mod_rewrite.c>
RewriteEngine On
# Force SSL
RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
</IfModule>