Skip to content

Instantly share code, notes, and snippets.

View catwhocode's full-sized avatar

Cat who code catwhocode

  • Jakarta, Indonesia
  • 19:31 (UTC +07:00)
View GitHub Profile
@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 / 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 / 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 / create-subdomain.php
Created September 23, 2023 01:28 — forked from iMaz1n/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 / 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.

The program below can take one or more plain text files as input. It works with python2 and python3.

Let's say we have two files that may contain email addresses:

  1. file_a.txt
foo bar
ok ideler.dennis@gmail.com sup
 hey...user+123@example.com,wyd
hello world!
@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 / 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 / createcertificate.php
Created April 10, 2022 09:02 — forked from jlainezs/createcertificate.php
Creates a certificate using OpenSSL with PHP. sing.php could be used to sign a text with the pkey generated with createCertificate. verify.java shows how to load the certificate from a resource and a verification sample of the text signed with sign.php
/**
* Creates an OpenSSL certificate
* @param $dn Array Associative array "key"=>"value"
* @param $duration int Number of days which the certificate is valid
* @throws Exception If there are any errors
* @return Array Associative array with the security elements: "cer"=>self signed certificate, "pem"=>private key, "file"=>path to the files
*
* @see http://www.php.net/manual/en/function.openssl-csr-new.php
* @author Pep Lainez
*/
@catwhocode
catwhocode / google-apps-script.md
Created April 5, 2022 08:01 — forked from labnol/google-apps-script.md
How to Learn Google Apps Script

Learning Google Apps Script

Find the best resources for learning Google Apps Script, the glue that connects all GSuite services including Gmail, Google Drive, Calendar, Google Sheets, Forms, Maps, Analytics and more.

A good place to learn more about Google Apps Script is the official documentation available at developers.google.com. Here are other Apps Script resources that will help you get up to speed.

  1. Google Apps Script Code Samples by Amit Agarwal
  2. Google Apps Script Development - Create Google Apps Script projects locally inside VS Code - video tutorial
  3. Awesome Google Scripts by Amit Agarwal
  4. Google Developer Experts - Follow Apps Scr
# [CONFIGURATION]
# Ensure WSL2 container is started and SSH is running
wsl sudo /etc/init.d/ssh start
# Ports to be forwarded
$ports = @(22) + @(6543,6544) + @(6800..6810);
# Change $addr to restrict connections to a particular interface IP
$listen_addr = '0.0.0.0';