Skip to content

Instantly share code, notes, and snippets.

View Btibert3's full-sized avatar

Brock Tibert Btibert3

View GitHub Profile
@benwattsjones
benwattsjones / gmail_mbox_parser.py
Last active May 28, 2024 15:16
Quick python code to parse mbox files, specifically those used by GMail. Extracts sender, date, plain text contents etc., ignores base64 attachments.
#! /usr/bin/env python3
# ~*~ utf-8 ~*~
import mailbox
import bs4
def get_html_text(html):
try:
return bs4.BeautifulSoup(html, 'lxml').body.get_text(' ', strip=True)
except AttributeError: # message contents empty
@Btibert3
Btibert3 / writeTDE.r
Created June 15, 2017 20:30 — forked from devmacrile/writeTDE.r
Write R data.frame to a Tableau data extract file (.tde)
# Write R data.frame to a Tableau data extract file (.tde) by building and executing
# a python script which utilizes the Tableau data extract API (a hack, yes).
#
# This, naturally, has a hard dependency on the TDE API, so is only available for
# Windows and Linux systems (unfortunately)
#
# Devin Riley
# October, 2014
@devmacrile
devmacrile / writeTDE.r
Created February 26, 2016 03:43
Write R data.frame to a Tableau data extract file (.tde)
# Write R data.frame to a Tableau data extract file (.tde) by building and executing
# a python script which utilizes the Tableau data extract API (a hack, yes).
#
# This, naturally, has a hard dependency on the TDE API, so is only available for
# Windows and Linux systems (unfortunately)
#
# Devin Riley
# October, 2014

Whitelist the host for interactive tutorials in neo4j-server.properties file

# Whitelist of hosts for the Neo4j Browser to be allowed to fetch content from.
# Set to '*' to allow all hosts.
dbms.browser.remote_content_hostname_whitelist=http://guides.neo4j.com,https://guides.neo4j.com,http://localhost,https://localhost

Start neo4j server

@Btibert3
Btibert3 / helper-load-csv.R
Last active December 29, 2015 23:04
Quick Helper Function to use Neo4j Shell for LOAD CSV. Sets the shell tool and expects a file path. Very alpha but it works.
## a function to import cypher statements into the shell
build_import = function(NEO_SHELL="~/neo4j-community-2.3.1/bin/neo4j-shell",
cypher_file) {
cmd = sprintf("%s -file %s", NEO_SHELL, cypher_file)
system(cmd)
}
## example
## import the database from scratch
## build_import(cypher_file="import-db.cql")
@Btibert3
Btibert3 / constraints.cql
Created June 28, 2015 13:13
Stackoverflow - Load CSV import
// Apply the Constraints
CREATE CONSTRAINT ON (s:Student) ASSERT s.pidm IS UNIQUE;
CREATE CONSTRAINT ON (v:Vendor) ASSERT v.name IS UNIQUE;
CREATE CONSTRAINT ON (t:Topic) ASSERT t.name IS UNIQUE;
CREATE CONSTRAINT ON (e:Email) ASSERT e.msgid IS UNIQUE;
CREATE CONSTRAINT ON (a:Ability) ASSERT a.name IS UNIQUE;
CREATE CONSTRAINT ON (c:Contact) ASSERT c.cid IS UNIQUE;
CREATE CONSTRAINT ON (p:Template) ASSERT p.name IS UNIQUE;
CREATE CONSTRAINT ON (v:Version) ASSERT v.version IS UNIQUE;
@m3nu
m3nu / md2pdf.py
Last active November 21, 2016 18:34
md2pdf - Command line Markdown to PDF converter with support for CSS stylesheets and custom fonts
#!/usr/bin/env python
import os
import sys
from markdown2 import markdown
from xhtml2pdf import pisa
"""
## Inspired by
@wadewegner
wadewegner / upload_rest.py
Last active October 20, 2022 05:59
Upload attachment to Salesforce using Python
import requests
import base64
import json
from simple_salesforce import Salesforce
userName = ''
password = ''
securityToken = ''
instance = ''
@bearloga
bearloga / tabletools.R
Created January 9, 2014 00:40
This shows how to add a DataTables plug-in (in this case TableTools) to your Shiny app.
library(shiny)
library(ggplot2)
# Download DataTables JS file and TableTools full package from http://datatables.net/download/
# Change the paths appropriately:
addResourcePath('datatables','/Users/yourusername/Downloads/DataTables-1.9.4/media')
addResourcePath('tabletools','/Users/yourusername/Downloads/TableTools-2.1.5/media')
runApp(list(
ui = basicPage(
@fredbenenson
fredbenenson / redshift_credentials.r
Last active December 28, 2015 21:39
Redshift Wrapper & Credentials
# Install the Redshift R library:
# https://github.com/pingles/redshift-r
# install.packages("~/Downloads/redshift-r-master", dependencies = T, repos = NULL, type = "source")
library(redshift)
redshift <- redshift.connect("jdbc:postgresql://REDSHIFT_DB:5439/DB_NAME", "LOGIN", "PASSWORD")
# Example Query:
data <- dbGetQuery(redshift, "SELECT COUNT(*) FROM table")