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 / icecast.xml
Last active February 27, 2016 09:37
Local insecure Icecast setup
<!-- Sets up an icecast mount point on your own machine -->
<icecast>
<limits>
<sources>2</sources>
</limits>
<authentication>
<source-password>hackme</source-password>
<relay-password>hackme</relay-password>
<admin-user>admin</admin-user>
<admin-password>hackme</admin-password>
@svandragt
svandragt / example.liq
Last active February 27, 2016 10:06
LiquidSoap flow, connecting to http://example.com:8124 transcoding an ice cast stream to a shoutcast server.
set("log.file",false)
set("log.stdout",true)
source_url = "http://localhost:8000/traktor.ogg"
output_host = "example.com"
output_port = 8124
output_pass = "mypassword"
s = input.http(buffer=4.0,source_url)
@svandragt
svandragt / gist:7713a901fdac7b24fe3b6adbd31f74a2
Created April 25, 2016 13:10 — forked from nternetinspired/gist:7482445
Load Disqus comments only on demand if you give a shit about page weight and your visitors. Even with no comments, i.e. an empty comment form, calling Disqus will load an extra 226Kb. If your page has comments this can be far higher. This Gist accompanies my blog post: http://internet-inspired.com/wrote/load-disqus-on-demand/
// Requires jQuery of course.
$(document).ready(function() {
$('.show-comments').on('click', function(){
var disqus_shortname = 'YOUR-DISQUS-USERNAME'; // Replace this value with *your* username.
// ajax request to load the disqus javascript
$.ajax({
type: "GET",
url: "http://" + disqus_shortname + ".disqus.com/embed.js",
dataType: "script",
@svandragt
svandragt / wxr2lektor.py
Last active April 28, 2016 14:43
Save WordPress Extended RSS posts export entries to Lektor content (Python3)
import errno
import feedparser
import os
import sys
t = '''
title: {title}
---
pub_date: {pub_date}
---
<?php
$user = "domain\user";
$pass = "password";
$dn = "OU=...";
$time = microtime();
$time = explode(" ", $time);
$time = $time[1] + $time[0];
$start = $time;
@svandragt
svandragt / example-adts-aac.liq
Created July 25, 2016 20:33
Liquidsoap example ADTS-AAC
set("log.file",false)
set("log.stdout",true)
source_url = "http://localhost:8000/traktor.ogg"
output_host = "example.com"
output_port = 8124
output_pass = "mypassword"
s = input.http(buffer=4.0,source_url)
@svandragt
svandragt / github-webhook-deploy.php
Created July 29, 2016 10:10 — forked from frippz/github-webhook-deploy.php
Github webhook PHP script
<?php
try {
// Decode JSON data from Github
$payload = json_decode($_REQUEST['payload']);
}
catch(Exception $e) {
exit(0);
}
// Deploy live if push was on master branch