Skip to content

Instantly share code, notes, and snippets.

View gadiener's full-sized avatar

Gabriele gadiener

View GitHub Profile
@gadiener
gadiener / RemoveAdminColorScheme.php
Last active April 27, 2016 10:40
Remove admin color scheme picker and set default scheme for new user in wordpress
<?php
add_action( 'init', function() {
remove_action( 'admin_color_scheme_picker', 'admin_color_scheme_picker' );
});
add_action( 'user_register', function ($user_id) {
wp_update_user([
'ID' => $user_id,
'admin_color' => 'Default' // Light | Blue | Midnight | Sunrise | Ectoplasm | Ocean | Coffee
]);
@gadiener
gadiener / LazyContainer.php
Created April 27, 2016 10:41
LazyContainer
<?php
class LazyContainer {
private $dictionary;
public function __construct( $definitions ){
$this->dictionary = $definitions;
}
public function __get( $n ){
@gadiener
gadiener / Menu.php
Last active May 13, 2016 07:27
Helper for build custom menu in wordpress
<?php
class Menu {
protected $elements = [],
$args = [],
$menu_location = "primary",
$setted = false;
/**
* Return array with all menu items.
@gadiener
gadiener / DigestAuth.php
Created June 3, 2016 15:25
Digest HTTP Authentication class for core
<?php
/**
* Digest HTTP Authentication class
*
* PHP version 5.5
*
* @author Gabriele Diener <gabriele.diener@caffeina.com>
*/
class DigestAuth {
@gadiener
gadiener / row-num.sql
Last active March 22, 2017 15:38
Add row number to MySql query
SELECT * FROM
(
SELECT
@i:=@i+1 AS rownum,
subq.*
FROM
(
SELECT id,date FROM articles
) subq,
(SELECT @i:=0) r
@gadiener
gadiener / facebook-ticker.js
Created July 25, 2016 16:04 — forked from kopiro/facebook-ticker.js
Filter Facebook ticker stories with a RegEx
(function() {
var filterName = new RegExp(prompt("Insert the regex"), 'i');
if (!filterName) {
return alert('Invalid regex');
}
var MAX_ITERATIONS = 500;
var $profileNode = document.querySelector('[title="Profile"] > span');
@gadiener
gadiener / tty.sh
Created November 23, 2016 09:05
Fix error: gpg-agent[30745]: command get_passphrase failed: Inappropriate ioctl for device
# With oh-my-zsh
echo 'export GPG_TTY=$(tty)' >> .my_zshrc
# With bash
echo 'export GPG_TTY=$(tty)' >> .bashrc
@gadiener
gadiener / _service.md
Created March 28, 2017 14:43 — forked from naholyr/_service.md
Sample /etc/init.d script

Sample service script for debianoids

Look at LSB init scripts for more information.

Usage

Copy to /etc/init.d:

# replace "$YOUR_SERVICE_NAME" with your service's name (whenever it's not enough obvious)
@gadiener
gadiener / test.tree.php
Created May 22, 2017 07:35 — forked from lastguest/test.tree.php
[CAFFEINA] Exercise #1
<?php
include "tree.php";
$x = new Tree();
$x->bacon = "Pancetta";
$x->pasta["fagioli"] = 3;
$y = clone $x;
$y->pasta = null;
@gadiener
gadiener / wp_mail_proxy.php
Created June 20, 2017 16:04
Reconfigures the wp_mail() function with SMTP.
<?php
/*
Plugin Name: WP Mail Proxy
Version: 1.0.0
Description: Reconfigures the wp_mail() function.
Author: Gabriele Diener
Author URI: https://gdiener.com
*/
/**