Skip to content

Instantly share code, notes, and snippets.

View tstachl's full-sized avatar

Thomas Stachl tstachl

  • Pilina
  • Remote
View GitHub Profile
'use-strict'
Emitter = require 'emitter'
_ = require 'lodash'
binder = require 'binder'
module.exports = class DrawingTracker extends Emitter
constructor: (@_element, visible = no) ->
if typeof this._element == 'string' or this._element instanceof String
this._element = document.getElementById this._element
@tstachl
tstachl / Multipass.cls
Last active April 5, 2017 17:52
Apex version to generate a multipass token for Desk.com.
public class Multipass
{
private static String SITE_KEY = 'site_key';
private static String API_KEY = 'api_key';
public static void generate()
{
System.debug('== Generating ==');
System.debug(' Create the encryption key using a 16 byte SHA1 digest of your api key and subdomain');
@tstachl
tstachl / multipass.js
Last active September 1, 2021 07:01
A multipass example written for Node.js.
var crypto = require('crypto')
// site name is your desk.com subdomain
, siteName = 'site_name'
// api key is generated here: https://your_subdomain.desk.com/admin/channels/support-center/auth_settings
, apiKey = 'multipass_token'
, data = JSON.stringify({
uid: '19238333',
expires: (new Date(Date.now() + 120000)).toISOString(),
customer_email: 'john@example.com',
@tstachl
tstachl / DeskTriggerHelper.class
Last active November 21, 2016 19:43
Fetch data trigger.
public class DeskTriggerHelper
{
private static DeskClient CLIENT = new DeskClient(new Map<String, String>{
'token' => 'TOKEN',
'tokenSecret' => 'TOKEN_SECRET',
'consumerKey' => 'CONSUMER_KEY',
'consumerSecret' => 'CONSUMER_SECRET',
'endpoint' => 'https://example.desk.com'
});
@tstachl
tstachl / CaseThemeAddition.html
Created June 20, 2014 21:47
This is some javascript and css code that allows you to have tabbed email and note replies in desk.com.
<script>
$(function() {
var tid = $('#tabs .ui-state-active a').attr('href').replace('#tabs-tid_', '')
, sel = '#email_reply_div_tid_' + tid
setTimeout(function() {
$(sel).prepend([
'<div>',
' <ul class="reply-toggle">',
' <li class="active">',
ticket = DeskApi.cases.create({
external_id: 123456,
subject: 'Subject',
description: 'Description',
priority: 1,
status: 'resolved',
type: 'email',
labels: ['Label 1', 'Label 2'],
custom_fields: {
my_key: 'My Value'
<apex:page standardStylesheets="false" showHeader="false" sidebar="false" recordSetVar="macros" docType="html-5.0"
standardController="Macro__c" extensions="ApplyMacroControllerExtension" title="Select Macro" >
<apex:includeScript value=""/>
<apex:includeScript value="/support/console/30.0/integration.js"/>
<apex:includeScript value="/soap/ajax/30.0/connection.js"/>
<apex:includeScript value="/support/api/30.0/interaction.js"/>
<apex:includeScript value="/canvas/sdk/js/30.0/publisher.js"/>
<apex:stylesheet value="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css" />
@tstachl
tstachl / upload.rb
Created August 7, 2014 00:37
Example on how you can upload customers to desk.com using the desk_api gem.
require 'desk_api'
require 'csv'
DeskApi.configure do |config|
config.username = 'you@example.com'
config.password = 'Top$ecret1'
config.endpoint = 'https://example.desk.com'
end
CSV.foreach('./customers.csv', headers: true) do |csv|
@tstachl
tstachl / script.rb
Created August 13, 2014 19:41
DeskApi Timeout fix
require 'desk_api'
DeskApi::Default::CONNECTION_OPTIONS[:request] = {
open_timeout: 45,
timeout: 45
}
client = DeskApi::Client.new({
token: 'TOKEN',
token_secret: 'TOKEN_SECRET',
new DESK.Widget({
id: 'test', // The ID of the element to place the button into
version: 1,
site: 'hecos.desk.com',
port: '80',
type: 'chat',
displayMode: 0, //0 for popup, 1 for lightbox
features: {
offerAlways: false,
offerAgentsOnline: true,