Skip to content

Instantly share code, notes, and snippets.

Martin Vidner mvidner

  • SUSE
  • Prague, CZ, EU
Block or report user

Report or block mvidner

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@mvidner
mvidner / rbx-encoding-ljust.out
Created Oct 16, 2012
Ruby 1.9 encoding: String#ljust forces US-ASCII
View rbx-encoding-ljust.out
rbx-2.0.0-dev
Running with rubinius 2.0.0dev (1.9.3 9ad741f3 yyyy-mm-dd JI) [i686-pc-linux-gnu]
* A binary packet
ASCII-8BIT: � ("\xFF") 1 bytes
* Aligning before appending more data, with String#ljust
US-ASCII: � ("\xFF\x00\x00\x00") 4 bytes
* More data
ASCII-8BIT: � ("\xEE") 1 bytes
* Putting them together with String#+
An exception occurred running rbx-encoding-ljust.rb
@mvidner
mvidner / rbx-encoding-pack-zstar.out
Created Oct 16, 2012
Ruby 1.9 encoding: Array#pack('Z*') is not binary
View rbx-encoding-pack-zstar.out
rbx-2.0.0-dev
Running with rubinius 2.0.0dev (1.9.3 9ad741f3 yyyy-mm-dd JI) [i686-pc-linux-gnu]
* A binary packet
ASCII-8BIT: � ("\xFF") 1 bytes
* A unicode string
UTF-8: Václav Havel ("V\xC3\xA1clav Havel") 13 bytes
* Plan B
** Adding NUL
UTF-8: Václav Havel ("V\xC3\xA1clav Havel\x00") 14 bytes
** Forcing 8-bit
@mvidner
mvidner / quick_vm.rb
Created Oct 17, 2012 — forked from rubiojr/quick_vm.rb
Quick OpenStack Server Create with ruby Fog
View quick_vm.rb
#!/usr/bin/env ruby
#
require 'rubygems'
require 'fog'
%w{OS_PASSWORD OS_USERNAME OS_AUTH_URL}.each do |env|
if ENV[env].nil?
$stderr.puts "Missing #{env} environment variable."
exit 1
end
@mvidner
mvidner / var-const.rb
Created Nov 2, 2012
Ruby Variables and Constants
View var-const.rb
#!/usr/bin/env ruby
# Ruby Variables and Constants
module M
variable = 1
CONSTANT = 2
variable = 3
# IMMUTABILITY is not guaranteed
@mvidner
mvidner / dbus-pulseaudio.rb
Created Nov 19, 2012
Pulse Audio socket path with ruby-dbus
View dbus-pulseaudio.rb
#! /usr/bin/env ruby
require 'rubygems'
require 'dbus'
b = DBus.session_bus
ps = b.service 'org.PulseAudio1'
po = ps.object '/org/pulseaudio/server_lookup1'
po.introspect
pi = po['org.PulseAudio.ServerLookup1']
a = pi['Address']
path = a.split('=').last
@mvidner
mvidner / ifcfg-eth0-tn.171
Created Dec 3, 2012
AutoYaST: network interface naming tests
View ifcfg-eth0-tn.171
BOOTPROTO='dhcp'
STARTMODE='auto'
@mvidner
mvidner / cli-dns-hostname.sh
Last active Dec 11, 2015
Testing FATE#312733 - hostname and nameservers via yast cli
View cli-dns-hostname.sh
#! /bin/sh
echo "1..2"
YASTCLI=/sbin/yast2
#####
newhn=atestinghostname
$YASTCLI dns edit hostname=$newhn
View transitive_deps.rb
#! /usr/bin/env ruby
$deps = {
:network => [ :foo, :bar, :baz],
:foo => [:testsuite, :yast2],
:bar => [:yast2, :testsuite],
:baz => [:yast2, :testsuite],
:yast2 => [:testsuite],
:testsuite => []
}
View Intermediate.ycp
{
module "Intermediate";
import "Modelist";
global void Hello() {
Modelist::Hello();
}
}
View dummy-location.ycp
// https://github.com/yast/yast-ruby-bindings/issues/23
// Y2DEBUG=1 /usr/lib/YaST2/bin/y2base -l - ~/snippets/dummy-location.ycp UI |& grep SECRET
{
term dummy_data = `DataMap($[], $[], $[], "DEFAULT");
// YCP:
// [agent-dummy] snippets/dummy-location.ycp:8 LOGTHIS_SECRET_314 Read .target.bash "ls" "DEFAULT"
// RB:
// [agent-dummy] :0 LOGTHIS_SECRET_314 Read .target.bash "ls" "DEFAULT"
SCR::RegisterAgent (.dummy, `ag_dummy(dummy_data));
any a = SCR::Read (.dummy.target.bash, "ls");
You can’t perform that action at this time.