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 digest library (default R-base library) | |
library(digest) | |
# get current date in UTC as ISO string and keep all chars up until minutes | |
# eg. 2019-10-14T17:40 | |
date <- strftime(as.POSIXlt(Sys.time(), tz = "UTC"), "%Y-%m-%dT%H:%M") | |
# get userId | |
userId <- "0000123" |
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
SELECT DP1.name AS DatabaseRoleName, | |
isnull (DP2.name, 'No members') AS DatabaseUserName | |
FROM sys.database_role_members AS DRM | |
RIGHT OUTER JOIN sys.database_principals AS DP1 | |
ON DRM.role_principal_id = DP1.principal_id | |
LEFT OUTER JOIN sys.database_principals AS DP2 | |
ON DRM.member_principal_id = DP2.principal_id | |
WHERE DP1.type = 'R' | |
ORDER BY DP1.name; |
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
linters: with_defaults( | |
line_length_linter(120), | |
camel_case_linter = NULL | |
) |
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
[net] | |
# Testing | |
# batch=1 | |
# subdivisions=1 | |
# Training | |
batch=1 | |
subdivisions=1 | |
width=416 | |
height=416 | |
channels=3 |
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 multiprocessing, joblib | |
def parallelize(iter_expression, func): | |
func = func.replace("(", ")(") | |
n_jobs = multiprocessing.cpu_count() | |
return eval("joblib.Parallel(n_jobs={})(joblib.delayed({} {})".format(n_jobs, func, iter_expression)) | |
parallelize("for i in range(10)", "print(i)") |
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 time | |
import pandas as pd | |
from multiprocessing import Pool | |
def worker(i): | |
t = time.time() | |
time.sleep(0.5) # simulate processing something | |
d = { | |
"name": "Player {}".format(i + 1), | |
"points": (i + 1) ** 2.0 |
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
const ua = require("universal-analytics"); | |
const request = require("request-promise"); | |
const { https } = require("firebase-functions"); | |
function getUserID (obj) { | |
if (!obj.source) { | |
return "dialogflow"; | |
} else { | |
switch (obj.source) { | |
case "twilio": |
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 re | |
def remove_padding(char, s, left=None, right=None): | |
if not left and not right: | |
print("You must specify either left or right.") | |
return | |
elif left: | |
return re.findall(re.escape(char) + r"*(.+)", s)[0] | |
elif right: | |
return re.findall(re.escape(char) + r"*(.+)", s[::-1])[0][::-1] |
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
# pip install lxml cssselect | |
import lxml.html | |
from lxml import etree | |
html = """ | |
<html> | |
<body> | |
<p>Hello world</p> | |
</body> |
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
# Install virtualenv | |
pip3 install virtualenv | |
# Go to project folder | |
cd path/to/project-name | |
# Create environment 'env' | |
virtualenv env | |
# Activate environment |