This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Game | |
attr_gtk | |
def tick | |
defaults | |
render | |
input | |
calc | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'ffi' | |
module FFI | |
typedef :pointer, :Display | |
typedef :ulong, :XID | |
typedef :XID, :Window | |
typedef :int, :Status | |
typedef :ulong, :Atom | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# % 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
NewerOlder