Skip to content

Instantly share code, notes, and snippets.

View sagea's full-sized avatar

Alexander Sage sagea

  • Nomad
View GitHub Profile
@sagea
sagea / .jsx
Last active May 10, 2017 11:55
Euro to Czk conversion. Used this when I went to Prague.
class Application extends React.Component {
constructor () {
super();
this.state = {
euro: 0,
czk: 0
}
}
updateEuro (event) {
const euro = parseInt(event.target.value);
@sagea
sagea / My Utils
Created January 17, 2017 22:52
A set of utility methods that I use in my projects. (Not unit tested yet.)
export function getRandomValueFromArray (arr) {
return arr[ Math.floor(Math.random() * arr.length) ];
}
// Credit: João Victor
// Github: https://github.com/Jvsierra
// CodePen: https://codepen.io/Jvsierra/pen/BNbEjW
export function uuidv4 () {
function s4() {
return Math.floor((1 + Math.random()) * 0x10000)
@sagea
sagea / circle-interactions.js
Created October 14, 2015 04:31
Circle & sphere interactions
// Point is inside circle.
function isWithinCircle(x, y, circleX, circleY, circleRadius){
return square(circleX - x) + square(circleY - y) < square(circleRadius);
}
// Two circles interecting
function doCirclesIntersect(x1, y1, r1, x2, y2, r2){
return Math.sqrt(square(x1-x2) + square(y1 - y2)) <= r1 + r2;
}