Skip to content

Instantly share code, notes, and snippets.

View thenayr's full-sized avatar

Ryan vanniekerk thenayr

View GitHub Profile
@thenayr
thenayr / Controllers.js
Created November 18, 2016 23:22
Vive controller component for A-frame VR project
import {Entity} from 'aframe-react';
import React from 'react';
export default props => (
<Entity id="controller-ent">
<Entity static-body={{shape: 'sphere', sphereRadius: '0.02'}}
vive-controls={{hand: 'right'}}
vive-cursor
className="controllers"
@thenayr
thenayr / ClusterInfo.js
Created November 18, 2016 23:15
The floating cluster info component
import React from 'react';
import ReactDom from 'react-dom';
import {Entity} from 'aframe-react';
import io from 'socket.io-client';
const socket = io('http://localhost:9003');
class ClusterInfo extends React.Component {
constructor(props) {
@thenayr
thenayr / destroy.js
Created November 18, 2016 00:17
The Node JS code to delete a pod
socket.on('k8sDestroyPod', function(data) {
k8.ns.po.delete(data.name, (err) => {
if(err) {
err;
}
});
})
@thenayr
thenayr / destroy-pod.js
Created November 18, 2016 00:15
Function on React component to delete pod
destroyChildPod(evt) {
var pod = {
name: evt.srcElement.id
}
socket.emit('k8sDestroyPod', pod)
}
@thenayr
thenayr / height.js
Created November 17, 2016 23:59
A-frame component to check current height position of an object
/**
* Simple y position tracker to determine if an object has fallen off the platform
*/
module.exports = {
schema: {type: 'vec3'},
init: function() {
this.timeout = setInterval(this.checkPosition.bind(this), 5000);
},
@thenayr
thenayr / Assets.js
Created November 17, 2016 23:22
A-frame asset management system
export default props => (
<a-assets>
<img id="nginx" src="../assets/images/nginx.jpg" />
<img id="wordpress" src="../assets/images/wordpress.jpg" />
<img id="ubuntu" src="../assets/images/ubuntu.png" />
<img id="redis" src="../assets/images/redis.jpg" />
<img id="k8s" src="../assets/images/k8s.jpg" />
</a-assets>
);
@thenayr
thenayr / k8s-api.js
Created November 17, 2016 23:20
The k8s Node js label lookup
if ("object.metadata.labels.type" in object) {
type = object.object.metadata.labels.type
} else {
type = "k8s"
}
@thenayr
thenayr / Pod.js
Created November 17, 2016 23:18
Pod component with the material texture mapping based on Pod labels.
class Pod extends React.Component {
constructor(props) {
super(props);
this.state = {
color: props.color,
clicked: false
}
this.containerMat = {
nginx: "#nginx",
@thenayr
thenayr / PodLayout.js
Created November 16, 2016 23:49
The parent pod holder that is responsible for positioning and lifecycle of the pods
import React from 'react';
import ReactDom from 'react-dom';
import {Entity} from 'aframe-react';
import Pod from './Pod';
import io from 'socket.io-client';
const socket = io('http://localhost:9003');
class PodLayout extends React.Component {
constructor(props) {
@thenayr
thenayr / Pod.js
Created November 16, 2016 23:45
A simplified version of the Pod component
import React from 'react';
import ReactDom from 'react-dom';
import {Entity} from 'aframe-react';
class Pod extends React.Component {
constructor(props) {
super(props);
this.state = {
color: props.color,