Skip to content

Instantly share code, notes, and snippets.

@jjcodes78
jjcodes78 / mysql-sail.md
Last active May 2, 2025 14:41
Laravel Sail - GRANT ALL PRIVILEGES to user

Run this command in sail project folder:

docker-compose exec mysql bash

execute the mysql -u root -p command

provide the default password password

then executes

@peshoicov
peshoicov / canvas.signature.js
Created October 9, 2017 10:55
Canvas signature, both desktop and mobile
// Setup canvas ..
var canvas = document.getElementById('main-canvas'),
ctx = canvas.getContext('2d');
// setup lines styles ..
ctx.strokeStyle = "#DDD";
ctx.lineWidth = 2;
// some variables we'll need ..
var drawing = false;
@LuenCC
LuenCC / gist:e8dcf4a38096617799f3002644012af6
Created October 6, 2016 21:26
Laravel find nearest location in km from lat, long database
private function findNearestLocation(Request $request)
{
$location = DB::table('locations')
->select('name', 'latitude', 'longitude', 'region', DB::raw(sprintf(
'(6371 * acos(cos(radians(%1$.7f)) * cos(radians(latitude)) * cos(radians(longitude) - radians(%2$.7f)) + sin(radians(%1$.7f)) * sin(radians(latitude)))) AS distance',
$request->input('latitude'),
$request->input('longitude')
)))
->having('distance', '<', 50)
->orderBy('distance', 'asc')
@MarkRedeman
MarkRedeman / on-service-providers-and-laravels-life-cycle.md
Created July 13, 2015 22:45
On Service Providers and Laravel's life cycle

On Service Providers and Laravel's life cycle

In this blog post I talk about Laravel's Service Providers and about its life cycles. In brief, a Laravel application is bootstrapped (started) whenever a webrequest hits index.php in the public folder, or when an artisan command is executed. Tough both the index.php and artisan file work very similarly, I will only talk about index.php. When the index.php file is called it registers the autoloader. After that Laravel's Application is initiated and stored in the $app variable which is used to construct a kernel that manages the input and output of our app. After handling the input by our $kernel it returns a $response object which is send back to our visitor.

Let's rewind a bit, there are four1 important things that are done in the index.php:

  1. The autoloader is registered
  2. Laravel's Application class is initiated and stored in $app
  3. A kernel is constructed using the $app's Service Container.
@plentz
plentz / nginx.conf
Last active November 27, 2025 12:39
Best nginx configuration for improved security(and performance)
# to generate your dhparam.pem file, run in the terminal
openssl dhparam -out /etc/nginx/ssl/dhparam.pem 2048
@nichtich
nichtich / README.md
Last active September 12, 2025 05:54 — forked from oodavid/README.md
How to automatically deploy from GitHub

Deploy your site with git

This gist assumes:

  • you have an online remote repository (github / bitbucket etc.)
  • you have a local git repo
  • and a cloud server (Rackspace cloud / Amazon EC2 etc)
    • your (PHP) scripts are served from /var/www/html/
    • your webpages are executed by Apache
  • the Apache user is named www-data (may be apache on other systems)
@jexchan
jexchan / multiple_ssh_setting.md
Created April 10, 2012 15:00
Multiple SSH keys for different github accounts

Multiple SSH Keys settings for different github account

create different public key

create different ssh key according the article Mac Set-Up Git

$ ssh-keygen -t rsa -C "[email protected]"