Skip to content

Instantly share code, notes, and snippets.

View catwhocode's full-sized avatar

Cat who code catwhocode

  • Jakarta, Indonesia
  • 19:52 (UTC +07:00)
  • Facebook felixphp
View GitHub Profile
@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 / export.sh
Created October 16, 2023 23:55
Export and remove environment variable from .env
export $(grep -v '^#' .env | xargs)
@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 / install-badaso-fresh.txt
Last active September 19, 2023 15:06
Install Badaso on Fresh Project
$ composer create-project badaso/starter myapp
# edit .env
$ php artisan migrate
$ php artisan storage:link
$ composer dump-autoload
$ php artisan db:seed --class="Database\Seeders\Badaso\BadasoSeeder"
$ php artisan badaso:admin your@email.com --create
$ npm install
$ npm run dev
$ php artisan jwt:secret
@catwhocode
catwhocode / rename.php
Last active August 30, 2023 00:40
Cut the file name taking advantage of their title pattern.
<?php
class FileUtils
{
public $keyword;
public $filenames;
public $extension;
public $folder;
public $newFile;
public $is_left;
@catwhocode
catwhocode / docx2pdf.php
Created July 27, 2023 13:34
Convert DOCX file to PDF
<?php
// source:
// https://github.com/yuya-takeyama/php-docx2pdf/blob/master/docx2pdf.php
require 'vendor/autoload.php';
\PhpOffice\PhpWord\Settings::setPdfRendererPath('vendor/tecnickcom/tcpdf');
\PhpOffice\PhpWord\Settings::setPdfRendererName('TCPDF');
$temp = \PhpOffice\PhpWord\IOFactory::load('dokumen.docx', 'Word2007');
@catwhocode
catwhocode / Branch.php
Created July 25, 2023 22:50
My Model Template for Custom Table
<?php
class Branch extends Model
{
use HasFactory;
// custom table name?
protected $table = 'tbl_branch';
// custom ID field?
@catwhocode
catwhocode / jquery-select-ajax.js
Created July 19, 2023 21:23
jQuery select element from AJAX HTML Response
$(document).on('click', '.btnEdit',function(){
alert("EDIT BUTTON CLICKED");
});
@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!