Skip to content

Instantly share code, notes, and snippets.

View tstachl's full-sized avatar

Thomas Stachl tstachl

  • Pilina
  • Remote
View GitHub Profile
@tstachl
tstachl / ssh_setup.sh
Created February 20, 2018 22:24
Steps to set up SSH keys for a newly created user account on my VPS.
# create the directory for ssh
mkdir -p ~/.ssh
# make sure it's editable only for the current user
chmod 700 ~/.ssh
# create the authorized keys file
touch ~/.ssh/authorized_keys
# use your favorite editor to add the public key
vim ~/.ssh/authorized_keys
@tstachl
tstachl / create_user.sh
Created February 20, 2018 22:14
Steps I took to create a sudo user on my Digital Ocean Droplet (Ubuntu).
# SSH as root to your Digital Ocean Droplet
ssh root@[DROPLET_IP]
# create the new user
adduser example
# add new user to the sudo group
gpasswd -a example sudo
# logging in with the new user
su - example
@tstachl
tstachl / gist:2760221
Created May 21, 2012 01:34
Salesforce open Simple Dialog in custom button/link or on a visualforce page
// if you want to use it inside a visualforce page create a function around it
function showFollowUp() {
// if you want to use it in a button make sure you require jQuery
// {!REQUIRESCRIPT("https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js")} // UNCOMMENT IF IN A BUTTON
// get the dialog with your dialog name
var d = sfdcPage.dialogs['MyCoolDialog'], close;
if (!d) {
// if the dialog doesn't exist create one
d = sfdcPage.dialogs['MyCoolDialog'] = new SimpleDialog('MyCoolDialog', false);
// set general information on your dialog and finally run the create function
@tstachl
tstachl / export.rb
Created December 18, 2014 23:44
This is a very rudimentary script of exporting data from desk.com to a CSV file.
require 'desk_api'
require 'csv'
# Create the CSV files
cases = CSV.open('./cases.csv', 'wb')
interactions = CSV.open('./interactions.csv', 'wb')
# Add the headers to the CSV files
cases << ['Case #', 'Subject', 'Description', 'Status']
interactions << ['Case #', 'Body', 'Created Date']
@tstachl
tstachl / Client.cs
Created August 19, 2016 23:13
Desk.com API Client for C#
using System;
using System.Collections.Generic;
using System.Net;
using System.Text;
using System.IO;
using System.Security.Cryptography;
namespace DeskApi
{
/// <summary>
<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 / desk_multipass.php
Last active April 23, 2017 03:16
WordPress - Desk.com Multipass SSO Plugin
<?php
/**
* Plugin Name: Desk.com Multipass
* Plugin URI: https://github.com/tstachl/wp-desk_multipass
* Description: A WordPress plugin to add a menu option that redirects to your Desk.com Support Site.
* Version: 1.0.0
* Author: Thomas Stachl
* Author URI: https://github.com/tstachl
* License: BSD 3-Clause License
*/
@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 / SSO.java
Created April 6, 2013 22:30
Desk.com Multipass SSO example.
import org.json.JSONObject;
import org.apache.commons.codec.binary.Base64;
import java.util.Arrays;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.net.URLEncoder;
import java.security.MessageDigest;
<!doctype html>
<html>
<head>
<script src="//ajax.deskapi.com/libs/desk/opencti/current/interaction.min.js"></script>
<script>
(function() {
desk.ready(function() {
var form = document.querySelector('form')
, text = document.querySelector('input')