Skip to content

Instantly share code, notes, and snippets.

View zachelrath's full-sized avatar

Zach McElrath zachelrath

View GitHub Profile
@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 fscotland0@purevolume.com Female fscotland0 6/20/85
2 Martainn Manners mmanners1@cpanel.net Male mmanners1 8/18/94
3 Benjy Biers bbiers2@multiply.com Male bbiers2 5/1/62
4 Jean Ickovits jickovits3@boston.com Male jickovits3 9/26/55
5 Cyrus Hamlett chamlett4@forbes.com Male chamlett4 9/7/53
6 Shayne Estabrook sestabrook5@cam.ac.uk Male sestabrook5 1/17/75
7 Nolie Szymonwicz nszymonwicz6@chicagotribune.com Female nszymonwicz6 9/4/95
8 Janette Ratchford jratchford7@deliciousdays.com Female jratchford7 2/17/93
9 Alissa Oloshkin aoloshkin8@about.com 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>
<skuidpage showsidebar="true" showheader="true" tabtooverride="Opportunity">
<models>
<model id="SortOrders" limit="100" query="true" createrowifnonefound="false" sobject="Sort_Order__c">
<fields>
<field id="Sort_Order__c"/>
<field id="Skuid_Page__c"/>
<field id="Skuid_Page__r.Name"/>
<field id="Model_Id__c"/>
</fields>
<conditions>