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 / 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
posts = [
{
'Post': {
'title':'Other today post',
'date': 43750,
'claps': 200
}
},
{
'Post': {
class DiscordHandler(logging.Handler):
"""
Custom handler to send certain logs to Discord
"""
def __init__(self):
logging.Handler.__init__(self)
self.discordWebhook = DiscordWebhook(url=config.DISCORD_URL)
def emit(self, record):
"""