Tumgik
#to_a
Tumblr media
[English Translation] Repost from @woorim_ko [20 July 2021] “Dandelion - PITTA✨ Our Hyungho hyung’s song has been released~! Everyone, the moment you listen to this song, The melody is bound to get stuck in your head, And you’ll find yourself humming along to it. This is a very precious song with Hyungho hyung’s touch all over it ✨ Please listen to it a whole lot ㅎㅎㅎ #Forestella #KangHyungho #pitta #dandelion #덴들라이언 #This_kind_of_Sensibility #To_a #Busan_Dude #This_is_the_first” https://www.instagram.com/p/CRi1_roMpGX/?utm_medium=tumblr
1 note · View note
tk-notebook · 5 years
Text
[Ruby][Jupyter Notebook][Plotly] 気温と気圧のグラフを表示する
require 'nokogiri' require 'open-uri' require 'daru' require 'rbplotly' require 'daru/plotly' require 'date' # データの取得と格納 url = # "https://www.jma.go.jp/jp/amedas_h/today-82182.html?areaCode=000&groupCode=58" # 福岡 "https://www.jma.go.jp/jp/amedas_h/today-44132.html?areaCode=000&groupCode=30" # 東京 doc = Nokogiri::HTML.parse(open(url){|f|f.read}) table =doc.css("#tbl_list") ary=[] table.css("tr").each do |tr| tmp=[] tr.css("td").each{|td| val= "#{td.text}".tr("\u00a0","") tmp << val } ary << tmp end # DataFrameに格納・表示 cols=ary.take(1).flatten! aryData = ary.drop(2).transpose table = Daru::DataFrame.new(aryData, order:cols) # グラフの作成 ## タイトルの設定 today=Date.today title= "#{today.year}年#{today.month}月#{today.day}日の気圧変動" nil # 最低値を求める: 単純にmin()だとN/Aが0.0になるため def min(table, threshold) minimum = threshold table.each{|v| if (! v.empty? && v.to_f < minimum) minimum = v.to_f end } return minimum end # r1=[1000,1030];r2=[0,20] # r1=[1011.7, 1027]; r2=[2.8, 14] ## 軸の設定 t_p=table['気圧']; t_t=table['気温'] r1=[min(t_p, t_p.max.to_f) - 5, (t_p.max.to_i) + 5] r2=[min(t_t, t_t.max.to_f) - 5, (t_t.max.to_i) + 5] layout = { title: title, xaxis:{title:"時", type: :time, range: [today.rfc3339, today.next_day(1).rfc3339] }, yaxis: {side:"left", title:"hPa", range: r1}, yaxis2:{side:"right", title:"degree", range: r2, overlaying: 'y'} } ## 系列の設定 s1={name: "pressure", x:table['時刻'].to_a, y: t_p.to_a, type: :line, mode: :lines, yaxis:'y1'} s2={name: "temperature",x:table['時刻'].to_a, y: t_t.to_a, type: :line, mode: :lines, yaxis:'y2'} data=[s1,s2] ## プロット plot = Plotly::Plot.new(data:data,layout:layout) # plot.layout.height=500 plot.show nil
0 notes
kimihito · 5 years
Quote
to_aして、selectして、idの配列作って、relationを新しく作るklass.where(id: relation. to_a.select{|r|r. foo?}.map(&:id))relation. select_with_sql_by_ast{|r|r. foo == bar} // 最近流行りのASTを使ってSQL生成させるとかどうですか— ぺん! (@tompng) May 25, 2019
http://twitter.com/tompng/status/1132265232775110657
0 notes
webnchi-blog · 7 years
Text
【艦これ】おもむろにスク水を脱ぎだしたイムヤ 伊168イラストまとめ
@siroarte: 雪代 あるて@1日目G-05a 2017-06-27 02:18 伊168ちゃん(๑╹◡╹)pic.twitter.com/oRhAKKCgjv 返信 リツイ お気に @to_a … Copyright © 2017 艦これイラストまとめ イラこれ! All Rights Reserved. Source: 【相互】艦これイラストまとめ イラこれ!
View On WordPress
0 notes
ruby-off-the-rails · 7 years
Text
Generate a random...password?
> a = ('a'..'z').to_a
=> ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"]
2.4.0 :013 > n = (0...10).to_a
=> [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
2.4.0 :014 > a + n
=> ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", 0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
2.4.0 :015 > mix = a + n
=> ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", 0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
2.4.0 :016 > mix.shuffle[0..9]
=> ["k", 7, "q", "c", "i", "m", "l", "x", "u", "v"]
2.4.0 :017 > mix.shuffle[0..9].join
=> "4ebl9wjq7r"
0 notes