Skip to content

Instantly share code, notes, and snippets.

View aaronjolson's full-sized avatar

Aaron Olson aaronjolson

View GitHub Profile
@aaronjolson
aaronjolson / llamaindex_activeloop_vectorize_data_from_github.py
Last active February 20, 2024 13:36
Code for using llama-index to load github data into the activeloop deeplake vector database. Originally from this course https://learn.activeloop.ai/courses/take/rag/multimedia/51349127-chat-with-your-code-llamaindex-and-activeloop-deep-lake-for-github-repositories this code has the imports modified to work with the latest version of llama-index
''' in .env file
GITHUB_TOKEN="YOUR_GH_CLASSIC_TOKEN"
OPENAI_API_KEY="YOUR_OPENAI_KEY"
ACTIVELOOP_TOKEN="YOUR_ACTIVELOOP_TOKEN"
DATASET_PATH="hub://YOUR_ORG/repository_vector_store"
need to install llama-index >= 0.10.0, python-dotenv, and llama-index-readers-github >= 0.1.5
'''
''' in .env file
GITHUB_TOKEN="YOUR_GH_CLASSIC_TOKEN"
OPENAI_API_KEY="YOUR_OPENAI_KEY"
ACTIVELOOP_TOKEN="YOUR_ACTIVELOOP_TOKEN"
DATASET_PATH="hub://YOUR_ORG/repository_vector_store"
need to install llama-index, python-dotenv, and llama-index-readers-github
'''
import bpy,bmesh
ob = bpy.data.objects['Cube']
bpy.ops.object.mode_set(mode='EDIT')
mesh=bmesh.from_edit_mesh(bpy.context.object.data)
for v in mesh.verts:
v.select = True
@aaronjolson
aaronjolson / material_cleanup.py
Created July 3, 2021 19:21
remove extra materials from all objects in a scene
import bpy
for obj in bpy.context.selected_editable_objects:
obj.active_material_index = 1
for i in range(1, len(obj.material_slots)):
bpy.ops.object.material_slot_remove({'object': obj})
for block in bpy.data.materials:
if block.users == 0:
bpy.data.materials.remove(block)
@aaronjolson
aaronjolson / settings.json
Created January 27, 2021 23:12
Windows terminal config
// To view the default settings, hold "alt" while clicking on the "Settings" button.
// For documentation on these settings, see: https://aka.ms/terminal-documentation
{
"$schema": "https://aka.ms/terminal-profiles-schema",
"defaultProfile": "{61c54bbd-c2c6-5271-96e7-009a87ff44bf}",
"profiles":
@aaronjolson
aaronjolson / select_face_in_blender_and_extrude.py
Created February 9, 2019 16:56
Demonstration of using Python to take an existing mesh, selecting a particular face, and extruding it
import bpy,bmesh
# Assumes we aleady have a cube out, nothing selected
ob = bpy.data.objects['Cube']
bpy.ops.object.mode_set(mode='EDIT')
mesh = bmesh.from_edit_mesh(bpy.context.object.data)
ur_face = None
# look at all of the faces of the cube, find the one that is 'facing' the positive direction on the y axis
for f in mesh.faces:
@aaronjolson
aaronjolson / create_spiral_stairs_in_blender.py
Created February 9, 2019 16:38
Script to create a spiral staircase in blender. As-is, it runs standalone, but it can easily be refactored to integrate it into a project
import bpy
import bmesh
# cleans out the rest of the objects from the scene and puts the cube in, essentially a fresh start, useful for debugging
bpy.ops.object.select_all(action='TOGGLE')
bpy.ops.object.select_all(action='TOGGLE')
bpy.ops.object.delete(use_global=False)
bpy.context.scene.cursor_location = (0.0, 0.0, 0.0)
bpy.ops.mesh.primitive_cube_add(radius=1, view_align=False, enter_editmode=False, location=(0, 0, 0), layers=(True, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False))
from flask import Flask
from flask import make_response
import os
app = Flask(__name__)
# Simple flask server to be used locally for serving images to get around constraints such as those created
# when trying to load textures in ThreeJs.
# https://stackoverflow.com/questions/24087757/three-js-and-loading-a-cross-domain-image
@aaronjolson
aaronjolson / convert_to_jpeg.py
Last active August 9, 2018 22:02
Converts all png, tif, and bmp files in a directory into jpegs
import os
from PIL import Image
for infile in os.listdir("./"):
print ("file : " + infile)
if infile[-3:] == "tif" or infile[-3:] == "bmp" or infile[-3:] == "png":
outfile = infile[:-3] + "jpeg"
im = Image.open(infile)
print("new filename : " + outfile)
out = im.convert("RGB")
@aaronjolson
aaronjolson / blender_select_face_normal_y_axis.py
Created June 9, 2018 22:49
Blender script to select the face of a cube with its normal facing the Y axis
import bpy,bmesh
ob = bpy.data.objects['Cube']
bpy.ops.object.mode_set(mode='EDIT')
mesh=bmesh.from_edit_mesh(bpy.context.object.data)
for f in mesh.faces:
if f.normal.y == 1.0:
f.select = True
# trigger viewport update