Skip to content

Instantly share code, notes, and snippets.

View noborus's full-sized avatar

Noboru Saito noborus

View GitHub Profile
@noborus
noborus / gist:7516369
Last active March 25, 2021 10:06
iBus(1.4)をD-Busで操作する方法

iBus(1.4)をD-Busで操作する方法

iBusはD-Busを通信プロトコルに使用しているため、外からもD-Busで制御することが出来る。 しかしながら、D-Busが一般に使用するSystem Bus と Session Busとは違うBusを使用するため、ちょっと注意が必要になる。

iBus1.5からはデスクトップ環境に統合されることを前提に変更されているため、ここではその変更前のバージョンを対象とする。

iBusのD-Busに接続するための接続情報

iBusのD-Busに接続するための接続するには IBUS_ADDRESSが必要になる。IBUS_ADDRESSは通常 iBusを起動しているユーザーの

@noborus
noborus / ibus_toggle.rb
Last active November 6, 2021 11:48
ibus_toggle のRuby版(iBus 1.4以下対応) ruby-dbusが必要($ gem install ruby-dbus)
#! /usr/bin/ruby
# -*- coding: utf-8 -*-
require 'dbus'
IBUS_SERVICE="org.freedesktop.IBus"
IBUS_PATH_IBUS="/org/freedesktop/IBus"
IBUS_INTERFACE_IBUS="org.freedesktop.IBus"
IBUS_INTERFACE_INPUTCONTEXT="org.freedesktop.IBus.InputContext"
@noborus
noborus / ibus_auto.rb
Created December 19, 2013 08:15
IBusをONにして自動で文字を入力する
#! /usr/bin/ruby
# -*- coding: utf-8 -*-
require 'dbus'
INPUT_TEXT="konnnitiha"
IBUS_SERVICE="org.freedesktop.IBus"
IBUS_PATH_IBUS="/org/freedesktop/IBus"
IBUS_INTERFACE_IBUS="org.freedesktop.IBus"
@noborus
noborus / akemasite.rb
Created December 31, 2013 15:10
IBusをONにして自動で入力正月バージョン
#! /usr/bin/ruby
# -*- coding: utf-8 -*-
require 'dbus'
INPUT_TEXT="akemasiteomedetougozaimasu"
IBUS_SERVICE="org.freedesktop.IBus"
IBUS_PATH_IBUS="/org/freedesktop/IBus"
IBUS_INTERFACE_IBUS="org.freedesktop.IBus"
SELECT COUNT (char) AS frequency, char
FROM
(SELECT substr (column_name, generate_series (1, LENGTH (column_name)), 1) AS char
FROM table_name) AS d
GROUP BY char
ORDER BY frequency DESC;
SELECT '0x' ||
encode(substr(s.word::text,generate_series(1,length(s.word::text),1),1)::bytea, 'hex') AS code,
substr(s.word::text,generate_series(1,length(s.word::text),1),1) AS char
FROM
(SELECT '漢字' AS word) AS s;
code | char
----------+------
0xe6bca2 | 漢
0xe5ad97 | 字
SELECT e.euc,convert(e.euc,'EUC_JIS_2004','UTF-8') as utf8, convert_from(convert(e.euc,'EUC_JIS_2004','UTF-8'),'UTF-8') as chr FROM (SELECT decode('8f'||to_hex('xa1a1'::bit(16)::int+generate_series(0,93)),'hex') as euc ) as e;
euc | utf8 | chr
----------+------------+-----
\x8fa1a1 | \xf0a08289 | 𠂉
\x8fa1a2 | \xe4b882 | 丂
\x8fa1a3 | \xe4b88f | 丏
\x8fa1a4 | \xe4b892 | 丒
\x8fa1a5 | \xe4b8a9 | 丩
@noborus
noborus / 0_reuse_code.js
Created March 20, 2014 04:44
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@noborus
noborus / temporary_table.md
Last active May 7, 2024 09:36
TEMPORARY TABLE(一時テーブル)を探る

TEMPORARY TABLE(一時テーブル)を探る

TEMPORARY TABLE(一時テーブル)を探る

PostgreSQLのTEMPORARY TABLE(一時テーブル)について主に速度面について探っていきます。 ここで書かれていることはPostgreSQL 10を対象としています。

はじめに

PostgreSQLのTEMPORARY TABLE(一時テーブル)は接続したセッションの間にしか生存できないテーブルです。このテーブルは他のセッションからはアクセスすることができません。

package main
import (
"database/sql"
"fmt"
_ "github.com/go-sql-driver/mysql"
)
func main() {