Skip to content

Instantly share code, notes, and snippets.

Christian Kirkegaard kirkegaard

Block or report user

Report or block kirkegaard

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
@kirkegaard
kirkegaard / plex-streams.sh
Last active Jul 30, 2019
Displays the current streams on plex
View plex-streams.sh
#!/bin/sh
PLEX_TOKEN=$(curl -H "Content-Length: 0" -H "X-Plex-Client-Identifier: my-app" -u $PLEX_USERNAME:$PLEX_PASSWORD -X POST https://my.plexapp.com/users/sign_in.xml --silent | xmllint --xpath "/user/authentication-token/text()" -)
XML=$(curl --silent http://$PLEX_HOST:32400/status/sessions -H "X-Plex-Token: $PLEX_TOKEN")
STREAMS=$(echo $XML | xmllint --xpath 'string(//MediaContainer/@size)' -)
echo "Current streams: ${STREAMS}"
for (( i=1; i <= $STREAMS; i++ )); do
USER=$(echo $XML | xmllint --xpath 'string(//Video['$i']/User/@title)' -)
@kirkegaard
kirkegaard / dumpoverssh.sh
Created Dec 20, 2010
pipe a mysql dump through gzip and send it over ssh
View dumpoverssh.sh
mysqldump -u MYSQL_USERNAME -p YOUR_DATABASE | gzip -c | ssh USERNAME@YOUR_TO_HOST 'cat > ~/dump.sql.gz'
View gist:299072
ranza@ant:~/Development/ircamp$ python ircamp.py
Traceback (most recent call last):
File "/usr/lib/python2.5/site-packages/twisted/python/log.py", line 51, in callWithLogger
return callWithContext({"system": lp}, func, *args, **kw)
File "/usr/lib/python2.5/site-packages/twisted/python/log.py", line 36, in callWithContext
return context.call({ILogContext: newCtx}, func, *args, **kw)
File "/usr/lib/python2.5/site-packages/twisted/python/context.py", line 59, in callWithContext
return self.currentContext().callWithContext(ctx, func, *args, **kw)
File "/usr/lib/python2.5/site-packages/twisted/python/context.py", line 37, in callWithContext
return func(*args,**kw)
View japan.mdown

Japan

Before you go

You can do a lot before you actually go! Like renting an internet dongle, grab tickets for the places you want to go or simply place stars on a google map. Its a good idea to plan where you want to go. Everything is huge so you'll wanna plan out before going out. And remember to drink a lot of water!

Internet

I cant stress this enough. Get an internet dongle! You can get these all around but look through the internet for cheap dongles. You can get these in the airport but its pretty expensive and the dataplans aint that good.

View m2embed.php
<?php
$title = (isset($_GET['t'])) ? $_GET['t'] : false;
$content = (isset($_GET['s'])) ? $_GET['s'] : false;
$providers = [
'drop' => [
'regex' => '/https?:\/\/files\.m2film\.dk\/(.*)/',
'embed' => '<video controls src="https://files.m2film.dk/{code}&video=true"></video>',
],
@kirkegaard
kirkegaard / opengl_vs_directx.mdown
Created Jun 30, 2011
The Tale of OpenGL vs. Direct3D
View opengl_vs_directx.mdown

The Tale of OpenGL vs. Direct3D

Many of the answers here are really, really good. But the OpenGL and D3D issue should probably be addressed. And that requires... a history lesson.

And before we begin, I know far more about OpenGL than I do about Direct3D. I've never written a line of D3D code in my life, and I've written tutorials on OpenGL. So what I'm about to say isn't a question of bias. It is simply a matter of history.

Birth of Conflict

One day, sometime in the early 90's, Microsoft looked around. They saw the SNES and Sega Genesis being awesome, running lots of action games and such. And they saw DOS. Developers coded DOS games like console games: direct to the metal. Unlike consoles however, where a developer who made an SNES game knew what hardware the user would have, DOS developers had to write for multiple possible configurations. And this is rather harder than it sounds.

View reddit_subscription.py
import requests
import praw
import time
import sqlite3
from urllib.request import pathname2url
class Subscriptions():
subscriptions = []
@kirkegaard
kirkegaard / app.py
Last active Jul 31, 2018
Subscribe to multiple channels using Pusher and post to Discord
View app.py
import requests
import pysher
import time
import json
appkey = '50ed18dd967b455393ed'
endpoint = '...'
auth = '...'
subscriptions = []
@kirkegaard
kirkegaard / ldapconn.php
Created Feb 16, 2015
Check if user exists in one or more groups in Apple ldap tree
View ldapconn.php
<?php
$ldapuser = 'user';
$ldappass = 'pass';
// Required groups
$groups = array('cn=group1', 'cn=group2');
// Ldap stuff
$directory = 'directory.example.dk';
@kirkegaard
kirkegaard / plasma.js
Created Jun 26, 2011
Plasma effect in javascript using canvas
View plasma.js
(function() {
var SCREEN_WIDTH = window.innerWidth,
SCREEN_HEIGHT = window.innerHeight,
canvas = document.getElementById('canvas'),
context = canvas.getContext('2d'),
res = 48,
rad = Math.PI / 180,
aa = ab = ac = ad = 0,
cr = cg = cb = 128, // COLOR
You can’t perform that action at this time.