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 / liquid_var_oneliner.sh
Created July 28, 2016 22:28
example one-liner to extract unique variable names from a html/liquid content
grep -o '{{.*}}' ./some_file_with_liquid.html | sort | uniq > ./variable_list.txt
@oheyandy
oheyandy / remove_list_field_values_from_selector.html
Last active May 25, 2016 21:43
Quick HTML/JS snippet to remove custom field values from selectors on contact forms (will remove values in the 'hide' array from ALL list fields on the form, so be careful! change the selector to, e.g., #ticket_custom12 if you need to target only a specific field).
<script type="text/javascript">
(function($) {
// add values to be hidden to this array
var hide = ['Hide this value', 'Also hide this value'];
$("select.default option").each(function() {
if ((function(option) {
for (var i = hide.length - 1; i >= 0; i--) {
if (option.value == hide[i]) {return true;}
}
@oheyandy
oheyandy / csat_form_validation.html
Created May 24, 2016 23:07
Two code updates to use a direct link to portal CSAT page & validate that CSAT rating present before submit since it would no longer be pre-populated from the email.
<!--
1. Navigate to Admin > Channels > Support Center > Web Themes
2. Click on the name of your live web theme
3. Click 'Advanced Themes'
4. Scroll down on the left-hand side and click into the "CSAT (New)" section
5. Add the <script> tag below to the very bottom of the "CSAT (New)" section.
-->
<script>
$(function() {
$('#customer-feedback-form').validate({
@oheyandy
oheyandy / create_state_custom_field.rb
Created December 3, 2015 09:18
example of how to create a custom list field populated w/ state names via API
require 'desk_api'
##########
# config #
##########
# Provide username and password below, as well as change "MYSUBDOMAIN" to
# your own Desk.com subdomain.
auth = {
@oheyandy
oheyandy / sort_articles_by_subject.rb
Last active November 20, 2015 01:10
DeskApi script to alphabetically sort KB articles in admin and portal.
#!/user/bin/env ruby
require 'desk_api'
DeskApi.configure do |config|
config.username = 'YOUR_EMAIL_ADDRESS_HERE'
config.password = 'YOUR_PASSWORD_HERE'
config.endpoint = 'https://YOUR_SUBDOMAIN_HERE.desk.com'
end
@oheyandy
oheyandy / desk_article_link_localizationizer.liquid
Last active August 26, 2015 21:51
automatically converts the /portal to /LOCALE/portal in hrefs within Desk KB article bodies on localized pages if the link isn't pointing to the current locale
<!-- Place this at the bottom of page_article just beneath #footer -->
<script type="text/javascript">
(function($) {
$(function() {
var default_language = "{{site.default_language}}";
var current_locale = "{{system.locale}}";
if (current_locale != default_language) {
var default_portal_locale = /\/customer\/portal\/articles|\/customer\/portal\/topics/
var portal_links = $(".article-content a");
for (var elem = portal_links.length - 1; elem >= 0; elem--) {
@oheyandy
oheyandy / default_article_brands.rb
Created July 7, 2015 21:48
(UNTESTED) quick & dirty script to default article brands to inherit from topic
require 'desk_api'
def desk
@desk ||= DeskApi::Client.new({
username: 'LOGIN_EMAIL',
password: 'PASSWORD',
endpoint: 'https://SUBDOMAIN.desk.com'
})
end
@oheyandy
oheyandy / textile.js
Created April 16, 2015 16:22
hacky proof of concept to render textile in chat
<script type="text/javascript" src="https://gist.githubusercontent.com/anonymous/649e238d9b6d0fe9c395/raw/f918dd9cd61846797af65a32b0cdef1457919dde/textile.js"></script>
<script type="text/javascript">
(function($) {
$(function() {
$(document).ajaxComplete(function() {
$(".chat_message_text.chat_message_agent")
.filter(function() { return !($(this).hasClass('textile_rendered')) })
.each(function() { render_textile($(this)) });
});
@oheyandy
oheyandy / jsonview_monokai.css
Last active August 10, 2016 20:48
quick attempt at a monokai theme for jsonview chrome extension
body {white-space: pre;font-family: monospace;font-size: 14px;background: #272822;color: #f8f8f2;}
.property {font-weight: bold;color: #d0d0d0;}
.type-null {color: #ae81ff;}
.type-boolean {color: #9effff;}
.type-number {color: #ae81ff;;}
.type-string {color: #e6db74;}
.callback-function {color: gray;}
.collapser:after {content: "-";color: #f92672;}
.collapsed > .collapser:after {content: "+";color: #a6e22e;}
.ellipsis:after {content: " … ";}
<script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/lunr.js/0.5.7/lunr.min.js"></script>
<script type="text/javascript">
// NOTE: This is code strictly a very simple proof of concept, has not been
// tested, and should be carefully reviewed before any use
// To use, copy and paste the example to your support center portal theme
// for "Page (Search Result)"
// Example search results can be viewed at https://support.desk.com/customer/portal/articles/search?q=agent&t=525381&b_id=6346