This version of CLI is only compatible with Angular versions ^13.0.0, but Angular version 12.2.13 was found instead Posted: 12 Nov 2021 09:22 AM PST my Ionic project was running fine a month ago. Today when I tried ionic serve or ionic build then I get the below error: My simple question is What CLI version is compatible with Angular version 12.2.13? If you really want to know why I am asking this question you can ready further. So I followed the advice to upgrade to Angular 13 on the official Angular website, I used the following command: npm @angular/cli@13 update @angular/core@13 @angular/cli@13 . This route asked me to upgrade my Node.js to version 16 (latest, current). After upgrading node.js to v16 I retried to upgrade to Angular 13 and during this process the installation failed/stopped due to unsupported dependencies and so on. I Googled most solutions and tried and winded up with a project where all my plugins can't be found and so on. So I reversed the above process by uninstalling node.js v16 to v12, removed npm, node_modules and now I am back at the point where I am getting the below error in the pic. Here's my dev environment from ionic info : Here's a copy of my package.json file: "dependencies": { "@angular/common": "~12.2.8", "@angular/core": "~12.2.8", "@angular/forms": "~12.2.8", "@angular/platform-browser": "~12.2.8", "@angular/platform-browser-dynamic": "~12.2.8", "@angular/router": "~12.2.8", "@babel/compat-data": "^7.8.0", "@ionic-native/app-version": "^5.36.0", "@ionic-native/call-number": "^5.36.0", "@ionic-native/camera": "^5.23.0", "@ionic-native/core": "^5.0.0", "@ionic-native/device": "^5.36.0", "@ionic-native/file": "^5.36.0", "@ionic-native/file-transfer": "^5.23.0", "@ionic-native/full-screen-image": "^5.23.0", "@ionic-native/in-app-browser": "^5.36.0", "@ionic-native/ionic-webview": "^5.36.0", "@ionic-native/keyboard": "^5.36.0", "@ionic-native/onesignal": "^5.36.0", "@ionic-native/photo-viewer": "^5.23.0", "@ionic-native/splash-screen": "^5.36.0", "@ionic-native/status-bar": "^5.36.0", "@ionic/angular": "^5.0.0", "@ionic/storage-angular": "^3.0.6", "bufferutil": "^4.0.1", "call-number": "^1.0.1", "cordova-plugin-actionsheet": "^2.3.3", "cordova-plugin-dialogs": "^2.0.2", "core-js": "^2.5.4", "rxjs": "~6.5.1", "tslib": "^1.9.0", "utf-8-validate": "^5.0.2", "zone.js": "~0.11.4" }, "devDependencies": { "@angular-devkit/build-angular": "^13.0.2", "@angular/cli": "^12.2.8", "@angular/compiler": "^12.2.8", "@angular/compiler-cli": "^12.2.8", "@angular/language-service": "~12.2.8", "@ionic/angular-toolkit": "^5.0.3", "@types/jasmine": "~3.3.8", "@types/jasminewd2": "~2.0.3", "@types/node": "~8.9.4", "codelyzer": "^5.0.0", "cordova-android": "^9.1.0", "cordova-plugin-app-version": "^0.1.12", "cordova-plugin-camera": "^6.0.0", "cordova-plugin-device": "^2.0.3", "cordova-plugin-file": "^6.0.2", "cordova-plugin-file-transfer": "git+https://github.com/apache/cordova-plugin-file-transfer.git", "cordova-plugin-inappbrowser": "^4.1.0", "cordova-plugin-ionic-keyboard": "^2.2.0", "cordova-plugin-ionic-webview": "^5.0.0", "cordova-plugin-splashscreen": "^6.0.0", "cordova-plugin-statusbar": "^2.4.3", "cordova-sqlite-storage": "^6.0.0", "jasmine-core": "^3.4.0", "jasmine-spec-reporter": "~4.2.1", "karma": "^6.3.4", "karma-chrome-launcher": "~2.2.0", "karma-coverage-istanbul-reporter": "~2.0.1", "karma-jasmine": "~2.0.1", "karma-jasmine-html-reporter": "^1.4.0", "onesignal-cordova-plugin": "^3.0.0", "protractor": "^7.0.0", "ts-node": "~7.0.0", "tslint": "~5.15.0", "typescript": "~4.3.5" }, "description": "Vuyou's Funerals", "cordova": { "plugins": { "cordova-plugin-inappbrowser": {}, "mx.ferreyra.callnumber": {}, "cordova-plugin-file-transfer": {}, "onesignal-cordova-plugin": {}, "cordova-plugin-camera": { "ANDROIDX_CORE_VERSION": "1.6.+" }, "cordova-plugin-ionic-webview": {}, "cordova-plugin-ionic-keyboard": {}, "cordova-plugin-splashscreen": {}, "cordova-plugin-device": {}, "cordova-plugin-statusbar": {}, "cordova-sqlite-storage": {}, "cordova-plugin-app-version": {} }, "platforms": [] } Thanks in advance. |
Need summation over all parts in the loop Posted: 12 Nov 2021 09:21 AM PST Im creating a loop for my university project. I need A to return an array of the sums. An=np.array([51,101,201,301,501]) t=100 MM=9 Mi=1 rep=5 for agentcount in np.arange(0,5): #count over agents N=An[agentcount] for M in np.arange(Mi,MM+1): for crep in range(1,rep+1): win=(np.random.rand(M,1)>0.5).astype(int) #winning record as 1/-1 #winning record s1=(np.random.rand(2**M,N)>0.5).astype(int) #random strat s2=(np.random.rand((2**M),N)>0.5).astype(int) #alternative strat payout=np.zeros([2,N]) #empty payout record for ct in range(1,t+1): #timesteps cc=np.abs((1+ np.dot((2**(np.arange(0,M))),win))) #pick next strat nex1=s1[cc-1,:] nex2=s2[cc-1,:] nexts=[[nex1],[nex2]] for cn in np.arange(0,N+1): # choose better strat if payout[0,cn-1]>payout[0,cn-1]: Next=nex1 else: Next=nex2 A=(np.sum(Next)/N) I want the ct section of the loop to run ct times and therefore return a 1xct array for A. I have tried using the built-in sum function and also using notation A[ct]= Thank you |
send json data to the elasticsearch directly and aggregate on the fly Posted: 12 Nov 2021 09:21 AM PST I'm newbie with elastic search and I need to send a huge JSON array to the elastic search directly. But i've no control on the source data. It means i can't add _index field to every object in the array. (I've written a middle-ware to add the _index key, but the data is huge and i need to send it directly and turn the middleware off) .So can i push this data to the elastic search? and is it possible to make mappings and aggregations inside elastic like postgres triggers and functions? I need to send nova metrics to the elastic search and aggregate them and create time series using ceilometer http publisher. |
Sequence Diagram - is this correct? Posted: 12 Nov 2021 09:21 AM PST as the title says, is this multi factor authentication sequence diagram correct? are there any security flaws? would much appreciate all the help I can get as I am new to this diagramming business. diagram in question |
BehaviorSubject: mutating current value between subcriptions Posted: 12 Nov 2021 09:21 AM PST Assume I have BehaviorSubject with User interface: interface User { firstName: string; lastName: string; } let user: User = { firstName: 'Cuong', lastName: 'Le', }; let bs = new BehaviorSubject<User>(user); There are two subsciptions, sub1 tried to change the first name. Sub2 subribes later and user object has first name changed also as the sub1 did change it before: let sub1 = bs.subscribe((u) => { u.firstName = 'An'; console.log(u); }); let sub2 = bs.subscribe((u) => { console.log(u); }); it's hard to debug when this case happens in big Angular application. How we make the value immutable when subscribing? I am looking deep immutable solution to avoid code somewhere else to change the data instead of the shalow one |
Extracting subtitles from YouTube videos no longer works Posted: 12 Nov 2021 09:21 AM PST Until today I was using this URL to get captions from YouTube videos: https://video.google.com/timedtext?lang=${lang}&v=${id} For example https://video.google.com/timedtext?lang=zh&v=rIZNQwCfeig . This was always working before, but as of today it started returning a blank response. Did the API change recently? Is there a new way to get captions from YouTube videos? |
How can I fix index out of range' error when generating a python code with Tkinter Designer from Figma? Posted: 12 Nov 2021 09:21 AM PST This is the error I'm getting on my shell when I use the credentials to generate a python code on Tkinter Desingner: window_data = self.file_data["document"]["children"][0]["children"][0] IndexError: list index out of range Exception in Tkinter callback Traceback (most recent call last): File "/usr/lib/python3.6/tkinter/__init__.py", line 1705, in __call__ return self.func(*args) File "gui.py", line 72, in btn_clicked designer.design() File "/home/carol/Tkinter-Designer/tkdesigner/designer.py", line 29, in design code = self.to_code() File "/home/carol/Tkinter-Designer/tkdesigner/designer.py", line 21, in to_code The Figma file: https://www.figma.com/file/Zadkbq5PwiqK15LjxlFyWn/login?node-id=0%3A1 |
How to handle two one billion record for file comparison Posted: 12 Nov 2021 09:20 AM PST I try to read two one billion record file from unix server for file comparison. I tried in python with paramiko package. when I try in python it is very slow to connect and read unix file that why I choose Java. In Java when I read the file I am facing memory issue and performance issue. My requirement first read all record from unix server file1 and the read second file record from unix server then compare the read file. kindly please help me on this. |
Filling a new column with values from a different column Posted: 12 Nov 2021 09:22 AM PST Supposing I have a dataframe like so : dataframe If I have to make a new column, which has the values from column 3 like so 4 N/A -1.135632 -1.044236 1.071804 0.271860 -1.087401 0.524988 -1.039268 0.844885 -1.469388 -0.968914 i.e, entry 1 of column 4 is filled with entry 0 of column 3, entry 2 of column 4 is filled with entry 1 of column 3 and so on...until the nth entry in the 4th column is filled with the (n-1)th entry of the 3rd column |
Keras model predict NaNs after save/load Posted: 12 Nov 2021 09:21 AM PST A Keras model works perfectly fine after compiling/training: >>> model.predict(values) array([[5.28525668e-10, 3.66615766e-12, 2.76005746e-10, ..., 1.06744905e-10, 3.96939370e-09, 1.54998125e-09], [1.08512407e-17, 1.16371355e-20, 3.40085518e-20, ..., 1.58855026e-15, 3.41645340e-23, 2.22618953e-18], [8.91928664e-07, 1.51766372e-07, 5.11579383e-05, ..., 2.09874074e-07, 1.08243627e-08, 1.00344047e-03], ..., [1.48135211e-06, 4.81735299e-07, 7.23933127e-08, ..., 6.75531879e-08, 2.97403737e-08, 5.35680655e-08], [2.52744006e-12, 1.91630305e-11, 4.30207465e-13, ..., 6.73083234e-09, 1.56778467e-13, 6.92025376e-13], [2.72180110e-08, 2.60345967e-08, 6.72346505e-05, ..., 1.04813864e-06, 8.22153803e-11, 6.33114814e-06]], dtype=float32) But after saving the model and loading it in a different script: # script 1 model.save('./model') # script 2: model = tf.keras.models.load_model(f"./model") Calling model.predict() on the loaded model returns only NaN values, on the exact same input data: >>> model.predict(values) array([[nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], ..., [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan]], dtype=float32) This worked perfectly fine up to recently, but now suddenly the model started to behave like this. Again, going back to script 1 works perfectly fine on the exact same data, restarting scripts (1 and 2) and saving the model again then reloading again does not improve anything. - I checked that the model saved and the model loaded are exactly the same
- I also tried to call
loaded_model(values, training=False) with no success Any idea what is happening here and how to fix this? Using TensorFlow 2.3.4. |
Why NPM is not offering update to latest version? Posted: 12 Nov 2021 09:21 AM PST I'm using npm 8.1.3 . What I'm wondering is why NPM is not offering the update to the latest version of axios : $ npm outdated Package Current Wanted Latest Location Depended by axios 0.21.1 0.21.4 0.24.0 node_modules/axios foo As far as I know "axios": "^0.21.1" allows updating to 0.24.0 then why it wants to install 0.21.4 ? (I've also tried yarn , same thing is happening it updates axios to 0.21.4 ). And here is my package.json file: { "name": "test", "version": "1.0.0", "description": "", "main": "", "scripts": { "test": "echo \"Error: no test specified\" && exit 1" }, "repository": { "type": "", "url": "" }, "keywords": [], "author": "", "license": "UNLICENSED", "bugs": { "url": "" }, "homepage": "", "devDependencies": { }, "dependencies": { "axios": "^0.21.1" } } |
Translate OLE call from MATLAB to Python Posted: 12 Nov 2021 09:21 AM PST I have a question regarding OLE methods. I have a MATLAB script that reads from a data logging software (Magneti Marelli Wintax) using OLE and it works fine. This is the script: %%%%%Create WinTAX4 Server Object.. oWTX4 = actxserver('WinTax4.Application'); oWTX4.visible = 'TRUE'; %%%%%Get the Data From WinTAX4.... %%%%% get the current DataSet Loaded in WinTAX4.. myData = oWTX4.CurrentData; myDataLoad = invoke(myData, 'Item', 0); %%%%% LapTime is.. myDataLoadTime = get(myDataLoad, 'Time' ); MyChannels = get(myDataLoad, 'Channels'); %%%%% only for demonstration purpose, get the channel "accx_can" .. MyChannel = invoke(MyChannels, 'Item', 'accx_can') This script returns in variable MyChannel an array of floats that contains all the data. Then I want to do the same in Python and I got a little bit lost: from win32com.client.dynamic import Dispatch import pandas as pd import inspect wintax = Dispatch('WinTax4.Application') wintax.Visible = True myData = wintax.CurrentData(0) Up to here I can load the data. (0) is the first open dataset in Wintax, (1) is the second data set and so on. But then I'm totally lost in translating to Python MyChannel = invoke(MyChannels, 'Item', 'accx_can') . As invoke function is typical MATLAB. And myData is not actually data but an still an OLE object. inspect.getmembers(myData) returns [('_ApplyTypes_', <bound method CDispatch._ApplyTypes_ of <COMObject <unknown>>>), ('_FlagAsMethod', <bound method CDispatch._FlagAsMethod of <COMObject <unknown>>>), ('_LazyAddAttr_', <bound method CDispatch._LazyAddAttr_ of <COMObject <unknown>>>), ('_NewEnum', <bound method CDispatch._NewEnum of <COMObject <unknown>>>), ('_Release_', <bound method CDispatch._Release_ of <COMObject <unknown>>>), ('__AttrToID__', <bound method CDispatch.__AttrToID__ of <COMObject <unknown>>>), ('__LazyMap__', <bound method CDispatch.__LazyMap__ of <COMObject <unknown>>>), ('__bool__', <bound method CDispatch.__bool__ of <COMObject <unknown>>>), ('__call__', <bound method CDispatch.__call__ of <COMObject <unknown>>>), ('__class__', win32com.client.dynamic.CDispatch), ('__delattr__', <method-wrapper '__delattr__' of CDispatch object at 0x0000027BCD707610>), ('__dict__', {'_oleobj_': <PyIDispatch at 0x0000027BCC17B500 with obj at 0x0000027B9A8B3918>, '_username_': '<unknown>', '_olerepr_': <win32com.client.build.LazyDispatchItem at 0x27bcd7077f0>, '_mapCachedItems_': {}, '_builtMethods_': {}, '_enum_': None, '_unicode_to_string_': None, '_lazydata_': (<PyITypeInfo at 0x0000027BCC17B530 with obj at 0x0000027B9A8B33D8>, <PyITypeComp at 0x0000027BCC230A20 with obj at 0x0000027B9A8B3BB8>)}), ('__dir__', <function CDispatch.__dir__()>), ('__doc__', None), ('__eq__', <bound method CDispatch.__eq__ of <COMObject <unknown>>>), ('__format__', <function CDispatch.__format__(format_spec, /)>), ('__ge__', <method-wrapper '__ge__' of CDispatch object at 0x0000027BCD707610>), ('__getattr__', <bound method CDispatch.__getattr__ of <COMObject <unknown>>>), ('__getattribute__', <method-wrapper '__getattribute__' of CDispatch object at 0x0000027BCD707610>), ('__getitem__', <bound method CDispatch.__getitem__ of <COMObject <unknown>>>), ('__gt__', <method-wrapper '__gt__' of CDispatch object at 0x0000027BCD707610>), ('__hash__', None), ('__init__', <bound method CDispatch.__init__ of <COMObject <unknown>>>), ('__init_subclass__', <function CDispatch.__init_subclass__>), ('__int__', <bound method CDispatch.__int__ of <COMObject <unknown>>>), ('__le__', <method-wrapper '__le__' of CDispatch object at 0x0000027BCD707610>), ('__len__', <bound method CDispatch.__len__ of <COMObject <unknown>>>), ('__lt__', <method-wrapper '__lt__' of CDispatch object at 0x0000027BCD707610>), ('__module__', 'win32com.client.dynamic'), ('__ne__', <bound method CDispatch.__ne__ of <COMObject <unknown>>>), ('__new__', <function object.__new__(*args, **kwargs)>), ('__reduce__', <function CDispatch.__reduce__()>), ('__reduce_ex__', <function CDispatch.__reduce_ex__(protocol, /)>), ('__repr__', <bound method CDispatch.__repr__ of <COMObject <unknown>>>), ('__setattr__', <bound method CDispatch.__setattr__ of <COMObject <unknown>>>), ('__setitem__', <bound method CDispatch.__setitem__ of <COMObject <unknown>>>), ('__sizeof__', <function CDispatch.__sizeof__()>), ('__str__', <bound method CDispatch.__str__ of <COMObject <unknown>>>), ('__subclasshook__', <function CDispatch.__subclasshook__>), ('__weakref__', None), ('_builtMethods_', {}), ('_enum_', None), ('_find_dispatch_type_', <bound method CDispatch._find_dispatch_type_ of <COMObject <unknown>>>), ('_get_good_object_', <bound method CDispatch._get_good_object_ of <COMObject <unknown>>>), ('_get_good_single_object_', <bound method CDispatch._get_good_single_object_ of <COMObject <unknown>>>), ('_lazydata_', (<PyITypeInfo at 0x0000027BCC17B530 with obj at 0x0000027B9A8B33D8>, <PyITypeComp at 0x0000027BCC230A20 with obj at 0x0000027B9A8B3BB8>)), ('_make_method_', <bound method CDispatch._make_method_ of <COMObject <unknown>>>), ('_mapCachedItems_', {}), ('_oleobj_', <PyIDispatch at 0x0000027BCC17B500 with obj at 0x0000027B9A8B3918>), ('_olerepr_', <win32com.client.build.LazyDispatchItem at 0x27bcd7077f0>), ('_print_details_', <bound method CDispatch._print_details_ of <COMObject <unknown>>>), ('_proc_', <bound method CDispatch._proc_ of <COMObject <unknown>>>), ('_unicode_to_string_', None), ('_username_', '<unknown>'), ('_wrap_dispatch_', <bound method CDispatch._wrap_dispatch_ of <COMObject <unknown>>>)] dir(myData) doesn't spit anything of any use for my little Python knowledge: ['_ApplyTypes_', '_FlagAsMethod', '_LazyAddAttr_', '_NewEnum', '_Release_', '__AttrToID__', '__LazyMap__', '__bool__', '__call__', '__class__', '__delattr__', '__dict__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattr__', '__getattribute__', '__getitem__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__int__', '__le__', '__len__', '__lt__', '__module__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__setitem__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__', '_builtMethods_', '_enum_', '_find_dispatch_type_', '_get_good_object_', '_get_good_single_object_', '_lazydata_', '_make_method_', '_mapCachedItems_', '_oleobj_', '_olerepr_', '_print_details_', '_proc_', '_unicode_to_string_', '_username_', '_wrap_dispatch_'] As invoke function is typical MATLAB. |
Good and bad edges Graph [closed] Posted: 12 Nov 2021 09:22 AM PST Given a graph (connected or disconnected), the graph contains edges ( classified into good and bad). Our goal is to find the maximal set of vertices such that for every vertex V in the subset, good neighbours of V must be included in set (u-v are called good neighbours if edge u-v is good) and no two vertices in the set have a bad edge between them and every two vertices in the subset is connected via good roads. |
Creating an object only the first time in mongodb Posted: 12 Nov 2021 09:21 AM PST I'm making an app where a user makes a safe by going to /mysafe. But i only want to create it the first time when he goes there and for the next time when he goes to /mysafe it should redirect to /mysafe/theidofit. See my app.js app.get('/mysafe',async (req,res)=> { const safe=new Safe() safe.author=req.user._id safe.save() res.redirect(`/mysafe/${safe._id}`) }) I tried adding a middleware but in my user schema i dont have a safe defined.Do i need to define it or can i do it without it? const UserSchema = new Schema({ email: { type: String, required: true, unique: true } }); |
Why is Textarea empty despite there is content between <textarea></textarea> Posted: 12 Nov 2021 09:21 AM PST I have included a Textarea in a Bootstrap modal like Before<textarea>Foo</textarea>After but it always shows only Before [empty textarea] After. I have no idea why that is the case. I have no JS doing anything to that textarea, so the content between <textarea></textarea> should just show up right? I have the below code for the Bootstrap modal <section class='modal fade' id='photo-caption-modal'> <div class='modal-dialog modal-dialog-centered'> <div class='modal-content w-75 mx-auto'> <div class='modal-header'> <h6 class='modal-title'>Modify the photo caption</h6> <button type='button' class='btn-close' data-bs-dismiss='modal'></button> </div> <div class='modal-body'> Before<textarea class='form-control' id='photo-caption' rows='3' placeholder="Write a caption"> HELLO WORLD </textarea>After </div> </div> </div> </section> Which I show by let captionModal = new bootstrap.Modal(document.querySelector('#photo-caption-modal')); captionModal.show(); I was simply expecting to see hello world between that Before and After in the textarea, but it is empty. "hello world" doesn't change anything. Below is a screenshot of what I see |
Hello guys, I'm trying to build an organisation attendance application,How can i use JavaScript to get the location of each offices in a building Posted: 12 Nov 2021 09:21 AM PST I have tried using navigator.geolocation.getCurrentLocation(location). But this is returning the longitude and latitude my my whole area(city) I need it to be more specific on my exact point. If youbknow which other method I can use please, reccommend. |
Vue3 extend component using composition api. Its this possible? Posted: 12 Nov 2021 09:21 AM PST Hy there, I'm trying to create a dialog plugin in vue3 using composition api. I'm at the step where i want to extend a base component. Here is what I have: I have created a live example here // dialogInstaller.js // component passed by user or some default components import userComponent from "./userComponent.vue"; // helper mount function source: https://github.com/pearofducks/mount-vue-component import { mount } from "@/mount"; // dialog related functions that must be accesible from the component above after extending const dialogClose = ref(() => console.log("dialog closed")); // just an example // extend the component const dialogPop = { extends: userComponent, setup() { return { dialogClose, ...userComponent.setup(), }; }, }; // now mount the component const { vNode, destroyVNode, el } = mount(dialogPop, { props: {}, app: appInstance, // vue app instance element: dialogWrapper, // component mount location }); User component look like this: <template> <div> <button type="button" @click="dialogClose">Close from template</button> <button type="button" @click="dialogCloseFromSetup">Close from setup</button> <button type="button" @click="dialogCloseFromInstance">Close from instance</button> </div> </template> <script> import { ref, getCurrentInstance } from 'vue'; export default { name: 'userComponent', setup() { const dialogCloseFromSetup = () => { dialogClose(); }; const instance = getCurrentInstance().ctx; const dialogCloseFromInstance = () => { instance.dialogClose(); }; return { dialogCloseFromSetup, dialogCloseFromInstance }; }, }; </script> What i want to achieve is that the method "dialogClose" to be available from the userComponent -- template (like button 1) and setup (like button 2). In other words i want that method to be accessible from every component that is passed to the dialog plugin. My head jump straight to the extend option because i used to use before in vue2 If button 1 is clicked everything working as expected, but the second button is not working, method is not accessible in setup. I found a workaround to this problem by looking into the vue instance and accessing the method from "getCurrentInstance().ctx". everything work as espected if i do this (button 3). I feel like this is not a good solution that's why im asking: - Its the way i extend the vue component correct ?
- If its correct why can i access the method directly in the template and not in the setup?
- Its a good idea to run the method from getCurrentInstance().ctx ?
Thanks in advance and stay safe ! |
Database Button PHP/MySQL Posted: 12 Nov 2021 09:21 AM PST I know this isn't something you do normally but this is for a class and is needed for grading. I have a site that I have created and am trying to create a button that when pushed will echo the database information (id, username, and passwords) for my teacher to view. However, my code (see below) is not doing anything when the button is pushed and I am unsure why or how to fix it. Question: How do I create a link that when pushed will echo out the contents of the database? Teacher Instruction: - Create a link called "users"
- When clicking on "users" it shows the username and password for all users as they are stored in the database
- Note, in the real world, this is foolish and an obvious security risk. However, for grading purposes (and since this is not a real site), I need it to be present
if(isset($_POST['database'])) { $sqldb = "SELECT * FROM user"; $results=mysqli_query($conn,$sqldb); $row_count=mysqli_num_rows($results); echo "<table>"; while ($row = mysqli_fetch_array($results)) { echo "<tr><td>".($row['id'])."</td></tr>"; echo "<tr><td>".($row['username'])."</td></tr>"; echo "<tr><td>".($row['password'])."</td></tr>"; } echo "</table>"; mysqli_close($conn); } ?> <!DOCTYPE html> <html lang="en"> <head> <link type="text/css" rel="stylesheet" href="css\style.css"> <script src="js\script.js"defer></script> <title>Relatively Secure</title> </head> <body> <div class="wrapper"> <?php //DATABASE VIEW echo '<button class="button" type="text" name="database">Users</button>'; ?> </div> <div class="wrapperforms"> <?php echo $login_form; ?> <?php echo $error; echo $errors; ?> </div> </body> </html> |
SQL - get rid of the nested aggregate select Posted: 12 Nov 2021 09:21 AM PST There is a table Payment , which for example tracks the amount of money user puts into account, simplified as =================================== Id | UserId | Amount | PayDate | =================================== 1 | 42 | 11 | 01.02.99 | 2 | 42 | 31 | 05.06.99 | 3 | 42 | 21 | 04.11.99 | 4 | 24 | 12 | 05.11.99 | What is need is to receive a table with balance before payment moment, eg: =============================================== Id | UserId | Amount | PayDate | Balance | =============================================== 1 | 42 | 11 | 01.02.99 | 0 | 2 | 42 | 31 | 05.06.99 | 11 | 3 | 42 | 21 | 04.11.99 | 42 | 4 | 24 | 12 | 05.11.99 | 0 | Currently the select statement looks something like SELECT Id, UserId, Amount, PaidDate, (SELECT sum(amount) FROM Payments nestedp WHERE nestedp.UserId = outerp.UserId AND nestedp.PayDate < outerp.PayDate) as Balance FROM Payments outerp How can I rewrite this select to get rid of the nested aggregate selection? The database in question is SQL Server 2019. |
PL/SQL API call/query returns multiple records, how to pass into multiple variables Posted: 12 Nov 2021 09:22 AM PST I have this api_call in oracle sql like this: select sb_transfer_crse.f_query_all('000497') from dual; The response looks like this: SHBTATC_SBGI_CODE SHBTATC_PROGRAM SHBTATC_TLVL_CODE SHBTATC_SUBJ_CODE_TRNS SHBTATC_CRSE_NUMB_TRNS SHBTATC_TRNS_TITLE ------ ------------ -- --------------------------------------------------------------------------------- 000497 ...... UG AAA 010 Acad Achievement Pre-College 000497 ...... UG AAA 050 Semester Survival 000497 ...... UG AAA 070 Special Topics 000497 ...... UG AAA 071 Special Topics 000497 ...... UG AAA 072 Special Topics 000497 ...... UG AAA 073 Special Topics I am trying to pass the response data into variables either to handle one a time in a loop or if possible take them all and export to a temp/new table What i have so far looks like this: Declare --variables for query VAR_p_sbgi_code shbtatc.shbtatc_sbgi_code%TYPE; --Variables for Data being returned VAR_r_sbgi_code shbtatc.shbtatc_sbgi_code%TYPE; VAR_r_program shbtatc.shbtatc_program%TYPE; VAR_r_tlvl_code shbtatc.shbtatc_tlvl_code%TYPE; VAR_r_subj_code_trns shbtatc.shbtatc_subj_code_trns%TYPE; VAR_r_crse_numb_trns shbtatc.shbtatc_crse_numb_trns%TYPE; VAR_r_trns_title shbtatc.shbtatc_trns_title%TYPE; Begin select sb_transfer_crse.f_query_all(p_sbgi_code => VAR_p_sbgi_code) INTO VAR_r_sbgi_code,VAR_r_program,VAR_r_tlvl_code,VAR_r_subj_code_trns,VAR_r_crse_numb_trns,VAR_r_trns_title From Dual; End; The problem is I am used to dealing with getting one result/response, not 6. and I'm not sure how to loop through the results? Any help would be appreciated. This is the function: Function f_query_all(p_sbgi_code shbtatc.shbtatc_sbgi_code%TYPE, p_program shbtatc.shbtatc_program%TYPE DEFAULT NULL) RETURN transfer_crse_ref This is what transfer_crse_ref is: transfer_crse_ref TYPE transfer_crse_ref IS REF CURSOR RETURN transfer_crse_rec; Entity cursor variable type and this is what transfer_crse_rec looks like: transfer_crse_rec TYPE transfer_crse_rec IS RECORD ( r_sbgi_code shbtatc.shbtatc_sbgi_code%TYPE, r_program shbtatc.shbtatc_program%TYPE, r_tlvl_code shbtatc.shbtatc_tlvl_code%TYPE, r_subj_code_trns shbtatc.shbtatc_subj_code_trns%TYPE, r_crse_numb_trns shbtatc.shbtatc_crse_numb_trns%TYPE, r_term_code_eff_trns shbtatc.shbtatc_term_code_eff_trns%TYPE, r_trns_title shbtatc.shbtatc_trns_title%TYPE, r_trns_low_hrs shbtatc.shbtatc_trns_low_hrs%TYPE, r_trns_high_hrs shbtatc.shbtatc_trns_high_hrs%TYPE, r_trns_review_ind shbtatc.shbtatc_trns_review_ind%TYPE, r_tast_code shbtatc.shbtatc_tast_code%TYPE, r_trns_catalog shbtatc.shbtatc_trns_catalog%TYPE, r_tgrd_code_min shbtatc.shbtatc_tgrd_code_min%TYPE, r_group shbtatc.shbtatc_group%TYPE, r_group_primary_ind shbtatc.shbtatc_group_primary_ind%TYPE, r_protect_ind shbtatc.shbtatc_protect_ind%TYPE, r_crse_desc shbtatc.shbtatc_crse_desc%TYPE, r_user_id shbtatc.shbtatc_user_id%TYPE, r_data_origin shbtatc.shbtatc_data_origin%TYPE, r_internal_record_id gb_common.internal_record_id_type); Business Entity record type |
Getting the last and oldest price of a grouped row Posted: 12 Nov 2021 09:21 AM PST I have this query and I want to select the mintime and maxtime in the same columns per row. I figured out how to select the maxtime but how can I select both in the same query? WITH tmp AS ( SELECT TrackID, ID, price, MAX(Time) as maxtime, MIN(Time) as mintime FROM track WHERE Time > NOW() - INTERVAL 1 HOUR GROUP BY ID ) SELECT T.TrackID, T.ID, tmp.Price as currentprice, T.Time FROM track AS T JOIN tmp ON T.ID = tmp.ID WHERE T.Time = tmp.maxtime; I'm really struggeling to grasp how to make a CTE query, I have read the documentation several times |
Version Sanity Check (Spring/SLF4J) Posted: 12 Nov 2021 09:21 AM PST I am trying to deploy Spring Boot application on Tomcat. But somehow I am getting: Unexpected problem occured during version sanity check Reported exception: java.lang.AbstractMethodError: org.apache.logging.slf4j.SLF4JServiceProvider.getRequestedApiVersion()Ljava/lang/String; at org.slf4j.LoggerFactory.versionSanityCheck(LoggerFactory.java:297) at org.slf4j.LoggerFactory.performInitialization(LoggerFactory.java:141) at org.slf4j.LoggerFactory.getProvider(LoggerFactory.java:421) at org.slf4j.LoggerFactory.getILoggerFactory(LoggerFactory.java:407) at io.micrometer.core.util.internal.logging.Slf4JLoggerFactory.<init>(Slf4JLoggerFactory.java:49) at io.micrometer.core.util.internal.logging.Slf4JLoggerFactory.<clinit>(Slf4JLoggerFactory.java:46) at io.micrometer.core.util.internal.logging.InternalLoggerFactory.newDefaultFactory(InternalLoggerFactory.java:60) at io.micrometer.core.util.internal.logging.InternalLoggerFactory.getDefaultFactory(InternalLoggerFactory.java:76) at io.micrometer.core.util.internal.logging.InternalLoggerFactory.getInstance(InternalLoggerFactory.java:108) at io.micrometer.core.util.internal.logging.InternalLoggerFactory.getInstance(InternalLoggerFactory.java:98) at io.micrometer.core.instrument.binder.jvm.JvmGcMetrics.<clinit>(JvmGcMetrics.java:61) at org.springframework.boot.actuate.autoconfigure.metrics.JvmMetricsAutoConfiguration.jvmGcMetrics(JvmMetricsAutoConfiguration.java:48) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:154) at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:653) at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:486) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1352) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1195) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:582) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542) at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) I have a few SLF4J/Log4J2 jars in a common class loader, that are used for some other webapps. Like: log4j-api-2.14.1.jar log4j-core-2.14.1.jar log4j-over-slf4j-2.0.0-alpha5.jar log4j-slf4j18-impl-2.14.1.jar slf4j-api-2.0.0-alpha5.jar I thought it was a conflict with the slf4j jars with the jars of the spring WAR. So i excluded all the sllf4j items from the Spring application, thinking that it would pick the classes from the common loader. But I get the above error. The application starts up fine, without any issues. But not sure how to get rid of this. My final dependency section of the of the spring application's pom is something like this: <dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-actuator</artifactId> <exclusions> <exclusion> <groupId>org.slf4j</groupId> <artifactId>slf4j-api</artifactId> </exclusion> <exclusion> <groupId>org.apache.logging.log4j</groupId> <artifactId>log4j-to-slf4j</artifactId> </exclusion> <exclusion> <groupId>org.slf4j</groupId> <artifactId>jul-to-slf4j</artifactId> </exclusion> <exclusion> <groupId>ch.qos.logback</groupId> <artifactId>logback-classic</artifactId> </exclusion> </exclusions> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-data-jpa</artifactId> <exclusions> <exclusion> <groupId>org.slf4j</groupId> <artifactId>slf4j-api</artifactId> </exclusion> </exclusions> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> <exclusions> <exclusion> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-tomcat</artifactId> </exclusion> </exclusions> </dependency> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-config-client</artifactId> </dependency> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-config</artifactId> </dependency> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-bootstrap</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-devtools</artifactId> <scope>runtime</scope> <optional>true</optional> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-test</artifactId> <scope>test</scope> <exclusions> <exclusion> <groupId>org.slf4j</groupId> <artifactId>slf4j-api</artifactId> </exclusion> </exclusions> </dependency> <dependency> <groupId>org.springframework.security</groupId> <artifactId>spring-security-test</artifactId> <scope>test</scope> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-configuration-processor</artifactId> <optional>true</optional> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-tomcat</artifactId> <scope>provided</scope> </dependency> <!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-core --> <dependency> <groupId>com.fasterxml.jackson.core</groupId> <artifactId>jackson-core</artifactId> </dependency> <!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-databind --> <dependency> <groupId>com.fasterxml.jackson.core</groupId> <artifactId>jackson-databind</artifactId> </dependency> </dependencies> Any pointers will be helpful. Thanks! |
How to remove data where participants answer the same all the way down? Posted: 12 Nov 2021 09:20 AM PST If na.rm = TRUE removes participants with incomplete responses, is there a way to remove participants who "straight-line" their responses (e.g. in a Likert scale)? Example: How to remove participant data with responses like Participant A? Participant A responses: 1, 1, 1, 1, 1, 1, 1 Participant B responses: 1, 6, 5, 5, 2, 3, 2 Thanks for your help :) Edit: My data columns include Participant, A_1, A_2, A_3, A_4, B_1, B_2, B_3. Would it be possible to get unique responses across a row (a participant). The "A_1" and others are the specific questions a participant can score 1-7. |
How do I replace text on a web page without the original text loading first? Posted: 12 Nov 2021 09:20 AM PST I'm trying to find the right JavaScript code for a browser extension that replaces the word "winter" with the word "summer" in the text of a web page. First attempt Based on this blog post, my first attempt was function wordFilter() { let target = "winter"; let replace = "summer"; var html = document.querySelector('html'); var walker = document.createTreeWalker(html, NodeFilter.SHOW_TEXT); var node; while (node = walker.nextNode()) { node.nodeValue = node.nodeValue.replace(target, replace); } } wordFilter() This almost works. It does replace "winter" with "summer", but the word "winter" still appears onscreen for a few seconds before it's replaced. I want the filter to work from the very beginning. At the very least, this attempt shows that my general extension setup an permissions are correct, so any further failures must be code problems. Second attempt My second attempt was based on this answer to a StackOverflow post. It's an involved post, but the section under "Naive enumeration of added nodes" is closest to what I want. The code in the onMutation() function searches for <h1> elements that contain the target text; just for proof-of-concept, I simplified that part of the code to apply to all Elements that are descendants of an added Element. If the initial DOM load qualifies as a set of Mutations (which I'm still not clear on, but from context that appears to be the expected behavior), then this should capture every Element and every piece of text on the page. The code: var observer = new MutationObserver(onMutation); observer.observe(document, { childList: true, // report added/removed nodes subtree: true, // observe any descendant elements }); function onMutation(mutations, observer) { for (var i = 0, len = mutations.length; i < len; i++) { var added = mutations[i].addedNodes; for (var j = 0, node; (node = added[j]); j++) { replaceText(node); } } } function replaceText(el) { let target_string = "winter"; let replacement_string = "summer"; const walker = document.createTreeWalker(el, NodeFilter.SHOW_TEXT); for (let node; (node = walker.nextNode());) { const text = node.nodeValue; const newText = text.replace(target_string, replacement_string); if (text !== newText) { node.nodeValue = newText; } } } This does not work at all. No instance of the word "winter" is replaced with anything at any time under any conditions. Now I'm at a loss. How do I replace text on a web page without the original text appearing before replacement? |
Typescript + Svelte - How to add types to spread component props Posted: 12 Nov 2021 09:21 AM PST Is it possible to ensure type safety with components that are composed of others? eg. if I want to build a special kind of input with certain validation, etc that should extend my base input. BaseInput.svelte <script lang="ts"> export let value = ''; // + a lot more props </script> <input bind:value ... /> AgeInput.svelte - this extends BaseInput <script lang="ts"> import BaseInput from './BaseInput.svelte' export let {...inputProps}: /* Can we spread and infer BaseInput props? */; </script> <BaseInput {...inputProps} type="number" /> Can we infer the BaseInput props? |
SceneKit-Use a SpriteKit overlay, and use nodes from SceneKit in SpriteKit code Posted: 12 Nov 2021 09:21 AM PST I am used to SpriteKit and just getting into SceneKit. Ive seen similar questions, all not quite what I am looking for. I am trying to make a SpriteKit overlay for my 3D app, my code looks like this: //under class GameViewController let OverlayScene = SKScene(fileNamed: "OverlayScene.swift") //under DidMoveToView sceneView?.overlaySKScene = OverlayScene This doesn't seem to be working and I am not sure why. Once I get this to work, does anyone have any extended information on how I can use the Nodes from SceneKit when writing in SpriteKit? |
React router v6 nested routing not working Posted: 12 Nov 2021 09:20 AM PST ReactDOM.render( <Router> <Routes> <Route path="/" element={<ParentComponent />}> <Route path="child" element={<ChildComponent />} /> </Route> </Routes> </Router>, document.getElementById("root") ); function ParentComponent() { return <div> <h1>hi i am parent component</h1> <Outlet/> // notice this </div>; } function ChildComponent() { return <div> <h1>hi i am child component</h1> </div>; } when i am visiting /child route i am expecting this output : I am parent component I am child component instead of above i am just getting : I am parent component |
Python: Could not install packages due to an OSError: [Errno 2] No such file or directory Posted: 12 Nov 2021 09:21 AM PST I try to use pip to install sklearn , and I receive the following error message: ERROR: Could not install packages due to an OSError: [Errno 2] No such file or directory: 'C:\Users\13434\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\LocalCache\local-packages\Python37\site-packages\sklearn\datasets\tests\data\openml\292\api-v1-json-data-list-data_name-australian-limit-2-data_version-1-status-deactivated.json.gz'**. Can anyone help? Thanks. |
stacked Bi-LSTM compare to 1 layer of Bi-LSTM Posted: 12 Nov 2021 09:20 AM PST I trained my model on BI LSTM for multi class text classification, but my result is not different when I use 2 stacked BI LSTM like below compare to just 1 layer of BI LSTM, any idea about that ? max_len = 409 max_words = 17666 emb_dim = 100 BB = Sequential() BB.add(Embedding(max_words, emb_dim,weights=[embedding_matrix], input_length=max_len)) BB.add(Bidirectional(LSTM(64, return_sequences=True,dropout=0.4, recurrent_dropout=0.4))) BB.add(Bidirectional(LSTM(34, return_sequences=False,dropout=0.4, recurrent_dropout=0.4))) BB.add(Dropout(0.5)) BB.add(Dense(3, activation='softmax')) BB.compile(optimizer='adam', loss='categorical_crossentropy', metrics=['accuracy']) BB.summary() |
Unpivot an Excel matrix/pivot-table? Posted: 12 Nov 2021 09:21 AM PST Is there a quick way to "unpivot" an Excel matrix/pivot-table (in Excel or elsewhere), without writing macros or other code ? Again, I can write code (C# or VBA or whatever) that does that myselfs. I want to know if it is possible to do it without code, quickly ? E.g. I need to convert this permission matrix (given as Excel-table/matrix) into this half-normalized table (so I can insert it into a SQL database): e.g. in SQL I could do it like this: CREATE TABLE dbo.T_DocumentMatrix ( [Function] [varchar](255) NULL, [GROUP-Admin] [varchar](255) NULL, [GROUP-SuperUser] [varchar](255) NULL, [GROUP-Manager] [varchar](255) NULL, [GROUP-OLAP] [varchar](255) NULL, [GROUP-1] [varchar](255) NULL, [GROUP-2] [varchar](255) NULL, [GROUP-3] [varchar](255) NULL, [GROUP-4] [varchar](255) NULL, [GROUP-5] [varchar](255) NULL, [GROUP-6] [varchar](255) NULL, [GROUP-7] [varchar](255) NULL, [GROUP-8] [varchar](255) NULL, [Externals] [varchar](255) NULL ); copy-paste the data from excel, and then SELECT * FROM ( SELECT [Function] ,[GROUP-Admin] ,[GROUP-SuperUser] ,[GROUP-Manager] ,[GROUP-OLAP] ,[GROUP-1] ,[GROUP-2] ,[GROUP-3] ,[GROUP-4] ,[GROUP-5] ,[GROUP-6] ,[GROUP-7] ,[GROUP-8] ,[Externals] FROM T_DocumentMatrix ) AS p UNPIVOT ( Rights FOR GroupName IN ( [GROUP-Admin] ,[GROUP-SuperUser] ,[GROUP-Manager] ,[GROUP-OLAP] ,[GROUP-1] ,[GROUP-2] ,[GROUP-3] ,[GROUP-4] ,[GROUP-5] ,[GROUP-6] ,[GROUP-7] ,[GROUP-8] ,[Externals] ) ) AS unpvt ; However, that requires I change the table-create script and the unpivot-script for every change in groups... |
No comments:
Post a Comment