Skip to content

Instantly share code, notes, and snippets.

View mvidner's full-sized avatar

Martin Vidner mvidner

  • SUSE
  • Prague, CZ, EU
View GitHub Profile
# A crude YaST UI recoder and player
#
# Usage:
# Y2UI_RECORD=/tmp/y2host.yaml LANG=en_US.UTF-8 \
# ruby -r ./ui_recorder.rb /usr/lib/YaST2/bin/y2start host qt
# less /tmp/y2host.yaml
# Y2UI_PLAY=/tmp/y2host.yaml LANG=en_US.UTF-8 \
# ruby -r ./ui_recorder.rb /usr/lib/YaST2/bin/y2start host qt
require "set"
#!/usr/bin/ruby
CACHE = "find_minimal_failure.cache".freeze
def usage
puts <<TXT
Usage: find_minimal_failure COMMAND [OPTIONS --] ARGUMENTS...
Finds the minimal ordered subsequence of ARGUMENTS that still
makes the command fail.
This is useful in place of "rspec --bisect"
when your extension library crashes without producing an exception.

This is a clarifying update to the AutoYaST documentation, applicable to all versions.

Resources and Properties

A resource element either contains multiple and distinct property and resource elements, or multiple instances of the same resource element, or it is empty. The permissible content of a resource element is

GEM
remote: http://rubygems.org/
specs:
activemodel (4.2.10)
activesupport (= 4.2.10)
builder (~> 3.1)
activesupport (4.2.10)
i18n (~> 0.7)
minitest (~> 5.1)
thread_safe (~> 0.3, >= 0.3.4)
@mvidner
mvidner / cheetah-y2log.rb
Last active November 30, 2017 08:23
Cheetah using the YaST log
#!/usr/bin/ruby
require "cheetah"
require "yast"
Cheetah.run("ls", "-la", "/var/lib/empty", logger: Yast::Y2Logger.instance)
# another way: "log" becomes a shortcut for Yast::Y2Logger.instance
include Yast::Logger
begin
@mvidner
mvidner / gist:e37e4ce292b50b4e533a414ba315a778
Created October 26, 2017 08:41
How to make a CustomWidget disappear but not destroying it?
#We have such a Tab, wich has a TargetsTableWidget(A customWidget has a table and buttons),
#TargetsTableWidget would be listed after class TargetsTab
class TargetsTab < ::CWM::Tab
def initialize
@target_table_widget = TargetsTableWidget.new
self.initial = false
end
def contents
VBox(
#!/usr/bin/ruby
# coding: utf-8
def vyber(* možnosti)
možnosti.shuffle.first
end
hrdina = vyber("hobit", "trpaslík", "skřet", "člověk", "elf",
"zlobr", "dobr", "půlčík", "čtvrtčík")
čaroděj = vyber("čaroděj", "létající delfín", "druid", "guru")
@mvidner
mvidner / fly.sh
Created March 24, 2017 14:23
A USB controlled fly
(sleep 5; echo 1700; sleep 2; echo 1500; sleep 1.1; echo 0) | socat - /dev/ttyUSB0,b115200,rawer
# encoding: utf-8
module Yast
class ReplacePoint1Client < Client
def main
Yast.import "UI"
UI.OpenDialog(
VBox(
ReplacePoint(Id("rp"), Label("This is a label with a string Id")),
PushButton(Id(:change), "Change")
#!/usr/bin/env python2
# Send a BEEP command via USB to a Lego Mindstorms EV3 brick
import sys
import usb.core # https://walac.github.io/pyusb/
def ev3_write(command):
# To send commands, we need an Endpoint.