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
@mvidner
mvidner / makebigfile.rb
Created February 3, 2016 15:07
generate a file that will not parse with parser-2.3.0.2
#!/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
@mvidner
mvidner / gist:94b7bbf77ee5a09b0ca5
Created March 1, 2016 15:59
bootloader proposal specification by jreidinger
#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
@mvidner
mvidner / RUNME.sh
Last active June 20, 2016 14:11
ruby-lint loading definitions of overlapping namespaces
#!/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 / command-quiz-all-in-one.rb
Last active May 31, 2017 07:42
What do these files do when you run them with Ruby?
#!/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"
# a dead stupid profiler/debugger
# usage: ruby -r .../trace_func_profiler.rb my_program.rb
set_trace_func proc { |event, file, line, id, binding, classname|
unless ["line"].include? event
m = "#{classname}.#{id}"
t = Time.now.strftime("%H:%M:%S.%4N")
printf "%s|%8s %s:%-2d %s\n", t, event, file, line, m
end
}
#!/usr/bin/ruby
require "fileutils"
require "pathname"
include FileUtils
FILTER_OUT_RES = [
"warning: PO file header fuzzy",
"warning: older versions of msgfmt will give an error on this",
#!/usr/bin/ruby
# coding: utf-8
def char_as_4hex(c)
format("%04x", c.ord)
end
REPLACEMENT = "\ufffd" # �
FSI = "\u2068" # First Strong Isolate
PDI = "\u2069" # Pop Directional Isolate

Vega is the second brightest star in the northern celestial hemisphere. Its name comes from the Arabic name "wāqi‘" (an-nasr al-wāqi‘), meaning "falling" (falling eagle). In the Arabic script, it is واقع (النسر الواقع).

Note how the parenthesized phrase ends up in the middle of the sentence, even though it should go at the end like this:

In the Arabic script, it is WAQE (ALNASR ALWAQE).

(Must include screenshots, because all renderers have their own incompatible sets of bugs)

/*
* Copyright (c) 2014 Angelo Naselli <anaselli@linux.it>
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions: