Skip to content

Instantly share code, notes, and snippets.

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

Faysal Ahamed devfaysal

🏠
Working from home
View GitHub Profile
@hanspagel
hanspagel / OpenGraphImageController.php
Last active January 27, 2020 07:17
Generate Open Graph Images for Blog Posts
<?php
namespace App\Http\Controllers;
use GDText\Box;
use GDText\Color;
use App\Models\Post;
use Illuminate\Support\Facades\Cache;
class OpenGraphImageController extends Controller
@calebporzio
calebporzio / RouteDirectives.php
Created January 4, 2020 10:33
Blade Route Directives
<?php
// Register these inside a service provider:
Blade::directive('route', function ($expression) {
return "<?php echo route({$expression}) ?>";
});
Blade::directive('routeIs', function ($expression) {
return "<?php if (request()->routeIs({$expression})) : ?>";
@devfaysal
devfaysal / csv-to-json.php
Last active February 6, 2023 10:04
CSV to JSON
<?php
/*
* Converts CSV to JSON
* Example uses the csv file of this gist
*/
$feed="https://gist.githubusercontent.com/devfaysal/9143ca22afcbf252d521f5bf2bdc6194/raw/ec46f6c2017325345e7df2483d8829231049bce8/data.csv";
//Read the csv and return as array
$data = array_map('str_getcsv', file($feed));
//Get the first raw as the key
$keys = array_shift($data);
@sadiesaurus
sadiesaurus / page.list-collections.liquid
Last active November 17, 2021 22:42 — forked from carolineschnapp/page.list-collections.liquid
To add at the bottom of page.list-collections.liquid. In the New Standard theme, use the content of page.full-width.liquid and copy the code at the bottom of that content. This won't work in the Lookbook, Brooklyn, Simple and Kickstand themes.
{% comment %}
Collections are listed here.
{% endcomment %}
{% capture uses_minimal_framework %}{% include 'product-loop' %}{% endcapture %}
{% if uses_minimal_framework contains 'Liquid error' %}
{% assign uses_minimal_framework = false %}
{% assign grid_item_width = 'large--one-quarter large-up--one-quarter medium--one-third medium-up--one-third small--one-half large--col-3 medium--col-4 small--col-6' %}
{% else %}
@carolineschnapp
carolineschnapp / page.list-collections.liquid
Last active June 21, 2021 20:39
To add at the bottom of page.list-collections.liquid. In the New Standard theme, use the content of page.full-width.liquid and copy the code at the bottom of that content. This won't work in the Lookbook, Brooklyn, Simple and Kickstand themes.
{% comment %}
Collections are listed here.
{% endcomment %}
{% capture uses_minimal_framework %}{% include 'product-loop' %}{% endcapture %}
{% if uses_minimal_framework contains 'Liquid error' %}
{% assign uses_minimal_framework = false %}
{% assign grid_item_width = 'large--one-quarter medium--one-third small--one-half large--col-3 medium--col-4 small--col-6' %}
{% else %}
@robflaherty
robflaherty / csv-to-json.php
Created September 1, 2011 02:26
Convert CSV to JSON
<?php
/*
* Converts CSV to JSON
* Example uses Google Spreadsheet CSV feed
* csvToArray function I think I found on php.net
*/
header('Content-type: application/json');
// Set your CSV feed