Skip to content

Instantly share code, notes, and snippets.

@NanoDano
NanoDano / PlayAnimationOnKey.cs
Created June 19, 2023 00:09
Play animation on keypress in Unity
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlayAnimationOnKey : MonoBehaviour
{
public Animation animationToPlay;
// Start is called before the first frame update
void Start()
{
@NanoDano
NanoDano / PlayerMovementController.cs
Created June 13, 2023 23:38
Unity MMORPG style player camera
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlayerMovementController : MonoBehaviour
{
public CharacterController characterController;
public Camera playerCamera;
private Vector3 playerVelocity;
@NanoDano
NanoDano / export_blend_to_gltf.py
Created May 15, 2023 00:09
Export a Blender file to glTF from the command-line headless
"""
This script automates the process of exporting the .glb file.
You can run this script from the command-line in a headless mode.
Example usages:
```sh
blender -b -P export_gltf.py mymodel.blend
/Applications/Blender.app/Contents/MacOS/Blender -b -P export_gltf.py "Monkey.blend"
```
@NanoDano
NanoDano / rename_all.py
Created March 4, 2023 21:07
Rename all files recursively
# Remove a prefix from all files in recursive subdirs
import os
PREFIX_TO_REMOVE = "Something - "
ROOT_DIR = "."
for (dirpath, dirs, files) in os.walk(ROOT_DIR):
for filename in files:
# print(f'{filename} {dirpath} {dirs}')
@NanoDano
NanoDano / macropad_piano.py
Created June 26, 2022 22:27
AdaFruit MacroPad as MIDI piano (CircuitPy)
# This is the `code.py` for CircuitPy
"""
G9 = 127
"A4" = 69
C4 = 60
C0 = 12
"""
from adafruit_macropad import MacroPad
# C minor pentatonic
@NanoDano
NanoDano / bounce_random_cubes.py
Last active April 18, 2022 17:31
Blender3D script to generate and animate bouncing cubes
import bpy
import random
# Reference: https://www.youtube.com/watch?v=r8hqLh_HE08
# After running the script, go to the Animation tab and hit SPACE to run the animation
def delete_all_cubes():
# Select all cubes by name
for o in bpy.context.scene.objects:
@NanoDano
NanoDano / minecraft_backup.rb
Created February 1, 2022 23:23
Rotating remote SSH backup script in Ruby
#!/usr/bin/env ruby
require 'net/http'
BACKUP_DESTINATION_DIR = '/home/nanodano/mc_backup_rotate/backup_test'
DISCORD_WEBHOOK_URL = ''
DIR_TO_BACKUP = '/home/nanodano'
DB_USER = 'username'
DB_HOST = '127.0.0.1'
DB_NAME = 'dbname'
DB_PASS = 'password'
@NanoDano
NanoDano / extract_images_from_pdf.py
Created October 14, 2021 06:57
Extract images from a PDF
#!/usr/bin/env python
"""
Extract images from a PDF
Modified from original at https://www.geeksforgeeks.org/how-to-extract-images-from-pdf-in-python/
pip install fitz frontend pymupdf
"""
import fitz
import io
from PIL import Image
@NanoDano
NanoDano / remind.sh
Last active June 23, 2021 04:09
Healthy Reminders
#!/bin/bash
# Healthy Reminders
#
# Setup a cron job to remind you to do healthy things
# Install dependency with: `sudo apt install libnotify-bin`
#
# Usage: remind.sh "Time to hydrate."
#
# Some cron examples (`crontab -e`):
# 0 * * * * /home/dano/Healthy-Reminders/remind.sh "Time to stand up."
@NanoDano
NanoDano / ssh-copy-id.py
Created June 9, 2021 04:12
Copy public SSH key to remote host using Paramiko
"""
Copy your SSH public key into a remote
host's `~/.ssh/authorized_keys` file.
pip install paramiko
Usage: ssh-copy-id.py <host> <username>
"""
from paramiko import SSHClient, AutoAddPolicy
import sys