Skip to content

Instantly share code, notes, and snippets.

View dtaivpp's full-sized avatar

David Tippett dtaivpp

View GitHub Profile
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)
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
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
@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
@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 / 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 / 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