Skip to content

Instantly share code, notes, and snippets.

View rruhlen's full-sized avatar

Ricky Ruhlen rruhlen

  • San Francisco, CA
View GitHub Profile
@rruhlen
rruhlen / businesshours.js
Last active July 8, 2018 01:36
Show/hide chat based off business hours
<script>
(function(a){function E(a,b,c,d){var e=c.lang();return e[a].call?e[a](c,d):e[a][b]}function F(a,b){return function(c){return K(a.call(this,c),b)}}function G(a){return function(b){var c=a.call(this,b);return c+this.lang().ordinal(c)}}function H(a,b,c){this._d=a,this._isUTC=!!b,this._a=a._a||null,this._lang=c||!1}function I(a){var b=this._data={},c=a.years||a.y||0,d=a.months||a.M||0,e=a.weeks||a.w||0,f=a.days||a.d||0,g=a.hours||a.h||0,h=a.minutes||a.m||0,i=a.seconds||a.s||0,j=a.milliseconds||a.ms||0;this._milliseconds=j+i*1e3+h*6e4+g*36e5,this._days=f+e*7,this._months=d+c*12,b.milliseconds=j%1e3,i+=J(j/1e3),b.seconds=i%60,h+=J(i/60),b.minutes=h%60,g+=J(h/60),b.hours=g%24,f+=J(g/24),f+=e*7,b.days=f%30,d+=J(f/30),b.months=d%12,c+=J(d/12),b.years=c,this._lang=!1}function J(a){return a<0?Math.ceil(a):Math.floor(a)}function K(a,b){var c=a+"";while(c.length<b)c="0"+c;return c}function L(a,b,c){var d=b._milliseconds,e=b._days,f=b._months,g;d&&a._d.setTime(+a+d*c),e&&a.date(a.date()+e*c),f&&(g=a.date(),a.date(
@rruhlen
rruhlen / ExecuteDeletion.txt
Created May 17, 2018 23:48
To run this class click on Debug→Open Execute Anonymous Window
BatchDeleteArticles b = new BatchDeleteArticles(null);
database.executebatch(b,75);
@rruhlen
rruhlen / BatchDeleteArticles.cls
Created May 17, 2018 23:45
Batch delete articles and topics via dev console.
public with sharing class BatchDeleteArticles implements Database.batchable<SObject>,Database.allowscallouts,Database.Stateful{
private String configId;
public BatchDeleteArticles (String configId) {
this.configId = configId;
}
public BatchDeleteArticles () {
}
@rruhlen
rruhlen / cases_reports.json
Created April 3, 2018 17:39
JSON to post to insights3/cases_reports endpoint.
{
"fields": [
"channel_id",
"status_id",
"user_id",
"group_id",
"priority",
"created_at",
"time_to_first_response",
"avg_time_to_resolution",
@rruhlen
rruhlen / recaptcha.js
Created February 28, 2018 00:02
jQuery to move captcha to another location on the Desk email widget
<script type="text/javascript">
$(document).ready(function() {
$(".g-recaptcha").insertBefore("<field>");
});
</script>
@rruhlen
rruhlen / email_notes
Created February 12, 2018 19:32
loop through all email and note interactions
{% for obj in case.emails_and_notes %}
{{ obj }}
{% endfor %}
@rruhlen
rruhlen / article-ratings.js
Created February 7, 2018 23:35
Insert brand id parameter to article rating liquid block. Fixes issue where the default brand has a CNAME and the other brands need to use the Desk subdomain.
<!-- fix multibrand issue with article rating links -->
{% capture tempfix %}rate?b_id={{desk.current_brand.id}}&{% endcapture %}
{{ rate_block | replace: "rate?", tempfix}}
@rruhlen
rruhlen / 01 - desk-external-variables
Last active November 8, 2017 20:42
Attach multiple files to a Desk email form. Input fields must be generated on the fly and can't be hard-coded on the page.
<!-- add to desk-external-variables div -->
<div id="max_number_attachments">{{desk.system.max_attachments}}</div>
<div id="system-snippets-add_attachment">{{system.snippets.add_attachment}}</div>
@rruhlen
rruhlen / 01 - header
Created August 16, 2017 01:40
Video Support Portal Theme for Desk.com
{% if desk.apps.get_satisfaction.enabled %}
{{ gsinit }}
{% endif %}
{% if favicon.size > 0 %}
<link rel="SHORTCUT ICON" type='image/ico' href='{{favicon}}' />
<link rel="icon" type='image/png' href='{{favicon}}' />
{% else %}
<link rel="icon" type='image/vnd.microsoft.icon' href='{{ "/favicon.ico" | portal_image_url: image_asset_host }}' />
<link rel="icon" type='image/png' href='{{ "/favicon.png" | portal_image_url: image_asset_host }}' />
@rruhlen
rruhlen / gist:a1ee8857bc822f425541be5de55ee19c
Last active July 4, 2017 02:14
Custom Action to create a new email case. POST to /api/v2/customers/{{case.customer.id}}/cases.
{
"type": "email",
"subject": "Follow up for case {{case.id}}",
"priority": "{{case.priority}}",
"status": "open",
"labels": [
"Demo Followup"
],
"custom_fields": {
"case_id": "{{case.id}}"