Skip to content

Instantly share code, notes, and snippets.

View slemrmartin's full-sized avatar

Martin Slemr slemrmartin

  • Red Hat Czech
  • Czech Republic
View GitHub Profile
@slemrmartin
slemrmartin / pointers.c
Last active January 4, 2020 22:24
C pointery basic
void main(void) {
int pole[5]; // tady mas staticky definovany pole pro 5 cisel, "pole" je typu "int *"
int pole2[5]; // "pole2" je typu "int *" (pointer(==adresa) na int)
// vztah pole a pointeru
// takhle se na nejaky volny adrese vyhradi pamet pro 5 cisel
// malloc == "memory allocation" fce
int *pole3; // definice pointeru - pointer je hodnota adresy v pameti, v tuhle chvili nejaka nedefinovana (pole3 je typu "int *")
pole3 = malloc(5* sizeof(int)); // ted je to uplne to samy jako "int pole3[5]"
@slemrmartin
slemrmartin / proxy.rb
Created November 13, 2019 10:26
proxy
class Server
SOCKET_PATH = "/tmp/receptor.sock".freeze
DELIM = "\x1b[K".freeze
def initialize
@proxy = SurroGate.new
@transmitter = Thread.new do
loop do
@proxy.select(1000)
@slemrmartin
slemrmartin / sources-api.sh
Created June 19, 2019 07:55
Sources API create/delete
# Red Hat Header
plain_rh_identity="{\"identity\":{\"account_number\":\"test-mock\"}, \"internal\": {\"org_id\": \"54321\"}}"
export X_RH_IDENTITY=$(echo ${plain_rh_identity} | base64 --wrap=0)
# Sources API service
# Create routes in openshift to get these hosts
export SOURCES_API_SERVICE_HOST="http://localhost"
export SOURCES_API_SERVICE_PORT=3002
export SOURCES_API_BASE_PATH="api/sources/v1.0"
@slemrmartin
slemrmartin / config
Created April 23, 2019 15:08
TP-Inv API bash config
#!/usr/bin/env bash
export X_RH_IDENTITY="{\"identity\":{\"account_number\":\"test\"}}"
base64_rh_identity=$(echo ${X_RH_IDENTITY} | base64)
# Topological API service
export TOPOLOGICAL_INVENTORY_API_SERVICE_HOST="http://topological-inventory-api-test-mslemr.10.8.96.54.nip.io"
export TOPOLOGICAL_INVENTORY_API_SERVICE_PORT=80
export BASE_PATH="api/topological-inventory/v0.1"
@slemrmartin
slemrmartin / tp-api-common.sh
Last active April 23, 2019 15:33
topological API requests
#!/usr/bin/env bash
source "config"
# Usage: api_get <path>
# Example: api_get "source_types?filter[name]=mock"
function api_get {
if [[ -z $2 ]]; then
api_path=${BASE_PATH}
else
@slemrmartin
slemrmartin / custom multiplier
Created April 15, 2019 15:18
Custom multiplier
#!/usr/bin/env ruby
#
class Integer
alias_method :old_multiply, :*
def *(num)
m = method(:old_multiply).unbind
m.bind(3).(num / self)
end
end
@slemrmartin
slemrmartin / update_tp-inv.sh
Created February 8, 2019 08:33
bundle install/update tp-inv repos, needs reset_db.sh
#!/bin/bash --login
# Usage: update_tp-inv.sh [update]
source "$HOME/.rvm/scripts/rvm"
# Script for creating/updating topology inventory plugins
cd /home/mslemr/Projects/topological-inventory
@slemrmartin
slemrmartin / clone_tp-inv.sh
Created February 8, 2019 08:31
Cloning Topological inventory repos
#!/bin/bash
# Script for creating/updating topology inventory plugins
# @param --clone for cloning and set upstream
#
# TODO: Change to your existing directory
#
cd /home/mslemr/Projects/topological-inventory
@slemrmartin
slemrmartin / repositories.sh
Created February 8, 2019 08:30
Array of TP-inv repos (included in other scripts)
repositories=("topological_inventory-api"
"topological_inventory-core"
"topological_inventory-ingress_api"
"topological_inventory-ingress_api-client-ruby"
"topological_inventory-collector-amazon"
"topological_inventory-collector-mock"
"topological_inventory-collector-openshift"
"inventory_refresh")
@slemrmartin
slemrmartin / start-tp-inv-local.sh
Created January 29, 2019 14:03
Start topological inventory locally
#!/bin/bash --login
source "$HOME/.rvm/scripts/rvm"
INGRESS_API_SVC_DIR=/home/mslemr/Projects/topological-inventory/topological_inventory-ingress_api
PERSISTER_SVC_DIR=/home/mslemr/Projects/topological-inventory/topological_inventory-persister
rvm use 2.4
rvm gemset use tp-inv