Skip to content

Instantly share code, notes, and snippets.

View martinpovolny's full-sized avatar

Martin Povolny martinpovolny

View GitHub Profile

Keybase proof

I hereby claim:

  • I am martinpovolny on github.
  • I am martin_povolny (https://keybase.io/martin_povolny) on keybase.
  • I have a public key ASACaQZj6pCJm7cV2RE1sRx8DzPIK5OzwOgSCzUl27IOiAo

To claim this, I am signing this object:

@martinpovolny
martinpovolny / physical_racks.sql
Created May 21, 2018 07:46
ManageIQ physical infra rack example
-- Dumped from database version 9.5.8
-- Dumped by pg_dump version 9.5.12
SET statement_timeout = 0;
SET lock_timeout = 0;
SET client_encoding = 'UTF8';
SET standard_conforming_strings = on;
SELECT pg_catalog.set_config('search_path', '', false);
SET check_function_bodies = false;
SET client_min_messages = warning;
# using this GIST
# wget https://gist.githubusercontent.com/martinpovolny/4d960e550a7838a9b04cb4d8396514b0/raw/dd5825a169953275f16a604bc62e8e482c36b4df/create_a_go_linked_to_a_service.rb
# bundle exec rails runner create_a_go_linked_to_a_service.rb
number = sprintf('%06d', rand(1_000_000))
# 1. Create the Generic Object Definition
go_def = GenericObjectDefinition.create(
:name => "GO example #{number}",
:description => "Go example with linked service",
@martinpovolny
martinpovolny / convert_toolbar_3.rb
Created February 16, 2016 13:34
To convert toolbar to a class, run the 2 commands in the comment on the top of the file below. Don't read the source, it's ugly. I will have to take your eyes out if you read it!
# bundle exec rails r convert_toolbar_3.rb toobar_name.yml
# rubocop -a -c .rubocop.yml app/helpers/application_helper/toolbar/toolbar_new_class.rb
require 'active_support'
require 'active_support/inflector'
require 'active_support/inflector/methods'
#in_file = 'product/toolbars/vm_clouds_center_tb.yaml'
#
def value_of(key, value)
@martinpovolny
martinpovolny / github-fetch-pullrequest.py
Created October 13, 2015 08:06
github-fetch-pullrequest.py
#!/usr/bin/env python
"""Fetch pull requests from GitHub
Usage:
* PROG -- With no arguments it just lists actual pull requests
* PROG <n> -- Fetches the pull request #n, creates separate branch
for it, rebases it on top of requested branch (ususally master)
and deletes remote.
"""
@martinpovolny
martinpovolny / gist:9254114
Created February 27, 2014 16:51
why don't we have .to_sym_if_exists in ruby? same as erlang has? http://www.erlang.org/doc/man/erlang.html#binary_to_existing_atom-2
iex(3)> :erlang.binary_to_existing_atom("foobar", :utf8)
** (ArgumentError) argument error
:erlang.binary_to_existing_atom("foobar", :utf8)
iex(3)> :foobar
:foobar
iex(4)> :erlang.binary_to_existing_atom("foobar", :utf8)
:foobar
Notice: /Stage[main]/Conductor::Setup::Dev/Exec[bundle install]/returns: Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.
Notice: /Stage[main]/Conductor::Setup::Dev/Exec[bundle install]/returns:
Notice: /Stage[main]/Conductor::Setup::Dev/Exec[bundle install]/returns: /home/test/.rbenv/versions/1.9.3-p374/bin/ruby extconf.rb
Notice: /Stage[main]/Conductor::Setup::Dev/Exec[bundle install]/returns: checking for libxml/parser.h... yes
Notice: /Stage[main]/Conductor::Setup::Dev/Exec[bundle install]/returns: checking for libxslt/xslt.h... no
Notice: /Stage[main]/Conductor::Setup::Dev/Exec[bundle install]/returns: -----
Notice: /Stage[main]/Conductor::Setup::Dev/Exec[bundle install]/returns: libxslt is missing. please visit http://nokogiri.org/tutorials/installing_nokogiri.html for help with installing dependencies.
Notice: /Stage[main]/Conductor::Setup::Dev/Exec[bundle install]/returns: -----
Notice: /Stage[main]/Conductor::Setup::Dev/Exec[bundle install]/returns: *** ext
# Install imagefactory 2 from repository
export WORKDIR=${WORKDIR:=~/aeolus-workdir}
# ensure we run as root
if [ ! $UID -eq 0 ]; then
echo "echo running sudo"
sudo $0
exit $?
fi
def penalty_for_cost(price,mode)
base = 100
reward = case mode
when 1
price*base
when 2
Math.log(price*base)*10
when 3
(price*base/10)**2
else
#!/bin/sh
# Use this script to install everything *system-wide* (as opposed to using
# bundler) to enable development. For example, ruby, rails, deltacloud,
# imagefactory, postgres, etc.
#
# Note: this works well for Fedora 16 and 17. For RHEL 6, some of the
# the dependencies may need to be manually downloaded and installed
# (e.g., rubygem-paranoia)