Skip to content

Instantly share code, notes, and snippets.

View bstrahija's full-sized avatar

Boris Strahija bstrahija

View GitHub Profile
@JeffreyWay
JeffreyWay / PjaxMiddleware.php
Last active February 24, 2024 13:40
Laravel middleware for working with pjax.
<?php
namespace App\Http\Middleware;
use Closure;
use Illuminate\Http\Request;
use Illuminate\Http\Response;
use Symfony\Component\DomCrawler\Crawler;
class PjaxMiddleware
@LeonanCarvalho
LeonanCarvalho / safe_display_images.php
Last active October 11, 2019 08:05
My way to safely display external pictures
/* =========================================================
* My way to safely display external pictures
* =========================================================
* Copyright 2015 Leonan Carvalho @leonancarvalho
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
[
{
"args": null,
"command": "find_under_expand"
},
{
"args":
{
"by": "words",
[
{
"command": "escape"
},
{
"command": "expand_selection",
"args": {"to": "word"}
},
{
"command": "copy"
@fideloper
fideloper / install.sh
Last active October 30, 2023 20:03
Vagrant Provisioning Script for PHP applications. This installs a LAMP stack.
#!/usr/bin/env bash
echo ">>> Starting Install Script"
# Update
sudo apt-get update
# Install MySQL without prompt
sudo debconf-set-selections <<< 'mysql-server mysql-server/root_password password root'
sudo debconf-set-selections <<< 'mysql-server mysql-server/root_password_again password root'
@msurguy
msurguy / eloquent.md
Last active February 8, 2022 03:13
Laravel 4 Eloquent Cheat Sheet.

Conventions:

Defining Eloquent model (will assume that DB table named is set as plural of class name and primary key named "id"):

class Shop extends Eloquent {}

Using custom table name

protected $table = 'my_shops';

@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() {
@niallobrien
niallobrien / gist:5098578
Last active January 12, 2016 01:46
Laravel 4 install & update process
// Clone L4 repo
git clone -b develop git://github.com/laravel/laravel.git myapp
cd myapp
// Install Composer
curl -sS https://getcomposer.org/installer | php
php composer.phar install
// Rename origin
git remote rename origin upstream
@ziadoz
ziadoz / awesome-php.md
Last active April 17, 2024 21:06
Awesome PHP — A curated list of amazingly awesome PHP libraries, resources and shiny things.
/*!
* jQuery TextChange Plugin
* http://www.zurb.com/playground/jquery-text-change-custom-event
*
* Copyright 2010, ZURB
* Released under the MIT License
*/
(function ($) {
$.event.special.textchange = {