Skip to content

Instantly share code, notes, and snippets.

# Your init script
#
# Atom will evaluate this file each time a new window is opened. It is run
# after packages are loaded/activated and after the previous editor state
# has been restored.
#
# An example hack to log to the console when each text editor is saved.
#
# atom.workspace.observeTextEditors (editor) ->
# editor.onDidSave ->
@maztak
maztak / mw-wp-form-error-pink.css
Last active December 1, 2018 14:35
MW WP Formのエラー項目にerror-pinkクラスを適用
.form-div p.error-pink input[type="text"],
.form-div p.error-pink input[type="email"],
.form-div p.error-pink input[type="tel"],
.form-div p.error-pink input[type="url"] {
background: pink !important;
}
// 絞り込み検索用カスタマイズ
// キーワード検索
$s = $_GET['s'];
// チェックボックス(栄養素)
$nutrient = $_GET['nutrient'];
if($nutrient){ // 通常の検索フォームなど$nutrientのクエリが存在しない時はmetaqueryspに追加しない
foreach($nutrient as $val){
$metaquerysp[] = array(
'key'=>'nutrient',
@maztak
maztak / file0.txt
Last active October 24, 2018 16:11
UIViewにActionClosurableを使ってタッチイベントを付ける方法 ref: https://qiita.com/takuya108817/items/0a10e719e88920ea2623
func addTapGesture(action: @escaping () -> Void) {
let tapGesture = UITapGestureRecognizer { (gr) in
print("UITapGestureRecognizer fire")
switch gr.state {
case .ended:
self.backgroundColor = UIColor.clear
action()
default:
return
}
@maztak
maztak / code_and_tips_in_ruby
Created September 6, 2018 07:21
RubyでTweetAppを作る際の雛形・備忘録
▶︎routes
get "posts/:id" => "posts#show"
これでposts/の次に何をいれてもshowが表示される
▶︎これでURLを叩くと・・・
sample.com/posts/1
→この1が :id として認識(取得)される
→ハッシュ(Swiftでいう辞書)pramsに{id: 1}が格納される(routesがやってるのか?)
→ハッシュの値へのアクセスはdies{:キー名}なので、controller側で params[:id]と書けば、この場合は「1」が取得できる
@maztak
maztak / file0.swift
Last active February 17, 2019 16:27
なんJ語で学ぶSwiftのdelegate(デリゲート) ref: https://qiita.com/maztak/items/98cfb215c16dd877c382
//ゲームの代理人規約(代理人は以下のメソッドを持たねばならない)
protocol GameDelegate: class {
func cleanPlayground(_ game: Game) //gameのグランドを清掃するメソッド
}
//グランド清掃役の代理人として、仕事が早いSpeedCleanerDelegateさんを用意しとく
class SpeedCleanerDelegate: GameDelegate {
func cleanPlayground(_ game: Game) {
@maztak
maztak / file0.swift
Last active August 26, 2019 15:24
Swiftのクロージャによるコールバックの説明 ref: https://qiita.com/maztak/items/ac668f5d8a47a46b8cb5
class Game {
var score = 0
func start(completion: (Int) -> Void) { // 呼び出し先であるメソッド
score = arc4random() % 10 // 0から9までの値をランダムで代入
completion(score) // ここでバックする(呼び出し元に引数scoreを渡して処理を実行してもらう)
}
}