Skip to content

Instantly share code, notes, and snippets.

View kaorimatz's full-sized avatar

Satoshi Matsumoto kaorimatz

View GitHub Profile
#!/bin/sh
COMMAND=`cat <<JS
const Gio = imports.gi.Gio;
let settings = new Gio.Settings({ schema: 'org.gnome.desktop.input-sources' });
let current = settings.get_uint('current');
let sources = settings.get_value('sources').get_child_value(current);
let type = sources.get_child_value(0).unpack();
if (type === 'xkb') {
let layout = sources.get_child_value(1).unpack();

Fedora 18 Installation

Kickstart File

install
url --url=http://ftp.jaist.ac.jp/pub/Linux/Fedora/releases/18/Fedora/x86_64/os/

# Yum Repos
repo --name=fedora \
#!/bin/sh
if [ $# -lt 1 ]; then
echo "usage: $0 [PAGE]"
exit 1
fi
OUTFILE=`mktemp`
BROWSER=firefox
PAGE=$1
#!/bin/sh
if [ $# -lt 2 ]; then
echo "usage: $0 [DOCUMENT_ROOT] [PORT]"
exit 1
fi
DOCUMENT_ROOT=$1
PORT=$2
function toIsbn13(isbn10) {
var digits = '978' + isbn10.substr(0, 9);
var tmp = digits.split('').map(function (e) {
return parseInt(e);
}).map(function (e, i) {
return (i % 2 == 0) ? e : e * 3;
}).reduce(function (a, b) {
return a + b;
}) % 10;
var checksum = tmp == 0 ? 0 : 10 - tmp;
@kaorimatz
kaorimatz / Rakefile
Created January 3, 2013 14:00
Generate bookmarklets.
JS = FileList['*.js']
JS.each do |js|
task "#{js}" do
sh "perl -pe 's/(^\\s+|\\s+$)//g' < #{js} | xclip -i"
end
end
@kaorimatz
kaorimatz / amount_of_work.py
Created December 18, 2012 15:26
Display the number of lines that you have changed.
#!/usr/bin/python2.7
from mercurial import patch, scmutil, ui, hg
from datetime import datetime
from time import gmtime
from itertools import groupby
def changedline(ui, repo, ctx1, ctx2):
added, removed = 0, 0
diff = ''.join(patch.diff(repo, ctx1.node(), ctx2.node()))
@kaorimatz
kaorimatz / mozilla-css-extensions-color-value.html
Created December 8, 2012 18:39
Display the actual colour of css keywords defined by Mozilla css extensions.
<?xml version="1.0"?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<title>MOZ CSS COLOR LIST</title>
<style type="text/css">
#container {
width: 980px;
margin: 10px auto;
}
@kaorimatz
kaorimatz / eclipse-bash-completion.sh
Created November 18, 2012 13:34
An bash completion specification for eclipse
function _eclipse {
local cur=${COMP_WORDS[COMP_CWORD]}
COMPREPLY=()
if (($COMP_CWORD == 1)); then
local i
eclipse_home=$SOFTWARE/eclipse
COMPREPLY=( $( compgen -W '$( ls -d $eclipse_home-* )' $eclipse_home-$cur ) )
for (( i=0; i < ${#COMPREPLY[@]}; i++ )); do
COMPREPLY[i]=${COMPREPLY[i]#$eclipse_home-}
@kaorimatz
kaorimatz / GmailAdsBlocker.user.js
Created November 18, 2012 13:29
A userscript for hiding ads at gmail.
// ==UserScript==
// @name Gmail Ads Blocker
// @namespace org.kaorimatz
// @include http*://mail.google.com/*
// @version 0.0.1
// ==/UserScript==
// right ads
GM_addStyle(".Bu { display:none; }");
GM_addStyle(".Bu:first-child { display:block; }");