Skip to content

Instantly share code, notes, and snippets.

View diegocasmo's full-sized avatar
👨‍💻

Diego Castillo diegocasmo

👨‍💻
View GitHub Profile
@diegocasmo
diegocasmo / polynomial_merge.txt
Created March 6, 2017 19:39
Mathematical examples used for the blogpost: 'The Fast Fourier Transform Algorithm'
A(w) = Ae(w^2) + w * Ao(w^2)
@diegocasmo
diegocasmo / polynomial_divide.txt
Created March 6, 2017 19:39
Mathematical examples used for the blogpost: 'The Fast Fourier Transform Algorithm'
Ae(y) = a0 + a2y + a4y^2 + a6^y3 + ... + a(n-2)y^(n-2/2)
Ao(y) = a1 + a3y + a5y^2 + a6^y3 + ... + a(n-1)y^(n-2/2)
@diegocasmo
diegocasmo / polynomial_rewrite.txt
Last active March 6, 2017 23:52
Mathematical examples used for the blogpost: 'The Fast Fourier Transform Algorithm'
a0 + a2x^2 + a4x^4 + a(n-2)x^(n-2)
+ a1x + a3x^3 + a4x^4 + a(n-1)x^(n-1)
@diegocasmo
diegocasmo / polynomial_example.txt
Created March 6, 2017 19:38
Mathematical examples used for the blogpost: 'The Fast Fourier Transform Algorithm' Raw
A(x) = a0 + a1x + a2x^2 + ... + a(n-1)x(n-1)
@diegocasmo
diegocasmo / polynomial_values.txt
Created March 6, 2017 19:36
Mathematical examples used for the blogpost: 'The Fast Fourier Transform Algorithm'
x = 0, then f(x) = 5
x = 1, then f(x) = 8
x = 2, then f(x) = 13
@diegocasmo
diegocasmo / App.jsx
Created February 20, 2017 15:25
The App component is the top level component of the application and all other components are wrapped by it.
class App extends React.Component {
// Encapsulate 'appData' context as props for all children
renderChildrenWithContextAsProps() {
return React.Children.map(this.props.children, (child) => {
return React.cloneElement(child, {
appData: this.context.appData
});
});
};
@diegocasmo
diegocasmo / client.jsx
Created February 20, 2017 15:23
This file starts the application like you would normally do in the client side. It is wrapped by the Provider component and passes to it the appData received from the index.ejs file.
window['MY_APP'] = window['MY_APP'] || (() => {
return {
initialize: (config) => {
ReactDOM.render(
<Provider appData={config.appData}>
<Router history={browserHistory}>
{ routes }
</Router>
</Provider>,
document.getElementById('root')
@diegocasmo
diegocasmo / index.ejs
Created February 20, 2017 15:22
This file bootstraps the whole application. It receives appData and then initializes the application.
<html>
<body>
<div id="root"><%- renderedRoot %></div>
<script src="/app.js"></script>
<script>
var config = {
appData: <%-JSON.stringify(appData)%>
};
MY_APP.initialize(config);
</script>
@diegocasmo
diegocasmo / server_snippet.jsx
Created February 20, 2017 15:21
This file has an Express handler to catch all routes and isomorphically serve the application using React's renderToString method. Notice appData is passed to both the Provider and the index template.
res.render('index', {
renderedRoot: ReactDOMServer.renderToString(
<Provider appData={appData}>
<RouterContext {...props}/>
</Provider>
),
appData: appData
});
@diegocasmo
diegocasmo / Provider.jsx
Last active February 20, 2017 15:24
This component implements the context feature, and exposes the prop called appData to other components. The whole application is going to be wrapped by it.
class Provider extends React.Component {
getChildContext() {
return {appData: this.props.appData};
}
render() {
return(
<div>
{this.props.children}
</div>