This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function executeRule(current, previous /*null when async*/) { | |
var slack = new SlackMessage(); | |
slack.endpoint = current.u_response_url; | |
var response = slack.send("This application is prototype application to integrate Slack's slash commands & ServiceNow "); | |
// Show error message if it failed | |
if(response.getStatusCode() != 200) { | |
gs.addInfoMessage("response.getBody: " + response.getBody()); | |
gs.addInfoMessage("response.getStatusCode: " + response.getStatusCode()); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function process(g_request, g_response, g_processor) { | |
var app = "slack slash"; | |
var tablename = "u_slash_commands"; | |
var record = new GlideRecord(tablename); | |
record.setValue("u_method",g_request.getMethod()); | |
record.setValue("u_querystring",g_request.getQueryString()); | |
var urlParamList = g_request.getParameterNames(); | |
while(urlParamList.hasMoreElements()){ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function process(g_request, g_response, g_processor) { | |
gs.log("slack method string: "+g_request.getMethod()); | |
gs.log("slack query string: " + g_request.getQueryString()); | |
var urlParamList = g_request.getParameterNames(); | |
var paramMsg = ""; //we're going to log parameter log here | |
while(urlParamList.hasMoreElements()){ | |
var param = urlParamList.nextElement(); | |
var value = g_request.getParameter(param); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import matplotlib.pyplot as plt | |
# Display the original image | |
f, (ax1, ax2) = plt.subplots(1,2) | |
ax1.imshow(X) | |
ax1.set_title('Original') | |
ax2.imshow(XRecovered) | |
ax2.set_title('Compressed') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from sklearn.cluster import KMeans | |
K=3 # number of clusers | |
# setting random_state to 0 seeds random number generate to get | |
# the same results every run. X is the a MxN matrix where N is the number of features | |
# and M is the number of examples. | |
kmeans = KMeans(n_clusters=K, random_state=0).fit(X) | |
# location of centroids |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import scipy.io as io | |
mat = io.loadmat('./data/ex7data1.mat') | |
print(mat.keys()) | |
# X = mat['X'] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
perm = np.random.permutation(m) | |
sel = X[perm[0:100],:] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'{}'.format(data) #plain | |
'{:.2f}'.format(data) #float to 2 decimal places | |
'{:.2e}'.format(data) #scientific notation to 2 decimal places |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
invDict = {v: k for k, v in dictionary.items()} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import asyncio | |
import time | |
class human: | |
def __init__(self, name): | |
""" """ | |
self.name = name | |
self.time = 2 | |
OlderNewer