Skip to content

Instantly share code, notes, and snippets.

Max Girkens gherkins

Block or report user

Report or block gherkins

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@gherkins
gherkins / CachedMySQLDatabase.php
Created May 14, 2015
CachedMySQLDatabase - stores results of SELECT queries as arrays and reuses those... not sure if this is a good idea, though
View CachedMySQLDatabase.php
<?php
/**
* Class CachedMySQLDatabase
* @inheritdoc
*/
class CachedMySQLDatabase extends MySQLDatabase
{
protected $cache = array();
@gherkins
gherkins / CachedMySQLDatabase.php
Created May 14, 2015
cache identical queries
View CachedMySQLDatabase.php
<?php
/**
* Class CachedMySQLDatabase
* @inheritdoc
*/
class CachedMySQLDatabase extends MySQLDatabase
{
protected $cache = array();
View gist:5107724
(function(){
var v = "1.3.2";
if (window.jQuery === undefined || window.jQuery.fn.jquery < v) {
var done = false;
var script = document.createElement("script");
script.src = "http://ajax.googleapis.com/ajax/libs/jquery/" + v + "/jquery.min.js";
script.onload = script.onreadystatechange = function(){
if (!done && (!this.readyState || this.readyState == "loaded" || this.readyState == "complete")) {
@gherkins
gherkins / image_xml_sitemap.php
Created Oct 20, 2012
Create Google (Image) XML Sitemaps using PHP
View image_xml_sitemap.php
header("Content-type: text/xml; charset=utf-8");
//create your XML document, using the namespaces
$urlset = new SimpleXMLElement('<?xml version="1.0" encoding="UTF-8"?><urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:image="http://www.google.com/schemas/sitemap-image/1.1" /><!--?xml version="1.0" encoding="UTF-8"?-->');
//iterate over your sites pages or whatever you like
foreach (getMyPagesOrWhatEver() as $item):
//add the page URL to the XML urlset
@gherkins
gherkins / jquery.magnetic.js
Created Jul 25, 2012
some experimental minimal plugin for fix/unfix position of a container inside another container...
View jquery.magnetic.js
(function($) {
$.fn.magnetic = function(options) {
var obj = this.find(options.selector);
var initialLeft = parseInt(obj.css('left'));
var mainOffset = this.offset().left;
var fixAt = (initialLeft - options.left ) + mainOffset;
this.on('scroll', function() {
@gherkins
gherkins / silverstripe_duplicate_relations.php
Created Mar 10, 2012
Silverstripe – has_many- and many_many-relations when duplicating pages
View silverstripe_duplicate_relations.php
<?php
public function duplicate() {
$items_to_duplicate = array(
'Images',
'Somehting'
);
$page = parent::duplicate();
@gherkins
gherkins / install_silverstripe.sh
Created Sep 11, 2011
install silverstripe + common modules from github
View install_silverstripe.sh
# install silverstripe + common modules from github
# usage sh install_silverstripe.sh <folder_name> <tag/branch>
# examples:
# sh install_silverstripe.sh some_folder tags/2.4.5
# sh install_silverstripe.sh some_folder master
#set up project base folder
git clone git@github.com:silverstripe/silverstripe-installer.git $1
cd $1
git checkout $2
@gherkins
gherkins / scrollToViewPort.js
Created Jun 10, 2011 — forked from dejoe/scrollToViewPort.js
Jquery Scroll To View Port
View scrollToViewPort.js
jQuery.fn.scrollToViewPort = function(options) {
var animTimeInterval = (typeof options.interval == "undefined")?"slow":animTimeInterval;
return this.each(function(){
var offSet = (typeof options.offset == "undefined")? $(this).offset().top : options.offset;
if( $(this).offset().top <= $(window).scrollTop() || ( $(this).offset().top + $(this).height() ) >= ( $(window).scrollTop() + $(window).height() ) ){
$('html,body').animate( { scrollTop: offSet }, animTimeInterval );
}
});
}
You can’t perform that action at this time.