Skip to content

Instantly share code, notes, and snippets.

#!/bin/bash
if [ "$(pidof firefox)" ]
then
echo Please close all instance of firefox to unlock the database >&2
exit 1
else
echo Database optimization begin ...
echo -------------------------------
time for i in `find ~/.mozilla -name \*.sqlite`
@Mic92
Mic92 / gist:703870
Created November 17, 2010 19:11
Service control completion for zsh
# This code generate the function start, stop, restart
# which you can use to control your deamons like alsa, hal ...
# To use it, put it in your .zshrc.
# Example
@Mic92
Mic92 / CMakeLists.txt
Created November 15, 2011 23:07
LuaBind Gist
cmake_minimum_required(VERSION 2.8)
project(LuaPulse)
include(FindPkgConfig)
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
find_package(Luabind REQUIRED)
find_package(Lua51 REQUIRED)
find_package(Boost COMPONENTS system REQUIRED)
@Mic92
Mic92 / list.c
Created November 24, 2011 12:44
List implementation in C
#include <stdlib.h>
#include <stdio.h>
typedef struct _IntList {
int current;
struct _IntList *next;
} IntList;
void Insert(IntList *l, int n) {
if (l == NULL) return;
@Mic92
Mic92 / 03.1-gerichteter_multigraph.tex
Created December 7, 2011 19:59
Mitschrift Algebra
\subsubsection{Beispielklasse: Binäre Relation als Netzwerke}
\paragraph{Def:} Eine binäre Relation ist erklärt als Paar $M:=(M,R)$
mit M und R sind Mengen und es ist $R\subseteqq MxM$, d.h R ist
``binäre Relation auf M''.
Sei $GM := (M,R,\sigma,\tau)$ mit $\sigma : E \rightarrow V, (p,q)
\mapsto p$ und $\tau : E \rightarrow V, (p,q) \mapsto q$
GM heiße den zu M gehörige Netzwerke bzw. ``M=(M,R) als Netzwerke''
@Mic92
Mic92 / node-finder.rb
Created December 14, 2011 08:17
Berechnet alle Möglichkeiten für 7 a)
#!/usr/bin/ruby
class Node
attr_accessor :right, :middle, :left
attr_accessor :first_val, :second_val
def assign(first_val, second_val)
@first_val = first_val
@second_val= second_val
end
def neighbors(right, middle, left)
@Mic92
Mic92 / Ergebnis.txt
Created January 31, 2012 13:54
Aufgabe 10 für 3.Feb 2012
Aufgabe a)
1) Münze 200 wird 12mal gedreht!
da Primzahlzerlegung 200=2^3*5^2
da |{2^0, 2^1, 2^2, 2^3}| * |{5^0, 5^1, 5^2}|
= 4 * 3 = 12
2) Folgende Münzen werden auch 12mal gedreht:
60: [2, 2, 3, 5]
72: [2, 2, 2, 3, 3]
84: [2, 2, 3, 7]
90: [2, 3, 3, 5]
@Mic92
Mic92 / scrape-surfmusic.rb
Created February 5, 2012 16:03
scrape surfmusic
#!/usr/bin/env ruby
require 'rubygems'
require 'nokogiri'
require 'open-uri'
def scrape(country)
doc = Nokogiri::HTML(open("http://www.surfmusik.de/land/#{country}.html"))
radio_links = doc.css("td.home1 a.navil")
@Mic92
Mic92 / showcase.py
Created February 14, 2012 22:09
Weird named Exception
#!/usr/bin/env python
err = "Foobar"
try:
print("Still the same %s" % err)
1/0
except ZeroDivisionError as err:
print("Got error: %s" % err)
try:
print("In python 2 err is overwritten %s " % err)
except NameError:
@Mic92
Mic92 / cache_client_icons.patch
Created February 26, 2012 15:22
Cache Client icons for efficiency
diff -r 8590b10b692f clients_icons/clients_icons.py
--- a/clients_icons/clients_icons.py Wed Jan 11 23:04:49 2012 +0400
+++ b/clients_icons/clients_icons.py Sun Feb 26 16:20:28 2012 +0100
@@ -162,16 +162,17 @@ class ClientsIconsPlugin(GajimPlugin):
'show_unknown_icon': (True, ''),
'pos_in_list': (0, ''),
'show_facebook': (True, '') }
self.config_dialog = ClientsIconsPluginConfigDialog(self)
icon_path = os.path.join(self.local_file_path('icons'), 'unknown.png')