Skip to content

Instantly share code, notes, and snippets.

View dtaivpp's full-sized avatar

David Tippett dtaivpp

View GitHub Profile
@dtaivpp
dtaivpp / Org_ContactPreCreatePlugin.cs
Last active August 2, 2019 16:52
Dynamics CRM Basic Plugin
using System;
using Microsoft.Xrm.Sdk;
namespace CRM.BusinessUnit.Plugins
{
// Attributes used to simplify creating plugins
[StepMessage, StepEntity, SetpStage, StepMode, StepId]
[StepPreImage, PreImageId]
[StepPostImage, StepPostImageId]
public class org_ContactPreCreatePlugin : Pluginbase IPlugin
@dtaivpp
dtaivpp / csi-tai-demo.py
Last active July 8, 2021 17:29
Sample of the csi-tai Virtual Observer python sdk
from csi-tai import CsiConnector, Endpoints, export_csv
# CsiConnector take a token and the endpoint URL
csi = CsiConnector('afwlf02394rjqw0494r034ifqojw4f',
'https://cloud.csiworld.com/VOWebAPI/v5/')
params = {
'filter': 'f.LName|o.eq|v.Tippett',
'fields': 'FName, LName',
'perpage':100
@dtaivpp
dtaivpp / Bad_Row_Join.py
Last active September 7, 2019 15:31
This is an example of how not to generate sql table queries dynamically
def gen_table_sql(table_obj):
row_len = length(table_obj)
query = ""
for index, row in enumerate(table_obj['columns']):
query.append(row)
# Needed so last line doesnt have a comma
if (index < length):
query.append(',\n')
@dtaivpp
dtaivpp / Good_Row_Join.py
Last active September 7, 2019 15:47
This is a good way to join several lines fo an array not adding punctuation to the end.
def gen_table_sql(table_obj):
# Joins all rows with a comma and a newline except for the last
query = ',\n'.join(table_obj['columns'])
return query
def gen_table_sql(col_list):
# Joins all rows with a comma and a newline except for the last
query = ',\n'.join(col_list)
return query
def join_col_list(col_list):
'''Takes in column list and joins with commas to form sql statement'''
query = ',\n'.join(col_list)
return query
dictionary = {'string key': "string value",
('tuple', 'key'): {'dict': "value"},
123: "Value for int key"}
keys = dictionary.keys()
print(keys)
# dict_keys(['string key', ('tuple', 'key'), 123])
values = dictionary.values()
print(values)
# Initialization
dictionary = {'string key': "string value",
('tuple', 'key'): {'dict': "value"},
123: "Value for int key"}
# Assign a key a new value
dictionary[123] = "New Value"
# Retrieve all keys from a dictionary
keys = dictionary.keys()
# Initialization
list = ["Lists", "Is", "Pretty", "Sweet"]
# Assigning an index a new value
list[1] = "Are"
# Extending a list
list.append("Cool")
# Removeing from the end
@dtaivpp
dtaivpp / Memoize.py
Last active October 31, 2019 14:21
List comprehension with memoization example from https://stackoverflow.com/a/15812933/4577237
def memoize(f):
""" Memoization decorator for functions taking one or more arguments. """
class memodict(dict):
def __init__(self, f):
self.f = f
def __call__(self, *args):
return self[args]
def __missing__(self, key):
ret = self[key] = self.f(*key)
return ret