Skip to content

Instantly share code, notes, and snippets.

View svandragt's full-sized avatar
🤞

Sander van Dragt svandragt

🤞
View GitHub Profile
@svandragt
svandragt / CMSGetRelationChainExtension.php
Last active August 29, 2015 13:56
CMSGetRelationChainExtension: get relation chains for new records
<?php
/**
* get relation chains for new records
*/
class CMSGetRelationChainExtension extends Extension {
private $parts = null;
private $keys = array(
'field',
@svandragt
svandragt / TempTask.php
Created March 3, 2014 14:04
Most basic BuildTask
<?php
class TempTask extends BuildTask {
protected $title = 'TempTask';
protected $description = '';
public function run($request) {
echo '<pre>';
// Do stuff
@svandragt
svandragt / page.php
Last active August 29, 2015 13:58
[SS] ModelController URL request argument handler problem
<?php
class Page_Controller extends ContentController {
public static $allowed_actions = array (
'test'
);
public function test($r) {
return 'ok';
}
@svandragt
svandragt / SvdGeolocationService.php
Created April 11, 2014 10:14
SvdGeolocationService
<?php
/**
* This helper is a minimal geolocation service wrapper that allows quick geolocating.
*
* freegeoip.net is community funded, therefore please consider donating if you like and use this service.
* Alternatively you can run your own server.
*
* Example (uses a 1 hour cookie to minimize lookups):
* $is_international = Cookie::get('IsInternational');
* if (is_null($is_international)) {
@svandragt
svandragt / atom.xml
Last active August 29, 2015 14:00 — forked from stammy/index.xml
Generalized atom.xml to use with jekyll (validates)
---
layout: nil
---
<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
<title type="text" xml:lang="en">{{ site.name }}</title>
<link type="application/atom+xml" href="{{ site.url }}/atom.xml" rel="self"/>
<link type="text/html" href="{{ site.url }}" rel="alternate"/>
<updated>{{ site.time | date_to_xmlschema }}</updated>
<id>{{ site.url }}/</id>
@svandragt
svandragt / AuthorativeOneWaySync.php
Last active August 29, 2015 14:00
Basic authorative one way sync pattern
<?php
// get $Records from external database
$inactive_ids = $DataObjects->getIDList();
while ($R = $Records->next()) {
$id = $this->ProcessRecord($R);
unset($inactive_ids[$id]);
}
$DataObjects->removeMany($inactive_ids);
function SvdSetElementFullHeight(elementId, bpad) {
// default
bpad = (typeof bpad === "undefined") ? 20 : bpad;
var inDesignMode = document.forms[MSOWebPartPageFormName].MSOLayout_InDesignMode.value;
if (inDesignMode == "1"){
return;
}
var e = document.getElementById(elementId);
@svandragt
svandragt / isChangedNotComparingWithStoredValue.php
Last active August 29, 2015 14:14
BUG isChanged is not comparing to the databasefields
<?php
/**
*/
class TempTask extends BuildTask {
protected $title = 'TempTask';
protected $description = '';
public function run($request) {
@svandragt
svandragt / Example.ps1
Last active August 29, 2015 14:26
FogBugz: BugzScout Automatic Crash Reporting using powershell
$ErrorActionPreference = "Stop"
#region functions - put this in an include and add it to every script
function DoTrap() {
$script = $_.InvocationInfo.ScriptName
$line = $_.InvocationInfo.ScriptLineNumber
$_errorDetails = $Error[0] | fl * -force | Out-string
if (Submit-BugzScoutReport -Description "TEST: $script:$line" -Extra $_errorDetails) {
Write-Host "Error reported."
@svandragt
svandragt / Pomodoro MediaPlayer.ahk
Last active August 29, 2015 14:27
Create a playlist and let this script divide up your poms. (more info on pomodoro work focus technique: http://workawesome.com/productivity/pomodoro )
#NoEnv
#SingleInstance ignore
SendMode Input
playPauseKey = {Control down}{Alt down}{Home}{Alt up}{Control up}
workPeriod := 25 * 60 * 1000
breakPeriod := 5 * 60 * 1000
pomsBeforeLongBreak := 4
Pomodoro: