Skip to content

Instantly share code, notes, and snippets.

View catwhocode's full-sized avatar

Cat who code catwhocode

View GitHub Profile
@catwhocode
catwhocode / nginx.conf
Created August 25, 2022 06:03 — forked from mreschke/nginx.conf
Nginx config for multiple laravel sites based on /api/v1 url paths
# This config will host your main [Laravel] GUI application at /, and any additional [Lumen] webservices at /api/v1 and /api/v2...
# This also works perfectly for all static file content in all projects
# This is full of debug comments so you can see how to print debug output to browser! Took me hours to nail this perfect config.
# Example:
# http://example.com - Main Laravel site as usual
# http://example.com/about - Main Laravel site about page as usual
# http://example.com/robots.txt - Main Laravel site static content as usual
# http://example.com/api/v1 - Lumen v1 api default / route
# http://example.com/api/v1/ - Lumen v1 api default / route
@catwhocode
catwhocode / Accessing Github Using cURL.md
Last active June 12, 2023 03:42 — forked from joyrexus/README.md
Accessing Github Using cURL

An introduction to curl using GitHub's API.

Basics

Makes a basic GET request to the specifed URI

curl https://api.github.com/users/caspyin

Includes HTTP-Header information in the output

@catwhocode
catwhocode / Extract-Email-From-Text-File.md
Last active June 16, 2023 00:38 — forked from dideler/example.md
A python script for extracting email addresses from text files.You can pass it multiple files. It prints the email addresses to stdout, one address per line.For ease of use, remove the .py extension and place it in your $PATH (e.g. /usr/local/bin/) to run it like a built-in command.
@catwhocode
catwhocode / create-subdomain.php
Created September 23, 2023 01:28 — forked from itsMaz1n/create-subdomain.php
Use API/Curl to create a new subdomain in both CloudFlare and cPanel
<?php
/**
* Create Subdomains
*
* Note: This script was designed to be called silently by a bash script for project creation.
* Add to bash script: php "$HOME/scripts/php/create-subdomains.php" "$new_account_subdomain"
*
* Requires "jamesryanbell/cloudflare": "^1.11" for the CloudFlare PHP library
* Recommends "kint-php/kint": "^3.2" for improved temporary PHP debugging
@catwhocode
catwhocode / curl.php
Created March 15, 2024 00:43 — forked from surferxo3/curl.php
Script to demonstrate how to extract Header and Body from the Curl response in PHP.
<?php
/*#############################
* Developer: Mohammad Sharaf Ali
* Designation: Web Developer
* Version: 1.0
*/#############################
// SETTINGS
ini_set('max_execution_time', 0);
@catwhocode
catwhocode / guzzle_req_res_middleware.php
Created May 7, 2024 10:08 — forked from appkr/guzzle_req_res_middleware.php
Guzzle RequestResponseLog Middleware Example
<?php
namespace App\Providers;
use GuzzleHttp\Client;
use GuzzleHttp\Exception\RequestException;
use GuzzleHttp\HandlerStack;
use GuzzleHttp\Middleware;
use GuzzleHttp\Promise\PromiseInterface;
use Illuminate\Contracts\Foundation\Application;
@catwhocode
catwhocode / HandlePutFormData.php
Created May 17, 2024 07:14 — forked from Stunext/HandlePutFormData.php
Laravel: Middleware to support multipart/form-data in PUT, PATH and DELETE requests
<?php
namespace App\Http\Middleware;
use Closure;
use Symfony\Component\HttpFoundation\ParameterBag;
/**
* @author https://github.com/Stunext
*
@catwhocode
catwhocode / verify_hmac.php
Created July 29, 2024 03:13 — forked from turret-io/verify_hmac.php
Verify HMAC in PHP
<?php
define("SHARED_SECRET", "sup3rs3cr3t!!");
if(!function_exists('hash_equals')) {
function hash_equals($str1, $str2) {
// Run constant-time comparison for PHP < 5.6 which doesn't support hmac_equals
$str1_len = strlen($str1);
$str2_len = strlen($str2);

Note

  • If your users come from many timezones, consider keep using UTC, leave the timezone configuration on the user side. Use this package for timezone conversion.
  • If you're using Laravel 11, you can use .env instead.

Open File App\Providers\AppServiceProvider

Change method boot

use Carbon\Carbon;
@catwhocode
catwhocode / codeiginter-server-config.md
Created October 7, 2024 02:13 — forked from yidas/codeiginter-server-config.md
Codeigniter 3 server configuration for Nginx & Apache

Codeigniter 3 server configuration for Nginx & Apache

Web Server Site Configuration

Recommended Apache Configuration

Use the following configuration in Apache's httpd.conf file or within a virtual host configuration. Note that you should set DocumentRoot and ServerName fit to your environment: