Skip to content

Instantly share code, notes, and snippets.

View lukethacoder's full-sized avatar
🤔
working on non-code projects

Luke Secomb lukethacoder

🤔
working on non-code projects
View GitHub Profile
@lukethacoder
lukethacoder / up-accounts-usage.md
Last active August 12, 2020 11:18
Google Sheets Function for fetching Accounts and their current values

Up Accounts API

  1. Create a new Sheet (or use an existing one)
  2. Tools -> Script Editor
  3. Copy + Paste the attached .js code snippet (Save)
  4. Back on the sheet, paste in =FetchAccounts("up:yeah:THE_REST_OF_YOUR_TOKEN_HERE", 0)
  5. Profit

Don't have an API token, get one here.

@lukethacoder
lukethacoder / remove-duplicates-by-field-name.js
Created August 16, 2020 13:15
Remove duplicate Objects within an array by specific field value
function removeDuplicateObjectsByKey(array, fieldToDuplicateCheck) {
const newArray = []
const arrayKeys = []
array.forEach((item) => {
// check if we don't already have the value within the arrayKeys array
if (!arrayKeys.includes(item[fieldToDuplicateCheck])) {
// push this value to the arrayKeys array
arrayKeys.push(item[fieldToDuplicateCheck])
// push this object to the newArray array
@lukethacoder
lukethacoder / line-awesome-array-objects.json
Last active August 16, 2020 13:53
List Awesome Font Library - class name by unicode, handy for running a custom icon search. https://icons8.com/line-awesome
[
{
"name": "accessible-icon",
"type": "lab",
"unicode": ""
},
{
"name": "american-sign-language-interpreting",
"type": "la",
"unicode": ""
@lukethacoder
lukethacoder / inverse-object-keys-and-values.ts
Created September 10, 2020 03:55
Inverse the Object keys/values
/**
* @description Inverse the Object keys/values
* @param {object} obj
*/
export function inverseObjectKeysAndValues(obj: { [key: string]: any }) {
return Object.keys(obj).reduce(
(acc, curr) => ({
...acc,
[obj[curr].toString()]: curr,
}),
@lukethacoder
lukethacoder / communities.cls
Last active October 6, 2020 23:06
snippet to get a list of Salesforce Communities in APEX
List<Network> communities = [ SELECT Id, Name, UrlPathPrefix, Status FROM Network ];
for (Network community : communities) {
System.debug(community.Name + ': ' + community);
}
// or via Connect API
List<ConnectApi.Community> communitiesConnect = ConnectApi.Communities.getCommunities().communities;
for ( ConnectApi.Community community : communitiesConnect) {
@lukethacoder
lukethacoder / upload-sql-db.sh
Created November 6, 2020 00:57
Upload MySQL DB via cli
mysql -u username -p database_name < file.sql
@lukethacoder
lukethacoder / content-editable.js
Created December 23, 2020 01:42
JS - make every element on a page editable
document.querySelectorAll('*').forEach(el => el.contentEditable = true)
@lukethacoder
lukethacoder / abn-entity-types-by-code.json
Created December 29, 2020 05:46
ABN Entity Types array with Code and Nice Name
[
{
"code": "PUB",
"label": "Australian Public Company"
},
{
"code": "PRV",
"label": "Australian Private Company"
},
{
@lukethacoder
lukethacoder / apex-picklist-values.cls
Created January 7, 2021 23:27
APEX: Get a list of picklist values (PicklistEntry) objects in Apex Salesforce
List<PicklistEntry> fields = Account.SObjectType.getDescribe().fields.getMap().get('Type').getDescribe().getPicklistValues();
for (PicklistEntry picklistEntry : fields) {
System.debug(picklistEntry.getLabel() + ' with value: ' + picklistEntry.getValue());
}
@lukethacoder
lukethacoder / datetime-as-local.cls
Created January 29, 2021 06:04
APEX: Datetime as Local (SF)
Datetime.valueOfGmt(String.valueOf(Datetime.now()));