Skip to content

Instantly share code, notes, and snippets.

View cdcarter's full-sized avatar

Christian Carter cdcarter

View GitHub Profile
@cdcarter
cdcarter / 01-the-app.md
Created December 31, 2010 04:00
couchapp_blog

CouchDb, CouchApps, Restful Asynchronous JavaScript, node.js, oh my!

This gist serves to be a tutorial or maybe a blog about building an application using all these mumbo jumbo new technologies that everyone around the world seems to love. We're going to start by implementing an application using only server-side javascript on a CouchDB server with couchapp, grow up to some client-side JS, and then extend outward to node.js to deal with some things server-side JS on Couch can't handle. We'll show off couch views, more advanced server-side JS, authentication, replication, Couch via jQuery, redirections, and more.

The Application

One thing I've learned from the process of building this app is that you need to define your problem before you start going around trying to solve it, so we'll start the series with a quick definition of what we need to accomplish. We're building an application for ticket reservations for a small theater company. The theater gives out it's tickets for free, and as a result

@cdcarter
cdcarter / test.js
Created January 1, 2011 19:16
couchapp tests
function(app) {
module("main");
test("all should be good", function() {
ok(true, "all is good")
equal(app.db.name,"tickets")
})
}
@cdcarter
cdcarter / form_helper.rb
Created June 4, 2011 02:52
NS Form Helper Class
class FormHelper
attr_accessor :form
def initialize(nsform=nil)
@form = nsform
end
def length
form.numberOfRows
end
#! /usr/bin/env ruby
require 'rubygems'
require 'twilio-ruby'
@account_sid = 'AC2947631da1d0049dd4b73646a107f33b'
@auth_token = '' #twilio auth token
@phonenumber = '' #recipient phone
# set up a client to talk to the Twilio REST API
@cdcarter
cdcarter / duplicate ID
Created May 10, 2015 06:53
System.ListException: Duplicate id in list: 001j000000HUMDNAA5
Account acc = [Select Id from Account Where Id='001j000000HUMDN'];
Account acc2 = [Select Id from Account Where Id='001j000000HUMDN'];
acc.Type = 'Prospect';
acc2.Type = 'Other';
List<SObject> thelist = new List<Sobject>();
thelist.add(acc);
thelist.add(acc2);
update thelist;
- set OWD to Public Read Only
- Created a new profile called "My Marketing Users" with full CRUD on Campaign
- Created a Role called "production" and a role called "Sales"
- Created two new users, "Blah" and "Haha", in the "My Marketing User" profile, marketing user checked, and one assigned to each role.
- Created a picklist on Campaign name "ROle Sharing Rule" with two types: Sales and Production
- Created a new sharing rule for campaign name "Role Share" based on criteria RoleSharingRule=Sales to give Sales Role full access.
- waitied for "done" email
- Created a new sharing rule for campaign name "Role Share2" based on criteria RoleSharingRule=Production to give Productiob Role full access.
- waitied for "done" email
- created a new campaign of sharing rule Production as sysadmin
<apex:page Controller="FlowRedirectController">
<flow:interview name="RedirectFlow" interview="{!redirectTo}" finishLocation="{!finishLocation}" >
<!-- This Parameter is *required!* -->
<apex:param name="StartFlow" value="YOUR_FLOW_NAME_HERE" />
<!--
Any Params you need to pass into your flow.
<apex:param name="CaseId" value="{!CaseId}"/>
-->
</flow:interview>
</apex:page>
IF( ISBLANK(Parent.Parent.Parent.Parent.Name),
IF(ISBLANK(Parent.Parent.Parent.Name),
IF(ISBLANK(Parent.Parent.Name),
IF(ISBLANK(Parent.Name),
Name,
Parent.Name),
Parent.Parent.Name),
Parent.Parent.Parent.Name),
Parent.Parent.Parent.Parent.Name)
@cdcarter
cdcarter / map.jsf
Last active October 9, 2015 15:41
Custom Object Page Layout Map
<apex:page standardController="Venue__c">
<apex:map width="400px" height="400px" mapType="roadmap"
center="{!Venue__c.City__c},{!Venue__c.State__c}">
<apex:mapMarker title="{! Venue__c.Name }"
position="{!Venue__c.Street__c},{!Venue__c.City__c},{!Venue__c.State__c}"/>
</apex:map>
</apex:page>
@cdcarter
cdcarter / .gitignore
Created October 15, 2015 17:40
mavensmate gitignore
config/
*.sublime-*
.gitignore
apex-scripts/*
deploy/
*DS_Store*