Skip to content

Instantly share code, notes, and snippets.

View catwhocode's full-sized avatar

Cat who code catwhocode

View GitHub Profile
@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.
<?php
$header = [
'typ' => 'JWT',
'alg' => 'HS256'
];
@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

<?php
namespace jeremykenedy\LaravelHttps\App\Http\Middleware;
use Closure;
use Illuminate\Http\Request;
use Response;
class CheckHTTPS
{
@catwhocode
catwhocode / datetime2date.php
Created April 27, 2023 11:40
Convert "datetime" string format (Y-m-d H:i:s) to simple date format (dd-mm-yyyy)
<?php
function formatDate($str)
{
return implode("-",array_reverse(explode("-", explode(" ", $str)[0])));
}
@catwhocode
catwhocode / php_carbon.php
Created January 8, 2023 02:41
Using Carbon
<?php
$tanggal = '2023-01-01';
if (Carbon::parse($tanggal)->gt(Carbon::now())){
echo 'Form input tidak tampil';
} else {
echo 'Form input tampil';
}