Skip to content

Instantly share code, notes, and snippets.

View AlexanderPoellmann's full-sized avatar

Alexander Manfred Pöllmann AlexanderPoellmann

View GitHub Profile
@AlexanderPoellmann
AlexanderPoellmann / function-parse-video.php
Last active December 24, 2018 05:18
A simple PHP function to parse a given string for a YouTube or Vimeo link (or embed code) and extract video ID, provider, etc.
<?php
/**
* Parse a video string
*
* @param string $haystack The string to be parsed
* @param string $protocol The protocol to be used for the urls
* @return array $video
*
* @version 2014-08-22
*
@AlexanderPoellmann
AlexanderPoellmann / .htaccess
Last active April 7, 2019 01:49
Set Expiry Headers in htaccess (by HTML5 Boilerplate)
# ----------------------------------------------------------------------
# | Expires headers |
# ----------------------------------------------------------------------
# Serve resources with far-future expires headers.
#
# (!) If you don't control versioning with filename-based
# cache busting, you should consider lowering the cache times
# to something like one week.
#
@AlexanderPoellmann
AlexanderPoellmann / .htaccess
Created January 21, 2015 22:43
Force SSL (https) on all Pages with htaccess
# Force https on all pages
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
</IfModule>
<?php
/**
* Update Teacher capabilities
* (synch with Author caps)
*
* @return void
**************************************************/
function update_teacher_caps() {
// get roles
$author = get_role('author');
@AlexanderPoellmann
AlexanderPoellmann / laravel-5-tweak-login-authcontroller.php
Created May 24, 2015 20:15
Log in with Username or Email in Laravel 5 - AuthController->postLogin()
<?php
/**
* This snippet goes into your
* \app\Http\Controllers\Auth\AuthController.php
*
* Make sure to update your login view as well
* (\resources\views\auth\login.blade.php). Just
* change
*/
@AlexanderPoellmann
AlexanderPoellmann / cleanup-woocommerce-db.sql
Created October 11, 2015 17:52
Clean up your database by deleting ALL (!) woocommerce sessions and ALL (!) transients. Use with caution!
DELETE FROM `wp_options` WHERE `option_name` LIKE ('%\wc_session\_%')
DELETE FROM `wp_options` WHERE `option_name` LIKE ('%\_transient\_%')
@AlexanderPoellmann
AlexanderPoellmann / function-antiMultiPosting.php
Last active February 16, 2017 09:35
Prevent multiple posting.
/**
* Prevent multiple posting.
*
* @return bool
*/
public function antiMultiPosting() {
/**
* @var $user User
*/
$user = auth()->user();