Skip to content

Instantly share code, notes, and snippets.

Avatar

結城浩 / Hiroshi Yuki hyuki

View GitHub Profile
@hyuki
hyuki / bold.rb
Last active Jul 7, 2021
How do you convert "Hello, **world**!" to "Hello, <b>world</b>!" in Ruby?
View bold.rb
text = <<"EOD"
Lorem**ipsum**dolorsitamet,
con*secteturadipiscing**elit**,
**sed****do**eiusmod**temporincididunt
utlabore**etdoloremagnaaliqua.
EOD
html = <<"EOD"
Lorem<b>ipsum</b>dolorsitamet,
con*secteturadipiscing<b>elit</b>,
@hyuki
hyuki / commonmarker-test.rb
Created Jul 6, 2021
commonmarker-test.rb
View commonmarker-test.rb
require 'commonmarker'
md = '$$\begin{align}x\\\\y\end{align}$$'
puts "BEFORE:" + md
puts "AFTER :" + CommonMarker.render_html(md)
@hyuki
hyuki / text-to-speech-quick-example-with-azure-in-japanese.js
Created Jun 12, 2021
text-to-speech-quick-example-with-azure-in-japanese.js
View text-to-speech-quick-example-with-azure-in-japanese.js
// cf. https://github.com/Azure-Samples/cognitive-services-speech-sdk/blob/master/quickstart/javascript/node/text-to-speech/index.js
var subscriptionKey = "99999999999999999999999999999999"; // Your Subscription Key.
var serviceRegion = "japaneast"; // "westus"
var filename = "output.mp3";
var audioConfig = sdk.AudioConfig.fromAudioFileOutput(filename);
var speechConfig = sdk.SpeechConfig.fromSubscription(subscriptionKey, serviceRegion);
// https://docs.microsoft.com/en-us/javascript/api/microsoft-cognitiveservices-speech-sdk/speechsynthesisoutputformat?view=azure-node-latest
@hyuki
hyuki / girlnote323-contains-instance.java
Last active May 14, 2021
Web連載「数学ガールの秘密ノート」 第323回 アルゴリズム、なかなか大変(前編)
View girlnote323-contains-instance.java
// 注意:本文に近付けるため、Javaとしては不自然な書き方になっています
// cf: https://cakes.mu/posts/33738
class List {
Node head;
public List(int... values) {
this.head = new Node(0, null);
this.head.next = this.head;
Node p = this.head;
for (int i = values.length - 1; i >= 0; i--) {
@hyuki
hyuki / girlnote323-contains.java
Last active May 14, 2021
girlnote323-contains.java - Web連載「数学ガールの秘密ノート」 第323回 アルゴリズム、なかなか大変(前編)
View girlnote323-contains.java
// 注意:本文に近付けるため、Javaとしては不自然な書き方になっています
// cf: https://cakes.mu/posts/33738
class Node {
int value;
Node next;
public Node(int value, Node next) {
this.value = value;
this.next = next;
}
View kuku.rb
yomi = {
"2" => 'に',
"3" => 'さ',
"4" => 'し',
"5" => 'ご',
"6" => 'む',
"7" => 'な',
"8" => 'は',
"9" => 'く',
}
@hyuki
hyuki / sample.tex
Created Mar 10, 2021
LaTeX to Image
View sample.tex
\documentclass[line_length=20zw]{jlreq}
\begin{document}
\thispagestyle{empty}
むかしむかし、あるところに、
おじいさんと、おばあさんが住んでいました。
おじいさんが$x$に関する方程式、
$$
ax^2 + bx + c = 0
$$
@hyuki
hyuki / time.rb
Created Feb 21, 2021
Time compare
View time.rb
system("echo Hello > a")
system("echo Hello > b")
system("touch -r a b")
a = File.mtime("a")
b = File.mtime("b")
puts "File.mtime('a') => #{a}"
puts "File.mtime('b') => #{b}"