Skip to content

Instantly share code, notes, and snippets.

View chucknado's full-sized avatar

Charles Nadeau chucknado

View GitHub Profile
@chucknado
chucknado / main.js
Last active August 14, 2021 11:01
Sample JavaScript for the Zendesk Apps tutorial, Accessing external data, at https://support.zendesk.com/hc/en-us/articles/222391587
$(function() {
var client = ZAFClient.init();
client.invoke('resize', { width: '100%', height: '400px' });
showStart();
$("#get-tasks").click(function() {
getTaskData(client);
});
});
function showStart() {
// FirstViewController.swift
// ChatBadgeCount
//
// Created by Barry Carroll on 30/05/2016.
// Copyright © 2016 chatbadge. All rights reserved.
// See the tutorial at https://support.zendesk.com/hc/en-us/articles/220080968
import UIKit
import ZDCChat
@chucknado
chucknado / search_in.js
Last active February 5, 2016 16:46
Sample script for "Letting users search other Help Centers" at https://support.zendesk.com/hc/en-us/articles/xyz
function search_other_hc(hc, hostname) {
var search_string = encodeURIComponent(document.getElementById('query').value);
var lang = document.getElementsByTagName('html')[0].getAttribute('lang').toLowerCase();
var url = 'https://' + hostname + '/hc/'+ lang + '/search?utf8=%E2%9C%93&commit=Search&query=' + search_string;
window.open(url);
}
function init_multi_product_search() {
if (document.getElementsByClassName('search-other-products')) {
var help_centers = [ {product: 'acme', hostname: 'acme.zendesk.com'},
@chucknado
chucknado / js_template.js
Last active February 4, 2016 23:06
JavaScript for multi-product search in HC
function search_other_hc(hc, hostname) {
var search_string = encodeURIComponent(document.getElementById('query').value);
var lang = document.getElementsByTagName('html')[0].getAttribute('lang').toLowerCase();
var url = 'https://' + hostname + '/hc/'+ lang + '/search?utf8=%E2%9C%93&commit=Search&query=' + search_string;
window.open(url);
}
function init_multi_product_search() {
if (document.getElementsByClassName('search-other-products')) {
var help_centers = [ {product: 'zendesk', hostname: 'support.zendesk.com'},
@chucknado
chucknado / write_posts.pl
Last active December 13, 2016 03:13
Sample script for "Write large data sets in Excel with Perl" at https://support.zendesk.com/hc/en-us/articles/212356448
#!/usr/bin/perl
use strict;
use warnings;
use Storable;
use Excel::Writer::XLSX;
my $topic_hash_ref = retrieve('my_serialized_data');
my %topic_data = %{ $topic_hash_ref };
my $workbook = Excel::Writer::XLSX->new( 'topic_posts.xlsx' );
@chucknado
chucknado / write_posts.py
Last active November 23, 2020 07:41
Sample script for "Write large data sets in Excel with Python and pandas" at https://support.zendesk.com/hc/en-us/articles/212227138
import dateutil.parser
import pandas as pd
topic = pd.read_pickle('my_serialized_data')
posts_df = pd.DataFrame(topic['posts'], columns=['id', 'title', 'created_at', 'author_id'])
users_df = pd.DataFrame(topic['users'], columns=['id', 'name']).drop_duplicates(subset=['id'])
posts_df['created_at'] = posts_df['created_at'].apply(lambda x: dateutil.parser.parse(x).date())
@chucknado
chucknado / list_posts.pl
Last active October 12, 2015 23:15
Completed script for for "Getting large datasets with the Zendesk API and Perl" at https://support.zendesk.com/hc/en-us/articles/212521277
use strict;
use warnings;
no warnings 'utf8';
use LWP;
use JSON;
use MIME::Base64;
use Storable;
my $topic_id = 123456;
my $zendesk = 'your_zendesk_url';
@chucknado
chucknado / list_posts.py
Last active February 14, 2018 00:24
Completed script for "Getting large datasets with the Zendesk API and Python" at https://support.zendesk.com/hc/en-us/articles/211713848
import pickle
import time
import requests
credentials = 'your_zendesk_email', 'your_zendesk_password'
session = requests.Session()
session.auth = credentials
zendesk = 'your_zendesk_url'
topic_id = 123456
@chucknado
chucknado / app.py
Last active May 27, 2021 13:37
A Python script for "Zendesk API tutorial: Building a custom ticket form" at https://support.zendesk.com/hc/en-us/articles/209003547
import json
import requests
from bottle import route, template, run, static_file, request, response
@route('/create_ticket', method=['GET', 'POST'])
def handle_form():
if 'verified_email' in request.cookies:
ask_email = False
@chucknado
chucknado / list_followers.pl
Last active August 29, 2015 14:25
A Perl script for "Zendesk API tutorial: Listing the followers of a KB section" at https://support.zendesk.com/hc/en-us/articles/206340488
use strict;
use warnings;
use LWP::UserAgent;
use JSON;
use MIME::Base64;
my $num_args = $#ARGV + 1;
if ($num_args != 1) {
print "Usage error: list_followers.pl hc_id\n";
exit;