Skip to content

Instantly share code, notes, and snippets.

View EDDYMENS's full-sized avatar
🏕️

Edmond Mensah EDDYMENS

🏕️
View GitHub Profile
@EDDYMENS
EDDYMENS / tinkerMod.php
Last active August 15, 2023 07:08
Script to reload Laravel Tinker sessions without existing
<?php
use Illuminate\Support\Facades\Process;
$__tinkerModeDefinedVars__ = get_defined_vars();
$_reload = function ($lineStart = null, $endLine = null) use ($__tinkerModeDefinedVars__) {
$histFile = '.__tinkerMode__history.php'; //stores executable history
@EDDYMENS
EDDYMENS / open-api-template.yaml
Created March 19, 2023 16:48
Simple Open API starter template
openapi: 3.0.3
info:
title: Simple OpenAPI template
description: |
Simple open API template
license:
name: Apache 2.0
url: http://www.apache.org/licenses/LICENSE-2.0.html
version: 1.0.11
servers:
@EDDYMENS
EDDYMENS / Surreal.php
Last active March 17, 2024 16:43
Surreal DB PHP SDK
<?php
/**
* Surreal fluent query
*
* @author EDDYMENS
* @license MIT (or other licence)
*/
class Surreal
{
@EDDYMENS
EDDYMENS / pusher.php
Last active April 24, 2019 16:50
Single file (pusher.com) PHP SDK
<?php
function push(string $region, string $app_id, string $app_key, string $app_secret, string $channel, string $event, string $data) {
$postData = json_encode(['data'=>$data, 'name'=>$event, 'channel'=>$channel]);
$md5_string = md5($postData);
$timestamp = strtotime('now +5 minutes');
$auth_signature = hash_hmac('sha256', "POST\n/apps/$app_id/events\nauth_key=$app_key&auth_timestamp=$timestamp&auth_version=1.0&body_md5=$md5_string", $app_secret);
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "http://api-$region.pusher.com/apps/$app_id/events?body_md5=$md5_string&auth_version=1.0&auth_key=$app_key&auth_timestamp=$timestamp&auth_signature=$auth_signature&",
CURLOPT_RETURNTRANSFER => true,
@robbens
robbens / default.blade.php
Created January 7, 2017 14:56
Bulma.io pagination for Laravel
@if ($paginator->hasPages())
<nav class="pagination is-centered">
@if ($paginator->onFirstPage())
<span class="pagination-previous is-disabled">Previous</span>
@else
<a class="pagination-previous" href="{{ $paginator->previousPageUrl() }}" rel="prev">Previous</a>
@endif
{{-- Next Page Link --}}
@if ($paginator->hasMorePages())
@johnotu
johnotu / addressbook.html
Created January 2, 2017 11:18
A Simple Addressbook using a DevLess Backend
<!DOCTYPE html>
<html>
<head>
<title>Address Book</title>
<link rel="stylesheet" type="text/css" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<style type="text/css">
button{margin: 0 20px;}
</style>
</head>
<body>
[...document.querySelectorAll('.invite-card')].forEach((card) => {
const acceptBtn = card.querySelector('.bt-invite-accept');
acceptBtn.click();
});
@EDDYMENS
EDDYMENS / notify.html
Last active October 31, 2016 10:55
Cool easy way to add pop up flash notification to web frontend with nothing more than bootstrap.
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://code.jquery.com/jquery-3.1.1.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<div class="modal fade" id="notif" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog" style="width:250px;height:3%;">
<div class="modal-content" style="background-color:#7BE454;">
<div class="modal-body">
<div id="left">
<div>
@derak-kilgo
derak-kilgo / mp4-to-gif.php
Created August 17, 2016 18:30
Convert a mp4 clip into a gif with php, imagemagick and ffmpeg. From OSX, these are easy to install with homebrew.
<?php
$video = __DIR__ . '/video.mp4';
$fps = 4;
# Convert an MP4 to a GIF - Requires ffmpeg
`ffmpeg -i "$video" -pix_fmt rgb24 -r $fps "$video.gif"`
# optimize the gif - Requires imagemagick
# via http://superuser.com/questions/436056/how-can-i-get-ffmpeg-to-convert-a-mov-to-a-gif
@jrmadsen67
jrmadsen67 / gist:bd0f9ad0ef1ed6bb594e
Last active February 15, 2022 08:41
Laravel Quick Tip: Handling CsrfToken Expiration gracefully
Quick tip for handling CSRF Token Expiration - common issue is when you use csrf protection is that if
a form sits there for a while (like a login form, but any the same) the csrf token in the form will
expire & throw a strange error.
Handling it is simple, and is a good lesson for dealing with other types of errors in a custom manner.
In Middleware you will see a file VerifyCsrfToken.php and be tempted to handle things there. DON'T!
Instead, look at your app/Exceptions/Handler.php, at the render($request, Exception $e) function.
All of your exceptions go through here, unless you have excluded them in the $dontReport array at the