Skip to content

Instantly share code, notes, and snippets.

View vluzrmos's full-sized avatar
🏠
Working from home

Vagner Luz do Carmo vluzrmos

🏠
Working from home
View GitHub Profile
@vluzrmos
vluzrmos / import_tgz.sh
Last active August 29, 2015 14:26
Function to import tgz file to mysql.
import_tgz(){
tar -xOzf $1 | mysql -u ${2:-root} -p${3:-1234}
}
@devster
devster / gist:9545326
Created March 14, 2014 10:24
Install mscorefonts on debian wheezy
# Add this repo to the /etc/apt/source.list file
deb ftp://ftp.debian.org/debian stable contrib non-free
# And run these commands
sudo apt-get update
sudo apt-get install ttf-mscorefonts-installer
@vluzrmos
vluzrmos / DatabaseSeeder.php
Last active April 19, 2017 13:08
Laravel - Seeding 100k many rows at 1s
<?php
use Illuminate\Database\Seeder;
use Illuminate\Database\Eloquent\Model;
use App\User;
class DatabaseSeeder extends Seeder {
/**
* Run the database seeds.
@Repox
Repox / laravel
Created August 18, 2014 19:10
Laravel logrotate configuration (1 daily rotation, 7 days retention)
/home/laravel/app/storage/logs/laravel.log {
daily
missingok
rotate 7
maxage 7
compress
notifempty
create 755 user group
su user group
}
@ManojKiranA
ManojKiranA / full.php
Last active December 21, 2021 01:39
Inertia Js Paginate
Route::get('/', function (\Illuminate\Http\Request $request) {
$initialSearch = $request->query('search', '');
$userQuery = User::query()
->when($request->filled('search'),function($query) use ($initialSearch){
$query->where('name','LIKE','%'.$initialSearch.'%')
->orWhere('email','LIKE','%'.$initialSearch.'%');
});
@langemike
langemike / streamed.php
Last active December 28, 2022 08:06 — forked from m4tthumphrey/streamed.php
Laravel response macro for streamed responses with seeking support (with bug fixes & usage example)
<?php
Response::macro('streamed', function($type, $size, $name, $callback) {
$start = 0;
$length = $size;
$status = 200;
$headers = [
'Content-Type' => $type,
'Content-Length' => $size,
@loilo
loilo / portfinder.md
Last active November 2, 2023 10:22
Find Free Port with PHP

Find Free Port with PHP

This is a quick way to find a random free port on a system using PHP:

$port = find_free_port();

Benchmarked locally, where finding a port always took around 0.15ms.