Skip to content

Instantly share code, notes, and snippets.

View pleonard212's full-sized avatar

Peter Leonard pleonard212

View GitHub Profile
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@karpathy
karpathy / stablediffusionwalk.py
Last active September 10, 2024 12:32
hacky stablediffusion code for generating videos
"""
stable diffusion dreaming
creates hypnotic moving videos by smoothly walking randomly through the sample space
example way to run this script:
$ python stablediffusionwalk.py --prompt "blueberry spaghetti" --name blueberry
to stitch together the images, e.g.:
$ ffmpeg -r 10 -f image2 -s 512x512 -i blueberry/frame%06d.jpg -vcodec libx264 -crf 10 -pix_fmt yuv420p blueberry.mp4
from SPARQLWrapper import SPARQLWrapper, JSON
import html, datetime, os, json, glob, time
def send_sparql_query(q, timeout=None, sleep=0):
time.sleep(sleep)
try:
sparql = SPARQLWrapper("http://dbpedia.org/sparql")
sparql.setReturnFormat(JSON)
if timeout: sparql.setTimeout(timeout)
sparql.setQuery(q)
@zhanwenchen
zhanwenchen / Install NVIDIA Driver and CUDA.md
Last active March 13, 2024 23:42 — forked from wangruohui/Install NVIDIA Driver and CUDA.md
Install NVIDIA CUDA 9.0 on Ubuntu 16.04.4 LTS
@cerisier
cerisier / chapters.md
Last active December 20, 2022 20:52
List iTunes podcast chapters to csv output
# ffprobe -v error -select_streams a:0 -show_chapters -of csv=print_section=1 ABGT160_847378.m4a

Example output:

chapter,0,1/600,0,0.000000,18523,30.871667,Group Therapy Intro - ABGT160
chapter,1,1/600,18523,30.871667,146505,244.175000,1. Arty ‘Kate’ [2015 Remix] (Anjunabeats)
chapter,2,1/600,146505,244.175000,262290,437.150000,2. Flashtech ’Shattered Dreams’ (Silk)
chapter,3,1/600,262290,437.150000,444517,740.861667,3. Bruce Gibson ‘Kristine’ [Adrian Alexander Remix] (Elliptical Sun)
@lukemetz
lukemetz / image_scatter.py
Created August 26, 2015 17:58
Image tsne scatter plot
from tsne import bh_sne
import numpy as np
from skimage.transform import resize
from matplotlib import pyplot as plt
def gray_to_color(img):
if len(img.shape) == 2:
img = np.dstack((img, img, img))
return img
L.CartoDB = L.GeoJSON.extend({
initialize: function (url, options) {
L.Util.setOptions(this, options);
this._layers = {};
var self = this;
if (url) {
this._jsonp(url, function(geojson){
@seanh
seanh / formatFilename.py
Created April 11, 2009 18:30
Turn any string into a valid filename in Python.
def format_filename(s):
"""Take a string and return a valid filename constructed from the string.
Uses a whitelist approach: any characters not present in valid_chars are
removed. Also spaces are replaced with underscores.
Note: this method may produce invalid filenames such as ``, `.` or `..`
When I use this method I prepend a date string like '2009_01_15_19_46_32_'
and append a file extension like '.txt', so I avoid the potential of using
an invalid filename.