Skip to content

Instantly share code, notes, and snippets.

View bakkdoor's full-sized avatar

Christopher Bertels bakkdoor

View GitHub Profile

Keybase proof

I hereby claim:

  • I am bakkdoor on github.
  • I am bakkdoor (https://keybase.io/bakkdoor) on keybase.
  • I have a public key whose fingerprint is E6B0 B248 A05B E8DC A0F1 E13C FF17 6E5B 2345 B203

To claim this, I am signing this object:

@bakkdoor
bakkdoor / clap
Last active August 29, 2015 14:07
#!/usr/bin/env ruby
def 👏
print "👏 "
end
[ARGV[0].to_i, 1].max.times { 👏 }
puts
def create_listener(superclass, methodname, &block)
focus_listener_class = Class.new() do
include superclass
implement superclass
def initialize(methodname, &block)
@block = block
define_method(methodname) do
@block.call
end
#create_method(methodname, &block)
def create_listener(superclass, methodname, &block)
focus_listener_class = Class.new() do
include superclass
implement superclass
def initialize(methodname, &block)
self.class.instance_eval do # <-- instance_eval makes this possible. :)
define_method(methodname, &block)
end
end
end
module RCalc
require "java"
require "rswing"
require "frame"
require "text_field"
include RSwing::Components
include_package 'javax.swing'
include_package 'java.awt'
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
module RSwing
module Components
module Events
module FocusEvents
FocusListener = java.awt.event.FocusListener
def on_focus(&block)
self.add_focus_listener(Listener.create(FocusListener, :focusGained ,&block))
end
class Test
def method(text)
if block_given?
yield "#{text} inside a block!"
else
puts "#{text} not in a block and just simply outputted to console."
end
end
f = File.new("myfile.txt", "r") # open a file with read-mode
# ... do some stuff with the file, like read its content, ouput it on the screen or whatever
# finally: close it!
f.close
# or:
module Numberconverter
require "rubygems"
require "rswing"
include RSwing::Components
GridBagLayout = java.awt.GridBagLayout
frame = Frame.new "Numberconverter",