Skip to content

Instantly share code, notes, and snippets.

zakuroishikuro zakuroishikuro

Block or report user

Report or block zakuroishikuro

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
View cycle_fizzbuzz.rb
fizz = [nil] * 2 << :Fizz
buzz = [nil] * 4 << :Buzz
(1..100).zip(fizz.cycle, buzz.cycle) do |n, *f|
puts f.any? && f.join || n
end
# (1..100).zip(([nil]*2<<:Fizz).cycle,([nil]*4<<:Buzz).cycle){|n,*z|puts z.any?&&z*""||n}
@zakuroishikuro
zakuroishikuro / range_as_python.js
Created Apr 7, 2019
JavaScriptのジェネレータでPythonのrangeみたいなやつ
View range_as_python.js
function *range(start=0, stop, step=1) {
if (stop === undefined) {
[start,stop] = [0, start];
}
let cond;
if (step > 0) {
cond = n=>n < stop;
} else if (step < 0) {
View util_ie.vbs
Option Explicit
Const DEFAULT_WAIT_MILLI_SECONDS As Long = 1500
Declare Sub Sleep Lib "kernel32" (ByVal wait_ms As Long)
Function get_ie(url_pattern As String) As InternetExplorer
Dim win As WebBrowser, wins As New ShellWindows
For Each win In wins
@zakuroishikuro
zakuroishikuro / itunes_unchecked_tracks.js
Last active Jun 1, 2016
iTunesでなぜかチェックがはずれている項目のチェックを自動で直す (JXA) ref: http://qiita.com/zakuroishikuro/items/bb6ceae9516055924583
View itunes_unchecked_tracks.js
// チェックのはずれた項目を取得
iTunes = Application("iTunes");
unchecked_tracks = iTunes.tracks.whose({enabled: false})();
// ダイアログ表示の下準備
app = Application.currentApplication();
app.includeStandardAdditions = true;
if (unchecked_tracks.length == 0){
app.displayAlert("チェックのはずれている項目はありませんでした。");
@zakuroishikuro
zakuroishikuro / math_girl.rb
Last active Feb 12, 2017
『数学ガールの秘密ノート 整数で遊ぼう』 5章の時計パズルを少し大げさに作る
View math_girl.rb
class Clocks
attr_reader :count, :clocks, :limits
def initialize(*limits)
limits = [2, 3, 5] if limits.empty?
@limits = limits
reset
end
def push
@zakuroishikuro
zakuroishikuro / math_girl.rb
Last active May 18, 2016
『数学ガールの秘密ノート 整数で遊ぼう』第4章の漸化式をRubyで
View math_girl.rb
list = [nil, 3, 3, 3]
(1..100).each do |n|
ans = (list[n] + list[n+1]) / list[n + 2].to_r
ans = ans.numerator if ans.denominator == 1
list << ans
end
list.shift
list.each.with_index(1) do |value, n|
@zakuroishikuro
zakuroishikuro / プログラマ脳を鍛える数学パズル_02.rb
Created May 17, 2016
『プログラマ脳を鍛える数学パズル』2
View プログラマ脳を鍛える数学パズル_02.rb
op_list = %w|+ - * /| + [""]
op_perm = op_list.repeated_permutation(3).to_a
(1000..9999).each do |i|
str = i.to_s
a = str.split ""
op_perm.each do |op|
st = a.zip(op).join
ans = eval st.gsub(/\D0+/, "") rescue nil
@zakuroishikuro
zakuroishikuro / answer.js
Last active May 17, 2016
『プログラマ脳を鍛える数学パズル』1
View answer.js
function check(n, base){
var s = n.toString(base);
for (var i = 0, len = s.length / 2; i < len; i++){
if (s[i] != s.substr(-i-1, 1)) return false;
}
return true;
}
for (var i = 10;; i++){
if (check(i, 10) && check(i, 8) && check(i, 2)) {
@zakuroishikuro
zakuroishikuro / simple_synth.html
Created Apr 22, 2016
シンプルなシンセサイザー的な何か
View simple_synth.html
<!DOCTYPE html>
<meta charset="utf-8">
<style>
body {
background-image:
repeating-linear-gradient(90deg, transparent, transparent calc(100% / 12 - 1px), black calc(100% / 12 - 1px), black calc(100% / 12)),
repeating-linear-gradient( 0deg, transparent, transparent calc(100% / 8 - 1px), black calc(100% / 8 - 1px), black calc(100% / 8));
}
@zakuroishikuro
zakuroishikuro / virtual_keyboard.html
Created Apr 21, 2016
動けばいいやって感じで書きなぐったバーチャルキーボード
View virtual_keyboard.html
<!DOCTYPE html>
<meta charset="utf-8">
<style>
.keyboard {
width: 600px;
}
button {
width: 4em;
height: 4em;
You can’t perform that action at this time.