Skip to content

Instantly share code, notes, and snippets.

Avatar

Dave Carroll dcarroll

View GitHub Profile
@dcarroll
dcarroll / NotDevHub.sh
Created Jul 28, 2017
Simple script to check if the org you are using is a Dev Hub. Run by passing a username or alias to the script.
View NotDevHub.sh
#!/bin/bash
# specify your username or alias
usernameOrAlias=$1
hub=$(sfdx force:data:soql:query -q "SELECT DurableId, SettingValue FROM OrganizationSettingsDetail WHERE SettingName = 'ScratchOrgManagementPref'" -t -u ${usernameOrAlias} --json)
# parse response
size="$(echo ${hub} | jq -r .result.size)"
View data-splitter.js
let fund = require("./data/dreaminvest-data-fund.json");
let plan = require("./data/dreaminvest-data-plan.json");
let records = fund.records;
let i,j,temparray = [],chunk = 200;
let fname = `data/dreaminvest-data-fund${i}d.json`;
let writeFile = function(name, contents) {
var fs = require('fs');
fs.writeFile(name, contents, function(err) {
View debug.sh
#!/bin/bash
while [ $# -gt 0 ]
do
echo $1
command=$command" "$1
shift
done
echo $command
node-debug.js <path to your toolbelt source code root>/debug.js "{ \"cmd\":\"$command\" }"
View debug.js
'use strict';
const path = require('path');
const cmds = require('./dist/index.js');
let cmd;
let flags;
const options = JSON.parse(process.argv[2].trim());
for (let i=0, len=cmds.commands.length; i<len; i++) {
View Uninstall SFDX Pilot Binary
#!/bin/sh
# NOTE: The pilot version included the Heroku CLI.
# Running the script will blow away ALL Heroku folders.
# You may need to reinstall the Heroku Toolbelt.
# NOTE: As with any script you download on the internet,
# please make sure you understand what each command is
# going to do before running it.
rm -rf /usr/local/heroku
View _authError.cshtml
@if (ViewBag.ErrorMessage == "AuthorizationRequired")
{
<p>You have to sign-in to @ViewBag.OperationName. Click <a href="@ViewBag.AuthorizationUrl" title="here">here</a> to sign-in.</p>
<p>@ViewBag.ErrorMessage</p>
}
View MyScheduler
global class MyScheduler implements Schedulable {
global void execute(SchedulableContext ctx) {
// The query used by the batch job.
String query = 'SELECT Id,CreatedDate FROM Merchandise__c ' +
'WHERE Id NOT IN (SELECT Merchandise__c FROM Line_Item__c)';
CleanUpRecords c = new CleanUpRecords(query);
Database.executeBatch(c);
}
View CreateMerchandiseData
public class CreateMerchandiseData {
public static void ClearMerchandiseDataBatch() {
String query = 'SELECT Id,CreatedDate FROM Merchandise__c ' +
'WHERE Id NOT IN (SELECT Merchandise__c FROM Line_Item__c)';
CleanUpRecords c = new CleanUpRecords(query);
Database.executeBatch(c);
}
public static void GenerateMerchandiseData() {
View CleanUpRecords
global class CleanUpRecords implements Database.Batchable<sObject> {
global final String query;
global CleanUpRecords(String q) {
query = q;
}
global Database.QueryLocator start(Database.BatchableContext bc) {
return Database.getQueryLocator(query);
}
You can’t perform that action at this time.