Skip to content

Instantly share code, notes, and snippets.

Hiroshi Yuki hyuki0000

Block or report user

Report or block hyuki0000

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@hyuki0000
hyuki0000 / makeopenapp.rb
Created Oct 4, 2017
URLをオープンするだけのアプリを作るスクリプト
View makeopenapp.rb
#!/usr/bin/env ruby
# cf. http://bit.ly/2raKfLZ
# makeopenapp - URLをオープンするだけのスクリプトをMacのアプリケーションにする
if ARGV.length != 2
abort("Usage: makeopenapp URL Example.app")
end
url = ARGV[0]
appname = ARGV[1]
View markdown.md

タイトル

見出し

ろーれむいぷさむ

見出し

見出し

@hyuki0000
hyuki0000 / aveprime.rb
Created Sep 17, 2017
小さい方からn個選んだ素数の平均が素数になることはn=1以外にあるかな?
View aveprime.rb
require 'prime'
MAX = 10000_00000_00000
n = Rational(0)
s = Rational(0)
Prime.each(MAX) do |p|
n += 1
s += p
if (s/n).denominator == 1
puts "f(#{n}) = #{s/n} : INTEGER"
@hyuki0000
hyuki0000 / curious.rb
Created Aug 25, 2017
まちがった約分なのに、なぜか正しくなる分数
View curious.rb
(1..9).each do |a|
(1..9).each do |b|
(1..9).each do |c|
x = (10 * a + b).to_r
y = (10 * b + c).to_r
# puts "a = #{a}, b = #{b}, c = #{c}, x = #{x}, y = #{y}"
if a != c and x / y == a.to_r / c.to_r
puts "\\frac{#{x.to_i}}{#{y.to_i}} = \\frac{#{a}}{#{c}}, "
end
end
@hyuki0000
hyuki0000 / a.rb
Created Aug 23, 2017
N人のうち1人が100点でN-1人が0点であるとき、100点の人の偏差値
View a.rb
# N人のうち1人が100点でN-1人が0点であるとき、100点の人の偏差値
N = 15802 # 人数
μ = 100.0 / N # 平均
v = ((N-1) * (0-μ) ** 2 + 1 * (100-μ) ** 2) / N # 分散
σ = Math.sqrt(v) # 標準偏差
puts 50 + (100-μ) / σ * 10 # 100点の人の偏差値
# => 1307.0202862324857
@hyuki0000
hyuki0000 / 1.txt
Last active Jul 25, 2017
Who am I? - Twitterの hyuki がどんなリストに入れられているかを調べました
View 1.txt
43 math
37 IT
34 science
30 tech
29 数学
27 famous
25 My
23 engineer
20 it
17 twizard-magic-list
View FameList.js
/*
* FameList.js
*
* When you see
* https://twitter.com/EXAMPLEUSER/...
* Then you jump to
* https://twitter.com/EXAMPLEUSER/memberships
*
* Written by Hiroshi Yuki.
* Licensed under CC0.
View upftp.pl
#!/usr/bin/perl
#
# This is UpFtp, Version 1.3
# Copyright (C) 2000,2003,2006,2017 by Hiroshi Yuki.
# http://www.hyuki.com/upftp/
#
# This program is free software; you can redistribute it and/or
# modify it under the same terms as Perl itself.
#
use strict;
View error.txt
[ 2017-07-02 23:34:03.2697 29259/7f7fb7fff700 age/Cor/CoreMain.cpp:588 ]: Signal received. Gracefully shutting down... (send signal 2 more time(s) to force shutdown)
[ 2017-07-02 23:34:03.2804 29259/7f7fca2e4880 age/Cor/CoreMain.cpp:999 ]: Received command to shutdown gracefully. Waiting until all clients have disconnected...
[ 2017-07-02 23:34:03.2860 29269/7fd29ffff700 age/Ust/UstRouterMain.cpp:430 ]: Signal received. Gracefully shutting down... (send signal 2 more time(s) to force shutdown)
[ 2017-07-02 23:34:03.2867 29269/7fd2a9f35880 age/Ust/UstRouterMain.cpp:500 ]: Received command to shutdown gracefully. Waiting until all clients have disconnected...
[ 2017-07-02 23:34:03.2877 29269/7fd29f7fe700 Ser/Server.h:862 ]: [UstRouterApiServer] Freed 0 spare client objects
[ 2017-07-02 23:34:03.2880 29269/7fd29f7fe700 Ser/Server.h:490 ]: [UstRouterApiServer] Shutdown finished
[ 2017-07-02 23:34:03.2878 29269/7fd29ffff700 Ser/Server.h:490 ]: [UstRouter] Shutdown finished
[ 2017-07-02 23:34:03.2855 29259/7f7fca2e
@hyuki0000
hyuki0000 / phi.rb
Created Jul 2, 2017
オイラーのφ関数を、RubyのPrimeモジュールを使って素朴に実装したものです
View phi.rb
require 'prime'
def φ(n)
if n == 1
return 1
end
Prime.each(n-1) do |p|
if n % p == 0
b = n
j = 0
You can’t perform that action at this time.