Skip to content

Instantly share code, notes, and snippets.

View kevinohara80's full-sized avatar

Kevin O'Hara kevinohara80

View GitHub Profile
@kevinohara80
kevinohara80 / gulpfile.js
Last active August 29, 2015 13:57
gulpfile.js
var gulp = require('gulp');
var jshint = require('gulp-jshint');
var stylish = require('jshint-stylish');
var mocha = require('gulp-mocha');
gulp.task('lint', function(){
return gulp.src(['./*.js', './lib/**/*.js', './models/**/*.js', './routes/**/*.js'])
.pipe(jshint('.jshintrc'))
.pipe(jshint.reporter('jshint-stylish'));
});
@kevinohara80
kevinohara80 / BasicTrigger.cls
Last active August 29, 2015 14:01
Basic trigger implementation - all contexts
trigger OpportunityTrigger on Opportunity (after insert, after update) {
if(Trigger.isAfter() && Trigger.isInsert()) {
OpportunityTriggerHandler.handleAfterInsert(Trigger.new);
} else if(Trigger.isAfter() && Trigger.isUpdate()) {
OpportunityTriggerHandler.handleAfterInsert(Trigger.new, Trigger.old);
}
}
<?xml version="1.0" encoding="UTF-8"?>
<!--
Salesforce.com Metadata API version 32.0
Copyright 2006-2014 Salesforce.com, inc. All Rights Reserved
-->
<definitions targetNamespace="http://soap.sforce.com/2006/04/metadata" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://soap.sforce.com/2006/04/metadata">
<types>
<xsd:schema elementFormDefault="qualified" targetNamespace="http://soap.sforce.com/2006/04/metadata">
<xsd:complexType name="CancelDeployResult">
@kevinohara80
kevinohara80 / dmc-semantics.md
Last active August 29, 2015 14:22
dmc globbing semantics proposal

dmc globbing semantics proposal

The goal of dmc is to provide a "file-sytem-like" command line api for salesforce.com metadata deploys and retrieves. The original goal was to allow simple globbing patterns to select the metadata to deploy as well as the metadata to retrieve. It was looking something like this...

Deploys:

@kevinohara80
kevinohara80 / benchmark.js
Created December 22, 2011 18:47
Javascript eval() benchmark
/* Test Eval */
var eval_string = 'var x = 1;'
+ 'if(x >= 1) {'
+ ' var y = x * 2;'
+ ' if(y==3) { y=3; }'
+ '}';
@kevinohara80
kevinohara80 / MergeTool.cls
Created January 18, 2012 21:05
Mustache merge class for Salesforce
public class MergeTool {
public static String mustacheMerge(String text, SObject obj) {
String p = '\\{\\{([^\\{\\}]*?)\\}\\}';
Pattern patt = Pattern.compile(p);
Matcher mat = patt.matcher(text);
Boolean foundValue = mat.find();
@kevinohara80
kevinohara80 / app.js
Created May 15, 2012 00:02
node.js proxy to salesforce REST
var fs = require('fs');
var bouncy = require('bouncy');
// load up your instance and port into environment variables
var instance = (process.env.instance) ? process.instance.env : 'na1';
var port = (process.env.port) ? process.env.port : 443;
// self-signed certificate created with openssl
var opts = {
key : fs.readFileSync(__dirname + '/key.pem'),
@kevinohara80
kevinohara80 / google.sh
Created July 25, 2012 17:16
Silly bash script so you can google something from the command line in Mac OSX
#!/bin/bash
QUERY="$(perl -MURI::Escape -e 'print uri_escape($ARGV[0]);' "$1")"
URL="https://www.google.com/search?q=$QUERY"
open $URL
@kevinohara80
kevinohara80 / app.js
Created September 7, 2012 20:38
Simple nested callback example
var express = require('express');
var request = require('request');
var app = module.exports = express();
app.configure(function() {
app.use(express.bodyParser());
app.use(express.methodOverride());
app.use(app.router);
});
@kevinohara80
kevinohara80 / app.js
Created October 31, 2012 15:38
Move socket.io setup to module for express 3.x
var app = express();
var server = require('http').createServer(app);
var io = require('./ioinit')(server);
server.listen(80);