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
View forums.o.o-topposters.rb
#! /usr/bin/env ruby
# Scrape the user list of forums.opensuse.org to make a list of those
# who have posted at least LIMIT items, for use by the feed filter mentioned in
# http://mvidner.blogspot.com/2010/07/helping-newcomers.html
require "rubygems"
require "nokogiri"
require "open-uri"
LIMIT = 15
PERPAGE = 50
View digits.rb
#! /usr/bin/env ruby
# in ruby 1.8, Enumerator is limited
require 'generator'
# 1234 -> [1, 2, 3, 4]
# but don't use a String
def digits(i, base = 10)
g = Generator.new do |g|
begin
@mvidner
mvidner / set_flag.pl
Created Feb 25, 2011
How to set/unset a flag in a space separated list?
View set_flag.pl
#! /usr/bin/env perl
use strict;
use warnings;
use Test::Simple tests => 2 * 9;
use List::Util qw(first);
# In a space separated list of flags, set one flag on or off (add or delete it).
# Don't modify the list unnecessarily.
sub set_flag {
View rot-gf2.rb
#!/usr/bin/env ruby
$data = IO.read(ARGV[0], 0x2400)
def check_contents_at(offset, contents, description)
size = contents.bytesize
raise "#{description} not found at offset #{offset}" unless $data[offset, size] == contents
end
EXIF_ORIENTATION = "\x12\x01\x03\x00\x01\x00\x00\x00"
View ycp-remove-define-backticks
#! /bin/sh
# Convert ancient YCP syntax:
# define TYPE NAME(ARGS) ``{ BODY }
# becomes
# TYPE NAME(ARGS) { BODY }
#
# usage: $0 foo.ycp
# or
# cd tree_to_find_ycp_in; $0
FINDARGS="-name *.ycp"
@mvidner
mvidner / fake-syslog-enable.diff
Created Jan 30, 2012
reducing swift unit test failures from 348 to 285 via changing the config map
View fake-syslog-enable.diff
diff --git a/.functests b/.functests
index 86abce3..7b5aa2b 100755
--- a/.functests
+++ b/.functests
@@ -1,4 +1,5 @@
#!/bin/bash
+set -e
nosetests test/functional --exe
nosetests test/functionalnosetests --exe
View ssh-pass
#!/usr/bin/expect
# usage: ssh-password mysecret command...
# where command is ssh user@machine
# or ssh-copy-id user@machine
# ...
match_max 100000
set timeout -1
set password [lrange $argv 0 0]
spawn {*}[lrange $argv 1 end]
# Look for passwod prompt
View Makefile
CFLAGS=`pkg-config --cflags dbus-1` -Wall
LDFLAGS=`pkg-config --libs dbus-1`
all: dbus-example
@mvidner
mvidner / qt-bold-menuitem.rb
Created Oct 2, 2012
first steps with Qt 4 + Ruby, wanting a menu item with bold text
View qt-bold-menuitem.rb
#!/usr/bin/env ruby
require 'Qt'
app = Qt::Application.new(ARGV)
# Qt.debug_level = Qt::DebugLevel::High
menu = Qt::Menu.new
click = menu.add_action("Clickme")
click.connect(SIGNAL :triggered) do
@mvidner
mvidner / rbx-encoding-backslash-x.out
Created Oct 16, 2012
Ruby 1.9 encoding: "\xFF" is not binary
View rbx-encoding-backslash-x.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 with 255.chr
ASCII-8BIT: � ("\xFF") 1 bytes
* A binary packet with "\xEE"
US-ASCII: � ("\xEE") 1 bytes
* Putting them together with String#+
An exception occurred running rbx-encoding-backslash-x.rb
undefined conversion for '"\xFF"' from ASCII-8BIT to US-ASCII (Rubinius::EncodingClass::Encoding::CompatibilityError)
You can’t perform that action at this time.