Skip to content

Instantly share code, notes, and snippets.

View bezhermoso's full-sized avatar

Bez Hermoso bezhermoso

View GitHub Profile
<?php
namespace App\ShopBundle\Security\Authentication\Provider;
use App\ShopBundle\Entity\Order;
use App\ShopBundle\Model\OrderManager;
use App\ShopBundle\Security\SessionToken;
use Symfony\Component\Security\Core\Authentication\Provider\AuthenticationProviderInterface;
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
@bezhermoso
bezhermoso / .bashrc
Created September 3, 2014 15:57
make me a sandwich...please.
alias please='sudo $(history -p \!\!)'
@bezhermoso
bezhermoso / 0_reuse_code.js
Last active August 29, 2015 14:07
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
#!/usr/bin/env node
'use strict';
/* Our bread & butter -- replaces a sub-string with something else */
function _replace(str, start, end, replacement) {
return str.substr(0, start) + replacement + str.substr(end, str.length);
}
/* Replaces user mentions based on object from tweet.entities.user_mentions */
@bezhermoso
bezhermoso / partial-function-applications.js
Created June 9, 2015 18:41
Function currying in JavaScript with blank variable support.
Function.prototype.__ = {};
Function.prototype.curry = function () {
var fn = this,
args = Array.prototype.slice.call(arguments, 0);
while(args.length < fn.length) {
args.push(Function.prototype.__);
}
@bezhermoso
bezhermoso / memoize-until.js
Last active June 2, 2022 08:39
`memoizeUntil` -- memoize function for n milliseconds
var R = require("ramda");
var memoizeUntil = function (fn, expiry) {
var cache = {};
var onExpiry = [];
var onCache = [];
var onCachedResult = [];
var memoized = function () {
@bezhermoso
bezhermoso / notification-actions.applescript
Created January 15, 2016 16:29
Handly AppleScripts to manage OS X notifications. (Use in Automator, bind to keyboard shortcuts via BetterTouchTool, etc.) Inspired by http://apple.stackexchange.com/a/155736
my closeNotifications()
on closeNotifications()
tell application "System Events"
tell process "Notification Center"
set theWindows to every window
repeat with i from 1 to number of items in theWindows
set this_item to item i of theWindows
try
click button 1 of this_item
@bezhermoso
bezhermoso / notification-actions.applescript
Created January 15, 2016 16:29
Handly AppleScripts to manage OS X notifications. (Use in Automator, bind to keyboard shortcuts via BetterTouchTool, etc.) Inspired by http://apple.stackexchange.com/a/155736
my closeNotifications()
on closeNotifications()
tell application "System Events"
tell process "Notification Center"
set theWindows to every window
repeat with i from 1 to number of items in theWindows
set this_item to item i of theWindows
try
click button 1 of this_item
@bezhermoso
bezhermoso / notification-actions.applescript
Last active February 11, 2023 09:54
Handly AppleScripts to manage OS X notifications. (Use in Automator, bind to keyboard shortcuts via BetterTouchTool, etc.) Inspired by http://apple.stackexchange.com/a/155736
# Close all notifications
my closeNotifications()
on closeNotifications()
tell application "System Events" to tell process "Notification Center"
set theWindows to every window
repeat with i from 1 to number of items in theWindows
set this_item to item i of theWindows
try
click button 1 of this_item
diff --git a/core/lib/Drupal/Core/Routing/UrlGenerator.php b/core/lib/Drupal/Core/Routing/UrlGenerator.php
index 9979b73..3dce650 100644
--- a/core/lib/Drupal/Core/Routing/UrlGenerator.php
+++ b/core/lib/Drupal/Core/Routing/UrlGenerator.php
@@ -340,7 +340,10 @@ public function generateFromRoute($name, $parameters = array(), $options = array
$base_url = $this->context->getBaseUrl();
$absolute = !empty($options['absolute']);
- if (!$absolute || !$host = $this->context->getHost()) {
+