Skip to content

Instantly share code, notes, and snippets.

View thenayr's full-sized avatar

Ryan vanniekerk thenayr

View GitHub Profile
@thenayr
thenayr / planetside-2-e3
Created July 11, 2012 04:41
Planetside 2 e3
Wins - 22
Best of Show: Game Informer
Best MMO: Game Informer
Bset PC Exclusive: Game Informer
Best Shooter: GameSpy
Best Free to Play: GameSpy
Best PC Exclusive: GameSpy
Best MMO Game: IGN
Best PC Game: IGN
@thenayr
thenayr / k8s-api.js
Created November 16, 2016 23:21
Kubernetes event stream handling new pods
case 'ADDED':
console.log("Unfortunately this doesn't mean a pod is Ready");
break;
case 'MODIFIED':
if(!("deletionTimestamp" in object.object.metadata) && "conditions" in object.object.status && "podIP" in object.object.status) {
console.log("This means a new pod is added AND ready");
}
break;
@thenayr
thenayr / k8s-api-events.js
Created November 16, 2016 23:23
Different event streams that come from the k8s watch API
const stream = k8Stream.ns.po.get({ qs: { watch: true } });
stream.pipe(jsonStream);
jsonStream.on('data', object => {
switch(object.type) {
case 'ADDED':
console.log("Do something when a pod is added");
break;
case 'MODIFIED':
console.log("Do something when a pod is modified");
break;
@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,
@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 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 / 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 / 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 / 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 / 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)
}