InfernoJS gives a very interesting but unfortunately very brief sketch of a purely functional way to bootstrap an app:
import Inferno from 'inferno';
import { scan, map } from 'most';
...
const model$ = scan(update, 0, actions$);
const vNodes$ = map(view(actions$), model$);
const renderer = Inferno.createRenderer();
const runApp = () => scan(renderer, container, vNodes$).drain();
runApp();
Can anyone give a fully functional example of an app designed this way?
Here is an example: https://github.com/joshburgess/inferno-most-fp-demo
It's simply a functional counter but a good starting point nonetheless.
Related
What is the best way in FMX to create a grid that supports bidimode and righttoleft languages
I have tried fmxrtl but it has many errors
Thanks
Is your app only for Windows ? If yes, I use a function to detect if it's a Bidi string and then use TTextLayout my test here
Else, try to use SKIA4Delphi (XE7+)Supporting right to left
I test an Android little app ScreenShot
procedure TForm1.Grid1DrawColumnCell(Sender: TObject; const Canvas: TCanvas;
const Column: TColumn; const Bounds: TRectF; const Row: Integer;
const Value: TValue; const State: TGridDrawStates);
begin
if (Column.Index=1) AND (Row>=1)
then begin
Canvas.Fill.Color:=TAlphaColors.Red;
Canvas.FillText(Bounds,Value.ToString,false,1,[TFillTextFlag.RightToLeft],TTextAlign.Leading);
end
else Column.DefaultDrawCell(Canvas,bounds,row,value,state);
end;
I'm trying to replicate the bokeh latex example mentioned at https://docs.bokeh.org/en/latest/docs/user_guide/extensions_gallery/latex.html#userguide-extensions-examples-latex in jupyter notebook for LabelSet. I could see the katex.min.js being loaded from web console. However when the LatexLabel renders, it states katex not defined.
Katex JS doc says, it should be available globally once js is loaded.
import * as p from "core/properties"
import {LabelSet, LabelSetView} from "models/annotations/label_set"
declare const katex: any
export class LatexLabelSetView extends LabelSetView {
model: LatexLabelSet
render(): void {
const draw = this._v_css_text.bind(this)
const {ctx} = this.plot_view.canvas_view
const [sx, sy] = this._map_data()
for (let i = 0, end = this._text.length; i < end; i++) {
try {
draw(ctx, i, this._text[i], sx[i] + this._x_offset[i], sy[i] - this._y_offset[i], this._angle[i])
katex.render(this._text[i], this.el, {displayMode: true})
}
catch(e) {
console.log( 'Error: ' + e);
}
}
}
}
class LatexLabelSet(LabelSet):
__javascript__ = ["https://cdn.jsdelivr.net/npm/katex#0.11.1/dist/katex.min.js"]
__css__ = ["https://cdn.jsdelivr.net/npm/katex#0.11.1/dist/katex.min.css"]
__implementation__ = TypeScript(TS_CODE)
Also tried adding the script element into document root. No luck though.
export class LatexLabelSet extends LabelSet {
properties: LatexLabelSet.Props
constructor(attrs?: Partial<LatexLabelSet.Attrs>) {
super(attrs)
}
static init_LatexLabelSet() {
let jsNode = document.createElement('script')
jsNode.id = 'bokeh-katex-js'
jsNode.src = "https://cdn.jsdelivr.net/npm/katex#0.11.1/dist/katex.min.js"
let cssNode = document.createElement('link')
cssNode.id = 'bokeh-katex-css'
cssNode.rel= 'stylesheet'
cssNode.href = "https://cdn.jsdelivr.net/npm/katex#0.11.1/dist/katex.min.css"
document.getElementsByClassName('bk-root')[0].appendChild(cssNode)
document.getElementsByClassName('bk-root')[0].appendChild(jsNode)
this.prototype.default_view = LatexLabelSetView
}
}
Any directions would be helpful.
Bokeh 2.4 adds support for LaTeX (and MathML) to some elements in Bokeh directly (no need to use an extension). Currently, you can use LaTeX on axis labels, tick labels, div widgets, and paragraph widgets, and this also works in Jupyter notebooks. LaTeX support for more elements should be added soon. For more information about the new math text feature and how to use them, see the Bokeh 2.4 release blogpost, the new blackbody radiation example, and the Bokeh user guide!
Note from maintainers: Initial built in LaTeX support was added in version 2.4, see this new answer https://stackoverflow.com/a/69198423/3406693
As stated in https://docs.bokeh.org/en/latest/docs/user_guide/embed.html#components, this is not possible to achieve within the notebook.
It says
Note that in Jupyter Notebooks, it is not possible to use components and show in the same notebook cell.
Indeed, if you use the code below, it opens a new tab with the plot and the formula, but if you call output_notebook(), the text does not appear and the browser console throws Uncaught ReferenceError: katex is not defined.
p = figure(title="LaTex Demonstration")
p.line([0,0,1,1,0],[0,1,1,0,0])
latex = LatexLabel(text=r"e^{i\pi}+1=0",
x=0.4, y=0.55,
render_mode='css', text_font_size='16pt',
background_fill_alpha=0)
p.add_layout(latex)
show(p)
Working in new tab:
Not working inside notebook:
I just started using SALT for a project i am working on. It is said to work with Python but I find quite a bit of difference in thier syntax and overall format. I have pasted a code for a simple task which just opens and imports and loads some libraries onto the SALT console. I hope someone can check abnd see if he/she can instantly identify the language being used and what the code does. This is because i have a suspicion that the code is a mixture between C, Python as well as Java... if that is so doen't that mean it should be a totally different language on its own?
code:
var rtwxlib = import'rtwxlib';
var string = import'string';
var monitor = rtwxlib.Monitor
{
EvActivate = func() { print "Activate\n"; };
EvShutdown = func() { print "Shutdown\n"; };
EvProgress = func(self, fDone, msg = "") {
print("Progress: %d %s \r"::format(fDone*100, msg));
};
EvEventMsg = func(self, msg) {
print("\nEvent: %s\n"::format(iStat, msg));
};
};
var solver = rtwxlib.Solver(monitor);
solver::Open("test.wrx");
solver::DelGeometry();
solver::SaveAs('testresults.wrx');
solver::Close();
I was able to indentify the syntax of the language used as C. I beieve the problem I had which confused me was the libraries used for this code which I later found out was for a particular program. Thank you to all those who tried to help though :)
How do I resolve the error of duplicate variable definitions? There has to be
separate namespaces and use for each definition, but I'm just not seeing it.
CODE
I didn't write this, but I've been trying to unpackage it and change the classes and seem to have broken it. I want to use this for time-scaling the playback of my movies.There's cool math in here for time-scaling.
//time-scaling script
import flash.display.*;
import flash.events.Event.*;
var _time_scale:Number = .25;
var _frames_elapsed:int = 0;
var _clip:MovieClip;
function Main():void {
_clip = new SomeClip;
addEventListener(Event.ENTER_FRAME, handleEnterFrame);
//integer??
function handleEnterFrame(e:Event):void {
_frames_elapsed ++;
}
// we multiply the "real" time with our timescale to get the scaled time
// we also need to make sure we give an integer as a parameter, so we use Math.round() to round the value off
_clip.gotoAndStop(Math.round(_clip.totalFrames * _frames_elapsed * _time_scale ));
}
var myTimer:Timer = new Timer(10);
myTimer.addEventListener(TimerEvent.TIMER, timerListener);
function timerListener (e:TimerEvent):void{
ball1.rotationY += 5;/////////replace function///////////
}
myTimer.start();
ERRORS
**3596**
Warning: Duplicate variable definition.
**1151**
A conflict exists with definition _clip in namespace internal
NOTES
integers, non nested loop
It's because you are missing the ending "}" of the constructor, after this line:
addEventListener(Event.ENTER_FRAME, handleEnterFrame);
And the two following lines should probably be in your constructor, not just in the class declaration:
var myTimer:Timer = new Timer(10);
myTimer.addEventListener(TimerEvent.TIMER, timerListener);
If you are using the Timer and TimerEvent classes, you should import them:
import flash.utils.Timer;
import flash.events.TimerEvent;
Also, you don't need the .* at the end of the Event import.
Another "also". You should have access modifiers on your members ie. vars, and functions. So you should really say:
private var _clip:MovieClip;
It sounds to me like you need to look into the basics of AS3. Here is a really good starting point: http://www.actionscript.org/resources/articles/611/1/Getting-started-with-Actionscript-3/Page1.html
_clip is a reserved key word, you'll have to use something else.
I was wondering how to distort a Flex object like Panel so it looks like a trapezoid?
Are you trying to do something like this? Flex skewing
private function skewit():void {
var smat:Matrix = new Matrix();
smat.b = Math.tan(50);
var mat:Matrix = myobject.transform.matrix;
mat.concat(smat);
myobject.transform.matrix = mat;
}
http://livedocs.adobe.com/flex/3/html/help.html?content=15_Geometry_6.html
If you're really serious about this stuff, you should write it in ActionScript and pick up the book Numerical Recipes and read the chapter on "Computational Geometry". It will probably answer all your questions and more! Have fun :)