Skip to content

Instantly share code, notes, and snippets.

View ayweak's full-sized avatar

ayweak ayweak

  • Individual
  • Japan
View GitHub Profile
@ayweak
ayweak / extract_css_property.xq
Created March 1, 2024 14:38
style 属性の値から指定の名称の CSS プロパティを値とともに抽出するような感じ。
xquery version "3.1" encoding "UTF-8";
(:
java -cp saxon-he-12.4.jar net.sf.saxon.Query -q:extract_css_property.xq -s:source.xml property="background-color"
:)
declare namespace output = "http://www.w3.org/2010/xslt-xquery-serialization";
declare option output:method "text";
declare variable $property as xs:string external := "";
@ayweak
ayweak / delete-if-0-directive.sed
Created January 19, 2024 12:34
単純な #if 0 から #endif の範囲を削除する。
# usage: sed -n -E -f delete-if-0-directive.sed file.c
# 単純な #if 0 から #endif の範囲を削除する。
# #if 0 の行にヒットしたら削除を開始する。
/^[ \t]*#[ \t]*if[ \t]+0([ \t]|$)/ {
b in_deletion_range
}
# 通常行は出力して次の行へ進む。
@ayweak
ayweak / delete-escaped-newline.py
Last active February 11, 2025 16:04
行末のバックスラッシュを削除して次の行と結合する。
#!/usr/bin/python3
import argparse
import re
import sys
import io
def delete_escaped_newline(
src: io.TextIOBase,
dest: io.TextIOBase,
# https://forums.virtualbox.org/viewtopic.php?f=7&t=77363
sudo /usr/src/linux-headers-$(uname -r)/scripts/sign-file sha256 ./MOK.priv ./MOK.der $(modinfo -n vboxdrv)
@ayweak
ayweak / application.js.diff
Created June 8, 2016 16:10
Redmine のリポジトリページを開いた時にリビジョン入力欄を選択させないようにする
--- a/redmine-3.2.1/public/javascripts/application.js 2016-06-09 00:31:47.825000000 +0900
+++ b/redmine-3.2.1/public/javascripts/application.js 2016-06-09 00:41:30.878000000 +0900
@@ -640,7 +640,7 @@
function defaultFocus(){
if (($('#content :focus').length == 0) && (window.location.hash == '')) {
- $('#content input[type=text], #content textarea').first().focus();
+ $('#content input[type=text], #content textarea').not('.contextual *').first().focus();
}
}
@ayweak
ayweak / bulk_edit.html.erb.diff
Created May 2, 2016 17:12
Redmine のチケット一括編集 (bulk edit) で必須のフィールドを入力できなくてチケットを更新できないのを修正する
--- a/redmine-3.2.1/app/views/issues/bulk_edit.html.erb 2016-03-14 02:18:44.000000000 +0900
+++ b/redmine-3.2.1/app/views/issues/bulk_edit.html.erb 2016-05-03 00:56:44.974966723 +0900
@@ -50,7 +50,8 @@
<label for='issue_status_id'><%= l(:field_status) %></label>
<%= select_tag('issue[status_id]',
content_tag('option', l(:label_no_change_option), :value => '') +
- options_from_collection_for_select(@available_statuses, :id, :name, @issue_params[:status_id])) %>
+ options_from_collection_for_select(@available_statuses, :id, :name, @issue_params[:status_id]),
+ :onchange => "updateBulkEditFrom('#{escape_javascript url_for(:action => 'bulk_edit', :format => 'js')}')") %>
</p>
@ayweak
ayweak / path2unc.ps1
Last active November 14, 2018 10:38
PowerShell でネットワークドライブ上のパスを UNC 形式にしてクリップボードにコピーする。
# -*- coding: utf-8-with-signature-dos -*-
# 「送る」からの実行でパスの日本語部分が文字化けしたので、その対策。
$OutputEncoding = [Console]::OutputEncoding
$Path = $Args[0]
$Drive = Split-Path -Qualifier $Path
$LogicalDisk = Get-WMIObject Win32_LogicalDisk -Filter "DriveType = 4 AND DeviceID = '$Drive'"
# PowerShell version 5 では Set-Clipboard が使える。
@ayweak
ayweak / application.css.3.1.2.diff
Last active October 12, 2016 16:08
Redmineのプロジェクトメニューを改造して「トラッカーを指定して『新しいチケット』ページを開く」メニューアイテムを追加する
--- a/redmine-3.1.2/public/stylesheets/application.css 2015-11-14 18:03:29.000000000 +0900
+++ b/redmine-3.1.2/public/stylesheets/application.css 2016-01-16 01:32:37.221000000 +0900
@@ -39,6 +39,7 @@
margin: 0px 2px 0px 0px;
padding: 0px 0px 0px 0px;
white-space:nowrap;
+ position: relative;
}
#main-menu li a {
display: block;
@ayweak
ayweak / git_adapter.rb.diff
Created November 27, 2015 15:18
Redmineがリポジトリからファイルの情報を取得する処理を効率良さそうにする
--- a/redmine-3.1.2/lib/redmine/scm/adapters/git_adapter.rb 2015-11-14 18:03:27.000000000 +0900
+++ b/redmine-3.1.2/lib/redmine/scm/adapters/git_adapter.rb 2015-11-27 01:04:15.191352707 +0900
@@ -125,7 +125,7 @@
else
# Search for the entry in the parent directory
es = entries(search_path, identifier,
- options = {:report_last_commit => false})
+ options = {:report_last_commit => false, :specific_children => [search_name]})
es ? es.detect {|e| e.name == search_name} : nil
end
@ayweak
ayweak / index.api.rsb.modified1
Last active August 29, 2015 14:27
Redmine の REST API "GET /issues.[format]" で出力するフィールドを制御できるようにする
inline_columns = @query.inline_columns
block_columns = @query.block_columns
output_fields = []
output_fields << ->(api, issue) {api.id issue.id}
if inline_columns.any? {|c| c.name == :project}
output_fields << ->(api, issue) do
api.project(:id => issue.project_id, :name => issue.project.name) unless issue.project.nil?