Skip to content

Instantly share code, notes, and snippets.

View jenkoian's full-sized avatar
👨‍💻
Works on my machine

Ian Jenkins jenkoian

👨‍💻
Works on my machine
View GitHub Profile
@jenkoian
jenkoian / configuration-role-map.yml
Created March 21, 2016 11:11
Configuration role map
editor:
- add_content
moderator:
- moderate_content
admin:
- edit_user
@jenkoian
jenkoian / routes-catch-all.yml
Created March 21, 2016 11:11
Catch all routes
catch_all:
path: /{route}
requirements:
route: .*
@jenkoian
jenkoian / is-granted-example.twig
Created March 21, 2016 11:12
Twig is_granted example
{% if is_granted(‘ROLE_ADMIN’) %}
<button>Secret Button</button>
{% endif %}
@jenkoian
jenkoian / is-granted-permission.twig
Created March 21, 2016 11:13
Permission is_granted
{% if is_granted(‘add_content’) %}
<button>Add content</button>
{% endif %}
@jenkoian
jenkoian / PermissionVoter.php
Created March 21, 2016 11:13
PermissionVoter
<?php
//...
class PermissionVoter implements VoterInterface
{
//...
/**
* {@inheritdoc}
*/
public function vote(TokenInterface $token, $object, array $attributes)
@jenkoian
jenkoian / PermissionFacade.php
Created March 21, 2016 11:14
PermissionFacade
<?php
//...
class PermissionFacade
{
/**
* Global static helper for using isGranted from legacy codebase.
* @param $attributes
* @param null $object
* @return bool|void
*/
@jenkoian
jenkoian / permission-facade-usage-example.php
Created March 21, 2016 11:14
PermissionFacade usage example
<?php
//...
if (PermissionFacade::isGranted(‘add_content’)) {
echo ‘<button>Add content</button>’;
}
@jenkoian
jenkoian / done-yet.sh
Created September 22, 2016 10:48
Is it done yet?
status=$(curl -L -s -o /dev/null -w "%{http_code}" "http://url/to/check");
if [ "200" == "${status}" ]; then say -v "Good News" "ALL DONE YO!"; elif [ "502" == "${status}" ]; then say -v Whisper "Still Fucked"; else say -v "Bad News" "Not yet"; fi;
@jenkoian
jenkoian / site-snuggler.css
Created October 21, 2016 15:07
Mirror of Mcvities site snuggler so it works over https http://www.mcvities.co.uk/extras/site-snuggler
#mcvities_snuggletWrapper {
position:fixed;
bottom:0;
width:100%;
height:1px;
pointer-events:none;
z-index: 2147483640;
}
#mcvities_snuggletWrapper.down {
@jenkoian
jenkoian / site-snuggler.js
Created October 21, 2016 15:08
Mirror of Mcvities site snuggler so it works over https http://www.mcvities.co.uk/extras/site-snuggler
if(window.SNUGGLE) { SNUGGLE.snug(); }
window.SNUGGLE || (function(window){
window.SNUGGLE = {
snug: function(){
var viewportWidth = document.documentElement.clientWidth,
viewportHeight = document.documentElement.clientHeight;
var body = document.getElementsByTagName('body');