Skip to content

Instantly share code, notes, and snippets.

View gmazzap's full-sized avatar

Giuseppe Mazzapica gmazzap

View GitHub Profile
@SynCap
SynCap / remove_node_modules_recursively.ps1
Last active April 18, 2024 08:33
Remove `node_modules` folders in Windows in all subfolders recursively with PowerShell to avoid exceeding path max_length
<#
Note: Eliminate `-WhatIf` parameter to get action be actually done
Note: PS with version prior to 4.0 can't delete non-empty folders
#>
Get-ChildItem -Path "." -Include "node_modules" -Recurse -Directory | Remove-Item -Recurse -Force -WhatIf
@sminnee
sminnee / foo.php
Last active November 5, 2015 23:20
Custom generator classes with IteratorAggregate
<?php
class ForLoop implements IteratorAggregate
{
public $from = 0, $to, $step = 1;
function getIterator() {
for($i = $this->from; $i <= $this->to; $i += $this->step) {
yield $i;
@Biont
Biont / mlp-autosync-terms.php
Last active October 3, 2017 09:34
MLP Autosync Terms
<?php
/**
* Plugin Name: MLP Autosync Terms
* Description: Automatically sync all linked terms when a post is saved
* Author: Biont
* Author URI: https://github.com/Biont
* License: GPLv3
*/
/**
@Rarst
Rarst / append.php
Last active April 27, 2016 12:31
My xhprof/uprofiler setup, tweaked for WordPress and more easily profiling segments.
<?php
use Rarst\Profiler\Handler;
global $wp;
if ( Handler::$profiling && empty( $wp ) ) {
Handler::close();
}
<?php
namespace igorw\lusp;
// all functions return a pair of [val, env]
function evaluate($expr, $env = []) {
if (is_string($expr)) {
if (is_numeric($expr)) {
$val = (float) $expr;
@Adirael
Adirael / fix-wordpress-permissions.sh
Created August 17, 2012 23:16
Fix wordpress file permissions
#!/bin/bash
#
# This script configures WordPress file permissions based on recommendations
# from http://codex.wordpress.org/Hardening_WordPress#File_permissions
#
# Author: Michael Conigliaro <mike [at] conigliaro [dot] org>
#
WP_OWNER=www-data # <-- wordpress owner
WP_GROUP=www-data # <-- wordpress group
WP_ROOT=$1 # <-- wordpress root directory
@ziadoz
ziadoz / awesome-php.md
Last active April 17, 2024 21:06
Awesome PHP — A curated list of amazingly awesome PHP libraries, resources and shiny things.