Skip to content

Instantly share code, notes, and snippets.

View mchang-r7's full-sized avatar

Marty Chang (Rapid7) mchang-r7

View GitHub Profile
@mchang-r7
mchang-r7 / .bash_profile
Created July 16, 2017 15:17
Git-friendly Terminal on Mac OS X
# Git shell
# https://gist.github.com/trey/2722934
source /Applications/Xcode.app/Contents/Developer/usr/share/git-core/git-completion.bash
source /Applications/Xcode.app/Contents/Developer/usr/share/git-core/git-prompt.sh
GIT_PS1_SHOWDIRTYSTATE=true
GIT_PS1_SHOWCOLORHINTS=true
export PS1='\[\033[0;36m\]\u@\h\[\033[0;35m\]:\[\033[0;33m\]\w\[\033[0;37m\]$(__git_ps1)\[\033[0m\]\n\$ '
@mchang-r7
mchang-r7 / revokeProfilePermissionsSfdcClassic.js
Created January 5, 2018 14:23
Revoke profile permissions in Salesforce Classic
var inputs = document.getElementsByTagName('input');
for (var i = 0; i < inputs.length; i++) {
var input = inputs[i];
// Clear user permissions
if (input.id.startsWith('userPerm___')) {
if (input.checked) {
input.click();
}
@mchang-r7
mchang-r7 / ReassignProfileJob.class
Created January 8, 2018 19:57
Reassign users from old profile to new profile with anonymous Apex
private class ReassignProfileJob {
private String oldProfileName;
private String newProfileName;
public ReassignProfileJob(String oldProfileName, String newProfileName) {
this.oldProfileName = oldProfileName;
this.newProfileName = newProfileName;
}
@mchang-r7
mchang-r7 / dumpCountriesAndStatesCsv.js
Created January 16, 2018 17:50
Export state and country picklists as CSV files from Salesforce by using the Chrome Developer Console to parse the XML in Address.settings
// Step 1, store the XML in a string
// Replace the string with the actual, full XML content copied as-is
// from Address.settings
var xml = '...';
// Step 2, parse the XML
// See https://www.w3schools.com/xml/xml_parser.asp
var parser = new DOMParser();
var xmlDoc = parser.parseFromString(xml, "text/xml");
@mchang-r7
mchang-r7 / ReassignUserRoleJob.java
Created January 28, 2018 18:16
Reassign users from old user role to new user role with anonymous Apex
private class ReassignUserRoleJob {
private String oldUserRoleName;
private String newUserRoleName;
public ReassignUserRoleJob(String oldUserRoleName, String newUserRoleName) {
this.oldUserRoleName = oldUserRoleName;
this.newUserRoleName = newUserRoleName;
}