Skip to content

Instantly share code, notes, and snippets.

View emdeeeks's full-sized avatar

Gareth Griffiths emdeeeks

View GitHub Profile
@emdeeeks
emdeeeks / main.rb
Created March 5, 2025 22:40 — forked from amirrajan/main.rb
Gauntlet written in DragonRuby Game Toolkit
class Game
attr_gtk
def tick
defaults
render
input
calc
end
@emdeeeks
emdeeeks / dmenu_goto_window.rb
Created May 28, 2024 00:05 — forked from janx/dmenu_goto_window.rb
Jump to specified window (archlinux + bspwm + dmenu)
#!/usr/bin/env ruby
# get a list of all windows
window_list = `wmctrl -l`.split("\n").map {|l| l.strip.split(' ', 4)}
# write window names to a tmp file
File.open('/tmp/dmenu_goto_windows', 'w') do |f|
window_list.each {|w| f.puts w[3] }
end
@emdeeeks
emdeeeks / win_class_title.rb
Created May 27, 2024 23:26 — forked from tmtm/win_class_title.rb
X のウィンドウのクラスとタイトルを取得する
require 'ffi'
module FFI
typedef :pointer, :Display
typedef :ulong, :XID
typedef :XID, :Window
typedef :int, :Status
typedef :ulong, :Atom
end
@emdeeeks
emdeeeks / scrot.rb
Created May 27, 2024 22:37 — forked from lian/scrot.rb
# % ruby scrot.rb /tmp/screenshot.png
# scrot.rb uses xlib + imlib via ffi to capture screenshots.
require 'ffi'
module X11
extend FFI::Library
ffi_lib 'X11'
attach_function :XOpenDisplay, [:string], :pointer
attach_function :XFlush, [:pointer], :pointer
@emdeeeks
emdeeeks / xlib.rb
Created May 27, 2024 22:35 — forked from ohac/xlib.rb
#!/usr/bin/env ruby
require 'rubygems'
require 'ffi'
module X11
extend FFI::Library
ffi_lib 'X11'
attach_function :open_display, :XOpenDisplay, [:pointer], :pointer
attach_function :query_tree, :XQueryTree,
[:pointer, :int, :pointer, :pointer, :pointer, :pointer], :int
attach_function :get_window_attributes, :XGetWindowAttributes,
"use strict";
// This file was originally written by @drudru (https://github.com/drudru/ansi_up), MIT, 2011
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
var ANSI_COLORS = [[{ color: "0, 0, 0", "class": "ansi-black" }, { color: "187, 0, 0", "class": "ansi-red" }, { color: "0, 187, 0", "class": "ansi-green" }, { color: "187, 187, 0", "class": "an
@emdeeeks
emdeeeks / terminal-eyes.rb
Created March 7, 2021 11:31 — forked from jrunning/terminal-eyes.rb
terminal-eyes.rb
at_exit { stop! }
require "io/console"
$last_click_pos = nil
LEFT_EYE_OFFSET = -3
RIGHT_EYE_OFFSET = 3
EYE_CENTER_OFFSET = 2
# Xterm control sequences
@emdeeeks
emdeeeks / 1_smtpd.rb
Created June 4, 2020 17:48 — forked from epitron/1_smtpd.rb
A 77 line SMTP server, and a 253 line POP3 server.
require 'gserver'
require 'rubygems'
require 'active_record'
dbconfig = YAML::load_file(File.dirname(__FILE__) + '/config/database.yml')
ActiveRecord::Base.establish_connection(dbconfig['development'])
# CREATE TABLE emails (id integer primary key autoincrement, mail_from, rcpt_to, subject, email, user_id integer);
# CREATE TABLE users (id integer primary key autoincrement, username, password, email);
# XTerm Control Sequences based on:
# - https://invisible-island.net/xterm/ctlseqs/ctlseqs.html
# ========================================================================= #
# XTerm Control Sequences from invisible-island.net as pythonic code.
# Basic control sequences are string variables.
# - eg: ESC = '\033'
# CSI = ESC + '['
# Control sequences that have args can be called to return a string.
# - eg: sgr = CSI + Ps + 'm'
@emdeeeks
emdeeeks / ansi_seq.rb
Created April 30, 2020 17:09 — forked from cabron/ansi_seq.rb
ANSI Escape Sequences
class String
def seq
gsub(%r{
%% |
% (?<bg> B )? (?<sgr> black|red|green|yellow|blue|magenta|cyan|white|[0bu!_]|clr ) |
% (?<n1> \d+ )? (?<c> [\^v><\|\-!fb]<? ) (?<n2> \d+ )?
}x) {
match, bg, sgr, n1, c, n2 = *$~
if sgr #Select Graphic Rendition (reset, bold, underline, negative, colors) TODO: xterm colors