Skip to content

Instantly share code, notes, and snippets.

View tehnrd's full-sized avatar

Jason Venable tehnrd

View GitHub Profile
@tehnrd
tehnrd / .js
Last active February 2, 2023 17:15
Node.js script to count number of unique values in a very large CSV file
const Papa = require("papaparse");
const fs = require("fs");
const FILE_NAME = "leads_modified_last7_days.csv";
const COLUMN_NAME = "LastModifiedById";
const file = fs.createReadStream(FILE_NAME);
const createdByIdCount = {};
let count = 0;
@tehnrd
tehnrd / gist:eea95073ea54fed7a2b8dc0c45634cae
Created January 29, 2023 16:28
Apex SOQL only Createable Fields
List<Schema.SObjectField> flds = Schema.sObjectType.Lead.fields.getmap().values();
List<String> selectFields = new List<String>();
for (Schema.SObjectField fld : flds) {
Schema.DescribeFieldResult fldDesc = fld.getDescribe();
if (fldDesc.isCreateable() == true) {
selectFields.add(fldDesc.getName());
}
}
@tehnrd
tehnrd / gist:57b2915210d776a15998
Created January 29, 2015 13:55
Convert Census Response to Objects
convertCensusResToObject: function(arrayResponse){
//The first row is always going to the the headers/keys
var headers = arrayResponse[0];
//Define array that will contain results as javascript objects
var objectResponse = [];
//Loop through the "rows" of data, start at index 1 as 0 is header row
for(var i = 1; i < arrayResponse.length; i++){
// See the question in the callback function
function getContacts() {
var accountId;
//Some code that dynamically sets accountId would be here
$.get("/contacts.json?accountId=" + accountId, function( data ) { //This is an asynchronous callback function
/*This inside an anonymous function executing asynchronously in a seperate context from when getContacts()
@tehnrd
tehnrd / gist:9278218
Created February 28, 2014 19:39
iOS7 SF1 Crash
Feb 28 11:38:21 Jasons-iPhone Chatter[276] <Warning>: Received memory warning.
Feb 28 11:38:21 Jasons-iPhone MobileMail[268] <Notice>: 2014-02-28 11:38:21.616 MobileMail[268:43815]: The connection to ACDAccountStore was interrupted.
Feb 28 11:38:21 Jasons-iPhone MobileMail[268] <Notice>: 2014-02-28 11:38:21.622 MobileMail[268:43815]: The connection to ACDAccountStore was interrupted.
Feb 28 11:38:21 Jasons-iPhone MobileMail[268] <Notice>: xpc __securityd_create_connection_block_invoke got event: Connection interrupted
Feb 28 11:38:21 Jasons-iPhone apsd[81] <Notice>: xpc __securityd_create_connection_block_invoke got event: Connection interrupted
Feb 28 11:38:21 Jasons-iPhone kernel[0] <Debug>: ttyioss7000002: enqueueData rtn (e00002d7)
Feb 28 11:38:21 Jasons-iPhone com.apple.launchd[1] (com.apple.librariand[265]) <Notice>: (com.apple.librariand) Idle-exit job was jettisoned. Will bypass throttle interval for next on-demand launch.
Feb 28 11:38:21 Jasons-iPhone com.apple.launchd[1] (com.apple.librariand[265])
@tehnrd
tehnrd / gist:9242970
Last active June 12, 2017 20:00
Check to see if Visualforce page is inside Salesforce1
//Determin if this is SF1 app
public static Boolean isSF1(){
if(!Utils.checkNullOrBlank(ApexPages.currentPage().getParameters().get('sfdcIFrameHost')) ||
!Utils.checkNullOrBlank(ApexPages.currentPage().getParameters().get('sfdcIFrameOrigin')) ||
ApexPages.currentPage().getParameters().get('isdtp') == 'p1' ||
(ApexPages.currentPage().getParameters().get('retURL') != null && ApexPages.currentPage().getParameters().get('retURL').contains('projectone') )
){
return true;
}else{
return false;
@tehnrd
tehnrd / gist:4559623
Last active March 1, 2023 07:27
Getting values out of a JSON list of objects with Apex code.
List<Object> fieldList = (List<Object>)JSON.deserializeUntyped('[{"field":"phone","object":"account"},{"field":"name","object":"account"}]');
for(Object fld : fieldList){
Map<String,Object> data = (Map<String,Object>)fld;
//Magic!
system.debug(data.get('field'));
}
if(this is a condition)
}
then I should probably put brackets
}
else
{
all over the place
}
@tehnrd
tehnrd / .gitignore
Created October 13, 2012 19:58 — forked from mrlannigan/.gitignore
Node.js http timeout
node_modules
@tehnrd
tehnrd / gist:3870100
Created October 11, 2012 04:06
Node.js http timeout
var http = require('http');
var extensions = ['com', 'ac', 'ad', 'ae', 'com.af', 'com.ag', 'com.ai', 'am', 'it.ao',
'com.ar', 'as', 'at', 'com.au', 'az', 'ba', 'com.bd', 'be', 'bf', 'bg', 'com.bh', 'bi',
'bj', 'com.bn', 'com.bo', 'com.br', 'bs', 'co.bw', 'com.by', 'com.bz', 'ca', 'com.kh',
'cc', 'cd', 'cf', 'cat', 'cg', 'ch', 'ci', 'co.ck', 'cl', 'cm', 'cn', 'com.co', 'co.cr',
'com.cu', 'cv', 'cz', 'de', 'dj', 'dk', 'dm', 'com.do', 'dz', 'com.ec', 'ee', 'com.eg',
'es', 'com.et', 'fi', 'com.fj', 'fm', 'fr', 'ga', 'gd', 'ge', 'gf', 'gg', 'com.gh',
'com.gi', 'gl', 'gm', 'gp', 'gr', 'com.gt', 'gy', 'com.hk', 'hn', 'hr', 'ht', 'hu',
'co.id', 'iq', 'ie', 'co.il', 'im', 'co.in', 'io', 'is', 'it', 'je', 'com.jm', 'jo',
'co.jp', 'co.ke', 'com.kh', 'ki', 'kg', 'co.kr', 'com.kw', 'kz', 'la', 'com.lb',