Skip to content

Instantly share code, notes, and snippets.

View victorjonsson's full-sized avatar
🎯
Focusing

Victor Jonsson victorjonsson

🎯
Focusing
View GitHub Profile
<?php
/**
*
* @example
* <?php
*
* class Day extends EnumeratedType
* {
* const MONDAY = 'Monday';
window.addEventListener("load", function() {
var self = window.self,
parent = window.parent,
setTransparentBackground = function(doc) {
doc.getElementsByTagName('html')[0].style.background = 'transparent';
doc.getElementsByTagName('body')[0].style.background = 'transparent';
};
// make current doc transparent
@victorjonsson
victorjonsson / sifo-tagg-bara-i-mobilen
Created October 23, 2014 16:14
sifo-tagg-bara-i-mobilen.html
<!-- SIFO mobile specific tracking -->
<script type='text/javascript' src='http://mmetrix.mobi/sifo_msr.js'></script>
<script type="text/javascript">
sifo_Msr("<?php echo VKWP_SIFO_CPID ?>", "", "<?php echo rawurlencode( $subsection1 ); ?>", "", "", "", "");
</script>
<noscript>
<p><img src="http://bh.mobiletech.no/sifo/img?cpid=<?php echo VKWP_SIFO_CPID ?>&amp;cat=<?php echo rawurlencode( $subsection1 ); ?>&amp;REF=" alt="" height="1" width="1" /></p>
</noscript>
<!-- /SIFO mobile specific tracking -->

PayGate

WordPress + Varnish + External Login Service

This plugin makes the following assumptions about the login service:

  • The login service uses JWT
  • The signature in the user cookie provided by the login service contains an array of products that the user owns.
  • The user cookie provided by the login service contains a user ID, this id is also present in the cookie signature.
  • The login service has a javascript API.
Usage: python generator.py [<flags>]
Options:
-h, --help show this help message and exit
--template=TEMPLATE File to use as template [index.mustache]
--file=FILE Name of the generated file [index.html]
--pages=PAGES Directory where the pages are located [pages]
-w, --watch Start monitoring file changes and generate the one-page
html file on the fly
@victorjonsson
victorjonsson / arlima-inline-articles.php
Created February 27, 2014 08:14
arlima, inline-articles
<?php
$current_renderer = false;
// Always catch which renderer that is at work
add_action('arlima_list_begin', function($renderer) use($current_renderer) {
$current_renderer = $renderer;
});
// Move "children" into "inline-children" and create their template object
<script>
setWallPaperAd('URL-till-bild', 'URL-man-klickar', '#000000');
</script>
@victorjonsson
victorjonsson / gist:6728599
Last active December 24, 2015 02:09
Tail -f but with PHP in a browser
<?php
error_reporting(E_ALL);
$file = '/var/log/fpm/fpm-php.log';
echo '<h5>'.$file.'</h5>';
$offset = filesize($file) - 80240;
if( $offset < 0 )
$offset = 0;
var mval = require('mval'),
MANIFEST = mval.MANIFEST;
// Validate android manifest file
var errors = mval.validate('AndroidManifest.xml', MANIFEST.ANDROID);
if( errors.length > 0 ) {
throw new Error('AndroidManifest.xml is invalid \n'+errors.join('\n'));
}
// You can of course also validate ordinary objects
// Make the element editable by double clicking on it
$('#some-element').editable();
// There are some options you can configure when initiating
// the editable feature as well as a callback function that
// will be called when textarea gets blurred.
$('#some-element').editable({
touch : true, // Whether or not to support touch (default true)
lineBreaks : true, // Whether or not to convert \n to <br /> (default true)
toggleFontSize : true, // Whether or not it should be possible to change font size (defualt true)