This is intended as a grab bag of tips, shortcuts, reference and otherwise useful information related to JavaScript (and Node.js).
Bind is a very useful tool for changing the scope of this
within functions as well as passing in parameters:
var fs = require('fs'); | |
var PDFDocument = require('pdfkit'); | |
var pdf = new PDFDocument({ | |
size: 'LEGAL', // See other page sizes here: https://github.com/devongovett/pdfkit/blob/d95b826475dd325fb29ef007a9c1bf7a527e9808/lib/page.coffee#L69 | |
info: { | |
Title: 'Tile of File Here', | |
Author: 'Some Author', | |
} | |
}); |
Using WebSockets, React and Reflux together can be a beautiful thing, but the intial setup can be a bit of a pain. The below examples attempt to offer one (arguably enjoyable) way to use these tools together.
This trifect works well if you think of things like so:
this.state
in react should instead live within stores. Stores can listen to other stores as well as to events being fired.var _ = require('lodash'); | |
var ranges = [ | |
["12:00", 0.0], ["12:15", 0.0], ["12:30", 0.0], ["12:45", 0.0], | |
["01:00", 0.0], ["01:15", 0.0], ["01:30", 0.0], ["01:45", 0.0], | |
["02:00", 0.0], ["02:15", 0.0], ["02:30", 0.0], ["02:45", 0.0], | |
["03:00", 0.0], ["03:15", 0.0], ["03:30", 0.0], ["03:45", 0.0], | |
["04:00", 0.0], ["04:15", 0.0], ["04:30", 0.0], ["04:45", 0.0], | |
["05:00", 0.0], ["05:15", 0.0], ["05:30", 0.0], ["05:45", 0.0], | |
["06:00", 0.0], ["06:15", 0.0], ["06:30", 0.0], ["06:45", 0.0], |
/* | |
SetIntervalMixin for React. | |
Usage: | |
var MyComponent = React.createClass({ | |
getInitialState: function () { | |
return { value: 0 }; | |
}, | |
Below are a small collection of React examples to get anyone started using React. They progress from simpler to more complex/full featured.
They will hopefully get you over the initial learning curve of the hard parts of React (JSX, props vs. state, lifecycle events, etc).
You will want to create an index.html
file and copy/paste the contents of 1-base.html
and then create a scripts.js
file and copy/paste the contents of one of the examples into it.
/Users/dana/code/libraries/install/bin/uic src/MainWindow.ui -o objects/ui_MainWindow.h | |
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -c -pipe -O2 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk -mmacosx-version-min=10.6 -Wall -W -DOPENSCAD_VERSION=2014.10.01 -DOPENSCAD_YEAR=2014.0 -DOPENSCAD_MONTH=10.0 -DOPENSCAD_DAY=01.0 -DDEBUG -DENABLE_MDI -DENABLE_CGAL -DENABLE_OPENCSG -D__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES=0 -DUSE_SCINTILLA_EDITOR -DQT_NO_DEBUG -DQT_PRINTSUPPORT_LIB -DQT_OPENGL_LIB -DQT_MACEXTRAS_LIB -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -I../libraries/install/mkspecs/macx-clang -I. -Isrc -I../libraries/install/include -I../libraries/install/lib/QtPrintSupport.framework/Versions/5/Headers -I../libraries/install/lib/QtOpenGL.framework/Versions/5/Headers -I../libraries/install/lib/QtMacExtras.framework/Versions/5/Headers -I../libraries/install/lib/QtWidgets.framework/Versions/5/ |