Skip to content

Instantly share code, notes, and snippets.

View oheyandy's full-sized avatar

Andrew Frauen oheyandy

  • Salesforce
  • San Francisco
View GitHub Profile
@oheyandy
oheyandy / change_name.rb
Created April 10, 2013 09:27
Whew. My (admittedly ugly looking) first attempt at using Ruby to loop through directories and append a 0 to .png files names 1.png, 2.png, etc.
d = Dir.new(Dir.pwd)
d.each do |x|
if File.directory?(x) && x != "." && x!= ".."
Dir.chdir("./"+File.basename(x))
to_change = Dir.glob("[0-9].png")
to_change.each { |x| File.rename(x, 0.to_s + x) }
to_change_small = Dir.glob("small-[0-9].png")
to_change_small.each { |x| File.rename(x, x[0,6] + 0.to_s + x[6,7]) }
Dir.chdir("../")
@oheyandy
oheyandy / send_test.py
Last active December 16, 2015 01:09
Simple script to test Desk.com/Assistly x-headers.
import smtplib
from email.MIMEText import MIMEText
text_subtype = 'text'
# Enter the desired body in the 'content' variable
content = 'body of the email here'
msg = MIMEText(content, text_subtype)
@oheyandy
oheyandy / require_email_for_chat.js
Created April 11, 2013 23:01
Script to require email address for Desk.com chat widget. Add this to your chat widget template in Admin > Channels > Chat > Widgets in an HTML <script> tag.
$(document).ready(function(){
$("#interaction_email").rules("add", {
required:true,
messages: {
required: "Email address is required",
email: "Email address is invalid"
}
});
});
@oheyandy
oheyandy / html2textile_app.rb
Created June 15, 2013 00:57
Ruby app built as a learning project to parse HTML to Textile powered by this fellows fine html2textile gem: https://github.com/jystewart/html2textile
#! /usr/bin/env ruby
require 'rubygems'
require 'bundler/setup'
require 'sinatra'
require 'haml'
require 'html2textile'
get('/') { haml :form}
@oheyandy
oheyandy / require_custom_field.html
Created June 21, 2013 21:48
Require custom field on Desk.com contact form example.
<script type="text/javascript">
$(function(){
$('#ticket_custom2 option').first().attr('value', '');
$('#ticket_custom2').rules( 'add', {
required: true,
messages: {
required: 'REQUIRED_MESSAGE_GOES_HERE'
}
@oheyandy
oheyandy / example.html
Created July 9, 2013 01:47
Example Liquid to display OS & Browser versions, as well as IP address, if available, on the Desk.com case template.
{% for first_interaction in case.interactions limit:1 %}
{% if first_interaction.os %}
<div> <strong>OS</strong> <br/>{{first_interaction.os}} – version {{first_interaction.os_version}} </div>
{% endif %}
{% if first_interaction.browser %}
<div> <strong>Browser</strong> <br/>{{first_interaction.browser}} – version {{first_interaction.browser_version}} </div>
{% endif %}
{% if first_interaction.ip_address %}
<div> <strong>IP</strong> <br/>{{first_interaction.ip_address}} </div>
{% endif %}
@oheyandy
oheyandy / gist:6272063
Last active December 21, 2015 07:38
Example of code to add to custom Case Theme to remind Agents to populate company data.
{% if case.customer.company_object.name == nil %}
<div style="padding: 12px 0px; background: red; color: white; text-align: center; font-size: 1.25em; font-weight: 300;">Don't forget to add the company!</div>
{% endif %}
@oheyandy
oheyandy / downloader.rb
Last active January 25, 2019 03:12
Desk.com API script to download attachments for cases from a .txt file of case_ids. In order to best handle duplicate filenames, a directory is created for each case_id and the attachments for that case will be downloaded into that directory. Duplicate filenames for attachments on the same case are handled by appending -1, -2, -3, etc., before t…
#! /usr/bin/env ruby
require 'oauth'
require 'open-uri'
require 'json'
require 'time'
require 'fileutils'
require 'progress_bar'
include FileUtils
@oheyandy
oheyandy / rss_import.xml
Created September 4, 2013 21:29
Example RSS/XML format to import articles to Desk (Admin > Content > Articles > Click "Import RSS" at top of the page).
<?xml version="1.0" encoding="ISO-8859-1" ?>
<rss version="2.0">
<channel>
<item>
<title>
First article's title here
</title>
<description>
First article body here
@oheyandy
oheyandy / README.txt
Last active December 22, 2015 18:29
XML files for RSS import of Desk.com demo site articles.
1. Create a each topic (i.e., Billing, LevelUp, Basics, General, & Social Connectivity) under Admin > Content > Topics.
2. Navigate to Admin > Content > Articles.
3. Complete the step for each of the URLs below:
- Click "Import RSS"
- Select the topic you are importing articles to.
- Copy the correlative URL from the Topic XML files below and paste it into the "RSS Feed" field"
- Set the "Show in Support Center" preference to "Yes"
- Click "Import"