Skip to content

Instantly share code, notes, and snippets.

View edwinheij's full-sized avatar
😊
Keep smiling

Edwin Heij edwinheij

😊
Keep smiling
View GitHub Profile
@edwinheij
edwinheij / gist:e96f2d24b52d6d93fe3a2d16f05d1dbc
Created January 21, 2020 10:36
Eloquent Sheet Cheat, the short one
in One to One:
u have to use HasOne on the first model and BelongsTo on the second model
to add record on the first model (HasOne) use the save function
example: $post->country()->save($country);
to add record on the second model (BelongsTo) use the associate function
example: $country->post()->associate($post)->save();

Multiple MySQL Versions with Homebrew

For homebrew version 0.9.5.

brew -v # => Homebrew 0.9.5

Install the current version of mysql.

# Install current mysql version

brew install mysql

@edwinheij
edwinheij / valid_utf8_bytes.php
Created May 3, 2017 10:12 — forked from ktomk/valid_utf8_bytes.php
filter valid utf-8 byte sequences
<?php
/**
* filter valid utf-8 byte sequences
*
* take over all valid bytes, drop an invalid sequence until first
* non-matching byte, start over at that byte.
*
* @param string $str
* @return string
*/
@edwinheij
edwinheij / VersionCompare.ps1
Created March 8, 2017 10:01
Powershell: Version compare
function getVersionFromFile($filepath) {
return [System.Diagnostics.FileVersionInfo]::GetVersionInfo($filepath)
}
function versionCompare($filepathReference, $filepathDifference) {
$versionReference = getVersionFromFile $filepathReference
$versionDifference = getVersionFromFile $filepathDifference
#$versionReference | fl
#$versionDifference
return Compare-Object -ReferenceObject $versionReference -DifferenceObject $versionDifference -Property FileVersionRaw
@edwinheij
edwinheij / streamLargeFile.php
Last active August 20, 2022 22:17
Stream large file with Laravel
<?php
//disable execution time limit when downloading a big file.
set_time_limit(0);
/** @var \League\Flysystem\Filesystem $fs */
$fs = Storage::disk('local')->getDriver();
$fileName = 'bigfile';
$metaData = $fs->getMetadata($fileName);
@edwinheij
edwinheij / gist:2ce9d40bd4bbfc65fd8cafcce6e6b702
Created August 22, 2016 20:59
composer package development with dependencies
develop your packages in a folder called, for example: packages/yourvendorname/packagename
push you package to git / packagist
after that, edit your main composer.json file so it will include you package (@section required)
now you autoloader knows about your package.
last but not least, the magic:
cd vendor/yourvendorname && rm -rf packagename && ln -s ../../packages/yourvendorname/packagename
now you can develop your package like it's in you live vendor directory.
so... now also you dependencies will load which you included in your 'required' section in your package composer.json
@edwinheij
edwinheij / ngrep.sh
Last active July 29, 2016 23:54
Track URL on Linux system
sudo apt-get install ngrep
sudo ngrep -W byline -qilwv 'referer' tcp dst port 80 | grep -i " -> \|get\|host"
@edwinheij
edwinheij / Faketest.php
Created June 18, 2016 19:23
Start nieuwe test @ laravel met Setup en Teardown method; saves you some time
<?php
class FakeTest extends TestCase{
public function setUp(){
parent::setUp();
}
public function tearDown(){
parent::tearDown();
Mockery::close();
}
@edwinheij
edwinheij / phpstorm.desktop
Created June 17, 2016 09:20
Plaats een desktop icon op het bureaublad van Ubuntu
[Desktop Entry]
Name=PHPStorm
Type=Application
Terminal=false
Exec=/home/edwin/Documenten/PhpStorm-145.1616.3/bin/phpstorm.sh
Icon=/home/edwin/Documenten/PhpStorm-145.1616.3/bin/webide.png
@edwinheij
edwinheij / Example.ps1
Last active June 5, 2016 20:26
Versie controle op 2 bestanden en eventueel updaten via setup als versies verschillen
. ./ShouldBeUpToDate.ps1
$pathExecutible = "C:\Program Files\Git\git-cmd.exe"
$pathSetupfile = "C:\Users\<username>\Downloads\Git-2.8.3-64-bit.exe"
ShouldBeUpToDate -pathExecutible $pathExecutible -pathSetupfile $pathSetupfile