Skip to content

Instantly share code, notes, and snippets.

View conrjac's full-sized avatar
🪁
Focusing

Connor Jackson conrjac

🪁
Focusing
View GitHub Profile
### Keybase proof
I hereby claim:
* I am conrjac on github.
* I am conrjac (https://keybase.io/conrjac) on keybase.
* I have a public key whose fingerprint is 9861 49D6 AE82 A9D9 8222 DA64 05E6 6782 1E14 2E26
To claim this, I am signing this object:
@conrjac
conrjac / gist:4040495
Created November 8, 2012 18:06
Update Data Grid
private void btnCustAdd_Click(object sender, EventArgs e)
{
if ((txtCustFirst.Text.Length == 0) || (txtCustFirst.Text == "First") || (txtCustLast.Text.Length == 0) || (txtCustLast.Text == "Last") || (txtCustHouse.Text.Length == 0) || (txtCustHouse.Text == "House") || (txtCustStreet.Text.Length == 0) || (txtCustStreet.Text == "Street") || (txtCustTown.Text.Length == 0) || (txtCustTown.Text == "Town") || (txtCustCounty.Text.Length == 0) || (txtCustCounty.Text == "County") || (txtCustPostcode.Text.Length == 0) || (txtCustPostcode.Text == "Postcode") || (txtCustHPhone.Text.Length == 0) || (txtCustHPhone.Text == "Home") || (txtCustMPhone.Text.Length == 0) || (txtCustMPhone.Text == "Mobile"))
{
MessageBox.Show("Please ensure all fields are not null", "Error");
}
else
{
try
@conrjac
conrjac / DateHelper.cls
Last active July 5, 2016 08:56
Add working days to a date in SalesForce, taking into account weekends and company holidays
global class DateHelper {
public static Date addBussinessDays(Date startDate, Integer iDays)
{
Integer businessDaysAdded = 0;
Date currentDate = startDate;
while (businessDaysAdded < iDays) {
currentDate = currentDate.addDays(1);
Datetime d = datetime.newInstance(currentDate.year(), currentDate.month(),currentDate.day());
if (d.format('E') != 'Sat' && d.format('E') != 'Sun' && checkifItisWorkingDay(currentDate)) {
// it's a business day, so add 1 to the counter that works towards the amount of days to add
@conrjac
conrjac / someclass.cls
Last active October 19, 2016 19:29
Using DateHelper.cls
public class myClass
{
MyObject__c.endDateField__c = DateHelper.addBusinessDays(startDateField__c, 10);
}
@conrjac
conrjac / Insert Holidays
Created October 19, 2016 19:34
SalesForce Insert Holidays
List<Holiday> holidays = new List<Holiday>{new Holiday(Name = 'Good Friday', IsAllDay = TRUE, ActivityDate = Date.newInstance(2016,03,25)),
new Holiday(Name = 'Easter Monday', IsAllDay = TRUE, ActivityDate = Date.newInstance(2016,03,28) ),
new Holiday(Name = 'Early May Bank Holiday', IsAllDay = TRUE, ActivityDate = Date.newInstance(2016,05,02) ),
new Holiday(Name = 'Spring bank holiday', IsAllDay = TRUE, ActivityDate = Date.newInstance(2016,05,30) ),
new Holiday(Name = 'Summer bank holiday', IsAllDay = TRUE, ActivityDate = Date.newInstance(2016,08,29) ),
new Holiday(Name = 'Boxing Day', IsAllDay = TRUE, ActivityDate = Date.newInstance(2016,12,26) ),
new Holiday(Name = 'Christmas Day (substitute day)', IsAllDay = TRUE, ActivityDate = Date.newInstance(2016,12,27) ),
new Holiday(Name = 'New Year’s Day (substitute day)', IsAllDay = TRUE, ActivityDate = Date.newInstance(2017,01,02) ),
new Holiday(Name = 'Good Friday', IsAllDay = TRUE, ActivityDate = Date.newInstance(2017,04,14) ),
new Holiday(Nam
@conrjac
conrjac / build.xml
Created October 20, 2016 14:31
SchemaSpy Build File
<project default="document">
<property name="sf.username" value="YOUR USERNAME"/>
<property name="sf.password" value="YOUR PASSWORD & YOUR SECURITY TOKEN"/>
<target name="document">
<echo message="Generating SchemaSpy documentation (requires Graphviz to be installed to produce diagrams)"/>
<delete dir="doc" failonerror="false"/>
<java classname="net.sourceforge.schemaspy.Main" fork="true" failonerror="true">
<arg line="-t schemaspy/force"/>
<arg line="-db Claims"/>
<arg line="-un ${sf.username}"/>
@conrjac
conrjac / MySQLBackup.sh
Created October 20, 2016 15:34
Simple MySQL Backup Shell Script
#!/bin/bash
USER="BACKUP-USER-ACCOUNT"
PASSWORD="BACKUP-USER-PASSOWRD"
TIME_STAMP=$(date +%Y-%m-%d-%T)
ROOT_BACKUP="BACKUP-LOCATION-ROOT"
BACKUP_LOCATION="${ROOT_BACKUP}/${TIME_STAMP}"
mkdir -p ${BACKUP_LOCATION}
@conrjac
conrjac / SendEmailEx.ps1
Created October 20, 2016 15:35
PowerShell Send Email from Exchange
function sendLoggingEMail($subject,$message){
Write-Host &quot;Sending Email&quot;
#Exchange Server
$exchangeServer = &quot;Exchange Address e.g webmail.domain.tld&quot;
#Creating a Mail object
$msg = new-object Net.Mail.MailMessage
#Creating SMTP server object
$smtp = new-object Net.Mail.SmtpClient($exchangeServer)
#Email structure
$msg.From = &quot;example@domain.tld&quot;
@conrjac
conrjac / .gitignore
Created November 2, 2016 13:25
SalesForce Git Ignore
.project
.settings
.metadata
salesforce.schema
Referenced Packages
*.sublime-project
*.sublime-settings
*.sublime-workspace
apex-scripts/log
build.properties
@conrjac
conrjac / SomeJSON.json
Created August 9, 2017 08:31
SomeJSON
{
"glossary": {
"title": "example glossary",
"GlossDiv": {
"title": "S",
"GlossList": {
"GlossEntry": {
"ID": "SGML",
"SortAs": "SGML",
"GlossTerm": "Standard Generalized Markup Language",