Skip to content

Instantly share code, notes, and snippets.

View enreeco's full-sized avatar
☁️
Salesforcing...

Enrico Murru enreeco

☁️
Salesforcing...
View GitHub Profile
@enreeco
enreeco / ExpressJS rawBody
Last active August 7, 2016 17:37
NodeJS ExpressJS Getting Raw Body on request object
app.configure(function() {
//. . .
app.use(express.bodyParser());
app.use(function(req, res, next) {
var data = '';
req.setEncoding('utf8');
req.on('data', function(chunk) {
data += chunk;
});
req.on('end', function() {
C.SF ={
LoginURL : 'https://login.salesforce.com/services/oauth2/token',
Username : process.env.SF_USERNAME,
Password : process.env.SF_PASSWORD,
ClientID : process.env.SF_CLIENTID,
ClientSecret : process.env.SF_CLIENTSECRET,
}
var options = {
//http://www.salesforce.com/us/developer/docs/api_rest/index_Left.htm#CSHID=quickstart_oauth.htm|StartTopic=Content%2Fquickstart_oauth.htm|SkinName=webhelp
@enreeco
enreeco / NodeJS SOAP modulo with SF
Created January 22, 2014 16:35
Use SOAP module on NodeJS to consume salesforce WSDL
function test(callback){
soap.createClient('./partner.wsdl', function(err, client) {
console.log('\t\tLogging in on Salesforce...');
client.login({username: C.SF.Username,password: C.SF.Password},function(err,result,raw){
console.log('\t\tDone.');
if(err){
console.log(error);
return callback(error);
}
var mongoose = require('./index')
, TempSchema = new mongoose.Schema({
salutation: {type: String, enum: ['Mr.', 'Mrs.', 'Ms.']}
});
var Temp = mongoose.model('Temp', TempSchema);
console.log(Temp.schema.path('salutation').enumValues);
var temp = new Temp();
console.log(temp.schema.path('salutation').enumValues);
// to get the current latitude and longitude from browser
// credits https://github.com/arunisrael/angularjs-geolocation
'use strict';
angular.module('geolocation',[]).constant('geolocation_msgs', {
'errors.location.unsupportedBrowser':'Browser does not support location services',
'errors.location.notFound':'Unable to determine your location',
});
angular.module('geolocation')
@enreeco
enreeco / Salesforce Apex Get Running batch
Created September 29, 2014 15:02
Apex - Are there batch jobs running with a given name?
public static Boolean isThereABatchRunningWithName(String batchClassName){
List<AsyncApexJob> jobs = [Select ApexClass.Name,JobType From AsyncApexJob
Where Status IN ('Queued','Processing','Preparing')
and ApexClass.Name = :batchClassName limit 1];
return jobs.isEmpty()==false;
}
@enreeco
enreeco / Salesforce Apex Get Stacktrace
Created September 29, 2014 15:03
Apex - Gets stacktrace of exception
public static String getStackTraceFromException(Exception e){
return e.getStackTraceString().replace('\n',' | ')+' | '+e.getMessage().replace('\n',' ');
}
@enreeco
enreeco / angularjs table
Created September 29, 2014 16:24
AngularJS fully functional table
<html>
<head>
<style>
.active-link{
font-weight: bold;
color: blue;
cursor: pointer;
}
</style>

Typography

Headings

Headings from h1 through h6 are constructed with a # for each level:

# h1 Heading
## h2 Heading
### h3 Heading