Skip to content

Instantly share code, notes, and snippets.

View tomoe-mami's full-sized avatar

Tomoe Mami tomoe-mami

View GitHub Profile
-- Displays xterm 256 color palette
bright_fg, dark_fg = 47, 40
function print_section_title(text)
local width = 42
local title = " " .. text .. " "
local tile = "\226\148\129"
print( "\027[7m" .. title .. "\027[m" .. string.rep(tile, (width - #title)) )
end
<?php
/**
* Validates XML tag/attribute name (See <http://www.w3.org/TR/xml/#sec-common-syn> for reference)
*/
function is_valid_xml_name($name)
{
return preg_match('/^[:_A-Za-z\x{00C0}-\x{00D6}\x{00D8}-\x{00F6}\x{00F8}-\x{02FF}\x{0370}-\x{037D}\x{037F}-\x{1FFF}\x{200C}-\x{200D}\x{2070}-\x{218F}\x{2C00}-\x{2FEF}\x{3001}-\x{D7FF}\x{F900}-\x{FDCF}\x{FDF0}-\x{FFFD}\x{10000}-\x{EFFFF}][:_A-Za-z\x{00C0}-\x{00D6}\x{00D8}-\x{00F6}\x{00F8}-\x{02FF}\x{0370}-\x{037D}\x{037F}-\x{1FFF}\x{200C}-\x{200D}\x{2070}-\x{218F}\x{2C00}-\x{2FEF}\x{3001}-\x{D7FF}\x{F900}-\x{FDCF}\x{FDF0}-\x{FFFD}\x{10000}-\x{EFFFF}.0-9\x{#00B7}\x{0300}-\x{036F}\x{203F}-\x{2040}-]*$/u', $name);
}
@tomoe-mami
tomoe-mami / gist:3672594
Created September 8, 2012 07:38
php imgur uploader
#!/usr/bin/env php
<?php
define('IMGUR_SCRIPT_VERSION', '0.1');
define('IMGUR_API_BASE_URL', 'http://api.imgur.com');
define('IMGUR_API_VERSION', 2);
define('IMGUR_CURL_TIMEOUT', 3000);
$api_key = getenv('API_KEY');
if (!empty($api_key))
@tomoe-mami
tomoe-mami / gist:3687674
Created September 9, 2012 22:24
eeeeeeeeklok
#!/usr/bin/env lua
normal_cell_fmt = "%s"
active_cell_fmt = "<color=#ffffff style=glow>%s</>"
spacer = "<item size=20x10></>"
tm = {}
active = {}
letters =
@tomoe-mami
tomoe-mami / video-thumbnails.sh
Last active January 15, 2025 05:38
Simple Video Thumbnail/Screencap Generator
#!/bin/sh
#
# video-thumbnails: A simple shell script to generate video thumbnails/screencaps
#
# Author: rumia <https://github.com/rumia>
# License: WTFPL
#
function quit {
rm -rf "$1"
@tomoe-mami
tomoe-mami / weedoc.css
Created September 26, 2012 22:18
Weechat docs with TOC displayed as sidebar
@namespace url(http://www.w3.org/1999/xhtml);
@-moz-document regexp("https?://(www\.)?weechat\.org/files/doc/stable/.*") {
.article {
margin: 0 !important;
}
#header, #content {
position: fixed;
top: 0;
@tomoe-mami
tomoe-mami / lemur.lua
Created September 28, 2012 01:43
Yet another imgur uploader
#!/usr/bin/env lua
-- Usage: lemur.lua [filename]
-- If filename is not specified, will output credit information
local os = require "os"
local io = require "io"
local string = require "string"
local table = require "table"
local socket = require "socket"
@tomoe-mami
tomoe-mami / imgtoedj.sh
Last active December 11, 2015 07:19
A script to convert images within a directory into edje files for E background.
#!/bin/sh
IMAGE_DIR=${1:-.}
OUTPUT_DIR=${2:-~/.e/e/backgrounds}
TEMPLATE='
images { image: "@IMAGE@" USER; }
collections {
group {
name: "e/desktop/background";
data { item: "style" "4"; item: "noanimation" "1"; }
max: @WIDTH@ @HEIGHT@;
@tomoe-mami
tomoe-mami / atom-neko.php
Last active December 15, 2015 00:48
Generating an Atom feed using Nekomata. https://github.com/rumia/nekomata
<?php
$doc = Nekomata::create(array(
'qualified_name' => 'feed',
'namespaces' => array('_' => 'http://www.w3.org/2005/Atom')
));
// to create a new node, just call Nekomata->_().
// the first arg is the node name, second arg is the node value,
// and the third arg is an array of attributes.
@tomoe-mami
tomoe-mami / xhtml-neko.php
Last active December 15, 2015 00:58
Generating XHTML document with Nekomata (https://github.com/rumia/nekomata). The XHTML+RDFa doctype is just for testing the doctype creation. The document itself does not use any features specific to XHTML+RDFa.
<?php
$doc = Nekomata::create([
'qualified_name' => 'html',
'create_doctype' => true,
'public_id' => '-//W3C//DTD XHTML+RDFa 1.0//EN',
'system_id' => 'http://www.w3.org/MarkUp/DTD/xhtml-rdfa-1.dtd',
'namespaces' => ['_' => 'http://www.w3.org/1999/xhtml'],
'attributes' => ['xml:lang' => 'en', 'version' => 'XHTML+RDFa 1.0']
]);