Skip to content

Instantly share code, notes, and snippets.

View krig's full-sized avatar
🏠
Working from home

Kristoffer Grönlund krig

🏠
Working from home
View GitHub Profile
@krig
krig / Dummy.py
Created October 4, 2018 16:01
Python version of Dummy resource agent
import errno
import os
import sys
import tempfile
OCF_FUNCTIONS_DIR = "%s/lib/heartbeat" % os.environ.get("OCF_ROOT")
sys.path.append(OCF_FUNCTIONS_DIR)
from ocf import *
@krig
krig / deannex.py
Last active June 21, 2018 20:48
Get files out of git-annex without any dependencies except Python 3
#!/usr/bin/python3
#
# A small utility for pulling files out of git-annex without
# actually having git-annex installed, with minimal
# dependencies.
import sys
import os
import argparse
import shutil
import hashlib
@krig
krig / gist:e4ed6fc6b861658a8826b1838ca9ac5e
Created October 25, 2017 08:27
crmsh regression test suite output py3
Wed Oct 25 08:21:29 UTC 2017: BEGIN testcase confbasic
----------
testcase confbasic failed
output is in crmtestout/confbasic.out
diff (from crmtestout/confbasic.diff):
--- /usr/share/crmsh/tests/testcases/confbasic.exp 2017-10-25 08:21:25.000000000 +0000
+++ - 2017-10-25 08:21:31.832475548 +0000
@@ -22,2 +22,3 @@
.INP: master m d4
+ERROR: 21: Cannot create ms with ID 'm': Found existing ms with same ID.
Environment
Bundler 1.10.6
Rubygems 2.2.2
Ruby 2.1.3p242 (2014-09-19 revision 47630) [x86_64-linux-gnu]
Git 2.1.2
Bundler settings
gemfile
[ 38s] /usr/lib64/ruby/gems/2.1.0/gems/bundler-1.10.6/lib/bundler/rubygems_integration.rb:292:in `block in replace_gem': json is not part of the bundle. Add it to Gemfile. (Gem::LoadError)
[ 38s] from /home/abuild/rpmbuild/BUILD/hawk2-1.0.1+git.1448874643.e07e008/hawk/vendor/bundle/ruby/2.1.0/gems/po_to_json-1.0.1/lib/po_to_json.rb:26:in `<top (required)>'
[ 38s] from /home/abuild/rpmbuild/BUILD/hawk2-1.0.1+git.1448874643.e07e008/hawk/vendor/bundle/ruby/2.1.0/gems/activesupport-4.2.5/lib/active_support/dependencies.rb:274:in `require'
[ 38s] from /home/abuild/rpmbuild/BUILD/hawk2-1.0.1+git.1448874643.e07e008/hawk/vendor/bundle/ruby/2.1.0/gems/activesupport-4.2.5/lib/active_support/dependencies.rb:274:in `block in require'
[ 38s] from /home/abuild/rpmbuild/BUILD/hawk2-1.0.1+git.1448874643.e07e008/hawk/vendor/bundle/ruby/2.1.0/gems/activesupport-4.2.5/lib/active_support/dependencies.rb:240:in `load_dependency'
[ 38s] from /home/abuild/rpmbuild/BUILD/hawk2-1.0.1+git.1448874643.e07e008/hawk/vendo
# Här är ett konkret exempel:
#
# 1. Inga namespaces:
def node_type_optional_no_namespaces(self):
path = '//element[@name="nodes"]//element[@name="node"]/optional/attribute[@name="type"]'
return len(schema.rng_xpath(path)) > 0
# 2. Namespaces:
@krig
krig / gist:5088ea9b9430ae1f7076
Created June 25, 2014 20:15
flatui palette as python
flatui_palette = {
'Untitled': '#1abc9c',
'Untitled': '#2ecc71',
'Untitled': '#3498db',
'Untitled': '#9b59b6',
'Untitled': '#34495e',
'Untitled': '#16a085',
'Untitled': '#27ae60',
'Untitled': '#2980b9',
'Untitled': '#8e44ad',
options_wait = True
def test_should_wait():
def f1(options_wait, rv, command_wait, level_should_wait, in_transit, interactive):
return options_wait and rv and (command_wait or (level_should_wait and (in_transit or not interactive)))
def f2(options_wait, rv, command_wait, level_should_wait, in_transit, interactive):
if not options_wait:
return False

Keybase proof

I hereby claim:

  • I am krig on github.
  • I am krig (https://keybase.io/krig) on keybase.
  • I have a public key whose fingerprint is 413B B235 E6E1 50B7 0B24 FCD5 ACD2 45E4 7872 96B8

To claim this, I am signing this object:

@krig
krig / parseiso8601utc2.c
Created July 8, 2013 22:02
(hopefully) fixed iso8601 parser. Should work in GNU/Linux systems now, at least.
/* parses only YYYY-MM-DDTHH:MM:SSZ */
time_t
parseiso8601utc_fixed(const char *date)
{
struct tm tt = {0};
double seconds;
if (sscanf(date, "%04d-%02d-%02dT%02d:%02d:%lfZ",
&tt.tm_year, &tt.tm_mon, &tt.tm_mday,
&tt.tm_hour, &tt.tm_min, &seconds) != 6)
return -1;