Skip to content

Instantly share code, notes, and snippets.

View svandragt's full-sized avatar
🤞

Sander van Dragt svandragt

🤞
View GitHub Profile
@svandragt
svandragt / sculptie_damage.lsl
Created June 26, 2012 12:50
Sculptie Damage Script - SecondLife Armor
// This is an initial finished prototype demonstrating Sculptie based armor that is affected by damage. (multiple stages of degradation, bullit holes etc)
integer damageStage = -1;
SendStatus(integer dmg)
{
string texture = llGetInventoryName(INVENTORY_TEXTURE,dmg);
list params = [PRIM_TYPE, PRIM_TYPE_SCULPT, texture, PRIM_SCULPT_TYPE_SPHERE];
llSetLinkPrimitiveParams(LINK_ALL_OTHERS,params);
}
@svandragt
svandragt / _config.php
Created November 20, 2012 11:38
How to cache silverstripe menu's for live environment
// limit caching to test + live environment and "Published stage" only
if (Director::isDev() || Versioned::current_stage() !== 'Live') SS_Cache::set_cache_lifetime('any', -1, 100);
@svandragt
svandragt / HowtoPage.php
Created November 21, 2012 11:22
Debug shows steps, but gridfield doesn't if author is not admin.
<?php
class HowtoPage extends DocumentPage {
public static $has_many = array(
'Steps' => 'Step',
);
public function getCMSFields() {
$fields = parent::getCMSFields();
Debug::show($this->Steps()); // shows steps when exist
@svandragt
svandragt / DateRange.php
Created February 25, 2014 14:16
DateRange class: Quickly find overlaps with other date ranges
<?php
/**
* Class to make it easier to compare date ranges (where range is between start date and end date)
*/
class DateRange {
public $StartDate = null;
public $EndDate = null;
/**
@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);