Skip to content

Instantly share code, notes, and snippets.

Avatar
:octocat:
hi

Jordan Matelsky j6k4m8

:octocat:
hi
View GitHub Profile
@j6k4m8
j6k4m8 / Set-Up-Blender-Infinite-Background.py
Created Aug 17, 2020
Set up an infinite Blender background (beveled plane), with Camera, Focus-empty, and DOF
View Set-Up-Blender-Infinite-Background.py
import math
import bpy
def add_infinite_background(coll_name = None):
mesh = bpy.data.meshes.new("InfiniteBackground")
obj = bpy.data.objects.new(mesh.name, mesh)
col = bpy.data.collections.get("Collection")
col.objects.link(obj)
bpy.context.view_layer.objects.active = obj
View Tmux for Absolute Beginners.md

new session

the first time after boot, start a new tmux session:

tmux

(it's working if your shell has a green bar at the bottom)

View ec2cost.py
EC2_NAME = "x1.32xlarge"
# https://stackoverflow.com/a/55109870/979255
def get_uptime():
with open('/proc/uptime', 'r') as f:
uptime_seconds = float(f.readline().split()[0])
return uptime_seconds
@j6k4m8
j6k4m8 / vol
Created Dec 11, 2019
Raspberry Pi Volume Control. Use with `vol 70` for 70% volume
View vol
#!/usr/bin/env python
import subprocess
import sys
if len(sys.argv) > 1:
subprocess.check_output("amixer sset 'PCM' {}%".format(sys.argv[1]), shell=True)
else:
print(subprocess.check_output("amixer get 'PCM' | grep '%'", shell=True).split()[3].strip('[]'))
@j6k4m8
j6k4m8 / README.md
Last active Jan 24, 2020
Comparator overrides
View README.md

Access REST endpoints in "object" dot-notation and pandas-like index-notation in Python.

Example usage:

Posts = RemoteDataProvider(
    list_all=lambda: requests.get("https://jsonplaceholder.typicode.com/posts").json(),
    get_one=lambda x: requests.get(f"https://jsonplaceholder.typicode.com/post/{x}").json(),
)
@j6k4m8
j6k4m8 / tv
Created Nov 5, 2017
rpi scripts
View tv
#!/usr/bin/env python
import os
import sys
import subprocess
if (sys.argv[1] == 'on'):
subprocess.check_output('/opt/vc/bin/tvservice -p', shell=True)
if len(sys.argv) > 2 and sys.argv[2] == "up":
@j6k4m8
j6k4m8 / data.Nov-2-2017.json
Last active Nov 3, 2017
Activity on 365papers tweets, re: media
View data.Nov-2-2017.json
{
"data": [{"id": "926202781534388224", "has_media": true, "favorites": 0, "retweets": 0}, {"id": "925899260981399553", "has_media": false, "favorites": 0, "retweets": 0}, {"id": "925466309869043714", "has_media": false, "favorites": 2, "retweets": 0}, {"id": "925107363782283269", "has_media": true, "favorites": 1, "retweets": 0}, {"id": "924714332591620097", "has_media": false, "favorites": 2, "retweets": 0}, {"id": "924327510124441602", "has_media": false, "favorites": 0, "retweets": 0}, {"id": "923986889803223040", "has_media": false, "favorites": 2, "retweets": 1}, {"id": "923752187288870914", "has_media": false, "favorites": 0, "retweets": 0}, {"id": "923376386047344640", "has_media": false, "favorites": 0, "retweets": 0}, {"id": "923017521296543744", "has_media": false, "favorites": 0, "retweets": 0}, {"id": "922573311799975936", "has_media": false, "favorites": 0, "retweets": 0}, {"id": "922210485453426691", "has_media": false, "favorites": 0, "retweets": 0}, {"id": "921818671022051333", "has_media
@j6k4m8
j6k4m8 / NiceNotebooks.md
Created Jul 9, 2017
How to write friendly Jupyter Notebooks
View NiceNotebooks.md

Jupyter Notebook Conventions

Manifesto

Notebooks are designed for easy reproducibility and code-sharing. Babysitting and debugging someone else's notebook sucks. Don't curse your friends with this burden!

When a user opens your notebook, they should be able to run all cells in order without any additional intervention.

Inputs that must be made to enable the code to run (e.g. password prompts, API tokens, etc) should be requested as soon as the notebook starts running.

Here's the TLDR:

@j6k4m8
j6k4m8 / git-nicely.md
Last active Jun 27, 2019
How to git nicely with others
View git-nicely.md

How to Git Nicely

Pull latest master.

git checkout master
git pull origin master

Check out a new feature-branch.

@j6k4m8
j6k4m8 / ipinfo
Last active Sep 21, 2017
Python: Get local, global, or router IP from the command line
View ipinfo
#!/usr/bin/env python3
"""
Usage:
./ipinfo [router|local|global]
./ipinfo geo [ip]
For example, to get your OWN location:
./ipinfo geo $(ipinfo global)
You can’t perform that action at this time.