Skip to content

Instantly share code, notes, and snippets.

View zachelrath's full-sized avatar

Zach McElrath zachelrath

View GitHub Profile
@zachelrath
zachelrath / is-ancestor-of-main.sh
Created June 26, 2024 14:21
Require tag's commit to have been built off of main branch
#!/bin/bash
# Get the current commit SHA
current_commit_sha=$(git rev-parse HEAD)
# Get the SHA of the "origin/main" branch
origin_main_sha=$(git rev-parse origin/main)
# Check if the current commit SHA matches the "origin/main" SHA or any parent commit SHA
if git merge-base --is-ancestor $current_commit_sha $origin_main_sha; then
@zachelrath
zachelrath / SimplePulsarMessageListener.java
Created May 19, 2022 13:54
Simple pulsar message listener
@Service
@Slf4j
@ConditionalOnProperty(name = "consumer.enabled", havingValue = "true")
public class SimpleMessageListener implements MessageListener<byte[]> {
private final int maxConsumeDelaySeconds;
private static final String CONSUMER_PREFIX = "(CONSUMER) [{}]: ";
public SimpleMessageListener(
@zachelrath
zachelrath / SimplePulsarQueueConsumer.java
Created May 19, 2022 13:52
Simple Pulsar queue consumer
@Configuration
@ConditionalOnProperty(name = "consumer.enabled", havingValue = "true")
@Slf4j
public class PulsarConsumerConfiguration {
private final PulsarClient client;
private final List<Consumer> consumers;
private final SimpleMessageListener msgListener;
public PulsarConsumerConfiguration(
@zachelrath
zachelrath / StructuredLoggingWithMap.java
Created February 15, 2022 15:36
Log4j structured logging with a Map
logger.info(new ObjectMessage(Map.of(
"totalItems", orderItems.size(),
"items", orderItems
)));
@zachelrath
zachelrath / StructuredLoggingWithObjectMessage.java
Last active February 15, 2022 15:20
Structured data logging with Log4j ObjectMessage
@Data
@AllArgsConstructor
@NoArgsConstructor
public class ItemLog {
private Integer totalItems;
private List<OrderItem> items;
public ItemLog(List<OrderItem> items) {
this.items = items;
this.totalItems = items.size();
}
id first_name last_name email gender username birthdate
1 Freda Scotland [email protected] Female fscotland0 6/20/85
2 Martainn Manners [email protected] Male mmanners1 8/18/94
3 Benjy Biers [email protected] Male bbiers2 5/1/62
4 Jean Ickovits [email protected] Male jickovits3 9/26/55
5 Cyrus Hamlett [email protected] Male chamlett4 9/7/53
6 Shayne Estabrook [email protected] Male sestabrook5 1/17/75
7 Nolie Szymonwicz [email protected] Female nszymonwicz6 9/4/95
8 Janette Ratchford [email protected] Female jratchford7 2/17/93
9 Alissa Oloshkin [email protected] Female aoloshkin8 8/16/92
<skuidpage unsavedchangeswarning="yes" personalizationmode="server" showsidebar="true" showheader="true">
<models>
<model id="Input" limit="20" query="true" createrowifnonefound="true" datasource="Ui-Only" processonclient="true">
<fields>
<field id="Data" displaytype="TEXT" label="Data"/>
<field id="ImportStatus" displaytype="PICKLIST" label="Import Status" ogdisplaytype="TEXT" picklistsource="manual" returntype="TEXT" defaultvaluetype="fieldvalue" defaultValue="ready" enclosevalueinquotes="true">
<picklistentries>
<entry value="inprogress" label="In Progress"/>
<entry value="ready" label="Ready"/>
</picklistentries>
@zachelrath
zachelrath / PendingApprovalItemsForUserGroups.xml
Created July 3, 2014 15:27
Skuid Page that shows Pending Approval Items for the User or for any Groups that the user is a part of, either directly or indirectly
<skuidpage showsidebar="true" showheader="true" tabtooverride="User">
<models>
<model id="UserGroups" limit="20" query="true" createrowifnonefound="false" sobject="Group">
<fields>
<field id="Name"/>
<field id="DeveloperName"/>
<field id="Type"/>
</fields>
<conditions>
<condition type="join" value="" field="Id" operator="in" enclosevalueinquotes="true" joinobject="GroupMember" joinfield="GroupId" logic="">
@zachelrath
zachelrath / DynamicModelsAndComponents.xml
Last active January 7, 2021 21:06
A Skuid Page with JavaScript code for creating Models and Components dynamically from JavaScript
<skuidpage showsidebar="true" showheader="true">
<models>
<model id="DummyUserModel" datasource="salesforce" sobject="User" limit="1" query="false"/>
</models>
<components>
<custom name="DynamicTableAndModel"/>
</components>
<resources>
<labels/>
<javascript>
@zachelrath
zachelrath / Opportunity_withInlineEditablePreview.xml
Created May 7, 2014 18:03
An Opportunity detail page with a popup that lets you use a prototype Skuid markup language feature within "fragments" of HTML code to generate inline-editable Skuid Ui Fields
<skuidpage showsidebar="true" showheader="true" tabtooverride="Opportunity">
<models>
<model id="Opportunity" limit="1" query="true" createrowifnonefound="false" sobject="Opportunity">
<fields>
<field id="Name"/>
<field id="CreatedDate"/>
<field id="CloseDate"/>
<field id="Amount"/>
</fields>
<conditions>