Skip to content

Instantly share code, notes, and snippets.

Avatar

Patrick Connelly pcon

View GitHub Profile
View gist:9548785
Map<String, Profile> profileMap {
get {
if (profileMap == null) {
profileMap = new Map<String, Profile>();
for (Profile p: [
select Name
from Profile
]) {
profileMap.put(p.Name, p);
@pcon
pcon / CaseTrigger.java
Created Mar 28, 2014
How to make a trigger not run based on a static variable
View CaseTrigger.java
//This would actually be your CaseTrigger.trigger but the hilighting wouldn't work then
List<ChatterPost> postsToInsert = new List<ChatterPost>();
for (Case c: trigger.new) {
if (c.Status == 'collab') {
postsToInsert.add(new ChatterPost(...));
}
if (!postsToInsert.isEmpty()) {
View gist:b9162450b4e899de0b68
Map<DateTime, User> userMap = new Map<DateTime, User>();
for (User u: [select LastLoginDate from User where Id in:userIds]) {
userMap.put(u.LastLoginDate, u);
}
@pcon
pcon / AutoConverter.java
Last active Aug 29, 2015
Lead Conversion
View AutoConverter.java
Trigger AutoConverter on Lead (after insert) {
LeadStatus convertStatus = [
select MasterLabel
from LeadStatus
where IsConverted = true
limit 1
];
List<Database.LeadConvert> leadConverts = new List<Database.LeadConvert>();
for (Lead lead: Trigger.new) {
View gist:ca95d121d71ead05dedf
/**
* Gets an admin user
*
* @return An admin user
*/
public static User getAdminUser() {
Profile adminProfile = [
select id
from profile
where name = 'System Administrator'
@pcon
pcon / gist:c34dcb7d3f219e3fde02
Created Aug 19, 2014
EncodingUtils weirdness
View gist:c34dcb7d3f219e3fde02
System.debug(System.LoggingLevel.ERROR, '| vs ' + EncodingUtil.urlDecode('%7C;', 'UTF-8'));
if ('|' == EncodingUtil.urlDecode('%7C', 'UTF-8')) {
System.debug(System.LoggingLevel.ERROR, 'Expected: %7C');
} else {
System.debug(System.LoggingLevel.ERROR, 'Unxpected: %7C');
}
System.debug(System.LoggingLevel.ERROR, '| vs ' + EncodingUtil.urlDecode('&#124;', 'UTF-8'));
if ('|' == EncodingUtil.urlDecode('&#124;', 'UTF-8')) {
System.debug(System.LoggingLevel.ERROR, 'Expected: &#124;');
@pcon
pcon / backtick_test_status.sh
Last active Aug 29, 2015
Screen configuration
View backtick_test_status.sh
#!/bin/bash
/usr/bin/node /home/$USER/bin/test_status.js
@pcon
pcon / TestData1.cls
Last active Aug 29, 2015
Fun with maps and sets
View TestData1.cls
class TestData {
public String data;
public TestData() {}
public TestData(String data) {
this.data = data;
}
}
@pcon
pcon / objDesc.html
Last active Aug 29, 2015
Object Description
View objDesc.html
<apex:page docType="html-5.0" showHeader="false" applyBodyTag="false" applyHtmlTag="false" standardStylesheets="false">
<html ng-app="objDescApp">
<head>
<title>Object Description</title>
<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css" />
<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/font-awesome/4.2.0/css/font-awesome.min.css" />
<style>body{padding-top:50px}.sub-header{padding-bottom:10px;border-bottom:1px solid #eee}.navbar-fixed-top{border:0}.sidebar{display:none}@media (min-width:768px){.sidebar{position:fixed;top:51px;bottom:0;left:0;z-index:1000;display:block;padding:20px;overflow-x:hidden;overflow-y:auto;background-color:#f5f5f5;border-right:1px solid #eee}}.nav-sidebar{margin-right:-21px;margin-bottom:20px;margin-left:-20px}.nav-sidebar>li>a{padding-right:20px;padding-left:20px}.nav-sidebar>.active>a,.nav-sidebar>.active>a:focus,.nav-sidebar>.active>a:hover{color:#fff;background-color:#428bca}.main{padding:
View barracks.txt
┌─┬───────────── Not used.
│ │ ┌─────────── Bottom Ranged
│ │ │ ┌───────── Bottom Melee
│ │ │ │ ┌─────── Middle Ranged
│ │ │ │ │ ┌───── Middle Melee
│ │ │ │ │ │ ┌─── Top Ranged
│ │ │ │ │ │ │ ┌─ Top Melee
│ │ │ │ │ │ │ │
0 0 0 0 0 0 0 0