Skip to content

Instantly share code, notes, and snippets.

@Strong
Strong / README.md
Last active August 29, 2015 14:17 — forked from hakre/README.md

Iterators for PHP XMLReader for ease of parsing

Changelog:

  • 0.1.8 maintenance release with fixes.

  • 0.1.7 maintenance release with fixes.

  • 0.1.6 maintenance release with fixes. added xml-file-scanner command-line tool example.

@Strong
Strong / transaction.php
Created August 15, 2017 23:04 — forked from KaduNovoK/transaction.php
Transactions in Symfony 2 and Doctrine 2
<?php
// Code sample to use Transactions
// Get the Entity Manager
$em = $this->getDoctrine()->getEntityManager();
// Suspend the auto-commit
$em->getConnection()->beginTransaction();
@Strong
Strong / alphaidgenerator.php
Created April 30, 2018 23:23 — forked from digitalhydra/alphaidgenerator.php
alpha id generator
<?php
/**
* Translates a number to a short alhanumeric version
*
* Translated any number up to 9007199254740992
* to a shorter version in letters e.g.:
* 9007199254740989 --> PpQXn7COf
*
* specifiying the second argument true, it will
* translate back e.g.:
@Strong
Strong / laravel_conditional_index_migration.php
Created December 25, 2020 16:31 — forked from Razoxane/laravel_conditional_index_migration.php
Laravel - Create Index If Not Exists / Drop Index If Exists
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class LaravelConditionalIndexMigration extends Migration
{
/**
* Run the migrations.
@Strong
Strong / watermark.php
Created November 30, 2021 13:07 — forked from lomboboo/watermark.php
PHP add watermark with centered diagonal text
<?php
// recursive search by pattern
function rsearch($folder, $pattern) {
$dir = new RecursiveDirectoryIterator($folder);
$ite = new RecursiveIteratorIterator($dir);
$files = new RegexIterator($ite, $pattern, RegexIterator::GET_MATCH);
$fileList = array();
foreach($files as $file) {
$fileList = array_merge($fileList, $file);
}
@Strong
Strong / readme.md
Created January 10, 2022 14:23 — forked from ubergesundheit/readme.md
systemd traefik.service

systemd Service Unit for Traefik

Adapted from caddy systemd Service Unit

The provided file should work with systemd version 219 or later. It might work with earlier versions. The easiest way to check your systemd version is to run systemctl --version.

Instructions

We will assume the following:

@Strong
Strong / ImageTextRenderUtils.php
Created February 17, 2022 15:08 — forked from y2k-shubham/ImageTextRenderUtils.php
Utility PHP snippet to wrap text (meant to be rendered on image) using pixel width
<?php
namespace Utils;
class ImageTextRenderUtils {
/**
* Returns expected width of rendered text in pixels
yup.addMethod(yup.string, 'domain', function pattern(name, message = VALIDATION_ERRORS.domain) {
const domainRules = [patterns.domain, patterns.punycode, patterns.cyrillicDomain];
return this.test({
message,
test: value => (value === null || value === '' || value === undefined) || domainRules.some(regex => regex.test(value)),
});
});
@Strong
Strong / axios.js
Created June 7, 2022 01:03 — forked from sidigi/axios.js
Nuxt Refresh token request
export default function ({$axios, app}) {
$axios.onResponseError(error => {
const code = parseInt(error.response && error.response.status);
let originalRequest = error.config;
if ([401, 403].includes(code)) {
originalRequest.__isRetryRequest = true;
let refresh_token = app.$auth.getRefreshToken(app.$auth.$storage.state.strategy).replace('Bearer ', '');
@Strong
Strong / hooks-index.js
Created June 28, 2022 23:38 — forked from renoirb/hooks-index.js
Nuxt 'render:setupMiddleware' hook example
// file: hooks/index.js
import render from './render'
// 'render:context'
export default (nuxtConfig) => ({
render: render(nuxtConfig),
})