Skip to content

Instantly share code, notes, and snippets.

View dmarx's full-sized avatar

David Marx dmarx

View GitHub Profile
#@title Prompts
prompts = {
0:"unfortunate failed crayon drawing sketched while drunk looks awful, should have thrown it away, badly drawn crayon sketch of bill murray scribbled by a child while having a stroke seizure, wouldnt even put this on my fridge, by five year old could've drawn this",
50:"unfortunate failed crayon drawing sketched while drunk looks awful, should have thrown it away, badly drawn crayon sketch CARICATURE of bill murray scribbled by a child while having a stroke seizure, wouldnt even put this on my fridge, by five year old could've drawn this",
150:"crayon drawing sketched while drunk looks awful, should have thrown it away, badly drawn crayon sketch of bill murray scribbled by a child while having a stroke seizure, wouldnt even put this on my fridge, by five year old could've drawn this",
200:"crayon drawing sketched while drunk, hastily drawn crayon sketch of bill murray scribbled by a child while having a stroke seizure, wouldnt even put this on my fridge, by five ye
"""
It looks like the Scene and Storyboard classes are intended to be used for creating animations by specifying keyframed curves for various parameters. The Scene class appears to allow users to specify the length of the scene and set keyframed curves for various attributes of the scene. The Storyboard class then allows users to create a sequence of Scene objects and specify default values for attributes that are not explicitly set in a given scene.
It looks like the KeyframedObject class is a subclass of the Keyframed class from the keyframed module, which provides some basic functionality for working with keyframed curves. The KeyframedObject class adds a weight attribute to the Keyframed class, which specifies the weight of the object when it is used in a storyboard.
The to_keyframed function provides a convenient way to convert various types of input into Keyframed objects, which can then be used as attributes in a Scene object. This function allows users to specify keyframed curves using strings, d
@dmarx
dmarx / scrape_reddit_w_R.r
Last active September 8, 2022 09:51
Demo code showing how to collect analyze the subreddits a particular user has participated in, using R sintead of python (praw). I don't believe the code is exiting when it should, but this should at least serve as a jumping off point from the person who asked for help: http://www.reddit.com/r/rstats/comments/1tq4au/accessing_the_reddit_api_thro…
#install.packages("rjson","RCurl")
library(RCurl)
library(rjson)
get_User_subs_page = function(user, after=NULL, cache=c()){
baseurl = "http://www.reddit.com/user/"
params = "limit=100"
if(!is.null(after)){
params = paste(params, "&after=",after, sep="")
@dmarx
dmarx / dl_reddit_saved_images.py
Created December 6, 2012 15:42
Downloads images from a user's saved links on reddit. Requires manual entry of username and password
"""
This script was written to illustrate libraries that could be used to improve upon
the efficiency of a script posted to /r/learnprogramming:
Original script:
https://github.com/aesptux/download-reddit-saved-images/blob/master/script.py
Reddit post
http://www.reddit.com/r/learnprogramming/comments/14dojd
/pythoncode_review_script_to_download_saved_images/
"""
from urllib2 import Request, urlopen
@dmarx
dmarx / perlin-noise.ipynb
Created February 14, 2022 08:06 — forked from adefossez/perlin-noise.ipynb
Perlin noise.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@dmarx
dmarx / LinkFixerClone.py
Last active January 19, 2021 02:20
A simple LinkFixerBot clone developed as a demonstration for anyone who is curious how a simple reddit bot might be coded. To kill this code, spam "Ctrl+C" until it catches the exception.
import praw # simple interface to the reddit API, also handles rate limiting of requests
import re
from collections import deque
from time import sleep
USERNAME = "Your username here"
PASSWORD = "Your password here"
USERAGENT = "Your useragent string here. It should include your /u/username as a courtesy to reddit"
r = praw.Reddit(USERAGENT)
@dmarx
dmarx / math504_hw12__recommendations.r
Last active June 14, 2019 10:46
Simple recommender system
partial_reconstruction = function(svd, n){
# Takes an SVD object, reconstructs the matrix using
# the top 'n' singular values
j = nrow(svd$u)
k = nrow(svd$v)
with(svd, u[,1:n] %*% (d[1:n]*diag(n)) %*% t(v[,1:n]) )
}
SVD_K_Test = function(mat, svd_ob=NULL, k=NULL){
# takes an SVD object and a vector of integers k. Let j be
@dmarx
dmarx / Arxiv Archive.md
Last active April 18, 2019 23:03
Machine learning articles I want to read or have read, mostly arxiv.org articles discussing recent advancements in deep learning.

To Read:

Publication Date Article Notes
2016 End-to-End Relation Extraction using LSTMs on Sequences and Tree Structures Cited in multi-task sciERC (2018, below)
2018-10-11 BERT: Pre-training of Deep Bidirectional Transformers for Language Understanding
Multi-Task Identification of Entities, Relations, and Coreference for Scientific Knowledge Graph Construction Probably a lot of useful citations in here, not sure we need the coreference stuff.
* SciERC datasets: http://nlp.cs.washington.edu/sciIE/
* Code: https://bitbucket.org/luanyi/scierc/src/master/
* Pretrained (best) models: NER, Coref, Relation
2017-08-08 [Structural
install.packages('caret')
install.packages('ccd')
install.packages('d3Network')
install.packages('data.table')
install.packages('dplyr')
install.packages('DMwR')
install.packages('e1071')
install.packages('ergm')
install.packages('ff')
install.packages('foreach')
@dmarx
dmarx / staged_classifiers_for_unknown_classes.r
Last active August 26, 2018 09:48
Demonstration of using a simple "two stage" strategy to handle classification that supports an "unknown" class that may contain arbitrarily many true subclasses.
library(MASS)
library(rpart)
random_pos_def_matrix = function(n){
# https://math.stackexchange.com/a/358092/109246
A = matrix(runif(n*n), n)
A = 0.5*(A+t(A))
A + n*diag(n)
}