Skip to content

Instantly share code, notes, and snippets.

Object a = 'あ';
Object b = 'ア';
System.assertEquals(true, a == b); // ←わかる
System.assertEquals(false, a.equals(b)); // => Assertion Failed ←は?
// Solution
System.assertEquals(false, ((String) a).equals(b));

Homebrew

macOSのコマンドラインツールなどをインストールしたりアップグレードしたりするパッケージマネージャです。

http://brew.sh/index_ja.html

インストールの前に

MacAppStoreからXcodeをインストールしてください。インストールしたら起動して、License Agreementに同意します。 Xcodeがバージョンアップするたびに同意が必要です。

@tarot
tarot / README.md
Created July 4, 2016 07:20 — forked from nicerobot/README.md
Mac OS X uninstall script for packaged install of node.js

To run this, you can try:

curl -ks https://gist.githubusercontent.com/nicerobot/2697848/raw/uninstall-node.sh | bash

I haven't tested this script doing it this way but i run a lot of my Gists like this so maybe this one'll work too.

Alternatively,

curl -ksO https://gist.githubusercontent.com/nicerobot/2697848/raw/uninstall-node.sh

chmod +x ./uninstall-node.sh

@tarot
tarot / CalloutJob.cls
Created February 1, 2016 16:28
QueueableとCalloutとTest
public class CalloutJob implements Queueable, Database.AllowsCallouts {
public void execute(QueueableContext context) {
String endpoint = 'https://trust.salesforce.com/';
HttpRequest req = new HttpRequest();
req.setMethod('GET');
req.setEndpoint(endpoint);
new Http().send(req);
}
@tarot
tarot / normalize_schemafile.rb
Created February 1, 2016 15:28
ridgepoleのSchemafileのカラムをソートするやつ(テーブルはソートされてる)
module SchemafileNormalizer
Table = Struct.new(:facing, :columns)
def self.normalize!(filename)
src = File.open(filename) { |io| io.read }
File.open(filename, 'w') { |io| io.write(sort_column(src)) }
end
def self.sort_column(src)
src.each_line.with_object([Table.new([], [])]) { |line, a|
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
class ApplicationController < ActionController::Base
rescue_from StandardError, with: :error500
def error500
respond_to do |format|
format.json { render json: {message: 'Internal Server Error'}, status: :internal_server_error }
# ↓こいつのContent-Typeをtext/htmlに固定したい
format.any { render 'error500', formats: :html, status: :internal_server_error }
end
end
module Tokenizable
extend ActiveSupport::Concern
module ClassMethods
def from_token(token)
row = Rails.cache.read(token).try { |id| find_by_id(id) }
Rails.cache.write(token, row.id, expires_in: 2.hours.to_i) if row.present?
row
end
end
@tarot
tarot / a.rb
Created October 30, 2015 14:40
class Parent < ActiveRecord::Base
# t.string name
has_many :children
end
class Child < ActiveRecord::Base
# t.integer parent_id
# t.boolean hide_parent
belongs_to :parent
@IsTest
private class CalloutSampleTest {
public class CalloutMock implements HttpCallout.Service {
public HttpResponse respond(HttpRequest req) {
return new HttpResponse();
}
}
@IsTest