Skip to content

Instantly share code, notes, and snippets.

View unfulvio's full-sized avatar
🇹🇼

Fulvio Notarstefano unfulvio

🇹🇼
  • Taipei, Taiwan
View GitHub Profile
@unfulvio
unfulvio / functions.php
Last active August 29, 2015 13:56
Just a self updating copyright year range
<?php
/**
* Copyright Years
* Outputs an years range based on specified year to current year
*
* @param int $copyYear - the year since the copyright starts (should be lower than current year)
* @return string - a range of years (eg. "2000-2010")
*/
function copyright( $copyYear ) {
@unfulvio
unfulvio / thinkpad.sh
Created May 30, 2015 14:11
Fix to re-enable Bluetooth on Thinkpad machines in Ubuntu in the event of a hardware hard off switch
echo options thinkpad_acpi dbg_bluetoothemul=1 bluetooth_state=1 | sudo tee -a /etc/modprobe.d/thinkpad_acpi.conf
@unfulvio
unfulvio / example.sh
Created June 19, 2015 11:05
Add all unversioned files to SVN
# See: http://stackoverflow.com/questions/1071857/how-do-i-svn-add-all-unversioned-files-to-svn
svn add --force * --auto-props --parents --depth infinity -q
@unfulvio
unfulvio / .htaccess
Created June 12, 2013 02:32
Protect a website folder (or root) with http password using .htaccess and .htpasswd
AuthUserFile /local/path/.htpasswd
AuthType Basic
AuthName "Insert a message here"
Require valid-user
@unfulvio
unfulvio / dt-toggle.js
Created June 17, 2013 14:33
Make every <dd> (definition description) element in a <dl> (definition llist) toggleable by the <dt> (definition term) element. Useful for creating toggleable lists, FAQs lists, etc.
$('#dl-container-id').on('click', 'dt.class-name', function() {
$(this).next().toggle();
});
@unfulvio
unfulvio / disable-woothemes-updater-notice.php
Created April 13, 2016 21:35
Disable WooThemes Updater Notice
<?php
/*
* Plugin Name: Disable WooThemes Updater Notice
* Version: 1.0.0
* Plugin URI: https://github.com/unfulvio/
* Description: Disables the WooThemes Updater activation notice nag when the Updater is deactivated.
* Author: Fulvio Notarstefano
* Author URI: https://github.com/unfulvio/
* Requires at least: 4.0
* Tested up to: 4.5
@unfulvio
unfulvio / functions.php
Created March 6, 2014 02:27
WordPress: get only terms connected to posts of a specified type
<?php
/**
* Get Terms used by Post Type
* Fetches only terms actually used by posts of a specified post type
*
* @param string $taxonomy the taxonomy to look for terms
* @param string $post_type the post type to match the taxonomy terms found
*
* @return array the query result (an array of taxonomy terms as objects)
@unfulvio
unfulvio / functions.php
Created February 13, 2017 13:02 — forked from mgibbs189/functions.php
FacetWP - WooCommerce Memberships fix
<?php
add_filter( 'facetwp_is_main_query', function( $is_main_query, $query ) {
if ( 'wc_user_membership' == $query->get( 'post_type' ) ) {
$is_main_query = false;
}
return $is_main_query;
}, 10, 2 );
@unfulvio
unfulvio / uninstall.sh
Last active June 12, 2018 19:04
Remove Intel Graphics Drivers for Linux and roll back to defaults in Ubuntu
#Source: http://theclonker.de/?p=89
sudo apt-get update
sudo sh -c 'echo "\nPackage: *\nPin: release a=trusty*\nPin-Priority: 1001\n\nPackage: *\nPin: origin download.01.org\nPin-Priority: -100\n" > /etc/apt/preferences.d/intel-removal'
sudo apt-get dist-upgrade
sudo rm /etc/apt/preferences.d/intel-removal
sudo rm /etc/apt/sources.list.d/intellinuxgraphics.list*
sudo apt-get update
# Use the following to find your i915 driver versions:
# dpkg --get-selections | grep i915
# then replace the version you find here and execute this line:
@unfulvio
unfulvio / m_array_keys_from_string.php
Created June 29, 2015 10:25
Make a multidimensional array with keys from a string with a variable amount of key names placed between square brackets
<?php
/**
* Problem:
* Given a string similar to '[key][subkey][otherkey]'
* we want to make a multidimensional array $array['key']['subkey']['otherkey']
*
* Original question on Stackoverflow:
* @link http://stackoverflow.com/questions/31103719/php-make-a-multidimensional-associative-array-from-key-names-in-a-string-separat/31104168
* There are alternative solutions posted.
*/