Skip to content

Instantly share code, notes, and snippets.

View blak3r's full-sized avatar

Blake Robertson blak3r

View GitHub Profile
@blak3r
blak3r / migration.js
Last active June 2, 2022 15:22
Create a gin gin_trgm_ops index, using a sequelize migration. Once created you can use this sql command to verify the index was created properly: `SELECT * FROM pg_indexes WHERE tablename = 'table_name';`
'use strict';
module.exports = {
up: (queryInterface, Sequelize) => {
return queryInterface.addIndex('Parties', {
fields: [Sequelize.literal('name gin_trgm_ops')], // <-- name = field name, gin_trgm_ops comes after the field name
using: 'gin',
indexName: 'party_name_gin_trgm_idx', // specify the index name manually otherwise sequelize will create party_
unique: false,
})
@blak3r
blak3r / zendesk-markdown-articles
Last active May 3, 2019 15:03
Zendesk, Hack to allow authoring in Markdown (which renders to HTML when viewing)
/**
* Step 1: Download showdown.js, from here: https://raw.githubusercontent.com/showdownjs/showdown/master/compressed/showdown.js
* Step 2: Customize Design --> edit theme --> assets and upload it.
* Step 3: Add a script tag to your head using the url from asset page.
* Step 4: Add this to article-body section, Javascript (make sure you select JS), add it before
* Step 5: Create an article, switch to source view, add <PRE>- to the top of the file,
* then put your markdown and end it with a </PRE>. If you don't do this, when you save the wysiwg will screw
* your markdown with html markup. The - is just what i chose to put on the top line... it could be any character
* or string
*
@blak3r
blak3r / f2z.py
Last active October 11, 2021 22:05
Freshdesk to Zendesk Conversion, It's a modified version of https://github.com/mittsh/freshdesk-zendesk-migration, that 1) Uses the import api, 2) sets the comment authors 3) couple other things... There are a couple hardcoded things in the script... review the comments.
import urllib2
import base64
import json
import logging
import os
import re
import unicodedata
logger = logging.getLogger(__name__)
@blak3r
blak3r / gist:7380034
Created November 9, 2013 00:56
Javascript interview question.
/**
* Takes in an array of two objects, flattens the currArray, and prints an HTML Table of the values.
* The HTML table has a column header which is a superset of all keys in all the objects.
* Any values that have changed (ie field value changed or is a new key altogether) should be bolded.
*
* @param prevArray is an array of objects
* @param currArray is an array of objects
* @return a string with HTML markup in it, should return null if error occurs.
*/
function arrayDiffToHtmlTable( prevArray, currArray) {
@blak3r
blak3r / oneCallMultipleContacts
Created October 31, 2013 17:56
Payload with 1 call... but multiple matching contacts.
[
{
"__v": 0,
"_id": "5271fa60dc34c80000000002",
"_organization": "526f3ca5174b310000000004",
"callerIdCity": "",
"callerIdName": "",
"createdDate": "2013-10-31T06:36:16.832Z",
"deleted": false,
"description": "",
@blak3r
blak3r / gist:7253901
Created October 31, 2013 17:44
Two active calls here.
[
{
"__v": 0,
"_id": "5271fa60dc34c80000000002",
"_organization": "526f3ca5174b310000000004",
"callerIdCity": "",
"callerIdName": "",
"createdDate": "2013-10-31T06:36:16.832Z",
"deleted": false,
"description": "",
@blak3r
blak3r / gist:5703941
Created June 4, 2013 06:17
A way to change tab name from Solutions to FAQ in Freshdesk
<script>
jQuery(document).ready( function() {
jQuery(".page-tabs a:contains(Solutions)").text("FAQ");
});
</script>
@blak3r
blak3r / panel_visibility_dep.php
Last active December 14, 2015 05:29
Example of how to use SugarLogic to SetPanelVisibility (ie toggle a panel on and off) http://developers.sugarcrm.com/wordpress/2011/06/13/learning-sugar-logic-using-custom-dependencies/
<?php
$dependencies['Cases']['panel_visibility'] = array(
'hooks' => array("edit"),
'trigger' => 'equal($status, "Closed")', //Optional, the trigger for the dependency. Defaults to 'true'.
'triggerFields' => array('status'),
'onload' => true,
//Actions is a list of actions to fire when the trigger is true
'actions' => array(
array(
'name' => 'SetPanelVisibility',
@blak3r
blak3r / KeyboardHook.cs
Last active July 28, 2021 21:55
Installing a global hot key with C# by Christian Liensberger This is the code posted here: <http://www.liensberger.it/web/blog/?p=207>. The blog post got html escaped which required some tweaks to get working so I posted it here to save others time.
using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;
using System.Windows.Forms;
namespace Liensberger
{
/// <summary>
/// Author: Christian Liensberger
@blak3r
blak3r / SugarOutfitters_ValidateLicense
Created September 12, 2012 02:38
Sugar Outfitters Validate License Key (in application code)
/**
* Returns true if license is valid, false otherwise
* @param $response this parameter is passed by reference and will be updated with the actual response from
* calling the Sugar Outfitters API. See: https://www.sugaroutfitters.com/docs/sugaroutfitters/selling-license-api
* @return true or false
*/
function isLicenseValid(&$response) {
//global $outfitters_config;
global $sugar_config;