Skip to content

Instantly share code, notes, and snippets.

View benlansdell's full-sized avatar

Ben Lansdell benlansdell

View GitHub Profile
@benlansdell
benlansdell / parallel_write.py
Created January 26, 2023 23:20 — forked from rossant/parallel_write.py
Write a NumPy array in parallel from multiple CPUs/processes, using shared memory. No copy/serialization involved. Pure Python/NumPy.
"""Write a NumPy array in parallel from multiple CPUs/processes, using shared memory."""
from contextlib import closing
import multiprocessing as mp
import os
import numpy as np
def _init(shared_arr_):
@benlansdell
benlansdell / 3d-solar-system-with-three-js.markdown
Created October 15, 2022 04:40
3D Solar System with Three.js

3D Solar System with Three.js

Three.js is really perfect for learning 3D. Plenty of great tutorials and examples out there. For this project, I just wanted to get the visual aspects down. The next step will be using an ECS design, and building the scene dynamically.

A Pen by Danie Clawson on CodePen.

License.

@benlansdell
benlansdell / filepicker.py
Last active April 18, 2024 16:52
FilePicker for streamlit
"""FilePicker for streamlit.
Still doesn't seem to be a good solution for a way to select files to process from the server Streamlit is running on.
Here's a pretty functional solution.
Usage:
```
import streamlit as st
@benlansdell
benlansdell / main.py
Created December 29, 2020 18:57
Basic python program template
#!/usr/bin/env python3
import argparse
parser = argparse.ArgumentParser()
parser.add_argument('headnode', type = str)
def main(args):
print("Now you can do stuff with the arguments")
if __name__ == "__main__":
@benlansdell
benlansdell / pointers.c
Created October 10, 2018 15:39
Basic pointer behavior in C
Basic pointer behavior in C
@benlansdell
benlansdell / extract_scalars.py
Created June 7, 2018 19:17 — forked from wchargin/extract_scalars.py
Extract scalars to CSV using the TensorBoard event multiplexer API
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
import csv
import errno
import os
import re
#Combine into montage 4 videos
avconv -i octopus_resize.mp4 -i jellyfish_nosound_resize.mp4 -i monkeytool.mp4 -i celegans_resize.mp4 -filter_complex \
'[0:v]pad=iw*2:ih*2:0:0[int2];[int2][1:v]overlay=0:H/2[int3];[int3][2:v]overlay=W/2:0[int4];[int4][3:v]overlay=W/2:H/2[out]' \
-map [out] -an -c:v libx264 -crf 23 -preset veryfast nervous_noaudio.mp4
@benlansdell
benlansdell / zenodo.py
Last active March 1, 2017 19:46
Upload files to Zenodo
headers = {"Content-Type": "application/json"}
r = requests.post("https://zenodo.org/api/deposit/depositions?access_token=ACCESS", data="{}", headers=headers)
deposition_id = r.json()['id']
l = len(nevfiles)
#for idx,nv in enumerate(nevfiles):
for idx in range(31,len(nevfiles)):
nv = nevfiles[idx]
print("Depositing %d/%d: %s"%(idx+1,l,nv))
__author__ = "Yasunobu OKAMURA"
__copyright__ = "Copyright (c) 2012 Y.Okamura"
__license__ = "GPL v3+"
import xml.parsers.expat
import networkx as nx
class XGMMLParserHelper(object):
"""
"""