Skip to content

Instantly share code, notes, and snippets.

View ronnyandre's full-sized avatar

Ronny-André Bendiksen ronnyandre

View GitHub Profile
<?php
// URL til varselet
$url = 'http://www.yr.no/sted/Norge/Hordaland/Bergen/Bergen/varsel.xml';
// Les data fra URL
$xmldata = file_get_contents($url);
// Les dataene og gjør om til SimpleXML-objekt
$xml = new SimpleXMLElement($xmldata);
@ronnyandre
ronnyandre / gist:900309
Created April 3, 2011 08:50
Comprehensive List of Browser-Specific CSS Hacks
/**
* Source: Paul Irish - Comprehensive List of Browser-Specific CSS Hacks
* http://paulirish.com/2009/browser-specific-css-hacks/
**/
/***** Selector Hacks ******/
/* IE6 and below */
* html #uno { color: red }
@ronnyandre
ronnyandre / js.js
Created March 8, 2012 13:33
JavaScript: Sexy PubSub
var o = $( {} );
$.subscribe = o.on.bind(o);
$.unsubscribe = 0.off.bind(o);
$.publish = o.trigger.bind(o);
@ronnyandre
ronnyandre / style.css
Created March 8, 2012 13:34
CSS: Image Replacement
.ir {
border: 0;
font: 0/0 a;
text-shadow: none;
color: transparent;
background-color: transparent;
}
@ronnyandre
ronnyandre / jQuery: PubSub
Created March 8, 2013 14:18
JavaScript: jQuery PubSub
(function($) {
var o = $( {} );
$.each({
on: 'subscribe',
trigger: 'publish',
off: 'unsubscribe'
}, function( key, api ) {
$[api] = function() {
o[key].apply( o, arguments );
@ronnyandre
ronnyandre / index.html
Created March 28, 2013 09:32
A CodePen by Ronny-André Bendiksen. Slide in from bottom boxes - Saw this while using Google+ app on my (Android) Nexus 7.
<section>
<div class="module"></div>
<div class="module"></div>
<div class="module"></div>
<div class="module"></div>
<div class="module"></div>
<div class="module"></div>
<div class="module"></div>
<div class="module"></div>
@ronnyandre
ronnyandre / gist:5261967
Last active December 15, 2015 12:39
Don't prevent events when users hold CTRL or META keys
document.getElementById("myLink").addEventListener("click", function(e) {
// e.preventDefault(); (bad)
if(e.meta || e.ctrlKey) return; // Don't block user if they want to open a new tab
e.preventDefault();
});
@ronnyandre
ronnyandre / dateinterval.php
Last active December 17, 2015 14:49
Get each occurence in DatePeriod
<?php
// Found at http://www.php.net/manual/en/class.dateperiod.php
// Credit goes to jkaatz at gmx dot de
// ************************************************
// Nice example from PHP Spring Conference (thanks to Johannes Schlüter and David Zülke)
$begin = new DateTime('2013-05-01 00:00:00');
$end = new DateTime('2013-12-31 23:59:59');
@ronnyandre
ronnyandre / download.php
Created August 14, 2013 11:39
Simultaneously download websites using PHP and Guzzle
<?php
use Guzzle\Http\Client,
Guzzle\Common\Exception\MultiTransferException;
$client = new Client('http://graph.facebook.com');
try {
$responses = $client->send(array(
$client->get('/' . urlencode('http://tech.vg.no')),
$client->get('/' . urlencode('http://www.vg.no')),
@ronnyandre
ronnyandre / A-Pen-by-Stoyan-Miladinov.markdown
Created October 26, 2013 09:36
A Pen by Stoyan Miladinov.