Skip to content

Instantly share code, notes, and snippets.

Ethan Willis ethanwillis

Block or report user

Report or block ethanwillis

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
@ethanwillis
ethanwillis / ngrams.py
Last active Aug 29, 2015
Python script to find ngrams in a corpus
View ngrams.py
def ngramsProgram(corpus, n):
# Input comes from our parameters
# process our input to find ngrams
ngrams = findNGrams(corpus, n)
# Output our ngrams.
outputNGrams(ngrams)
def findNGrams(corpus, n):
@ethanwillis
ethanwillis / ngrams.py
Last active Aug 29, 2015
Final Version of Ngrams script with CSV Output and multi query support
View ngrams.py
import os
import csv
from string import maketrans
def ngramsProgram(directory, ngramQueries):
# Input: get corpus from all text files within a directory
# Step 1: Get list of files in a directory
txtFileList = os.listdir(directory)
# Step 2: Process each text file in our list of files
searchResults = []
View processFiles.sh
#!/bin/bash
FILES=/path/to/*
for f in $FILES
do
echo "Processing $f file..."
# take action on each file. $f store current file name
cat $f
done
View gist:5209795
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package sorts;
import java.io.PrintStream;
import java.util.ArrayList;
/**
View gist:5209906
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package sorts;
import java.io.PrintStream;
import java.util.ArrayList;
/**
View React Style Example 1
// Template for display data JSON object
template(name="channels")
with data
if params.error
+channels_error
.row
.col.s12
| Channels Forms Goes Here
template(name="channels_error")
@ethanwillis
ethanwillis / tab_2_state.json
Created Sep 20, 2016
JSON object for saving state of tab 2 in DC Email editor
View tab_2_state.json
{
selected_outcome_name: "Insurance Concerns",
selected_outcome_id: "id of selected outcome",
slice_name: "{SelectedOutcome}Slice.X"
template_id: "id of selected template",
template_html: "html + text of template that was edited in the live preview pane. This will include all user text changes."
}
@ethanwillis
ethanwillis / get_protocols_result.json
Created Feb 16, 2017
ProtcolsIOAPI getProtocols() example result
View get_protocols_result.json
{
"request": "OK",
"protocols": [{
"protocol_name": "Transformation of Skeletonema marinoi using Multipulse Electroporation",
"protocol_id": "5038",
"version_class": "5038",
"activity": "1486591925",
"is_owner": "0"
}, {
"protocol_name": "Modeling ecological drivers in marine viral communities using comparative metagenomics and network analyses",
View mongoclientexample.js
var MongoClient = require('mongodb').MongoClient;
var mongo_url = "mongodb://localhost:27017/mydbname"
MongoClient.connect(settings.application_settings.mongo_url, function(err, db_client) {
var mongo_collection = db_client.collection("a_collection_name");
// Insert empty object { } or whatever you want
mongo_collection.insert({ }, function(err, result) {
// handle err and result
})
@ethanwillis
ethanwillis / tnbear_scrape.js
Created Jul 1, 2017
tnbear business scraper.
View tnbear_scrape.js
(function() {
// Load in a modern version of JQuery from Google CDN.
var script = document.createElement("SCRIPT");
script.src = 'https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js';
script.type = 'text/javascript';
script.onload = function() {
var $ = window.jQuery;
};
document.getElementsByTagName("head")[0].appendChild(script);
You can’t perform that action at this time.