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 / gist:e37e4ce292b50b4e533a414ba315a778
Created Oct 26, 2017
How to make a CustomWidget disappear but not destroying it?
View gist:e37e4ce292b50b4e533a414ba315a778
#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(
View multipribeh.rb
#!/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 Mar 24, 2017
A USB controlled fly
View fly.sh
(sleep 5; echo 1700; sleep 2; echo 1500; sleep 1.1; echo 0) | socat - /dev/ttyUSB0,b115200,rawer
View ReplacePointWithStringId.rb
# 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")
View mindstorms-ev3-linux.py
#!/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.
View Test-YTree-selection.cpp
/*
* 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:
View bidi-failure-modes.md

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)

View chardump.rb
#!/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
View update-yast-pot.rb
#!/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",
View trace_func_profiler.rb
# 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
}
You can’t perform that action at this time.