Skip to content

Instantly share code, notes, and snippets.

View Happsson's full-sized avatar

Hannes Paulsson Happsson

View GitHub Profile
@Happsson
Happsson / SphereRotate.cs
Created December 8, 2019 11:42
part of day 6 of AoC 2019 in unity.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class SphereRotate : MonoBehaviour
{
float speed = 5;
Vector3 euls;
// Update is called once per frame
private void Start()
@Happsson
Happsson / day6.cs
Created December 8, 2019 11:40
Day 6 of AoC 2019 in unity.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System.Linq;
public class Day6 : MonoBehaviour
{
public TextAsset input;
void ShowFrame(char * s, int r, int g, int b){
pixels.clear();
delay(10);
char* command = strtok(s, "&");
while (command != NULL)
{
int num = atoi(command);
Serial.println(num);
@Happsson
Happsson / InactiveCodeDetector.cs
Last active September 14, 2023 15:35
A script that lets you find unused scripts in your unity projects.
/*
This tool iterates through all the files in your project and checks for scripts.
It then goes through all the GameObjects in all the scenes in the project, and
checks for scripts that are not present on any GameObjects.
Note that this does not mean that the script is not used, just that it is possible that it isn't.
The script could still be used in many other ways. This tool is just to narrow the search for
unused code.
@Happsson
Happsson / CornerPin.shader
Created October 12, 2017 09:08
Four corner pin unity shader
Shader "Distort/CornerPin"
{
Properties{
_MainTex("Base (RGB)", 2D) = "white" {}
_DLx("Down Left x", Range(-2.0,2.0)) = 0
_DLy("Down Left y", Range(-2.0,2.0)) = 0
_DRx("Down Right x", Range(-2.0,2.0)) = 0
_DRy("Down Right y", Range(-2.0,2.0)) = 0
#include <Wire.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_BNO055.h>
#include <utility/imumaths.h>
#include <EEPROM.h>
#include <SPI.h>
#define BNO055_SAMPLERATE_DELAY_MS (16) //16.6666 ms equals 60fps.
Adafruit_BNO055 bno = Adafruit_BNO055(55);
@Happsson
Happsson / getBNO055_calib_as_code.ino
Created July 6, 2017 09:20
BNO055 calibration code generator
#include <Wire.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_BNO055.h>
#include <utility/imumaths.h>
/* This driver reads raw data from the BNO055
Connections
===========
Connect SCL to analog 5
@Happsson
Happsson / ArduinoKeyboardEmulator.pde
Last active February 6, 2018 13:47
Processing sketch that lets you use any Arduino as a keyboard emulator.
/*
Auth. Hannes Paulsson
Used to simulate keypresses on any Arduino board.
In arduino sketch, start serial at baudrate 9600 (or edit variable in this sketch)
Only 0-9 and a-z (not case sensitive). Enter can be sent by writing \n.
If you need other keys,
add check for those in serialEvent()-function. Look at: https://docs.oracle.com/javase/7/docs/api/constant-values.html
under java.awt.KeyEvent to see the values for all possible keys.
This file has been truncated, but you can view the full file.
{{204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,20
This file has been truncated, but you can view the full file.
{{204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,20