Good day, as you know in Ionic 2 / Angular 2 it was possible to use the selector of one component in another. Please tell me how it can be done on Ionic 3 / Angular 4
from the error you post, I think you want to use "page-weather" in the component of "page-news", if these two component belongs to different modules, then you should import the "page-weather" module to the "page-news" module, like the following:
import {WeatherModule} from '../your component's path';
#NgModule({
imports: [WeatchModule]
})
export class NewsModule {}
then you can use "page-weather" in the "page-news" template like this:
<page-weather></page-weather>
hope this can help you!
Related
I am currently using Nest.js, Postgresql, Typeorm for my backend. Now I am trying to do is to see an specific entity field differently by each user.
For example there are 10 posts and one user has bookmarked 3 of them. Only a user who bookmarked the post can get isBookmarked = true, others isBookmarked = false.
I used Django a bit and I used serializer to implement the same logic. I looked for Nest.js serializer (https://docs.nestjs.com/techniques/serialization) but I think it is a bit different than what I thought. Please tell me how to use this serializer as Django does, or any other ways to implement the logic.
Since NestJS is using class-transform you can follow the documentation to achieve what you wants => https://github.com/typestack/class-transformer#additional-data-transformation
import { Transform } from 'class-transformer';
export class Post {
id: number;
#Transform(({ value }) => isBookmarkedByTheUser())
bookmarked: boolean;
}
Something like that ;)
We are trying to build a web app--Dashboard-- to show different interactive(including click callback, fetch new data etc) charts with Bokeh + Holoviews + Datashader on DJango.
Since data is very large and could have 10+ million points we are using datashader. We can have a static html from backend from Bokeh + Holoviews + Datashader from Backend and pass it to front end using Django REST api as :
views.py
import numpy as np
import holoviews as hv
import datashader as ds
from dask import dataframe as dd
from bokeh.io import show, curdoc
from bokeh.layouts import layout
from bokeh.models import Slider, Button
from holoviews.operation.datashader import datashade
renderer = hv.renderer('bokeh').instance(mode='server')
def home(request):
def plot_info(y_col):
from vaex import dataframe as datafm
df_dask = dd.read_parquet(r"C:\Dropbox\1mln.parquet", engine='pyarrow',
columns=['nest11', 'nest21', 'first_element', 'second_element', 'timestamp'])
df_dask['timestamp'] = dd.to_datetime(df_dask.timestamp, unit='ns')
return hv.Curve((df_dask['timestamp'], df_dask[y_col]))
def bearer():
stream = hv.streams.Stream.define('y-axis', y_col="nest11")()
dmap = hv.DynamicMap(plot_info, streams=[stream])
vmap = datashade(dmap).opts(width=1200, height=600, responsive=True)
html = renderer.static_html(vmap)
return html
context = {
'seq_num': bearer(),
}
return render(request, 'home/welcome.html', context)
Works fine. However Since we used Datashader, data is aggregated and converted in static html when we zoom in we would not get the data which we are looking for at from end side. For that, my guess is we need Bokeh server.
My doubts are :(since use of Datashader is must for large dataset)
How can i use Bokeh server along with Django REST apis ? Also i want to have a customized html page at front end so i am using Django template.
Is there an alternative to Django for REST apis development with Bokeh + Datashader ?
Does Bokeh support REST APIs ? how ? pls share some examples of REST APIs and callbacks ? for example I've a Dashboard and when i click one chart, I should get more details about the chart and play around those charts in dashboard ? dropdown etc
I would strongly suggest using Panel which is built on top of Bokeh and supports HoloViews. For Django integration have a look at these docs.
/ 3. The Bokeh server is built on Tornado, which means it can be easily extended, e.g. in the next release of Panel (0.10) you will be able to easily register custom REST APIs to be served alongside your app. There aren't any examples yet since it's not released but I'll be working on a few examples in time for the next release which is due in about two weeks.
I'm using flask blueprints just as written here:
http://flask.pocoo.org/docs/0.12/patterns/appdispatch/
Specifically, I'm running the following piece of code:
from werkzeug.wsgi import DispatcherMiddleware
from frontend_app import application as frontend
from backend_app import application as backend
application = DispatcherMiddleware(frontend, {
'/backend': backend
})
Flask has an awesome feature of reloading application as it detects change in code. However, in my case it is not desirable for both apps: backend app is too heavy to be reloaded every few minutes. When I reload fronend, backend gets reloaded as well and it takes too long. Is there any way to reload only app that was changed?
I realize it might be difficult, because as far as I understand at this point
application = DispatcherMiddleware(frontend, {
'/backend': backend
})
applications are merged into a single one and they are not separate anymore.
Anyway, maybe there is a different way to achieve what I want?
Thanks.
I am not sure if there is anything direct for doing such thing. Only thing I can think if you preventing a reinitialization of your module.
See a below example of how one can achieve this
reloadme.py
import sys
if 'reloadme' in sys.modules and hasattr(sys.modules['reloadme'], '__MODULE_LOADED'):
print ("module is being reloaded")
mod = sys.modules['reloadme']
x = mod.x
else:
print ("Loading module for first time")
__MODULE_LOADED = True
x = 2
def printx():
print (x)
reloadtest.py
from importlib import reload
import reloadme
reloadme.printx()
reloadme.x = 10
reloadme.printx()
print("Reloading reloadme to check if x is changed back to 2")
reload(reloadme)
reloadme.printx()
The output of running reloadtest.py will be as below
Loading module for first time
2
10
Reloading reloadme to check if x is changed back to 2
Reloading module
10
I'm creating a web application where I've used the active admin gem. Suppose, i've a model named Category with fields names. Now, in my names field i want to insert multiple values by comma separated. And it will look like this. That's why i've used the tagsinput gem. But its not working.
Anyone have any idea how do I do this?
I would do next.
Add to active_admin.js
//= require jquery.tagsinput
$(selector).tagsInput({
'autocomplete_url': url_to_autocomplete_api,
'autocomplete': { option: value, option: value},
'height':'100px',
'width':'300px',
'interactive':true,
'defaultText':'add a tag',
'onAddTag':callback_function,
'onRemoveTag':callback_function,
'onChange' : callback_function,
'removeWithBackspace' : true,
'minChars' : 0,
'maxChars' : 0 //if not provided there is no limit,
'placeholderColor' : '#666666'
});
Add to active_admin.css.scss
*= require jquery.tagsinput
Make sure that you have an action in controller that would create new category. Check if you have it in your routes.rb and that will be your
'autocomplete_url': url_to_autocomplete_api
I didn't try to do all these step. But I think I should give you some ideas.
If that wouldn't work I would add js and css files to my assets directly from tagsinput
If you choose go this way you may need add your js and css to initializer/assets.rb
Rails.application.config.assets.precompile += %w()
I hope it helps.
I would like to call the Curve.Trim(CurveEnd, Double) method from the RhinoCommon API via IronPython. How can I make sure I don't get the overload for Curve.Trim(Double, Double)?
crv.Trim(geo.CurveEnd.End, 8.8)
#raised: Message: expected float, got CurveEnd
Note: If you want to try it yourself you will need to install a trial version of Rhino. It includes a Python editor.
Edit / Addition: the .Overloads property as mentioned by Jeff does not work here either. A snippet for testing:
import rhinoscriptsyntax as rs
import Rhino.Geometry as geo
import System
# first draw a curve longer than 8.8 units
crvO = rs.GetObject() # to pick that curve on the 3d GUI screen
crv = rs.coercecurve(crvO) # to get Rhino.Geometry.Curve
# these both don't work:
crv.Trim(geo.CurveEnd.End, 8.8)
#Message: expected float, got CurveEnd
crv.Trim.Overloads[geo.CurveEnd, System.Double](geo.CurveEnd.End, 8.8)
#Message: Trim() takes at least 2147483647 arguments (2 given)
rhinscriptsyntax is a library based on Rhino namespace from RhinoCommon
Use the .Overloads property to access a method's overloads:
csv.Trim.Overloads[CurveEnd, float](geo.CurveEnd.End, 8.8)
The docs.
I'm late to the party. But this code works (out the override).
import rhinoscriptsyntax as rs
import Rhino
import scriptcontext as sc
import System
crv_id = rs.GetObject()
crv = rs.coercecurve(crv_id)
trimmed = crv.Trim(Rhino.Geometry.CurveEnd.End, 4)
sc.doc.Objects.Replace(crv_id, trimmed)
sc.doc.Views.Redraw()