Skip to content

Instantly share code, notes, and snippets.

View sjorsvanheuveln's full-sized avatar
👋
Hi

Sjors van Heuveln sjorsvanheuveln

👋
Hi
View GitHub Profile
@sjorsvanheuveln
sjorsvanheuveln / Time.jsx
Created April 7, 2018 13:52
A simple Time object that allows you to add, subtract and print times.
export function Time(hours, minutes) {
this.h = hours;
this.m = minutes;
this.add = (h, m) => {
this.h = (this.h + h) % 24;
this.h = this.h + Math.floor((this.m + m) / 60);
this.m = (this.m + m) % 60;
return this; // for method chaining
};
@sjorsvanheuveln
sjorsvanheuveln / mathDisplay.jsx
Last active February 14, 2018 13:36
Display Math or Formulae in ReactJS using ES6.
import React from 'react';
import { Fraction, toTex } from 'algebra.js';
import { Node, Context } from 'react-mathjax';
function Formula(props) {
return (
<Context input="tex">
<Node inline>{props.tex}</Node>
</Context>
);
import React from 'react';
import { Link } from 'react-router-dom';
import { TweenMax } from 'gsap';
import { Button, Card, CardBlock, CardHeader, Col } from 'reactstrap';
export default class StoryBlock extends React.Component {
componentWillEnter(callback) {
const el = this.container;
TweenMax.fromTo(el, 0.4, { x: 500, opacity: 0 }, { x: 0, opacity: 1, onComplete: callback });
}
#Analysis of Dutch Language Vocabulary
#Sjors van Heuveln 28-10-2017
#Analyze triplet occurrences in the Dutch Language. This script can easily source another vocab file to do new analysis.
#Functions
trimWord <- function(rawWord) {
return(unlist(strsplit(rawWord,'/'))[1]); #trims off ID
}
wordTriplets <- function(word, size) {
if (grepl(' ', word)) { return(); } #break if word contains spaces
@sjorsvanheuveln
sjorsvanheuveln / Box.jsx
Created August 26, 2017 23:02
Easy Example for ReactTransitionGroup animation in Node
import React from 'react';
import { TweenMax } from 'gsap';
export default class Box extends React.Component {
componentWillEnter(callback) {
const el = this.container;
TweenMax.fromTo(el, 0.3, { y: 100, opacity: 0 }, { y: 0, opacity: 1, onComplete: callback });
}