Skip to content

Instantly share code, notes, and snippets.

View Amakata's full-sized avatar

Yoshihisa Amakata Amakata

View GitHub Profile
@Amakata
Amakata / gist:b902bdd5cf0b45b5fcf50bd4ac76fd5e
Last active April 13, 2018 20:53
macでiscisi経由でntfsを編集できるようにする。
# System Integrity Protection 解除
事前にリカバリモードでSystem Integrity Protectionを解除
```
csrutil disable
```
作業がおわったら
```
csrutil enable
```
@Amakata
Amakata / pandoc-filter.sh
Created August 29, 2017 15:32
pandocのfilter Tableのwidthを0でリセットするをjqで記述
jq '(.blocks[] | select(.t == "Table") .c[2]) |= [0,0,0]'
@Amakata
Amakata / setIsSuperMode.php
Created August 28, 2017 06:10
Magentoで、カートから注文にデータ変換するところで、設定可能商品の子商品が明細に出ちゃう問題への対策は、setIsSuperModeを呼ぶこと
$parent->getProduct()->setIsSuperMode(true);
@Amakata
Amakata / add_attribute_option_value.php
Created August 28, 2017 06:02
属性のオプション値がなければオプション値を追加をセットアップスクリプトじゃないところでしたい場合
$attribute_code = '';
$value = '';
$attribute = Mage::getSingleton('eav/config')->getAttribute(Mage_Catalog_Model_Product::ENTITY, $attribute_code);
if (in_array($attribute->getFrontendInput(), array('select')) && strlen($value) > 0) {
$values = Mage::getResourceModel('eav/entity_attribute_option_collection')->setAttributeFilter(
$attribute->getId())
->setStoreFilter()
->addFieldToFilter('tdv.value', array('in' => $value))
->load();
@Amakata
Amakata / release.sh
Created August 28, 2017 05:55
CircleCIからGithubのReleaseにファイルをアップロードするスクリプト
#!/usr/bin/env bash
# 既にタグが存在していればそのURLを抽出
UPLOAD_URL=`curl -s -H "Authorization: token $GITHUB_ACCESS_TOKEN" https://api.github.com/repos/$CIRCLE_PROJECT_USERNAME/$CIRCLE_PROJECT_REPONAME/releases|jq "map(select(.tag_name == \"v$CIRCLE_BUILD_NUM\")) | .[].upload_url" | sed -e 's/{?name,label}/?name=/g' | sed -e 's/"//g'`
# タグが存在していなければ、新規タグを作成する
if [ -z ${UPLOAD_URL} ]; then
API_JSON=$(printf '{"tag_name": "v%s","target_commitish": "master","%s": "v%s","body": "Release of version %s","draft": true,"prerelease": false}' $CIRCLE_BUILD_NUM $CIRCLE_BRANCH $CIRCLE_BUILD_NUM $CIRCLE_BUILD_NUM)
echo $API_JSON
UPLOAD_URL=`curl -s -H "Authorization: token $GITHUB_ACCESS_TOKEN" --data "$API_JSON" https://api.github.com/repos/$CIRCLE_PROJECT_USERNAME/$CIRCLE_PROJECT_REPONAME/releases | jq '.upload_url' | sed -e 's/{?name,label}/?name=/g' | sed -e 's/"//g'`
fi
@Amakata
Amakata / core_resource_iterator.php
Last active August 28, 2017 06:06
Magentoで商品Collectionでmemory limitを超えてしまったら
```
$handler = fopen($file, 'w+');
$encoding = 'SJIS';
$attributeCodes = array('price','name');
$collection = Mage::getResourceModel('catalog/product_collection');
// * はjoinしないので使えない $collection->addAttributeToSelect('*');
foreach ($attributeCodes as $attributeCode) {
// $collection->addAttributeToSelect($attributeCodes, 'left'); は1.9では使えない
$collection->addAttributeToSelect($attributeCode, 'left'); // leftにしないと属性が無い場合に取得できない
}
@Amakata
Amakata / example.sh
Created March 23, 2017 13:53
shのお勉強
#!/bin/sh
# コマンドでエラーが返ってきた時点で停止
set -e
# 1つめの引数に-が含まれている場合 ${variable#pattern}で、variableの値の最初の部分とpatternが一致した場合に、最も短く一致した部分を削除して、残りを返す。
if [ "${1#-}" != "$1" ]; then
# set -- a b は、 --の後のパラメータを$1,$2,...に格納し直す
# "$@"は、$1 $2 $3 ... を "$1" "$2" "$3" という感じの形式に変換する
set -- php "$@"
@Amakata
Amakata / gist:649ff9028fe63068ae99e3e7f3b43207
Created January 2, 2017 08:43
kpeg ダブルクオートで囲った文字列
```
# ダブルクオートで囲った文字列
# バックスラッシュ記法できる文字
# 「\"」 ダブルクオート
# 「\n」 改行
# 「\r」 キャリッジリターン
# 「\t」 タブ
# 「\v」 垂直タブ
# 「\f」 改ページ
# 「\b」 バックスペース
@Amakata
Amakata / gist:c89f7db9ec17215ca365f0b1c50b79ff
Created December 31, 2016 13:16
kpegでシングルクオート文字列をparse
```
# クオートで囲った文字列 クオートの中で「\'」を使うことで「'」表現することができる。「\\」を使うことで「\」を表現することができる。
QuoteString = "'" QuoteStringElement+:cc "'" { cc.join }
QuoteStringElement = ( QuoteStringSingleQuote
| QuoteStringBackslash
| QuoteStringOtherchar
)
QuoteStringSingleQuote = "\\'" { "'" }
QuoteStringBackslash = "\\\\" { "\\" }
QuoteStringOtherchar = < /[^']/ > { text }
@Amakata
Amakata / atom.md
Last active August 15, 2016 07:16
Atom

package install

共通

apm install platformio-ide-terminal
apm install japanese-menu
apm install file-icons
apm install markdown-preview-plus
apm install file-types
apm install minimap