Skip to content

Instantly share code, notes, and snippets.

View starfys's full-sized avatar
🤖
foo

Starfys starfys

🤖
foo
View GitHub Profile
@starfys
starfys / fisr.js
Last active May 18, 2024 00:09
Fast inverse square root in Javascript
//Based on the fast inverse square root function
// https://en.wikipedia.org/wiki/Fast_inverse_square_root
// Some original comments preserved for humor value
// Designed to try to mimic the original as closely as possible
function Q_rsqrt(number)
{
var i;
var x2, y;
const threehalfs = 1.5;
using UnityEngine;
using System.Collections;
public class HealthBar : MonoBehaviour
{
GUIStyle healthStyle;
GUIStyle backStyle;
Combat combat;
void Awake()
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.Networking;
public class TankHealth : NetworkBehaviour
{
public float m_StartingHealth = 100f; // The amount of health each tank starts with.
public Slider m_Slider; // The slider to represent how much health the tank currently has.
public Image m_FillImage; // The image component of the slider.
public Color m_FullHealthColor = Color.green; // The color the health bar will be when on full health.
using UnityEngine;
using UnityEngine.Networking;
public class TankMovement : NetworkBehaviour
{
public int m_PlayerNumber = 1; // Used to identify which tank belongs to which player. This is set by this tank's manager.
public int m_LocalID = 1;
public float m_Speed = 12f; // How fast the tank moves forward and back.
public float m_TurnSpeed = 180f; // How fast the tank turns in degrees per second.
public float m_PitchRange = 0.2f; // The amount by which the pitch of the engine noises can vary.
@starfys
starfys / many_dimensions.c
Created April 27, 2016 20:06
A test of C's dimensional skills
#include <stdio.h>
int main()
{
int a[1][1][1][1][1][1][1][1][1][1][1][1][1][1][1][1][1][1][1][1][1][1][1][1][1][1][1][1][1][1][1][1][1][1][1][1][1][1][1][1][1][1][1][1][1][1][1][1][1][1][1][1][1][1][1][1][1][1][1][1][1][1][1][1][1][1][1][1][1][1][1][1][1][1][1][1][1][1][1][1][1][1][1][1][1][1][1][1][1][1][1][1][1][1][1][1][1][1][1][1][1][1][1][1];
a[0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0] = 88889999;
printf("%d\n",a[0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0]);
return 0;
@starfys
starfys / bf2c.py
Created May 16, 2016 04:12
Brainfuck to C compiler, Takes Brainfuck at stdin, prints c to stdout
#!/usr/bin/env python3
import sys
print("//This converts brainfuck in stdin to c on stdout")
brainfuck_program = sys.stdin.read().rstrip()
#Print the starting code
print("#include <stdio.h>")
print("int main(){")
@starfys
starfys / analyze.py
Created June 29, 2016 19:01
Does cool analysis stuff
#!/bin/env python3
import matplotlib.pyplot as plt
from scipy.optimize import curve_fit
import numpy as np
from math import log
with open('resilience.txt','r') as res_file:
data = list(map(str.rstrip, res_file.readlines()))
data = list(map(lambda line: tuple(map(float, line.split(',')))[1], data))
@starfys
starfys / keybase.md
Created July 25, 2016 04:56
keybase.md

Keybase proof

I hereby claim:

  • I am starfys on github.
  • I am starfys (https://keybase.io/starfys) on keybase.
  • I have a public key ASBwKh51bcXg42N0IEnsQmLlLapOB-qIEN0nDwV8SBvYvwo

To claim this, I am signing this object:

let day_name = match day_number {
0 => "Sunday",
1 => "Monday",
2 => "Tuesday",
3 => "Wednesday",
4 => "Thursday",
5 => "Friday",
6 => "Saturday"
_ => panic!("There are only 7 days in a week.")
};
std::string day_name;
switch(day_number) {
case 0:
day_name = "Sunday";
break;
case 1:
day_name = "Monday";
break;
case 2:
day_name = "Tuesday";