Skip to content

Instantly share code, notes, and snippets.

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
// Simple example usage script for MarchingCubes.cs:
// at: https://gist.github.com/cmdr2/b5326aa6fbf3c367747cc5ec31ba831e
//
// Attach to an empty GameObject in the scene
//
// Not optimized, performs poorly! Written for simple readability
@cmdr2
cmdr2 / MarchingCubes.cs
Last active May 3, 2023 03:36
Reimplementation of a simple Marching Cubes algorithm in C# for Unity. Not for production use, it needs performance improvements. Example script to run this in Unity: https://gist.github.com/cmdr2/b5aea11b9bd5259b9198f4fdc027061c
using System.Collections.Generic;
using UnityEngine;
// Reimplementation of http://paulbourke.net/geometry/polygonise/
// in C# for Unity.
//
// Example script to run this in Unity: https://gist.github.com/cmdr2/b5aea11b9bd5259b9198f4fdc027061c
//
// Note: This uses Unity's Linear Interpolation and Vector3
//
@cmdr2
cmdr2 / test.js
Last active April 28, 2020 11:24
<script src="https://cdnjs.cloudflare.com/ajax/libs/processing.js/1.6.0/processing.min.js"></script>
<body>
<script type="application/processing">
void setup(){
size(200, 200);
}
void draw(){
background(64);
ellipse(40, 40, 20, 20);
@cmdr2
cmdr2 / iss-brightness.py
Last active February 4, 2020 09:35
Calculate brightness magnitude of ISS (and whether Earth's shadow is falling on it) using pyephem
# by cmdr2, anyone is free to use and modify this, without the need to give credit
import math
import ephem
import time
from datetime import datetime, timedelta
# consts
degrees_per_rad = 180.0 / math.pi
au = 149597892
// by cmdr2, anyone is free to use and modify this, without the need to give credit
const satellite = require('satellite.js'); // https://www.npmjs.com/package/satellite.js
const SunCalc = require('suncalc'); // https://www.npmjs.com/package/suncalc
var satrec = satellite.twoline2satrec('1 71066C 20001A 20014.19313215 -.01059873 00000-0 -43936-2 0 145',
'2 71066 52.9993 1.7743 0000976 92.9471 326.1492 15.86148217 16');
var stdMag = 4.7; // for Starlink-2
@cmdr2
cmdr2 / fun_smartphone.js
Last active November 14, 2019 15:56
Access to the full power of a smartphone to a javascript file, with the simplest (least-verbose) possible API of what a "smartphone" is. Probably scary, and some parts might not be possible yet.
var acc = require('imu');
var camera = require('camera');
var file = require('file');
var notification = require('notification');
var vibrate = require('vibrate');
var led = require('led');
var location = require('location');
var sms = require('sms');
var contacts = require('contacts');
@cmdr2
cmdr2 / colorclassifier.go
Last active April 23, 2018 06:19
Simple classifier (no libraries) to label RGB colors
package main
import (
"fmt"
"math"
"net/http"
"strconv"
"sort"
)
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using WebSocketSharp;
/**
* a reference client for the fakedaydreamcontroller
* by cmdr2 <[email protected]>
*
@cmdr2
cmdr2 / GenerateMesh02.cs
Last active November 1, 2023 14:28
A mesh extrusion along a bezier curve (Unity3d)
[RequireComponent(typeof(MeshFilter))]
public class GenerateMesh02 : MonoBehaviour {
/* scratchpad */
private MeshFilter mf;
void Start () {
mf = GetComponent<MeshFilter> ();
GenerateMesh ();
@cmdr2
cmdr2 / ExoPlayerExample.java
Created August 1, 2016 15:32
An example of using ExoPlayer from scratch
package org.cmdr2.exoplayerbridge;
import android.app.Activity;
import android.media.AudioManager;
import android.media.MediaCodec;
import android.net.Uri;
import android.util.Log;
import android.view.Surface;
import android.view.SurfaceView;