Skip to content

Instantly share code, notes, and snippets.

View btxtiger's full-sized avatar
:octocat:

btxtiger

:octocat:
View GitHub Profile
@btxtiger
btxtiger / convert.php
Last active March 30, 2024 23:12
Convert Google Fonts embed URL to self-hosted font package
<?php
/*
How to Use:
1. Go to GoogleFonts, and save the URL from the font embedding code in a new directory as `gfont-data.css`.
2. Save this script in the same directory as `convert.php`
3. Run the script via the command line: `php -f convert.php`.
4. The script will create a `downloaded` folder, download all fonts into it, and update the CSS file to point to these local copies.
5. The updated CSS file will be saved as `fonts.css` in the same directory.t
6. Now you can upload it to your site and import it using `@import url(/assets/fonts/fonts.css)`.
@btxtiger
btxtiger / wp-github-plugin-updater.php
Last active March 11, 2024 01:15
Update WordPress Plugin from GitHub Releases
<?php
/**
* Retrieve updates from GitHub
* Add the following snipped to your main wordpress plugin file
* Note that the public github API has a rate limit of 60 per hour per IP
*/
add_filter('site_transient_update_plugins', function($transient) {
// Config
$wpPluginSlug = 'my-wordpress-plugin';
@btxtiger
btxtiger / Controller.php
Last active December 25, 2023 23:35
Laravel download CSV string as file
<?php
$csv = \App\Services\DataExportService::createCsvExport();
$BOM = "\xEF\xBB\xBF";
return response()->streamDownload(
function () use ($BOM, $csv) {
echo $BOM . $csv;
},
'data-export.csv',
@btxtiger
btxtiger / BackupDbImportCmd.php
Last active February 14, 2024 16:53
Laravel MySQL DB Backup Command
<?php
namespace App\Console\Commands\DB;
use Illuminate\Console\Command;
class BackupDbImportCmd extends Command {
/**
* The name and signature of the console command.
*/
@btxtiger
btxtiger / EUVatService.php
Last active December 21, 2023 10:19
EU VAT-ID validation in PHP
<?php
namespace App\Services;
use Http;
use Log;
class EUVatService {
/**
* Check vat in EU interface
@btxtiger
btxtiger / wp-font-awesome-local.md
Last active August 22, 2023 14:36
WordPress Local FontAwesome with Plugin
@btxtiger
btxtiger / unv-card-grid.css
Created July 30, 2022 14:30
Card Grid Layout – auto-growing by screen size
/**
* Card Grid Layout
* auto-growing by screen size
*/
body {
--unv-card-grid-base-size: 300px;
--unv-card-grid-gap: 8px;
}
@btxtiger
btxtiger / typescript-array-natural-sort.ts
Last active November 29, 2021 12:19
TypeScript array natural sort (optional object property)
/**
* TS array natural sort (optional object property)
*/
function naturalObjectSort<T>(arr: T[], objPropertyPath = ''): T[] {
return [...arr].sort((a: T, b: T) => {
let propPathParts = objPropertyPath.split('.');
const getDeepValue = (obj: T): string => {
let value = obj as any;
for (let i = 0; i < propPathParts.length; i++) {
@btxtiger
btxtiger / AesUtil.ts
Last active April 25, 2024 08:10 — forked from AndiDittrich/AesUtil.js
Node.js - AES Encryption/Decryption with AES-256-GCM using random Initialization Vector + Salt
/**
* Cryptography Functions
*
* Forked from AndiDittrich/AesUtil.js
* https://gist.github.com/AndiDittrich/4629e7db04819244e843
*/
import crypto, { CipherGCM, CipherGCMTypes, DecipherGCM } from 'crypto';
import { Password } from './types';