Skip to content

Instantly share code, notes, and snippets.

View stomita's full-sized avatar

Shinichi Tomita stomita

View GitHub Profile
javascript:(function(d){__sfdcSessionId=d.cookie.match(/(^|;\s*)sid=(.+?);/)[2];d.body.appendChild(d.createElement('script')).src='/soap/ajax/18.0/connection.js';setTimeout("sforce.debug.open()",2000)})(document)
javascript:(function(d){d.body.appendChild(d.createElement('script')).src='/soap/ajax/18.0/connection.js';setTimeout(function(c,u,ui){c=sforce.connection;c.sessionId=d.cookie.match(/(^|;\s*)sid=(.+?);/)[2];u=new sforce.SObject('User');ui=c.getUserInfo();u.Id=ui.userId;u.LanguageLocaleKey=/ja/.test(ui.userLanguage)?'en_US':'ja';c.update([u]);location.reload()},1000)})(document)
@stomita
stomita / AccountAddressTrigger.trigger
Created November 16, 2010 12:45
AccountAddressTrigger.trigger
trigger AccountAddressTrigger on Account (before insert, before update) {
Pattern p = Pattern.compile('^\\s*〒?\\s*(\\d{3}\\-\\d{4})?\\s*(東京都|北海道|(?:京都|大阪)府|.{2,3}県)?\\s*(.[^市区町村]*[市区群町村])(.*\\s*.*)$');
for (Account acc : Trigger.new) {
if (Trigger.isUpdate) {
Account oldAcc = Trigger.oldMap.get(acc.Id);
if (oldAcc.Address__c == acc.Address__c) continue;
}
if (acc.Address__c == null) continue;
Matcher m = p.matcher(acc.Address__c);
if (m.find()) {
@stomita
stomita / SimpleSalesforceConnection.js
Created May 25, 2011 08:40
A Google Apps Script, which simply connects and fetches data from Salesforce RESTful API with OAuth authentication.
/**
* Connect and fetch Salesforce data via OAuth
*/
function queryDataFromSalesforce() {
// Read OAuth consumer key / secret of this client app from script properties,
// which can be issued from Salesforce's remote access setting in advance.
var sfConsumerKey = ScriptProperties.getProperty("sfConsumerKey");
var sfConsumerSecret = ScriptProperties.getProperty("sfConsumerSecret");
if (!sfConsumerKey || !sfConsumerSecret) {
Browser.msgBox("Register Salesforce OAuth Consumer Key and Secret in Script Properties");
/*global sforce:true */
(function() {
function loadScript(url, callback) {
var script = document.createElement('script');
script.type = 'text/javascript';
script.src = url;
if (callback) {
script.onload = callback;
script.onreadystatechange = function() {
#!/bin/sh
#
# This installation script is for creating environment of heroku buildpack of PhantomJS
# Assuming the script to be run on fakesu command by using fakesu buildpack.
# See. https://github.com/fabiokung/heroku-buildpack-fakesu
#
export PATH=/sbin:/usr/sbin:$PATH
cd /app/
#!/bin/sh
cd /app
SCRIPT=$1
PORT=$2
export DISPLAY=:1
Xvfb :1 -screen 0 1024x768x24 -nolisten tcp -shmem &
phantomjs $SCRIPT $PORT
curl https://raw.github.com/gist/1977632/install.sh -o ./install.sh
chmod 755 ./install.sh
fakesu -c $PWD/install.sh
#!/bin/sh
cd $1
shift
export DISPLAY=:1
phantomjs $@
#!/bin/sh
if ! [ -e $HOME/.root/tmp/.X1-lock ]; then
echo "X server not started. Starting..."
fakesu -c "Xvfb :1 -screen 0 1024x768x24 -nolisten tcp -shmem" &
fi
fakesu -c "phantomexec.sh $PWD $@"