Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

Vagner Luz do Carmo vluzrmos

🏠
Working from home
View GitHub Profile
@devster
devster / gist:9545326
Created Mar 14, 2014
Install mscorefonts on debian wheezy
View gist:9545326
# 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
@Repox
Repox / laravel
Created Aug 18, 2014
Laravel logrotate configuration (1 daily rotation, 7 days retention)
View laravel
/home/laravel/app/storage/logs/laravel.log {
daily
missingok
rotate 7
maxage 7
compress
notifempty
create 755 user group
su user group
}
@vluzrmos
vluzrmos / DatabaseSeeder.php
Last active Apr 19, 2017
Laravel - Seeding 100k many rows at 1s
View DatabaseSeeder.php
<?php
use Illuminate\Database\Seeder;
use Illuminate\Database\Eloquent\Model;
use App\User;
class DatabaseSeeder extends Seeder {
/**
* Run the database seeds.
@vluzrmos
vluzrmos / import_tgz.sh
Last active Aug 29, 2015
Function to import tgz file to mysql.
View import_tgz.sh
import_tgz(){
tar -xOzf $1 | mysql -u ${2:-root} -p${3:-1234}
}
@langemike
langemike / streamed.php
Last active Jun 22, 2020 — forked from m4tthumphrey/streamed.php
Laravel response macro for streamed responses with seeking support (with bug fixes & usage example)
View streamed.php
<?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 Jul 12, 2022
Find Free Port with PHP
View portfinder.md

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.

@ManojKiranAppathurai
ManojKiranAppathurai / full.php
Last active Dec 21, 2021
Inertia Js Paginate
View full.php
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.'%');
});