This file contains 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
// https://www.blockspring.com/blog/serverless-slack-bots | |
blockspring = require('blockspring'); | |
var webhook = function(team_domain, service_id, token, user_name, team_id, user_id, channel_id, timestamp, channel_name, text, trigger_word, raw_text) { | |
// Basic bot will just echo back the message | |
response = ["*", user_name, "* said _", text, "_"].join('') | |
return { |
This file contains 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
var handlers = { | |
onConnect: function () { | |
console.log('Connected!'); | |
}, | |
onMessage: function () { | |
console.log('Message!'); | |
} | |
}; | |
var map = { |
This file contains 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
soup(lambda tag: tag.name == 'div' and tag.get('class') == ['some-class']) |
This file contains 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 os, random | |
random.choice(os.listdir("INSERT-DIR")) |
This file contains 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
# Non-recursive | |
import os | |
def load_directory(data_path): | |
files_list = [] | |
try: | |
for file_name in os.listdir(data_path): | |
if file_name.endswith(".html"): | |
files_list.append(file_name) |
This file contains 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
file_header = "<html>\n<head>\n<meta charset='utf-8'>\n</head>\n<body>\n" | |
file_footer = "\n</body>\n</html>" |
This file contains 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
def longest_common_substring(s1, s2): | |
m = [[0] * (1 + len(s2)) for i in range(1 + len(s1))] | |
longest, x_up_to = 0, 0 | |
for x in range(1, 1 + len(s1)): | |
for y in range(1, 1 + len(s2)): # match every char in s2 against every char in s1 | |
if s1[x - 1] == s2[y - 1]: # record a char match | |
m[x][y] = m[x - 1][y - 1] + 1 # char match tally will accumulate if previous char also matched | |
if m[x][y] > longest: | |
longest = m[x][y] | |
x_up_to = x # record char position of last found match |
This file contains 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 bs4 import BeautifulSoup | |
import re # Regular Expressions | |
import collections # Data Types | |
import sys # File operations | |
import codecs # UniCode support | |
import os | |
def clear_output_file(out_file): | |
file_header ="""<html> | |
<head> |
This file contains 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 bs4 import BeautifulSoup | |
import re # Regular Expressions | |
import collections # Data Types | |
import sys # File operations | |
import codecs # UniCode support | |
import os | |
import locale | |
def extract_index_word(entry): | |
first_head = entry.find('div', class_="head-block") |
This file contains 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 bs4 import BeautifulSoup | |
from bs4.element import Tag | |
import re # Regular Expressions | |
import collections # Data Types | |
import sys # File operations | |
import codecs # UniCode support | |
import os | |
import locale | |
def is_tag(tag): |
OlderNewer