Skip to content

Instantly share code, notes, and snippets.

View xhochy's full-sized avatar

Uwe L. Korn xhochy

View GitHub Profile
module Cache
def Cache.file(filename, cache_lifetime=604800)
if File.exists?(filename)
if File.mtime(filename) < (Time.now - cache_lifetime)
body = yield
File.open(filename, 'w') do |file|
file << body.to_yaml
end
return body
else
package com.xhochy
import com.tinkerpop.blueprints.impls.neo4j.Neo4jGraph
import com.tinkerpop.blueprints.util.io.graphml.GraphMLReader
import java.io.FileInputStream
/**
*/
object App {
package com.xhochy
import com.tinkerpop.blueprints.impls.neo4j.Neo4jGraph
import com.tinkerpop.blueprints.util.io.graphml.GraphMLReader
import java.io.FileInputStream
/**
*/
object App {
@xhochy
xhochy / gist:3447675
Created August 24, 2012 08:47
Calculate free ranges of an IPv4Network
blocked_ips = [ipv4Network[0], ipv4Router]
ranges = [[ipv4Network[1], ipv4Network[-1]]]
for ip in blocked_ips:
index = 0
# Find range which includes the ip, i.e. 'start <= ip <= end'
while (index < len(ranges)) and (not ((ranges[index][0] <= ip) and (ip <= ranges[index][1]))):
index += 1
if index == len(ranges):
# IP address is already excluded
pass
#! /bin/sh
LD_PRELOAD="\${LD_PRELOAD} /usr/share/spotify/libcef.so"
export LD_PRELOAD
exec ${SPOTIFY_HOME}/spotify
# Copyright 1999-2012 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/media-libs/libechonest/libechonest-2.0.1.ebuild,v 1.2 2012/12/27 23:14:16 hasufell Exp $
EAPI=4
inherit cmake-utils
DESCRIPTION="A library for communicating with The Echo Nest"
HOMEPAGE="http://projects.kde.org/projects/playground/libs/libechonest"
SRC_URI="http://files.lfranchi.com/${P}.tar.bz2
@xhochy
xhochy / generate.scala
Created January 15, 2013 11:45
Generate graph communities and annotate vertices so that each vertex has its community as a property
package com.xhochy
import com.tinkerpop.blueprints.impls.tg.TinkerGraph
import com.tinkerpop.furnace.generators.{ CommunityGenerator, EdgeAnnotator, NormalDistribution, PowerLawDistribution, VertexAnnotator }
object Generator {
def main(args: Array[String]) = {
val graph = new TinkerGraph
Range(0, 100).foreach(graph.addVertex(_))
val generator = new CommunityGenerator("edge", EdgeAnnotator.NONE, VertexAnnotator.COPY_CONTEXT)
@xhochy
xhochy / gist:4663822
Created January 29, 2013 12:16
Spotify 0.8.8 exit backtrace
(gdb) bt
#0 0x0000000001cbaa20 in ?? ()
#1 0x00000000011301f7 in ?? ()
#2 0x000000000113054f in ?? ()
#3 0x0000000000cfa2b2 in ?? ()
#4 0x0000000000cfa424 in ?? ()
#5 0x0000000000e14bc9 in ?? ()
#6 0x0000000000d2385f in ?? ()
#7 0x0000000000d1a6bf in ?? ()
#8 0x0000000000d1d61b in ?? ()
@xhochy
xhochy / tomahawk.lua
Created January 29, 2013 15:45
How to control tomahawk via media keys in awesome wm. See http://xhochy.com/2013/01/29/tomahawk-awesome-wm
-- Mediakeys directly control tomahawk
globalkeys = awful.util.table.join(globalkeys,
awful.key({ }, "XF86AudioPrev", function () awful.util.spawn("dbus-send --print-reply --dest=org.mpris.MediaPlayer2.tomahawk /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Previous") end),
awful.key({ }, "XF86AudioPlay", function () awful.util.spawn("dbus-send --print-reply --dest=org.mpris.MediaPlayer2.tomahawk /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.PlayPause") end),
awful.key({ }, "XF86AudioStop", function () awful.util.spawn("dbus-send --print-reply --dest=org.mpris.MediaPlayer2.tomahawk /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Stop") end),
awful.key({ }, "XF86AudioNext", function () awful.util.spawn("dbus-send --print-reply --dest=org.mpris.MediaPlayer2.tomahawk /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Next") end)
)
@xhochy
xhochy / tell.coffee
Last active December 12, 2015 03:38
# Description:
# Tell Hubot to send a user a message when present in the room
#
# Dependencies:
# None
#
# Configuration:
# None
#
# Commands: