Skip to content

Instantly share code, notes, and snippets.

@ScreamingDev
ScreamingDev / push-media.php
Created November 3, 2014 14:11
Import images in the uploads folder to the WordPress Media
<?php
define( 'DOING_AJAX', true );
define( 'WP_ADMIN', true );
define( 'WP_IMPORTING', true );
$err = array();
/** Load WordPress Bootstrap */
require_once '../../../../wp-load.php';
@ScreamingDev
ScreamingDev / last-5-days.sh
Last active July 2, 2022 06:52
What did I do today?
#!/bin/bash
#
# Find the "5 days" in this code
# and change it to whatever you want
#
tmpfile=$(tempfile)
for D in $(ls -1); do
<?php
class SudoObject
{
/**
* @var object
*/
private $instance;
/**
@ScreamingDev
ScreamingDev / Form.php
Created April 2, 2013 12:45
Mage - Adminhtml - Form fields (simple)
<?php
// text
$fieldset->addField('title', 'text', array(
'label' => Mage::helper('form')->__('Title3'),
'class' => 'required-entry',
'required' => true,
'name' => 'title',
'onclick' => "alert('on click');",
'onchange' => "alert('on change');",
@ScreamingDev
ScreamingDev / sexy-minimal.bash
Created February 26, 2017 10:19
Sexy Minimal Bash Prompt theme for bash-it
# Sexy Bash Prompt, inspired by "Extravagant Zsh Prompt"
# Screenshot: http://cloud.gf3.ca/M5rG
# A big thanks to \amethyst on Freenode
if [[ $COLORTERM = gnome-* && $TERM = xterm ]] && infocmp gnome-256color >/dev/null 2>&1; then export TERM=gnome-256color
elif [[ $TERM != dumb ]] && infocmp xterm-256color >/dev/null 2>&1; then export TERM=xterm-256color
fi
if tput setaf 1 &> /dev/null; then
if [[ $(tput colors) -ge 256 ]] 2>/dev/null; then
@ScreamingDev
ScreamingDev / WalletRepositoryInterface.php
Created February 11, 2017 17:51
DDD RepositoryInterface to "bypass" collections
<?php
namespace Foo\Domain\Wallet;
use Foo\Domain\RepositoryInterface;
use Foo\Domain\Wallet;
interface WalletRepositoryInterface extends RepositoryInterface
{
@ScreamingDev
ScreamingDev / script.md
Last active December 4, 2016 10:07
Ubuntu formatting before and after - a todo- and checklist

System

sudo apt-get update
sudo apt-get upgrade

Environment

Control

Less memory swapped / write-operations to the SSD

@ScreamingDev
ScreamingDev / deployer-wordpress-recipe.php
Last active November 16, 2016 07:53
Deployer: WordPress recipe using wp-cli
<?php
// some might like this as 'deploy:clean', most have 'cleanup'
$clean_hook = 'cleanup';
// assume wp cli is in the repo via composer
// change this to the path of your wp executable
set( 'wpcli_command', 'vendor/bin/wp' );
function deployer_wp_cli( $command ) {
@ScreamingDev
ScreamingDev / DeliveryTicketType.php
Created November 10, 2016 06:40
EntityType unit test - no SQL
<?php
namespace Crmp\AccountingBundle\Form;
use Crmp\AccountingBundle\Entity\DeliveryTicket;
use Crmp\AccountingBundle\Entity\Invoice;
use Crmp\AcquisitionBundle\Entity\Contract;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\NumberType;
@ScreamingDev
ScreamingDev / class-abstract-controller.php
Last active October 23, 2016 08:36
Doing Magento-like-Controllers in WordPress
<?php
// make the url "/register/index" and "/register" available
class Register_Controller extends Abstract_Controller {
public function index_action() {
wp_die( 'You can register here' );
}
}