Skip to content

Instantly share code, notes, and snippets.

@tarot
tarot / sample.page
Created July 30, 2015 08:04
ページ内の最初の利用がinputField/outputFieldだった変数は、そのページ内ではObject型として扱われる模様。なんでもいいから先にinputField/outputField以外で出力すれば通った
<apex:page standardController="Account">
<div style="display: none;">{!Account.CreatedDate}</div>
<apex:outputField value="{!Account.CreatedDate}"/>
<apex:outputText value="{0,date}">
<apex:param value="{!Account.CreatedDate}"/>
</apex:outputText>
</apex:page>
@tarot
tarot / FindHelper.cls
Last active July 8, 2016 02:36
PicklistとMultiPicklistとTextかTextAreaな数式項目の値を、指定したLongTextArea項目に連結してコピーする。SOSLはこれらの項目を検索できないので。トランスレーションには無力(最後に更新した時のユーザ言語で保存される)。`NOW()`関数や親レコードを参照する数式にも無力(最後に更新した時の値で保存される)
public without sharing class FindHelper {
private static Map<Schema.SObjectType, Schema.SObjectField[]> fieldCache = new Map<Schema.SObjectType, Schema.SObjectField[]>();
public static void beforeSave(SObject[] xs, Schema.SObjectField searchField) {
Schema.SObjectField[] copyingFields = copyingFieldsOf(xs.getSObjectType());
Integer length = searchField.getDescribe().getLength();
for (SObject e : xs) {
putSearchField(e, copyingFields, searchField, length);
}
@tarot
tarot / Readme.md
Last active February 28, 2018 13:21
rails, postgres, redis, hipchat-notify, heroku-deployなwercker.yml

Werckerの設定

Environment variables

hipchat-notify用の設定。werckerのApplication Settings (右上の歯車アイコン) → Environment variables から、HIPCHAT_TOKENHIPCHAT_ROOM_IDを追加する。

@tarot
tarot / reduce.js
Created August 17, 2015 04:18
you can't javascript under pressure #5
function(i) {
var fn = function(sum, e) {
if (typeof e === typeof 0) return sum + e;
if (e instanceof Array) return e.reduce(fn, sum);
return sum;
};
return i.reduce(fn, 0);
};
@tarot
tarot / myfirstltng.cmp
Last active September 22, 2015 08:11
<aura:component implements="force:appHostable" controller="myfirstltngController">
<aura:attribute name="account" type="Account"/>
<aura:handler name="init" action="{!c.init}" value="{!this}"/>
{!v.account.Name}
<button onclick="{!c.save}">click</button>
</aura:component>
@tarot
tarot / alert.js
Last active September 24, 2015 12:29
document.querySelector('#phHeaderLogoImage').src = 'http://pic.prepics-cdn.com/f2de00c74d43/17946611.jpeg'
@tarot
tarot / normalize.rake
Last active October 6, 2015 19:44
空配列と空ハッシュで改行しないJSON.pretty_generate 先にjson/extがロードされてても大丈夫版
require 'json'
require 'json/pure/generator'
module Generator
module GeneratorMethods
(JSON::Pure::Generator::GeneratorMethods.constants - %i(Array Hash Integer)).each do |constant|
const_set constant, JSON::Pure::Generator::GeneratorMethods.const_get(constant)
end
%i(Fixnum Bignum).each do |constant|
@tarot
tarot / normalize.rake
Created October 6, 2015 19:52
空配列と空ハッシュで改行しないJSON.pretty_generate モンキーパッチ版
require 'json'
require 'json/pure/generator'
module JSON::Pure::Generator::GeneratorMethods
%i(Fixnum Bignum).each do |constant|
const_set constant, Integer
end
module Array
alias_method :pure_to_json, :to_json
@tarot
tarot / ABC.keylayout
Last active October 11, 2015 15:39
Option, Option+Shiftのレイアウトをブランクに設定したやつ。あと¥を\にしてる。
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE keyboard PUBLIC "" "file://localhost/System/Library/DTDs/KeyboardLayout.dtd">
<!--Created by Ukelele version 2.2.8 on 2015-10-11 at 20:11 (JST)-->
<!--Last edited by Ukelele version 2.2.8 on 2015-10-12 at 00:37 (JST)-->
<keyboard group="0" id="11413" name="ABC (option keystrokes blank)" maxout="1">
<layouts>
<layout first="0" last="17" modifiers="f4" mapSet="16c"/>
<layout first="18" last="18" modifiers="f4" mapSet="984"/>
<layout first="21" last="23" modifiers="f4" mapSet="984"/>
<layout first="30" last="30" modifiers="f4" mapSet="984"/>
@tarot
tarot / a.rb
Last active October 12, 2015 00:14
_typeがサブクラスを指すようにしたい。
class Picture < ActiveRecord::Base
belongs_to :imageable, polymorphic: true
end
class Product < ActiveRecord::Base
end
class PublicProduct < Product
has_one :picture, as: :imageable
end