Skip to content

Instantly share code, notes, and snippets.

@higuma
higuma / color-display.md
Last active March 2, 2023 09:59
GitHub MarkdownのCSS色表示機能

コメント中の色表現

本機能はGitHub repo本文(READMEなど)では機能しないことに注意。効果はこの本文の下にあるコメント欄を見ると確認できる。

GitHubのComments/Issues/Pull requestsではコードスパンの中にCSSの色表現を記述するとカラーサンプル付きで表示する。

ただし全ての表現が使えるのではなく、使える書式とそうでないものがある。確認コードは次の通り。

| 表現 | 文例 | 判定 |

Markdownにおける<details>タグの使用

Markdownでも<details>を使い、折り畳みセクションを作成できる。

<details>
<summary>折り畳み記事</summary>
折り畳まれるコンテンツ
</details>
@higuma
higuma / markdown-preview-output-deference.md
Last active August 11, 2022 14:19
GistのPreviewとOutputで結果が異なるMarkdown文書の例

(2022-08-11現在) 次のMarkdown文書はPreviewとOutputで結果が異なる。

\[これはリンクではない、しかしリンク先に注意](https\://www\.example\.com)

[これはリンクではない、しかしリンク先に注意](https://www.example.com)

https://...の部分は次のように処理される。

@higuma
higuma / markdown-escapes.md
Last active August 26, 2022 02:40
Backslash escapes in GitHub Markdown

Backslash escapes in Markdown

Backslash escape effects for all ASCII printable characters (→ source)

U+ 0 1 2 3 4 5 6 7 8 9 A B C D E F
0020 \
\
\!
!
\"
"
\#
#
\$
$
\%
%
\&
&
\'
'
\(
(
\)
)
\*
*
\+
+
\,
,
\-
-
\.
.
\/
/
0030 \0&NoBreak;\0 \1&NoBreak;\1 \2&NoBreak;\2 \3&NoBreak;\3 \4&NoBreak;\4 \5&NoBreak;\5 \6&NoBreak;\6 \7&NoBreak;\7 \8&NoBreak;\8 \9&
@higuma
higuma / markdown-escapes.rb
Last active August 26, 2022 02:40
Backslash escapes in GitHub Markdown (source code)
# Render markdown-escapes.md
N_COL = 16
puts "# Backslash escapes in Markdown"
puts
puts "Backslash escape effects for all ASCII printable characters (→ [source](https://gist.github.com/higuma/15de141310855a8f654792046dca5c50))"
puts
puts "| U+ |" + (0...N_COL).inject('') {|row, col| row + sprintf(" %X |", col) }
puts (0..N_COL).inject('|') {|row, _| row + ' :-: |' }
#!/usr/bin/env ruby
# Recursive line/word/byte counter
require 'find'
require 'fileutils'
ARGV.push '.' if ARGV.empty?
total_lines = total_words = total_bytes = 0
@higuma
higuma / httpd
Created June 13, 2022 14:00
HTTP dev server with ruby webrick
#!/usr/bin/env ruby
require 'optparse'
require 'webrick'
# Add additional MIME types here
WEBrick::Config::HTTP[:MimeTypes].update({
'wasm' => 'application/wasm'
})
#!/usr/bin/env ruby
# git-id: calculates the git ID (sha-1) with the specified object type
require 'optparse'
require 'openssl'
type = 'blob' # as default
opt = OptionParser.new
@higuma
higuma / mnist.go
Last active August 25, 2021 00:48
MNIST database reader with Golang
// MNIST database reader
// http://yann.lecun.com/exdb/mnist/
package mnist
import (
"fmt"
"os"
"path/filepath"
)
require 'net/http'
URI_BASE = 'https://www.marutsu.co.jp/contents/shop/marutsu/mame'
EXT = ['html', 'htm', 'pdf']
NUMBER_RANGE = 1..220 # max = 205?
def https_request(uri)
uri = URI uri
Net::HTTP.start uri.host, uri.port, use_ssl: uri.scheme == 'https' do |http|
response = http.request Net::HTTP::Get.new(uri)