Skip to content

Instantly share code, notes, and snippets.

View novasky-zz's full-sized avatar

William Novasky novasky-zz

View GitHub Profile
@novasky-zz
novasky-zz / gist:46642dbf97ec7c3da3370f0f80110e46
Created February 14, 2018 16:04
How to find the correct php.ini
~php -i | grep 'php.ini'
{
"bold_folder_labels": true,
"color_scheme": "Packages/User/SublimeLinter/base16-ocean.dark (SL).tmTheme",
"detect_indentation": false,
"detect_slow_plugins": false,
"ensure_newline_at_eof_on_save": true,
"font_options":
[
"gray_antialias",
"subpixel_antialias"
@novasky-zz
novasky-zz / gist:d2e03825fd4caf5c415ced19c35e0ca6
Created February 2, 2017 12:22
MAC PHP ERROR: Terminal displys wrong php version
Check using which php. This should tell you which is being used.
For a more direct solution to the problem:
Rename the OLD version of PHP
> sudo mv /usr/bin/php /usr/bin/php5424
Create a Symbolic link for your new version of php so it can live in /usr/bin
> sudo ln -s /usr/local/php5/bin/php /usr/bin/php
@novasky-zz
novasky-zz / gist:694831b9ff1565e344d1a281b975fcf7
Created October 4, 2016 12:09
Laravel 5 TokenMismatchException
When I realized this was only happening in IE and Chrome, but not Firefox, it led me to the fix.
The app was using AddThis share buttons and the javascript was adding an iframe to the pages.
This issue is resolved by adding a P3P header to the VerifyCsrfToken Middleware. Hope this saves somebody the hours I lost.
<?php
public function handle($request, Closure $next)
{
$response = $next($request);
if (last(explode('\\',get_class($response))) != 'RedirectResponse') {
@novasky-zz
novasky-zz / gist:5610b1455c9b870c1903e3d14ee96ffc
Created June 30, 2016 13:00
Resolv DNS problem in linux SO
$vi /etc/resolv.conf
# Clean all the content and add:
nameserver 8.8.8.8
nameserver 8.8.4.4
@novasky-zz
novasky-zz / gist:d6b425fd938d1be65004208f7ff1485e
Created June 7, 2016 13:48
Laravel: Embed an image directly into your email template
// emails/has-image.blade.php
Here's that image we talked about sending:
<img src="{{ $message->embed(storage_path('embed.jpg')) }}">
Thanks!
@novasky-zz
novasky-zz / gist:06026742e9c486124910b98c8a7e21b9
Created June 7, 2016 13:47
Laravel: Attaching files to emails
Mail::send('emails.whitepaper', [], function ($m) {
$m->to('email@domain.com');
$m->subject('Your whitepaper download');
$m->attach(storage_path('pdfs/whitepaper.pdf'));
});
@novasky-zz
novasky-zz / gist:280ac1f433e32624826d
Created September 10, 2015 20:49
BE RIGHT BACK - HTACCESS
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REMOTE_ADDR} !^999\.99\.99\.99$
RewriteCond %{REQUEST_URI} !/temp.html$
RewriteRule .* /temp.html [R=302,L]
</IfModule>
@novasky-zz
novasky-zz / gist:4665e87c8c73d50afd09
Created August 27, 2015 17:49
Composer: Optimize for production
Just a reminder, before deploying your code in production, don't forget to optimize the autoloader:
$ composer dump-autoload --optimize
This can also be used while installing packages with the --optimize-autoloader option. Without that optimization, you may notice a performance loss from 20 to 25%.
http://www.ricardclau.com/2013/03/apc-vs-zend-optimizer-benchmarks-with-symfony2/
@novasky-zz
novasky-zz / gist:1e346e4290d87e77e299
Created August 18, 2015 17:24
Remove o HTTP e o HTTPS de uma URL
echo preg_replace("$^http[s]?:\/\/$", "", $url);