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 / command-quiz-all-in-one.rb
Last active May 31, 2017
What do these files do when you run them with Ruby?
View command-quiz-all-in-one.rb
#!/usr/bin/ruby
# Ruby Gotcha Quiz, by Martin Vidner
# Aimed at people who have written something in Ruby already
def command(s)
system(s)
end
command "echo A"
@mvidner
mvidner / RUNME.sh
Last active Jun 20, 2016
ruby-lint loading definitions of overlapping namespaces
View RUNME.sh
#!/bin/sh
ruby app.rb
ruby-lint -c cfg-top.yml app.rb
ruby-lint -c cfg-nested.yml app.rb
exit
# the definitions were made like this
rake -r project-base generate:definitions[Project,.]; mv project.rb defs-project.rb
rake -r project-ui generate:definitions[Project,.]; mv project.rb defs-ui-top.rb
rake -r project-ui generate:definitions[Project::UI,.]; mv project.rb defs-ui-nested.rb
@mvidner
mvidner / gist:94b7bbf77ee5a09b0ca5
Created Mar 1, 2016
bootloader proposal specification by jreidinger
View gist:94b7bbf77ee5a09b0ca5
#propose
proposes timeout to 8 seconds
proposes gfx mode to auto
proposes to disable recovery boot entry
proposes empty distributor entry
proposes serial console from its usage on kernel command line
os_prober proposal
on s390
disable os probing
on Power PC
View signal-handling-and-ruby.md
@mvidner
mvidner / makebigfile.rb
Created Feb 3, 2016
generate a file that will not parse with parser-2.3.0.2
View makebigfile.rb
#!/usr/bin/ruby
# parser-2.3.0.2 fails with fatal: unterminated string meets end of file
# ruby makebigfile.rb && ruby bigfile.rb && bundle exec ruby-parse --23 bigfile.rb
SIZE = 14500
header = <<EOS
#!/usr/bin/ruby
# encoding: utf-8
View 0001-Factored-out-pipe-juggling-more-readably.patch
From 1cb40243b120b86057688d64d88a23384d234a91 Mon Sep 17 00:00:00 2001
From: Martin Vidner <mvidner@suse.cz>
Date: Thu, 17 Dec 2015 14:20:27 +0100
Subject: [PATCH] Factored out pipe juggling more readably.
---
lib/cheetah.rb | 45 ++++++++++++++++++++++++++-------------------
1 file changed, 26 insertions(+), 19 deletions(-)
diff --git a/lib/cheetah.rb b/lib/cheetah.rb
View ruby-dbus-bluez.rb
#!/usr/bin/ruby
# https://lists.luon.net/pipermail/ruby-dbus-devel/2015-November/000500.html
require 'dbus'
def dbus_get_service_prefix path
bus = DBus::SystemBus.instance
service = bus.service path.join('.')
service.introspect # othewise cannot walk dbus namespace
root = service.root
prefix = root
View insane-tty.c
/* scroll down to see an explanation in insane-tty.md */
/* gcc -Wall -o insane-tty insane-tty.c */
#include <stdlib.h>
#include <sys/ioctl.h>
#include <termios.h>
#include <unistd.h>
#include <string.h>
#include <stdio.h>
@mvidner
mvidner / call_whitespace.rb
Created Jun 9, 2015
ruby whitespace is significant
View call_whitespace.rb
def upcase_all(strings)
strings.map(&:upcase)
end
puts upcase_all (["You", "can", "use", "YOU"]).uniq
puts upcase_all(["You", "can", "use", "YOU"]).uniq
View registration-without-comments.pot
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2015-06-02 14:53+0200\n"
"PO-Revision-Date: 2015-06-02 14:53+0200\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"Language: \n"
"MIME-Version: 1.0\n"
You can’t perform that action at this time.