Skip to content

Instantly share code, notes, and snippets.

View yuyosy's full-sized avatar
💭
I may be slow to respond.

yuyosy yuyosy

💭
I may be slow to respond.
View GitHub Profile
@yuyosy
yuyosy / Main.sublime-menu
Created September 25, 2018 03:05
SublimeText3 Custom Layout (Add few layouts)
{
"caption": "Layout",
"mnemonic": "L",
"id": "layout",
"children":
[
{
"caption": "Single",
"command": "set_layout",
"args":
@yuyosy
yuyosy / print.jl
Created September 25, 2018 13:37
Julia <print>
print("a") # 改行なし出力
println("b") # 改行付き出力
println("\n") # \nは改行文字を表す
# 文字列
str = "ABC_def_0123456789_HelloWorld!"
println(str)
# 大文字小文字変換
println(uppercase(str)) # すべて大文字に変換
@yuyosy
yuyosy / calc.jl
Created September 25, 2018 13:39
Julia <calc>
x = 2
y = 3
println("x = $x, y = $y")
# 変数を含む計算 (*の省略)
println("2x+1 = ", 2x+1)
println("(x+2)x = ", (x+2)x) # xを括弧の前にするのは不可 x(x+2)
# 表記が関数と混在するため
# 除算
@yuyosy
yuyosy / if-else.jl
Created September 25, 2018 13:40
Julia <if-else>
x = 2
y = 5
# プログラムでの一般的なの書き方
println(0<x && x<3) # true
println(0<x && x<1) # false
# 数学的な書き方(`&&` の省略)
println(0<x<3) # true
println(0<x<1) # false
@yuyosy
yuyosy / function.jl
Created September 25, 2018 13:41
Julia <function>
# 一般的な記法の関数定義
function f1(a)
return a + 1
end
println("f1 : ", f1(3))
# 括弧をつけない関数f1は、関数オブジェクトとして、他の値と同じように受け渡しが可能
g = f1
println("g : ", g(3))
@yuyosy
yuyosy / loop.jl
Created September 25, 2018 13:41
Julia <loop>
for i in 1:5 # i = 1:5と同等 1~5の範囲
print("$i ")
end
println()
for i in 5:-1:1 # 5~1の範囲で-1ずつ変化
print("$i ")
end
println()
@yuyosy
yuyosy / math_basic.jl
Created September 25, 2018 13:43
julia <math_basic>
# JuliaではUTF-8エンコードではUnicode文字をサポート
# 対話モード(インタプリタ)でバックスラッシュ(円マーク)に続けて記号名称を入力しTabキーを押すことで変換可能
# π は \pi で変換可能
# 円周率の値は pi でも π でも利用可能
println("pi = $(pi), π = $(π))")
# 数学でよく使う演算
println("|-10| = ", abs(-10)) # 絶対値
println("√9 = ", sqrt(9)) # 平方根
@yuyosy
yuyosy / matrix.jl
Created September 25, 2018 13:43
Julia <matrix>
m1 = [1 2 3] # 横行列
m2 = [1; 2; 3] # 縦行列 [1, 2, 3]と同等
println("m1 = ", m1)
println("m2 = ", m2)
# 2×2の行列
m3 = [
2 3;
4 5;
]
# install beautifulsoup4
# install ffmpeg-python
from bs4 import BeautifulSoup
import urllib.request
import ffmpeg
import re
import os
save_path = 'C:/Users/' # 保存先パス
url = 'http://example.com/' # スクレイピングするURL
@yuyosy
yuyosy / Main.sublime-menu
Created March 11, 2019 08:09
Sublime Text Menu (Japanese)
[
{
"caption": "File",
"mnemonic": "F",
"id": "file",
"children":
[
{ "command": "new_file", "caption": "新規作成(N)", "mnemonic": "N" },
{ "command": "prompt_open_file", "caption": "ファイルを開く(O)", "mnemonic": "O", "platform": "!OSX" },