Skip to content

Instantly share code, notes, and snippets.

Marty Chang martyychang

Block or report user

Report or block martyychang

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@martyychang
martyychang / .bash_profile
Created Oct 29, 2018
Better Git integration with Terminal on Mac OS X
View .bash_profile
# 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\$ '
@martyychang
martyychang / listObjectFields.java
Last active Oct 8, 2018
Generate a list of all fields and data types for a given object and send the metadata in CSV format via email
View listObjectFields.java
// README: This is the only line you need to edit (generally speaking)
// This is the object for which I want to extract the field describes.
// Running this script will send the resulting field list to your user's email,
// with the fields as an attached CSV file.
Schema.DescribeSObjectResult objectDescribe = Schema.SObjectType.OpportunityLineItem;
/**
* Wrapper class to return CSV rows
*/
public class FieldCsvWriter {
@martyychang
martyychang / check.sh
Last active Dec 28, 2018
Trailblazer .bin
View check.sh
# Check to require a username to be [given as argument][1]
#
# [1]: https://stackoverflow.com/questions/6482377/check-existence-of-input-argument-in-a-bash-shell-script
if [ -z "$1" ]; then
echo ERROR: Username argument required!
# [terminate and indicate error][3]
#
# [3]: https://stackoverflow.com/questions/4381618/exit-a-script-on-error
exit 1
@martyychang
martyychang / .gitignore
Created Jul 17, 2017
MavensMate project init
View .gitignore
# MavensMate
config/
# Sublime Text
*.sublime*
@martyychang
martyychang / CommunityTopicListItemController.cls
Created Apr 18, 2017
Server-side controller for Lightning component enabling partner users to follow and unfollow topics
View CommunityTopicListItemController.cls
public class CommunityTopicListItemController {
@AuraEnabled
public static void subscribe(Id entityId) {
ConnectApi.Subscription subscription =
ConnectApi.ChatterUsers.follow(Network.getNetworkId(), 'me', entityId);
}
@AuraEnabled
public static void unsubscribe(Id subscriptionId) {
@martyychang
martyychang / STRUCTURE.md
Last active Dec 13, 2016
Suggested directory structure for a web API project, written in Python
View STRUCTURE.md

api/

Handlers, etc. Everything needed to translate a web request into data that can be passed into a regular Python function and vice versa.

api/exports.py

Typically this would be imported into an app like this.

@martyychang
martyychang / AdvertiserListingTaskService.java
Created May 24, 2016
How to map task names to task services
View AdvertiserListingTaskService.java
@Service
public class AdvertiserListingTaskService {
public void executeWithConfig(TaskConfig config) {
AdvertiserListingTask task = getTask();
task.apply(config);
task.run(); // Or something like executor.execute(task)
}
@Lookup
@martyychang
martyychang / IntegrationService.java
Last active Apr 26, 2016
Unsure whether using `ObjectFactory` is the best way to get a new prototype bean.
View IntegrationService.java
@Service
public class IntegrationService {
@Autowired
private TaskExecutor integrationTaskExecutor;
@Autowired
private IntegrationTaskFactory integrationTaskFactory;
/**
View Config.java
@Configuration
public class AppConfig {
public @Bean Foo fooer() {
return new Foo("fooer");
}
public @Bean Foo fooey() {
return new Foo("fooey");
}
View SimpleDomain.groovy
public class SimpleDomain {
ObjectId _id;
String code;
int numberOfUses;
}
You can’t perform that action at this time.