Skip to content

Instantly share code, notes, and snippets.

View svandragt's full-sized avatar
🤞

Sander van Dragt svandragt

🤞
View GitHub Profile
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:
@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 / worklog.py
Last active August 1, 2019 15:58
WorkLogPy: Keep track of what you are working on (Python 3). Writes a timestamped message to a CSV file.
#!/usr/bin/env python3
#v2.2
from random import choice
from datetime import datetime
def wlog(answer,now):
with open(f"worklog-{now:%Y%m%d}.csv", "a") as f:
f.write(f'"{now}","{answer.strip()}"\n')
@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;