Skip to content

Instantly share code, notes, and snippets.

View mberizzo's full-sized avatar

Matias Berizzo mberizzo

  • Rosario - Santa Fe - Argentina
View GitHub Profile
<?php
namespace Tests;
use Illuminate\Contracts\Console\Kernel;
/**
* Original source: https://gist.github.com/mberizzo/013f49d89b96049c5e8c73284efdb071
*
*/
@mberizzo
mberizzo / Nginx non www redirect
Created September 7, 2018 20:06
Redirect www.domain.com to domain.com
server {
listen 80;
listen 443;
server_name www.mywebsite.com;
return 301 $scheme://mywebsite.com$request_uri;
}
# exclude everything except directory themes/mytheme
/*
!README.md
!.editorconfig
!.gitignore
!artisan
!composer.json
!server.php
!.htaccess
@mberizzo
mberizzo / GEO IP
Created January 23, 2018 12:22
Get Country details by IP
http://freegeoip.net/csv/
avconv -i video.webm -s 640x480 output.webm
@mberizzo
mberizzo / gist:5636ecb2dc10af52e46bb456248fff00
Created January 27, 2017 18:53
Convert webm video to mp4
ffmpeg -i output.webm -r 10 -cpu-used 5 -c:v libx264 -crf 20 -c:a aac -strict experimental -loglevel error output.mp4
ffmpeg -i video.mkv -acodec libmp3lame audio.mp3
@mberizzo
mberizzo / PHP Unzip
Last active March 12, 2019 06:57
PHP script that unzip file.zip
<?php
// When i have to upload multiple files in a shared hosting:
// 1. Compress your project and upload to your shared server
// 2. Visit url via shell (ex: "curl http://domain.com/unzip.php &") or any navigator
// Alternative step 2 (sometimes php throw timeout error):
// 1. Create a cronjob that visit unzip.php file (just one time)
error_reporting(E_ALL ^ E_STRICT);
ErrorException: proc_open(): fork failed - Cannot allocate memory in phar:///usr/local/bin/composer/vendor/symfony/console/Application.php on line 954
It's because of a lack of memory. You need to set up a swap file so that composer can do it's thing:
sudo dd if=/dev/zero of=/swapfile bs=1024 count=512k
mkswap /swapfile
swapon /swapfile
@mberizzo
mberizzo / lamp - mysql
Last active July 18, 2020 19:20
Ubuntu install LAMP - commands
You can import "file.sql" file using the standard input like this:
* mysql -u <user> -p <dbname> < file.sql
Import mysql database in laradock. Note: database "my-database-name" should be exists (empty)
docker-compose exec -T mysql mysql -uroot -proot my-database-name < /home/matias/Downloads/my-database-name.sql
Import all mysql databases
mysql -u root -p < all_databases.sql
You can export all mysql databases to "all_databases.sql"