2018-01-01から1年間の記事一覧

Nuxt.js でredirect

middleware/redirect.js export default function({ route, redirect }) { const currentPath = route.path; if (currentPath === '/') { redirect('/jp'); return; } } nuxt.config.js router: { middleware: 'redirect' }, ref NuxtをSPAモードで動かすと…

新規Railsプロジェクトの作成手順のメモ

$ mkdir project_name $ cd project_name $ bundle init $ echo "gem 'rails'" >> Gemfile $ bundle install --path vendor/bundle --jobs=4 $ bundle exec rails new . -B -d mysql --skip-turbolinks --skip-test --api # -B: bundle installを行わないよ…

linuxのサーバでcronでコマンドを定期実行する

cron は決められた時間にコマンドを実行するデーモン(Unix系のOSで、主にバックグラウンドで動作するプロセス) ユーザーが直接コマンドをプロンプトに入力しなくても希望の時間に特定のコマンドを実行するための仕組み cronはデーモンとしてシステム起動時に…

Trello APIで特定のboardのlabelを削除する

背景 trello のボードを整理したくて、labelを削除しようと思ったけど、量が多すぎて萎えて、scriptでやろうと思った コード require 'trello' require 'dotenv' Dotenv.load Trello.configure do |config| config.consumer_key = ENV['TRELLO_CONSUMER_KEY'…

Swift ざっくり文法 (4)

Class import Foundation class Myclass { let msg:String let name:String? init(msg:String = "hello") { self.msg = msg self.name = nil } init(msg:String = "hello", name:String) { self.msg = msg self.name = name } func hello() { var helloMsg:S…

Swift ざっくり文法 (3)

関数定義 func dice() -> Int { let num = 1 + arc4random_uniform(6) return Int(num) } // メソッド定義(戻り値がない関数をメソッドと呼ぶ) func hello() { print("hello") } or func hello() -> Void { print("hello") } guard-else ( 条件を満たさな…

Swift ざっくり文法 (2)

Tuple ( タプル ) let product: (String, Int) = ("Swift", 2015) let kingaku = (1000, 80) // 型推論で(Int, Int)に決まる kingaku = (1060, "hoge") // error: cannot call value of non-function type '(Int, Int)' let data = (1000, 80) let (price, _…

Swift ざっくり文法 (1)

statement 区切りは、; か改行 ; 付けないことが一般的 print print("blue", "green", separator: "+", terminator: ",") print("yellow", terminator: ",") print("red") // blue+green,yellow,red print(#file) // MyPlayground.playground print(#line) /…

SwiftのOptionalまわりについて

Swiftの変数・定数はnilが発生しないようになっていて、nilを代入したい変数は、型をOptional型にする必要がある。 String?のように型の後ろに?をつけるとnilを代入できるOptional型にWrapされる let nums = [3, 4, 6] let lastNum = nums.last let ans = la…

随時更新!! Xcode shortcutまとめ

Xcode --- shortcut New Project command + shift + n New Playground option + command + shift + n Tool Bar command + option + t Navigation command + 0 Debug Area shift + command + y Utility Area command + option + 0 Modify Indentation ctrl + …

随時更新!! AWS S3 cli のよく使うコマンドまとめ

s3にあるオブジェクトの総量を見たい時 $ aws s3 ls --summarize --human-readable --recursive s3://<backet name> --- Total Objects: 21887 Total Size: 2.7 GiB s3にディレクトリを同期 $ aws s3 sync <local path> s3://<s3 backet> --exact-timestamps reference from http://www.task-note</s3></local></backet>…

随時更新!! やってそうでやってなかったchromeのデバッグ手法

chromeでdebugするときどういう機能を使ってデバックしていますでしょうか?自分は基本、debugger とconsoleくらいしか使っていません。この記事では、目についたやってなかったchromeのデバッグ手法を随時追記していきます。 条件的breakpoint source panel…

知ってそうで知らなかったJavascript

最近いろいろvueとかreactとか触っているときにそもそも自分はJavascriptがわかっているのかと不安になったので、以下のチュートリアルをやってみた。なんとなくわかるけど、明確に言語化できていなかったところをまとめた。 javascript.info Strict mode wh…

随時更新!!vim でよくやることまとめ!

vimで複数行の先頭に文字列追加 Ctrl + v -> 該当の行頭選択 -> Shift + i -> 文字列追加 -> ESC reference from http://itengine.seesaa.net/article/442698942.html

node でdebugしたいとき!!

$ node inspect index.js reference from https://nodejs.org/api/debugger.html

Automated testing with mocha / mocha 触ってみた

install Install with npm globally: $ npm install --global mocha npm install --save-dev mocha mocha とは Mocha is a feature-rich JavaScript test framework テスト全体を取りまとめて管理したり、画面に表示したりするためのもの chaiとの違い chai…

よく使うUNIXコマンド

user 確認 $ cat /etc/passwd linux log確認 $ cat /var/log/secure directory内のファイル数確認 $ ls -U1 | wc -l ref https://orebibou.com/2015/06/linux%E3%81%A7%E3%83%A6%E3%83%BC%E3%82%B6%E3%81%AE%E8%BF%BD%E5%8A%A0%E3%83%BB%E5%89%8A%E9%99%A4%E…

Bootstrap ざっと全容把握

Bootstrapとは? the world’s most popular framework for building responsive, mobile-first sites 要は結構有名なCSS framework frameworkと、design pattern (atomic designとか) Design pattern is a category of patterns that deals with object orie…