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
""" | |
Minimal character-level Vanilla RNN model. Written by Andrej Karpathy (@karpathy) | |
BSD License | |
""" | |
import numpy as np | |
# data I/O | |
data = open('input.txt', 'r').read() # should be simple plain text file | |
chars = list(set(data)) | |
data_size, vocab_size = len(data), len(chars) |
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
// SPDX-License-Identifier: MIT | |
// | |
// This code will add a GPT3() function in your Google Sheets | |
// This code is originally inspired from https://twitter.com/fabianstelzer/status/1572926883179778050 | |
// To use it, insert your API key below, open Google Sheets -> Extensions -> Apps Script -> Copy & Paste this -> Save | |
// | |
// Usage: =GPT3(prompt, max_tokens (default=15), model (default=davinci)) | |
// Example usage: =GPT3("Once upon a time,", 1000, "davinci") | |
var API_KEY = "your-API-key"; |
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
#!/bin/bash | |
# | |
# video conversion script for publishing as HTML 5 video, via videojs (with hd button extension) | |
# 2011 by zpea | |
# feel free to use as public domain / Creative Commons CC0 1.0 (http://creativecommons.org/publicdomain/zero/1.0/) | |
# | |
FFMPEG=/usr/bin/ffmpeg | |
HD_SUFFIX='_hd' |
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
# get recent changes from wikipedia | |
library(rvest) | |
n_changes <- 5000 | |
recent_changes_url <- paste0("https://en.wikipedia.org/w/index.php?title=Special:RecentChanges&limit=", n_changes , "&days=1") | |
# connect to website | |
html <- read_html(recent_changes_url) |
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
#!/usr/bin/env python | |
import Image | |
import os, sys | |
def resizeImage(infile, dir, output_dir="", size=(1024,768)): | |
outfile = os.path.splitext(infile)[0]+"_resized" | |
extension = os.path.splitext(infile)[1] | |
if extension.lower()!= ".jpg": |
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
# This line imports the modules we will need. The first is the sys module used | |
# to read the command line arguments. Second the Python Imaging Library to read | |
# the image and third numpy, a linear algebra/vector/matrix module. | |
import sys; from PIL import Image; import numpy as np | |
# This is a list of characters from low to high "blackness" in order to map the | |
# intensities of the image to ascii characters | |
chars = np.asarray(list(' .,:;irsXA253hMHGS#9B&@')) | |
# Check whether all necessary command line arguments were given, if not exit and show a |
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
# Set working directory | |
dir <- "C:\\" # adjust to suit | |
setwd(dir) | |
# configure variables and filenames for MALLET | |
## here using MALLET's built-in example data and | |
## variables from http://programminghistorian.org/lessons/topic-modeling-and-mallet | |
# folder containing txt files for MALLET to work on | |
importdir <- "C:\\mallet-2.0.7\\sample-data\\web\\en" |
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
# This script builds on Aleszu Bajak's excellent | |
# [tutorial on building a course website using R Markdown and Github pages](http://www.storybench.org/convert-google-doc-rmarkdown-publish-github-pages/). | |
# I was excited about the concept but wanted to automate a few of the production steps: namely generating the HTML files | |
# for the site from the RMD pages (which Aleszu describes doing one-by-one) and generating the site navigation menu, | |
# which Aleszu handcodes in the `_site.yml` file. This script should automate both processes, though it may have some quirks | |
# unique to my setup that you'd want to tweak to fit your own. It's likely more loquacious than necessary as well, so feel free | |
# to condense as you can. Ideally, each time you make updates to your RMD files you can run this script to generate updated HTML | |
# pages and a new `_site.yml`. Then commit changes to Github and you're up and running! | |
# Once you've got everything configured for your own site below, you should be able to run `source('rend |
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
#!/usr/bin/python | |
## Split audio files into chunks | |
## Daniel Pett 1/5/2020 | |
__author__ = 'portableant' | |
## Tested on Python 2.7.16 - yes I know I need to upgrade. | |
import argparse | |
import os | |
import speech_recognition as sr |
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
--- | |
title: "Programming Literary Bots" | |
author: "Ryan Cordell" | |
date: "3/12/2017" | |
output: html_document | |
--- | |
## Acknowledgements | |
This version of my twitterbot assignment was adapted from [an original written in Python](https://www.dropbox.com/s/r1py3zazde2turk/Trendingmore.py?dl=0), which itself adapted code written by Mark Sample. That orginal bot tweeted (I've since stopped it) at [Quoth the Ravbot](https://twitter.com/Quoth__the). The current version owes much to advice and code borrowed from two colleagues at Northeastern University: Jonathan Fitzgerald and Benjamin Schmidt. |
NewerOlder