Skip to content

Instantly share code, notes, and snippets.

Thomas Stachl tstachl

Block or report user

Report or block tstachl

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@tstachl
tstachl / restart_ssh_client.sh
Created Feb 20, 2018
After any changes to the SSH configuration the service needs to be restarted.
View restart_ssh_client.sh
sudo service ssh restart
@tstachl
tstachl / sshd_config
Last active Feb 20, 2018
My sshd_config with Root and Password access diabled.
View sshd_config
# /etc/ssh/sshd_config
# ...
# Authentication
LoginGraceTime 120
PermitRootLogin no
StrictModes yes
# ...
@tstachl
tstachl / ssh_setup.sh
Created Feb 20, 2018
Steps to set up SSH keys for a newly created user account on my VPS.
View ssh_setup.sh
# 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 Feb 20, 2018
Steps I took to create a sudo user on my Digital Ocean Droplet (Ubuntu).
View create_user.sh
# 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
Salesforce open Simple Dialog in custom button/link or on a visualforce page
View gist:2760221
// 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 / api_content_type.rb
Created Aug 18, 2013
This is a simple Rack Middleware to set the request content type for specific routes. It checks if a content type is set and does not override the existing one. The options allow you to specify the request methods, path (with a string or a regular expression) and the content type to be set.
View api_content_type.rb
module Rack
class ApiContentType
def initialize(app, methods = [:post, :patch], path = /^\/api\/v2+/, content_type = 'application/json')
@app = app
@methods = (methods.is_a?(Array) ? methods : [methods]).map{ |item| item.to_s.upcase }
@path = path
@content_type = content_type
end
def call(env)
@tstachl
tstachl / export.rb
Created Dec 18, 2014
This is a very rudimentary script of exporting data from desk.com to a CSV file.
View export.rb
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 Aug 19, 2016
Desk.com API Client for C#
View Client.cs
using System;
using System.Collections.Generic;
using System.Net;
using System.Text;
using System.IO;
using System.Security.Cryptography;
namespace DeskApi
{
/// <summary>
View ApplyMacro
<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 Apr 23, 2017
WordPress - Desk.com Multipass SSO Plugin
View desk_multipass.php
<?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
*/
You can’t perform that action at this time.