Skip to content

Instantly share code, notes, and snippets.

View pakjiddat's full-sized avatar

Pak Jiddat pakjiddat

View GitHub Profile
@pakjiddat
pakjiddat / compress-css.php
Created March 28, 2023 04:18
Recursively scans folder for CSS files. Compresses the CSS code in place using Toptal CSS compressor webservice
<?php
$dir = '{absolute path to css folder}';
$files_and_dirs = ListAllFiles($dir);
$files = GetFiles($files_and_dirs);
CompressFiles($files);
function CompressFiles($files) {
@pakjiddat
pakjiddat / ui.R
Created May 31, 2021 06:27
Shiny app for predicting words - UI code
#
# This is the user-interface definition the word-predictor application. You can
# run the application by clicking 'Run App' above.
#
# Find out more about building applications with Shiny here:
#
# http://shiny.rstudio.com/
#
library(shiny)
@pakjiddat
pakjiddat / server.R
Last active May 31, 2021 06:58
Shiny app for predicting words - server code
#
# This is the server logic of the word-predictor application. You can run the
# application by clicking 'Run App' above.
#
# Find out more about building applications with Shiny here:
#
# http://shiny.rstudio.com/
#
library(shiny)
@pakjiddat
pakjiddat / array_to_table.php
Last active April 16, 2020 11:52
Php function for displaying contents of an array in NxM html table. Description: https://pakjiddat.netlify.app/posts/displaying-contents-of-an-array-in-nxm-html-table
<?php
/** The column counter */
$column_counter = 0;
/** The row counter */
$row_counter = 0;
/** The total counter */
$total_counter = 0;
/** The maximum number of columns to show */
$max_columns = 3;
@pakjiddat
pakjiddat / toc.php
Last active April 16, 2020 11:52
A Php class that allows generating table of contents from given article text. Description: https://pakjiddat.netlify.app/posts/generating-table-of-contents
<?php
declare(strict_types=1);
/**
* This class provides functions that generate the table of contents
*
* @category Library
* @author Nadir Latif <nadir@pakjiddat.pk>
* @license https://www.gnu.org/licenses/gpl-2.0.html GNU General Public License, version 2
@pakjiddat
pakjiddat / restore_innodb.php
Last active April 16, 2020 11:52
Script for restoring crashed MySQL innodb database tables. It requires backup of MySQL database folder containing .frm and .ibd files. Description: https://pakjiddat.netlify.app/posts/recovering-innodb-data-after-accidental-removal-of-log-files
<?php
$args = ParseArgs();
$src_db = $args["src_db"];
$target_db = $src_db . "_restore";
$backup_folder = $args["backup_folder"];
$backup_folder .= $src_db;
$src_db_folder = $args["mysql_data_dir"] . $src_db;
$target_db_folder = $args["mysql_data_dir"] . $target_db;