Skip to content

Instantly share code, notes, and snippets.

backupbrain

Block or report user

Report or block backupbrain

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View get_email_from_name.py
#!/usr/bin/env python3
import urllib.request
import json
import requests
full_name = "Professor John Roberts Smith Jr."
domain = "example.com"
api_key = "<neverbounce_api_key>"
name_parts = full_name.lower().split(" ")
View guess_url_from_company_name.py
import re
import requests
import nltk
from lxml import html
from nltk.corpus import stopwords
stop_words = set(stopwords.words("english"))
# A Company Name
company_name = "The Boring Company"
search_terms = ["flamethrower"] # The Boring Company sells flamethrowers
View job_title_analysis.py
import re
import nltk
from nltk.corpus import stopwords
import pandas as pd
stop_words = set(stopwords.words("english"))
def get_first_title(title):
# keep "co-founder, co-ceo, etc"
title = re.sub(r"[Cc]o[\-\ ]","", title)
View qasm_lexer_parse_error.js
LexicalAnalyzer.prototype.generateParseError = function(lineNumber=null, message="") {
error = {"line": lineNumber, "message": message};
return error;
}
View qasm_lexer_run.js
LexicalAnalyzer.prototype.run = function(tokenLines) {
lexOutput = this.getClassifiedTokenFromLines(tokenLines);
return lexOutput;
};
View qasm_lexer_classify_tokens.js
LexicalAnalyzer.prototype.getClassifiedTokenFromLines = function(tokenLines) {
classifiedTokens = [];
errors = [];
// loop through each line of code
for (var lineId = 0; lineId < tokenLines.length; lineId++) {
line = tokenLines[lineId];
// loop through each token in each line
for (var tokenId = 0; tokenId < line.length; tokenId++) {
token = line[tokenId];
classifiedToken = null;
View qasm_lexer_token_types.js
function LexicalAnalyzer() {
this.tokenTypes = {
"include": /^include$/,
"string": /^\"[^\"]+\"$/,
"unaryop": /^(sin|cos|tan|exp|ln|sqrt)$/,
"exp": /^(\+|\-|\*|\/|\^)$/,
"comma": /^\,$/,
"openparen": /^\($/,
"closeparen": /^\)$/,
"openbracket": /^\[$/,
View tokenizer_run.js
Tokenizer.prototype.run = function(text) {
formattedText = this.prepareCodeForTokenization(text);
tokens = this.getTokenLines(formattedText);
return tokens;
}
Tokenizer.prototype.prepareCodeForTokenization = function(text) {
text = this.stripComments(text);
text = this.trimWhitespace(text);
text = this.resetNewlines(text);
View tokenizer_get_token_lines.js
Tokenizer.prototype.getTokenLines = function(text) {
lines = text.split("\n");
tokenLines = [];
for (var lineId = 0; lineId < lines.length; lineId++) {
line = lines[lineId];
tokens = line.split(" ");
tokenLines.push(tokens);
}
return tokenLines;
}
View tokenizer_pad_tokens.js
Tokenizer.prototype.padTokens = function(text) {
tokenized = text.replace(/ ?([,\(\)\/\[\]\+\*\-]+) ?/g, " $1 ");
tokenized = tokenized.replace(/ ?([,]) ?/g, " $1 ");
tokenized = tokenized.replace(/- >/g, "->")
tokenized = tokenized.replace(/ ?(==) ?/g, " $1 ");
tokenized = tokenized.replace(/;/g, " ;");
tokenized = tokenized.replace(/\s{2,}/g, " ");
return tokenized;
}
You can’t perform that action at this time.