Skip to content

Instantly share code, notes, and snippets.

import argparse
import sys
import koji
import yaml
parser = argparse.ArgumentParser()
parser.add_argument("TAG")
parser.add_argument("--koji-profile", default="brew")
parser.add_argument("--arch", action="append")
import click
import requests
def parse_rates(data):
header, names, *lines = data.splitlines()
rates = {}
for line in lines:
_, _, amount, currency, value = line.replace(",", ".").split("|")
rates[currency] = float(value) / float(amount)
@lubomir
lubomir / contextmanager.patch
Created February 12, 2016 08:03
Context manager instead of wrapper
diff --git a/pdc/apps/common/hacks.py b/pdc/apps/common/hacks.py
index ca55552..c9ce891 100644
--- a/pdc/apps/common/hacks.py
+++ b/pdc/apps/common/hacks.py
@@ -5,6 +5,7 @@
# http://opensource.org/licenses/MIT
#
import re
+import contextlib
@lubomir
lubomir / kerberos.html
Created January 5, 2016 14:43
XMLHttpRequest with Kerberos credentials
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Token example</title>
</head>
<body>
<div id="token">Loading token...</div>
<script>
document.addEventListener("DOMContentLoaded", function () {
#! /usr/bin/env python
# -*- coding: utf-8 -*-
import pdc_client
# This will automatically obtain token from server identified by "prod" in
# configuration file.
client = pdc_client.PDCClient('prod')
@lubomir
lubomir / main.hs
Last active August 29, 2015 14:04
import qualified Database.Persist as P
main :: IO ()
main = do
conf <- Yesod.Default.Config.loadConfig $ (configSettings Testing)
{ csParseExtra = parseExtra
}
dbconf <- withYamlEnvironment "config/postgresql.yml" (appEnv conf)
P.loadConfig >>=
P.applyEnv
@lubomir
lubomir / Iris.hs
Created January 10, 2014 13:41
Part 3 of final assignment for Complex Valued Neural Networks with Multi Valued Neurons course
module Iris where
import Data.Vector (Vector)
import Control.Arrow
import qualified Data.Vector as V
import Data.Complex
learning :: Vector (Vector (Complex Double), Int)
learning = V.fromList $ map (first $ V.fromList . map cis)
[ ([0.31, 0.873, 0.095, 0.058], 0)
data Alert = MSuccess | MWarning | MInfo
deriving (Eq, Enum, Bounded, Show)
mkToCls :: Alert -> Text
mkToCls MSuccess = "alert-success"
mkToCls MWarning = "alert-warning"
mkToCls MInfo = "alert-info"
class (Enum a, Bounded a, Show a) => MessageKey a
#define _POSIX_SOURCE
#include <stdio.h>
#include <sys/types.h>
#include <signal.h>
#include <stdlib.h>
#include <string.h>
#define CMDLINE "NEJAKY_PRIKAZ"
module Graph_t where
import Graph
import Test.HUnit
import Control.Exception
import Control.Monad
--t_ = TestCase $ assertEqual "" (show ( )) ""