Skip to content

Instantly share code, notes, and snippets.

View YuukiToriyama's full-sized avatar
🚲
On Cycling

ToriChan YuukiToriyama

🚲
On Cycling
  • Kyoto, Japan
View GitHub Profile
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

函数

アロー関数(=>)

アロー関数とfunction(){}構文は同じ。アロー(=>)を使って書いたほうが直感的かな?

[1,2,3,4].map(function(x) {return x * x}) // [1,4,9,16]
[1,2,3,4].map(x => x * x)                 // [1,4,9,16]

Rubyだと、

@YuukiToriyama
YuukiToriyama / mistake.md
Created October 11, 2019 17:23
ModuleNotFoundError: No module named 'numpy'

Jupyter Notebookからnumpyを使おうと思ったけど使えなかった

理由

  • pippip3を取り違えていた
  • python2系のほうのnumpyをインストールしていて、python3系のほうをインストールしていなかった
  • pip3 install numpyとすべきだった
@YuukiToriyama
YuukiToriyama / vscode_japanese.md
Created October 12, 2019 18:08
Visual Studio Codeで日本語化する方法
  1. Visual Studio Codeを起動する
  2. サイドバーからExtensionsを開く
  3. 検索窓に@category:"language packs"を入力
  4. Japanese Language Pack for VS Codeを見つけてInstallをクリック
  5. VSCodeを再起動
@YuukiToriyama
YuukiToriyama / get_url_list.rb
Created October 17, 2019 21:23
flickrから条件に合う写真を取ってくるスクリプト
#!/usr/bin/env ruby
require 'open-uri'
require 'json'
query_table = [
["api_key", ""], # https://www.flickr.com/services/appsでアプリを作成しapiキーを入手してください
["method", "flickr.photos.search"],
["tags", "soviet,russia"], # タグをコンマ区切りで指定します
["tag_mode", "all"], # anyを指定すると「または」、allを指定すると「かつ」
@YuukiToriyama
YuukiToriyama / kojiki_old_book.bash
Created October 27, 2019 11:40
真福寺本ぶっこ抜きワンライナーコマンド
curl "https://www.dl.ndl.go.jp/api/iiif/1184132/manifest.json" | jq .sequences[].canvases[].images[].resource.'"@id"' > output.list
@YuukiToriyama
YuukiToriyama / rust.snippets
Created December 7, 2019 14:53
my snipMate setting for Rust(.rs)
# snippets for Rust(.rs)
# install snipMate to your Vim and copy this file to $HOME/.vim/snippets
# version 2019/12/07
# © Copyright 2019 YUUKIToriyama. All Rights Reserved.
snippet use
use ${1:library};
snippet fn
fn ${1:func_name}() {
${2}
@YuukiToriyama
YuukiToriyama / generate_AA.bash
Created December 21, 2019 16:27
ImageMagick One-liner that generates funny AA
echo "よいお年を" | sed 's/./&\n/g' | xargs -I@ convert -size 100x100 xc:White -fill Black -font "Takao明朝" -pointsize 100 -gravity Center -draw 'text 0,0 "@"' ubrl: | grep -v : > yoi_otoshi_wo.txt
@YuukiToriyama
YuukiToriyama / calculatePi.lua
Created December 29, 2019 14:16
モンテカルロ法
#!/usr/bin/env lua
function calcPi(m)
local count = 0
for i = 1, m do
x, y = math.random(), math.random()
if x^2 + y^2 < 1 then
count = count + 1
end
end
@YuukiToriyama
YuukiToriyama / generateRandomColorcode.js
Created January 6, 2020 15:34
カラーコードの自動生成
/* generateRandomColorcode.js */
function generateRandomColorcode() {
var str = "";
for (var i = 0; i < 6; i++) {
str = str + Math.round(Math.random()*15).toString(16);
}
return "#" + str
}