Skip to content

Instantly share code, notes, and snippets.

View andreaja's full-sized avatar

Andreas Jacobsen andreaja

  • Oslo, Norway
View GitHub Profile
@andreaja
andreaja / c2c.py
Created June 15, 2018 19:23
Convert a fixtur.es FIFA 2018 calendar from long names to emoji names
#!/usr/bin/python
# -*- coding: utf-8 -*-
import pycountry
import sys
import re
from emojiflags.lookup import lookup
r = re.compile(r'^SUMMARY:\[(\S)\] (.+?) - (.+?)$')
@andreaja
andreaja / gist:894d4c94cbabbd22dbe4
Created November 27, 2014 13:07
automatically run bundle install
# From: http://madebynathan.com/2012/12/17/automatically-run-bundle-install-if-bundler-raises-gemnotfound/
function bundle_install_wrapper() {
# Run command
eval "$@"
if [ $? = 7 ]; then
# If command crashes, try a bundle install
echo -e "\033[1;31m'$*' failed with exit code 7."
echo "This probably means that your system is missing gems defined in your Gemfile."
echo -e "Executing 'bundle install'...\033[0m"
bundle install
Soccer Livescore: (ROU-2S1R) #Rapid Suceava vs #Dunarea Galati: 0-2 (2nd Half Started)
Soccer Livescore: (ROU-2S1R) #CF Braila vs #CS Unirea Tarlungeni: 0-1 (2nd Half Started)
Soccer Livescore: (VNM-VL1) #Thanh Hoa vs #Than Quang Ninh: 0-0 (Kick Off)
Soccer Livescore: (ROU-2S2P) #CS Univers. Craiova vs #Alro Slatina: 0-0 (Kick Off)
Soccer Livescore: (IDN-ISL) #Persita Tangerang vs #Barito Putera: 0-1 (Goal for Barito Putera)
Soccer Livescore: (MAS-PR) #Kuala Lumpur SPA FC vs #Perlis: 0-0 (Kick Off)
Soccer Livescore: (CRC-CL) #LD Alajuelense vs #Belen Siglo: 1-0 (Game Finished)
Soccer Livescore: (ECU-D1) #Emelec vs #LDU Loja: 3-1 (Game Finished)
Soccer Livescore: (CONMEBOL-R16) #The Strongest (BOL) vs #Defensor Sp. (URU): 2-0 (Game Finished)
Soccer Livescore: (SLV-CL) #Santa Tecla vs #Dragon: 2-0 (Game Finished)
return new RouteBuilder() {
@Override
public void configure() throws Exception {
String testingEndpoint = "activemq:test." + getClass().getName();
String customErrorEndpoint = "direct:error";
errorHandler(deadLetterChannel(customErrorEndpoint));
from(testingEndpoint)
.process(new Processor() {
@andreaja
andreaja / gist:1476408
Created December 14, 2011 12:35
grep weirdness
andreaja:~$ wc -l test.txt
10000000 test.txt
andreaja:~$ grep -c ^a$ test.txt
10000000
andreaja:~$ time grep -iv a test.txt
real 0m3.286s
user 0m3.232s
sys 0m0.016s
(defvar find-file-root-prefix (if (featurep 'xemacs) "/[sudo/root@localhost]" "/sudo:root@localhost:" )
"*The filename prefix used to open a file with `find-file-root'.")
(defvar find-file-root-history nil
"History list for files found using `find-file-root'.")
(defvar find-file-root-hook nil
"Normal hook for functions to run after finding a \"root\" file.")
(defun find-file-root ()
[color]
branch = auto
diff = auto
status = auto
[color "branch"]
current = yellow reverse
local = yellow
remote = green
[color "diff"]
diff --git a/munin/mod/prop.py b/munin/mod/prop.py
index ac18e19..decace1 100644
--- a/munin/mod/prop.py
+++ b/munin/mod/prop.py
@@ -283,7 +283,12 @@ class prop(loadable.loadable):
irc_msg.reply("Only %s may expire proposition %d."%(prop['proposer'],prop['id']))
return
if prop['prop_type'] == 'invite' and self.too_many_members(irc_msg):
+ return
+ if (datetime.datetime.now()-prop['created']).hours < self.MIN_TIME_TO_EXPIRE:
session = Session()
Q = session.query(Planet.id, func.count().label('planets')).filter(Planet.x < 200).group_by(Planet.x, Planet.y).order_by(desc(func.count()))
subQ = Q.subquery()
Q = session.query(subQ.c.planets, func.count().label('count')).group_by(subQ.c.planets).order_by(asc(subQ.c.planets))
diff --git a/munin/loadable.py b/munin/loadable.py
index 374663b..52b4f40 100755
--- a/munin/loadable.py
+++ b/munin/loadable.py
@@ -360,9 +360,15 @@ class planet(object):
return 1
def calc_xp(self,victim):
- bravery = max(0,(min(2,float(victim.value)/self.value)-0.1 ) * (min(2,float(victim.score)/self.score)-0.2))
- bravery *= 10