Skip to content

Instantly share code, notes, and snippets.

View Ch00k's full-sized avatar
🪒
shaving yaks

Andrii Yurchuk Ch00k

🪒
shaving yaks
View GitHub Profile
package main
import (
"fmt"
"golang.org/x/net/html"
"net/http"
)
func main() {
resp, err := http.Get("http://example.com")
<?xml version="1.0"?>
<config>
<centos version="7"/>
<host type="stitcher" image="centos-7-x86_64-genericcloud-1606" host="172.19.4.205" doProvisioning="false" enabledComponents="collectd,av-utils"/>
<host type="transcoder" image="centos-7-x86_64-genericcloud-1606" host="172.19.2.243" doProvisioning="false" flavor="dev.medium" enabledComponents="collectd,av-utils"/>
<host type="csm" image="centos-7-x86_64-genericcloud-1606" host="172.19.2.237" doProvisioning="false" flavor="dev.medium" enabledComponents="collectd,av-utils"/>
<host type="udc" image="centos-7-x86_64-genericcloud-1606" host="172.19.2.241" doProvisioning="false" flavor="dev.medium" enabledComponents="collectd,av-utils"/>
<cluster type="scaler-cluster" image="centos-7-x86_64-genericcloud-1606" flavor="dev.small" enabledComponents="av-utils,av-ffmpeg" doProvisioning="true">
<cluster>
@Ch00k
Ch00k / rest_api_design.md
Last active November 28, 2016 06:31
RESTful API

I am designing a RESTful API that will be used by test execution software to keep metadata about the tests it executes. It needs to save some information about the test itself, as well as which hosts it runs the tests on. Besides that, before starting a new test, test execution software needs to check whether any of the hosts it intends to run this test on, are already in use by other tests. I came up with the following. I have 3 resources: Host, Test, TestRun. There is a many-to-one relation for Host-Test, one-to-one relation for Test-TestRun, many-to-many relation for Host-TestRun.

I create a Host to start with:

POST api/v1/host

Request:
{
    "ip_address": "192.168.0.1",
@Ch00k
Ch00k / tox.wtf
Last active August 28, 2016 19:07
tox wtf
[gingerbook][master *]~/projects/personal/gingerbook 0$ tox
GLOB sdist-make: /Users/ay/projects/personal/gingerbook/setup.py
py27 recreate: /Users/ay/projects/personal/gingerbook/.tox/py27
py27 installdeps: pytest, deepdiff
py27 inst: /Users/ay/projects/personal/gingerbook/.tox/dist/gingerbook-0.0.1.zip
py27 installed: deepdiff==2.5.1,gingerbook==0.0.1,py==1.4.31,pytest==3.0.1
py27 runtests: PYTHONHASHSEED='2612682897'
py27 runtests: commands[0] | py.test
Traceback (most recent call last):
File "/Users/ay/projects/personal/gingerbook/.tox/py27/lib/python2.7/site-packages/_pytest/config.py", line 338, in _importconftest
@Ch00k
Ch00k / python_venv.rst
Last active March 12, 2016 07:49
Installing Python and creating a virtualenv (Linux, Mac OS X, Windows)

Linux

CentOS

sudo yum -y update
sudo yum -y install centos-release-SCL  # the package is part of CentOS Extras repository
sudo yum -y install python27
source /opt/rh/python27/enable
import time
import urllib
import numpy as np
from stbt import press, wait_until, match, Region
black_rect = np.empty((8, 8, 3), dtype=np.uint8)
black_rect.fill(16)
@Ch00k
Ch00k / app.html
Created December 17, 2015 10:16
App
<html>
<head>
<style>
html, body {
height: 100%;
padding: 0;
margin: 0;
}
div {
width: 16px;
[2015-12-15 12:10:26.332724 +0000] libdc1394 error: Failed to initialize libdc1394
[2015-12-15 12:10:26.451147 +0000] stbt-run: Arguments:
[2015-12-15 12:10:26.451301 +0000] control: lirc:/run/lirc/lircd:motorola
[2015-12-15 12:10:26.451370 +0000] save_trace: None
[2015-12-15 12:10:26.451443 +0000] verbose: 1
[2015-12-15 12:10:26.451513 +0000] args: []
[2015-12-15 12:10:26.451582 +0000] source_pipeline: pulsevideosrc bus-name=com.stbtester.VideoSource.capture
[2015-12-15 12:10:26.451644 +0000] script: /var/lib/stbt/test-pack/tests/docker_network_test.py::test_ifconfig
[2015-12-15 12:10:26.451690 +0000] restart_source: False
[2015-12-15 12:10:26.451738 +0000] structured_logging: None
Hello Anna,
Thanks for the summary. I would like to correct some of the points though.
1. Our very minimum requirements for an apartment are floor and a washing machine (also obviously a kitchen but as far as I know it's available in all apartments). All the other points (furnished vs. unfurnished, etc.) are not that important.
2. We would prefer the apartment to be as close to the school as possible (ideally within a walking distance). It does not matter much how far away would it be from Hilversum or eBay (we are even considering Utrecht). This requirement makes me think that we first need to find the school and only then search for a home. Does it make sense to do it this way? Please advice.
3. We consider 1500 Euro excluding utilities the maximum affordable price for the apartment. We parsed funda.nl and they have plenty of properties at this price. Of course any kind of advice from your side regarding price for a good home is very welcome.
require 'rest-client'
require 'json'
AUTH_URL = 'http://185.39.229.173:5000/v3'
AUTH_TOKEN = '123qwe'
HEADERS = {:content_type => :json,
:accept => :json,
:'X-Auth-Token' => AUTH_TOKEN}