Skip to content

Instantly share code, notes, and snippets.

@stefansundin
stefansundin / svnsync.php
Last active Dec 15, 2015
This is a PHP script that can process PostCommitWebHooks from Google Code Project Hosting.
View svnsync.php
<?php
/*
https://gist.github.com/stefansundin/5224325
https://code.google.com/p/support/wiki/PostCommitWebHooks
To use PHP to verify the authentication hash, you can do this. It supports multiple projects and can also run svnsync. However, this requires you to make your web server user (often 'www-data') to be able to launch svnsync without sudo having to ask for a password:
$ sudo visudo
Then add this to the bottom (it's important that it is in the bottom!):
www-data ALL=(ALL) NOPASSWD:/usr/bin/svnsync
@stefansundin
stefansundin / youtube_live.php
Last active Dec 17, 2015
PHP script that converts GData feeds for YouTube Live events to human readable feeds.
View youtube_live.php
<?php
/*
https://gist.github.com/stefansundin/5519170
Converts GData feeds for YouTube Live events to human readable feeds.
http://stefansundin.com/blog/476
https://developers.google.com/youtube/2.0/developers_guide_protocol_retrieving_live_events
Use this url to get data for streams that no longer appear in any of the feeds:
https://gdata.youtube.com/feeds/api/users/CHANNELNAME/live/videos/VIDEOID?v=2
It does not appear to contain all of the info though. Replace CHANNELNAME and VIDEOID.
@stefansundin
stefansundin / guess-ytlive-url.py
Last active Apr 16, 2016
Python script to hax YouTube Live segments that are no longer accessible via the playlist. See http://stefansundin.com/blog/452#comments
View guess-ytlive-url.py
# https://gist.github.com/stefansundin/6261442
# Python 3.x
# Binary search for the correct clen parameter for YouTube live streams, which is useful when a segment is no longer listed in the playlist file (check EXT-X-EARLIEST-MEDIA-SEQUENCE).
# It's quick and dirty. clen is always a multiple of 188 (since it is TS). lmt and dur does not have any impact it seems.
# Usually finds the correct url in about 15 tries.
# See http://stefansundin.com/blog/452#comments
# TODO: add threading to process multiple sequence numbers at the same time.
"""
Regexps to extract clen and dur from a playlist:
@stefansundin
stefansundin / paypal-gadget.xml
Last active Dec 22, 2015
Google Gadget for a PayPal button with an amount text input. Meant to be used on Google Project Hosting.
View paypal-gadget.xml
<?xml version="1.0" encoding="UTF-8"?>
<Module>
<ModulePrefs title="PayPal gadget" author="Stefan Sundin" width="400" height="35"></ModulePrefs>
<UserPref name="business" datatype="string" default_value="8727MAF7NTYRE" />
<UserPref name="item_number" datatype="string" default_value="Donation" />
<UserPref name="amount" datatype="string" default_value="$5.00" />
<UserPref name="return_url" datatype="string" default_value="" />
<UserPref name="return_text" datatype="string" default_value="" />
<Content type="html">
<![CDATA[
@stefansundin
stefansundin / .Xmodmap
Last active May 26, 2018
Xmodmap for Chromebook Pixel. This is customized for a Swedish layout, you might want to edit these lines for your preferred layout. Use 'xmodmap -pke' to print your current Xmodmap.
View .Xmodmap
! Chromebook Pixel Xmodmap
! https://gist.github.com/stefansundin/6987698
! setxkbmap -layout se
! xmodmap .Xmodmap
! xev
! Startup applications:
! Command: sh -c "xmodmap ~/.Xmodmap"
! I also manually bind F4 and F5 in Ubuntu's keyboard shortcuts:
@stefansundin
stefansundin / install-kbd-backlight.sh
Last active Mar 25, 2019
Script to control keyboard backlight brightness on a Chromebook Pixel running Ubuntu. Includes extra bits like restore old session value on boot, dim keyboard on screen lock, restoring value when resuming from suspend, and so on. Relies on kernel module acpi_call (instructions below).
View install-kbd-backlight.sh
#!/bin/sh
# This script will install the files below.
# Please look through them first so you know what will happen.
# Install by running this command:
# curl -fL https://gist.githubusercontent.com/stefansundin/7003429/raw/install-kbd-backlight.sh | sh
# Uninstall with:
# sudo rm /opt/kbd-{backlight,lock}.sh /etc/pm/sleep.d/70-kbd-backlight
# rm ~/.config/autostart/kbd-{backlight,lock}.sh.desktop
@stefansundin
stefansundin / 1-devtld.js.md
Last active Dec 2, 2018
A node.js server to redirect custom TLDs in Chrome without the need for the http:// prefix. You can extend this to do all kinds of things.
View 1-devtld.js.md

What this is

A simple node.js server to redirect whatever.dev to http://whatever.dev. It also redirects you to other websites based on your query (see tips below).

Tips

You can quickly go to different websites with certain queries:

  • mdn css transition will search MDN for css transition
  • AWS identifiers will take you to the correct place in the AWS console:
@stefansundin
stefansundin / youtube-iframe.xml
Last active Jan 1, 2016
Google Gadget to embed YouTube videos.
View youtube-iframe.xml
<?xml version="1.0" encoding="UTF-8"?>
<Module>
<ModulePrefs title="YouTube iframe embed" author="Stefan Sundin" width="640" height="390"></ModulePrefs>
<UserPref name="id" datatype="string" default_value="" />
<UserPref name="width" datatype="string" default_value="" />
<UserPref name="height" datatype="string" default_value="" />
<UserPref name="args" datatype="string" default_value="" />
<Content type="html">
<![CDATA[
<script type="text/javascript">
@stefansundin
stefansundin / flattr-gadget.xml
Last active Jan 1, 2016
Google Gadget for Flattr.
View flattr-gadget.xml
<?xml version="1.0" encoding="UTF-8"?>
<Module>
<ModulePrefs title="Flattr button" author="Stefan Sundin" width="55" height="62" scrolling="false"></ModulePrefs>
<UserPref name="url" datatype="string" default_value="" />
<UserPref name="uid" datatype="string" default_value="" />
<UserPref name="title" datatype="string" default_value="" />
<UserPref name="desc" datatype="string" default_value="" />
<UserPref name="cat" datatype="string" default_value="software" />
<UserPref name="lang" datatype="string" default_value="en_GB" />
<UserPref name="tags" datatype="string" default_value="" />
You can’t perform that action at this time.