Skip to content

Instantly share code, notes, and snippets.

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

Arthur Monney mckenziearts

🏠
Working from home
View GitHub Profile
@simonhamp
simonhamp / AppServiceProvider.php
Last active March 26, 2024 15:56
A pageable Collection implementation for Laravel
<?php
namespace App\Providers;
use Illuminate\Support\Collection;
use Illuminate\Pagination\LengthAwarePaginator;
class AppServiceProvider extends ServiceProvider
{
public function boot()
@bladeSk
bladeSk / laravel-on-shared-hosting-htaccess.md
Last active March 5, 2024 09:51
Deploying Laravel on a shared hosting using only .htaccess

Deploying Laravel on a shared hosting using only .htaccess

Making Laravel work on a shared hosting can be troublesome, because Laravel needs to have its document root set to the public directory. This may not be configurable by a user or even desirable, when the server is hosting multiple websites.

Here's a simple method using only a .htaccess file placed in Laravel's root directory - e.g. alongside app, bootstrap, config, ... No changes whatsoever are necessary to your code.

The file rewrites all the requests so that requesting /file.png would in fact return /public/file.png and anything else is routed to /public/index.php. This also ensures that nothing outside the public folder can be accessed, thereby protecting any sensitive files like .env or database/*.

The simple method

@tzmartin
tzmartin / embedded-file-viewer.md
Last active April 22, 2024 19:39
Embedded File Viewer: Google Drive, OneDrive

Office Web Apps Viewer

('.ppt' '.pptx' '.doc', '.docx', '.xls', '.xlsx')

http://view.officeapps.live.com/op/view.aspx?src=[OFFICE_FILE_URL]

<iframe src='https://view.officeapps.live.com/op/embed.aspx?src=[OFFICE_FILE_URL]' width='px' height='px' frameborder='0'>
</iframe>

OneDrive Embed Links

@npotier
npotier / PSR-2-coding-style-guide-french
Created September 6, 2016 10:13
PSR-2 traduit en français
Guide du style de code
Ce guide étend et agrandit le PSR-1, le standard basique de codage
Le but de ce guide est de réduire la complexité de lecture du code d'auteurs différents. Il le fait en listant un ensemble de règles et d'explication à propos du format du code PHP.
Les règles de styles sont issues de points communs entre les différents membre du projet. Quans plusieurs auteurs collaborents ensemble sur différents projets, la mise en place de bonnes pratiques est une aide. Cependant, les avantages de ce guide ne sont pas les règles en elle-mêmes, mais le fait de partager ces règles.
Les mots clés "DOIT", "NE DOIT PAS", "REQUIS", "DEVRAIT", "NE DEVRAIT PAS", "RECOMMANDE", "POURAIT", "OPTIONNEL", dans ce document doivent être interprétés comme décrit dans la RFC 2119.
@cecilemuller
cecilemuller / letsencrypt_2020.md
Last active April 15, 2024 02:19
How to setup Let's Encrypt for Nginx on Ubuntu 18.04 (including IPv6, HTTP/2 and A+ SSL rating)

How to setup Let's Encrypt for Nginx on Ubuntu 18.04 (including IPv6, HTTP/2 and A+ SLL rating)


Virtual hosts

Let's say you want to host domains first.com and second.com.

Create folders for their files:

@rxaviers
rxaviers / gist:7360908
Last active April 25, 2024 09:09
Complete list of github markdown emoji markup

People

:bowtie: :bowtie: 😄 :smile: 😆 :laughing:
😊 :blush: 😃 :smiley: ☺️ :relaxed:
😏 :smirk: 😍 :heart_eyes: 😘 :kissing_heart:
😚 :kissing_closed_eyes: 😳 :flushed: 😌 :relieved:
😆 :satisfied: 😁 :grin: 😉 :wink:
😜 :stuck_out_tongue_winking_eye: 😝 :stuck_out_tongue_closed_eyes: 😀 :grinning:
😗 :kissing: 😙 :kissing_smiling_eyes: 😛 :stuck_out_tongue:
@JeffreyWay
JeffreyWay / laravel.js
Last active April 6, 2024 20:12
Want to send a DELETE request when outside of a form? This will handle the form-creation bits for you dynamically, similar to the Rails implementation. (Requires jQuery, but doesn't have to.) To use, import script, and create a link with the `data-method="DELETE"` attribute.
/*
<a href="posts/2" data-method="delete"> <---- We want to send an HTTP DELETE request
- Or, request confirmation in the process -
<a href="posts/2" data-method="delete" data-confirm="Are you sure?">
*/
(function() {
@djaiss
djaiss / gist:2938259
Created June 15, 2012 19:13
PHP List of countries
<?php
$countries =
array(
"AF" => "Afghanistan",
"AL" => "Albania",
"DZ" => "Algeria",
"AS" => "American Samoa",
"AD" => "Andorra",
"AO" => "Angola",
@mathewbyrne
mathewbyrne / slugify.js
Created October 12, 2011 04:34
Javascript Slugify
function slugify(text)
{
return text.toString().toLowerCase()
.replace(/\s+/g, '-') // Replace spaces with -
.replace(/[^\w\-]+/g, '') // Remove all non-word chars
.replace(/\-\-+/g, '-') // Replace multiple - with single -
.replace(/^-+/, '') // Trim - from start of text
.replace(/-+$/, ''); // Trim - from end of text
}
@nickfloyd
nickfloyd / create_branch_from_tag
Created January 27, 2011 05:38
To create a branch from a tag
-Go to the starting point of the project
>> git checkout origin master
-fetch all objects
>> git fetch origin
-Make the branch from the tag
>> git branch new_branch tag_name
-Checkout the branch
>> git checkout new_branch
-Push the branch up
>> git push origin new_branch