Static and non-static member function templates with the same parameter types and requires clause in C++ Posted: 31 Dec 2021 04:19 AM PST Static and non-static member functions with the same parameter types cannot be overloaded. But if member functions are templates and one of them has requires clause then all compilers allow it. But the problems appear when one calls both of the member functions: struct A { static int f(auto) { return 1; } int f(auto) requires true { return 2; } }; int main() { [[maybe_unused]] int (A::*y)(int) = &A::f; // ok everywhere (if no below line) [[maybe_unused]] int (*x)(int) = &A::f; //ok in GCC and Clang (if no above line) } If only one (any) line is left in main() then GCC and Clang accept the program. But when both lines in main() are present, Clang prints error: definition with same mangled name '_ZN1A1fIiEEiT_' as another definition and GCC reports an internal compiler error. Demo: https://gcc.godbolt.org/z/4c1z7fWvx Are all compilers wrong in accepting struct A definition with overloaded static and not-static member functions? Or they just have similar bugs in the calling of both functions. |
In Selenium python, unable to select radio elements in Modal Posted: 31 Dec 2021 04:19 AM PST I'm trying to click on the radio button that comes from in MODAL but a timeout exception comes every time. Here is the DOM element with a modal screenshot I'm using the PAGE OBJECT MODEL design pattern and below is the code. I'm trying to click through the main input locator and also select the main class. Explitroy wait: def get_element_clickable(self, by_locator): WebDriverWait(self.driver, 30).until(EC.element_to_be_clickable(by_locator)) Call the locator in function: def get_select_radio(self): return self.get_element_clickable(self.Select_radio_button_of_modal) Also, try this: def get_element_clickable(self, by_locator): WebDriverWait(self.driver, 30).until(EC.visibility_of_element_located(by_locator)) Can someone please help suggest to me how to resolve this issue? |
javascript - sending JSON path as a function argument Posted: 31 Dec 2021 04:19 AM PST I have a nested JSON object with a filed "modifiedDate", that I want to validate that is Date. the full path to the field is: result.instance.data.modifiedDate it works great when validating the whole path: result.instance.data.modifiedDate instanceof Date But if put in a more generic function - that will receive part of the path as a parameter, it doesn't work, and always returns false. function validateDate(result, filedPath) { const dateValidation = result.instance[filedPath] instanceof Date console.log(dateValidation); // false } validateDate(result, "data.modifiedDate"); How to fix it? Thanks |
- POSTGRESQL Use arrays or create new table Posted: 31 Dec 2021 04:18 AM PST Postgresql v. 14 I want to be able to query all genres related to a movie in a efficient and scalable way, I thought of these approaches and need help deciding, if you know a better approach feel free to post it. Problem: I have 2 tables. 1 is movie that contains information related to a movie and the 2nd table is genre in which it contains a list of genres that can be added to movies. Each movie can have 0/null or many genres. Solution 1: Create a new table called movie_genre which references movie_id and genre_id. This will need to be maintained by a trigger to keep it updated once a new movie gets inserted. OR Solution 2: Create a new column in movie called genres which contain array of integers that are linked with genre ids, then I'll be able to query the genres like so: select genre.* from genre join movie on genre.id = any(movie.genres) where movie.id = 1; Which do you think is a more sensible way of doing it? Would like to hear from you. |
Unable to access context object in HTML page rendered in Django Posted: 31 Dec 2021 04:18 AM PST The below view function send news object to HTML page but HTML page gives no result/blank page. def Newsdetail(request,slug): news = get_object_or_404(News,slug=slug) return render(request, 'newsfront/news_detail.html', {news:news}) below is the model class News(models.Model): title=models.TextField() .......... def get_absolute_url(self): return reverse('Newsdetail', kwargs={'slug': self.slug}) HTML PAGE <h5>{{news.title}}</h5> |
GAMS Error in MIP Transportation Problem - Uncontrolled set entered as constant Posted: 31 Dec 2021 04:17 AM PST I am trying to formulate an MIP model in which a transportation can be performed by available trains or new ship investments. My current code includes three tables: Monthly costs for trains, monthly costs for ships and initial investment costs for ships. It raises the following error n149 at the "cost.. z =e=" line: Uncontrolled set entered as constant. Also errors with codes 257 and 141 are raised at the 56th and 57th rows, respectively. Sets i supply nodes /Plant1, Plant2, Plant3, Plant4/ j demand nodes /City1, City2, City3, City4, City5, Dummy/; Parameters a(i) supply capacities /Plant1 290 Plant2 220 Plant3 180 Plant4 280/ b(j) demands /City1 180 City2 200 City3 160 City4 140 City5 250 Dummy 40/; Table c1(i,j) transport costs for trains City1 City2 City3 City4 City5 Dummy Plant1 8.5 7 8 6.5 9 0 Plant2 7.5 8 7 10 8.5 0 Plant3 11 6 6.5 8 7 0 Plant4 9 7 12 6 7.5 0 ; Table c2(i,j) transport costs for ships City1 City2 City3 City4 City5 Dummy Plant1 5.5 6 99999 3.5 4 0 Plant2 3 4.5 4 6.5 6 0 Plant3 99999 99999 3 4 4.5 0 Plant4 5 4.5 7 3 99999 0 ; Table in(i,j) investment costs for ships City1 City2 City3 City4 City5 Dummy Plant1 40 90 99999 40 80 0 Plant2 60 40 80 20 40 0 Plant3 99999 99999 80 60 100 0 Plant4 100 60 60 80 99999 0 ; Positive Variables x(i,j) flow between supply node i and demand node j; Variables y(i,j) whether a ship is bought for the trasfer from i to j z total cost; Binary Variables y; Equations cost objective function supply(i) supply constraint demand(j) demand constraint; cost.. z =e= sum((i,j), c1(i,j)*x(i,j)*12*10*(1-y(i,j)) + c2(i,j)*x(i,j)*12*10*y(i,j)) + in(i,j)*y(i,j); supply(i).. sum(j, x(i,j)) =l= a(i); demand(j).. sum(i, x(i,j)) =g= b(j); Model homework1c /all/; homework1c.OPTFILE=1; Solve homework1c using MIP minimizing z; Display x.l, x.M, y.l; I would appreciate any suggestions to fix them, thanks in advance. |
How to pass options from PyTest to Twisted.trial? Posted: 31 Dec 2021 04:17 AM PST I have some twisted.trial tests in my project, that is tests inheriting from twisted.trial.unittest.TestCase. I need to pass some trial options to my test, specifically it is --reactor option of twisted.trial command line utility. Is there some way for me to pass it to pytest? My thinking is: I add something to pytest.ini, and pytest would somehow launch my trial unittest testcase with this option. Is that possible at the moment? Sample to reproduce this. Take the following unit test: # test_reactor.py from twisted.trial.unittest import TestCase class CrawlTestCase(TestCase): def test_if_correct_reactor(self): from twisted.internet import reactor from twisted.internet.asyncioreactor import AsyncioSelectorReactor assert isinstance(reactor, AsyncioSelectorReactor) Now run it with trial with --reactor flag python -m twisted.trial --reactor=asyncio test_reactor test_reactor CrawlTestCase test_if_correct_reactor ... [OK] ------------------------------------------------------------------------------- Ran 1 tests in 0.042s PASSED (successes=1) Now run it without --reactor flag python -m twisted.trial test_reactor test_reactor CrawlTestCase test_if_correct_reactor ... [ERROR] =============================================================================== [ERROR] Traceback (most recent call last): File "/home/pawel/.../test_reactor.py", line 8, in test_if_correct_reactor assert isinstance(reactor, AsyncioSelectorReactor) builtins.AssertionError: test_reactor.CrawlTestCase.test_if_correct_reactor ------------------------------------------------------------------------------- Ran 1 tests in 0.081s FAILED (errors=1) Now run it with pytest py.test test_reactor.py ============================================================================================================ test session starts ============================================================================================================= platform linux -- Python 3.9.4, pytest-6.2.3, py-1.11.0, pluggy-0.13.1 benchmark: 3.4.1 (defaults: timer=time.perf_counter disable_gc=False min_rounds=5 min_time=0.000005 max_time=1.0 calibration_precision=10 warmup=False warmup_iterations=100000) rootdir: /home/pawel/../aaomw, configfile: pytest.ini plugins: Faker-8.1.3, hypothesis-6.10.1, benchmark-3.4.1 collected 1 item test_reactor.py F Question is: how do I pass something to pytest so that it passes it to trial? Is there something I can put in pytest.ini so that reactor is passed to twisted trial? If what I'm trying to do is not possible, please provide proof that it is not possible, this is also possibly accepted answer, perhaps something needs to be changed in pytest to make this kind of thing possible. |
material-ui, apply global style for buttons Posted: 31 Dec 2021 04:17 AM PST I'm trying to apply a global style for all buttons. What I want is to remove the hover effect for all buttons, so I don't want any styling for the button, but I want the icon to have a hover effect. I want to metion that If I'm using this variant import { makeStyles } from "@material-ui/core/styles"; const useStyles = makeStyles({ button: { "&:hover": { backgroundColor: "transparent !important", }, }, }); const Buttons = ({ onSave, onPrev, formState }) => { const classes = useStyles(); return ( <Stack direction="row" spacing={1}> <Button className={classes.button} onClick={onPrev} color="error" startIcon={<ArrowBackIosNewIcon fill="red" />} /> <Button className={classes.button} disabled={formState.submitting} color="info" onClick={onSave} startIcon={<SendIcon fill="info" />} /> </Stack> ); }; I eliminate the hover effect for the button, still I don't know how to apply the effect on the SendIcon and ArrowBackIosNewIcon instead. This is what I'm trying and it does not work. import { MuiThemeProvider, createMuiTheme } from "@material-ui/core/styles"; const theme = createMuiTheme({ button: { "&:hover": { backgroundColor: "transparent !important", }, }, overrides: { MuiIconButton: { root: { "&:hover": { backgroundColor: "red", }, }, }, }, }); function App() { return ( <BrowserRouter> <div className="main"> <h2 className="main-header">O_x</h2> <div> <MuiThemeProvider theme={theme}> <InvoiceFormCmp /> </MuiThemeProvider> </div> </div> </BrowserRouter> ); } |
Array/table declaration in C with variable lengths in element entries Posted: 31 Dec 2021 04:18 AM PST I need to define a table that contain some values of variable lengths. I preferably want to declare it in one go since it's related to constants that will never change. I am checking if I can avoid a dynamic solution i.e. using malloc and set it up in code. The code below will only serve as pseudo-code of what I want to achieve. It does not work. i.e. typedef struct myelems { char* name; int count1; int** values1; int count2; int** values2; } myelems; myelems arr[] = { {"a", 3, {{1}, {2}, {3}}, 1, {{42}} }, {"b", 2, {{123}, {321}}, 3, {{99}, {88}, {77}}, // other elements here. . . {"x", 0, NULL, 0 , NULL} }; In this example "a" will contain 3 entries in values1 and 1 entry in values2 such that arr[0].values1[0] = 1 arr[0].values1[1] = 2 arr[0].values1[2] = 3 arr[0].values2[0] = 42 "b" will contain 2 entries in values1 and 3 in values2 such that arr[1].values1[0] = 123 arr[1].values1[1] = 321 arr[1].values2[0] = 99 arr[1].values2[1] = 88 arr[1].values2[2] = 77 and "x" have 0 entries in both values1 and values2 I hope this is not a silly question but I just can't find if it is not supported or if it is... if it is how should I do it? Thanks for anything! |
Music suddenly stops playing while using winsound in python script Posted: 31 Dec 2021 04:18 AM PST I have a computer project where I am using tkinter to make a GUI application. The user has the option to either switch on or switch off the music through radiobuttons in the window. I made the below code so that you guys can replicate it and try it for yourself. import tkinter as tk import winsound as ws import sys root = tk.Tk() # Main window root.geometry("200x200") myColor = '#40E0D0' # Its a light blue color root.configure(bg=myColor) # Setting color of main window to myColor def musicplayer(music_onoff): if sys.platform == "win32": if music_onoff == True: ws.PlaySound('8-bit.wav', ws.SND_FILENAME | ws.SND_ASYNC | ws.SND_LOOP) else: ws.PlaySound(None, ws.SND_ASYNC) else: popup.showwarning('Warning', "Only supported on Windows devices") # Linking style with the button rb1 = tk.Radiobutton(text="Off") rb2= tk.Radiobutton(text="On") rb1.configure(command=lambda x=False: musicplayer(x)) rb2.configure(command=lambda x=True: musicplayer(x)) rb1.pack() # Placing Radiobutton rb2.pack() root.mainloop() The 8-bit.wav file corresponds to this video which is a 8-bit version of Never Gonna Give You Up. I converted the video to a .wav format. The full song plays when I play the .wav file on my windows default mp3 player(which is groove music), but not when I use winsound. I am not sure why this is happening because no error shows up on my console as well, when the music stops. |
Error: [firestore/permission-denied] The caller does not have permission to execute the specified operation Posted: 31 Dec 2021 04:17 AM PST i'm trying to get/write and update data in firestore in react native (0.66.3), Showing error [Error: [firestore/permission-denied] The caller does not have permission to execute the specified operation.] i update rules also rules_version = '2'; service cloud.firestore { match /databases/{database}/documents { match /{document=**} { allow read, write: if request.auth != null; } } } App code const users = await firestore().collection('users').get(); console.log(users); Tried with anonymous user await auth().signInAnonymously().then(()=> { return firestore().collection('users').get(); }).catch((err)=>{ console.log(err); }); |
How can I quickly retrieve Bitcoin's price from Bybit? (Python) Posted: 31 Dec 2021 04:17 AM PST I'm having an issue retrieving Bitcoin's current price from Bybit (connected to Bybit API). I would like to update Bitcoin's current price every nth fraction of a second. However it seems to take quite long to retrieve the value from Bybit as it has to search through a large dictionary. Is there any way of speeding up the process? Thanks in advance! This is the code: (Bitcoin's price is being printed every second) |
Error 404 when using GITHUB when I reload the page Posted: 31 Dec 2021 04:19 AM PST I am making an E-commerce website with react and I upload the website to Github pages the deployment works ok, but when I click the Nav buttons to go to different parts of the webpage and reload the page, an error 404 appears: Failed to load resource: the server responded with a status of 404 () In the local host it works totally fine. Should I need to deploy my website as a new project again? I have always upload the websites the same way and I did not have this problem. I actualized my google browser, can there can be a compatibility problem? Thanks a lot! |
Can we have multiple channels having multiple go routines in golang Posted: 31 Dec 2021 04:18 AM PST Can we have multiple go routines listening to multiple channels facing issuing in printing all the problems. I am not able to print all the numbers how can I improved this piece of code If possible can anyone provide some example as I am struggling with this example. Is time.sleep needed after every go routine package main import ( "fmt" "strconv" "sync" "time" ) var count string func worker3(var3 chan string, wg *sync.WaitGroup) { defer wg.Done() for ch := range var3 { count += ch + " " } } func worker2(var2 chan string, var3 chan string, wg *sync.WaitGroup) { defer wg.Done() for ch := range var2 { var3 <- ch } } func worker1(var1 chan string, var2 chan string, var3 chan string, wg *sync.WaitGroup) { defer wg.Done() for ch := range var1 { var2 <- ch } } func main() { var1 := make(chan string, 1500) var2 := make(chan string, 1500) var3 := make(chan string, 1500) var wg sync.WaitGroup count = "" for i := 0; i < 15; i++ { time.Sleep(time.Second) wg.Add(1) go worker1(var1, var2, var3, &wg) } for i := 0; i < 15; i++ { time.Sleep(time.Second) wg.Add(1) go worker2(var2, var3, &wg) } for i := 0; i < 15; i++ { time.Sleep(time.Second) wg.Add(1) go worker3(var3, &wg) } for i := 0; i <= 100000; i++ { var1 <- strconv.Itoa(i) } time.Sleep(time.Second) wg.Wait() fmt.Println(count) } |
Convert camelCase to snake_case ignoring multiple uppercase [duplicate] Posted: 31 Dec 2021 04:17 AM PST I would like to convert camelCase to snake_case, but ignoring multiple capitalized letters in the camelCase. I have the following function: re.sub(r'(?<!^)(?=[A-Z])', '_', name).upper() This returns the following results: abcFunction --> ABC_FUNCTION ABCFunction --> A_B_C_FUNCTION Is there a way to get the following: abcFunction --> ABC_FUNCTION ABCFunction --> ABC_FUNCTION |
fetching data from store in react redux Posted: 31 Dec 2021 04:19 AM PST I am making a project in which I have a JSON server (having id, feature, description in it) running back and I have used saga, store to fetch the items after fetching the items on the page.js ... now I want to do is when I click on the feature(fetched data from JSON) then it should show me the description to that feature (description and feature both are available in the JSON). Can someone help Code below: .js code const dispatch = useDispatch(); useEffect(() => { dispatch(getFeatrure()) }, [dispatch]) const feature = useSelector(state => state.feature.feature) const descHandler = () => { dispatch(getFeatrure()) } return ( <div> <ul> {feature ? feature.map((list) => {return( <li key={list.id}> <a onClick={descHandler}> {list.Features} </a> </li> ) }) :'' } </ul> </div> ) } Now above when I click feature then it should give me its specific description. |
Chrome management undefined [duplicate] Posted: 31 Dec 2021 04:17 AM PST I'm busy with a chrome extension in which I want to know which other extensions have being installed. I tried to used chrome.management.getAll() but I can't get it to work. My manifest looks like this: { ... "manifest_version": 3, "permissions": [ "management", ... ], ... } I tried to run the following code in both content/script.js as background.js chrome.management.getAll(function(info) { console.log(info); alert(info); }); background.js gives me no response of any kind, no error but no log aswell. content/script.js gives me this however: Error handling response: TypeError: Cannot read properties of undefined (reading 'getAll') What am I doing wrong? |
not able to define logic for decrementing pattern Posted: 31 Dec 2021 04:19 AM PST I am trying to print the below pattern but not getting how to build logic where i am going wrong in below code. I want to achieve using stack Expected output : 01 02 01 03 02 01 04 03 02 01 05 04 03 02 01 06 05 04 03 02 01 07 06 05 04 03 02 01 08 07 06 05 04 03 02 01 07 06 05 04 03 02 01 06 05 04 03 02 01 05 04 03 02 01 04 03 02 01 03 02 01 02 01 01 My code : n=15 lst=[] var='' lg = len(str(n)) for row in range(1,n+1): if row <=breaking: print( str(row).zfill(lg) + ' ' +var ) var = str(row).zfill(lg) + ' ' +var else: pass This above code printed up till here after that how to procced with decrementing pattern 01 02 01 03 02 01 04 03 02 01 05 04 03 02 01 06 05 04 03 02 01 07 06 05 04 03 02 01 08 07 06 05 04 03 02 01 |
Edges of a CSS grid cannot be scrolled to Posted: 31 Dec 2021 04:18 AM PST Basically, I have this user-customisable CSS-grid (node: width and height don't have limits, and I do not want it to have such) and it can be really really wide and/or really really high, and if that happens, the scrolling just stops somewhere and the elements not in the middle of the grid just get made inaccessible. This is what I have at the moment and I got zero idea how to make it scroll to all parts of the grid body { display: flex; align-items: center; justify-content: center; height: 100%; margin: 0px; } #board { display: grid; grid-template-columns: 26px } .tile { width: 20px; height: 20px; border-style: solid; border-color: rgb(64, 64, 64); background-color: lightgray; display: flex; justify-content: center; align-items: center } <div id="game_div"> <div id="board"> <div class="tile"></div> <div class="tile"></div> <div class="tile"></div> <div class="tile"></div> <div class="tile"></div> <!-- There are a lot more tiles that get added via .appendChild(). Imagine like a few thousand more tiles here. --> </div> <!-- Irrelevant Minesweeper stuff --> <button onclick="help()">Stuck?</button> <p id="minecount" style="display:inline"></p> </div> PS: Before anyone links me to this, I have tried to understand it and it hasn't worked, so I am asking more specifically. (also that as well) EDIT: Thank you Teemu, I had to add flex-wrap: wrap to the body ruleset |
How do I copy those 3 cards in a third array Posted: 31 Dec 2021 04:17 AM PST I'm stumbling on an exercise on the poker game and I can't see how to do it: I have created an initia array of objects that contains 7 cards. Each card is designated by its value (7, 8, 9, 10, jack...) and its suit (club, diamond...). I created a second array that counts the number of cards of the same value. For example, if I have 3 cards of value 7, then in my second table, an integer of value 3 will fit in the box for cards of value 7. My question is this: In a third array Card[] cards = new Card[5] , how can I copy these 3 cards of value 7 to the beginning of this one please? I'm not looking for the solution but just a simple idea of how I could do this. I have created the following first array: Card[] sevencards = new Card[7]; I created the following method to count the number of cards of the same value is the following: private int[] nbCardsvalue(Card[] sevencards){ int[] nbvalue = new int[13]; for (int i = 0; i < sevencards).length; i++){ if (sevencards[i].getValue() == 2){ nbvalue [0]++; }else if (sevencards[i].getValue() == 3){ nbvalue [1]++; }else if (sevencards[i].getValue() == 4){ nbvalue [2]++; }else if (sevencards[i].getValue() == 5){ nbvalue [3]++; }else if (sevencards[i].getValue() == 6){ nbvalue [4]++; }else if (sevencards[i].getValue() == 7){ nbvalue [5]++; }else if (sevencards[i].getValue() == 8){ nbvalue [6]++; }else if (sevencards[i].getValue() == 9){ nbvalue [7]++; }else if (sevencards[i].getValue() == 10){ nbvalue [8]++; }else if (sevencards[i].getValue() == 11){ nbvalue [9]++; }else if (sevencards[i].getValue() == 12){ nbvalue [10]++; }else if (sevencards[i].getValue() == 13){ nbvalue [11]++; }else if (sevencards[i].getValue() == 14){ nbvalue [12]++; }else{ return nbvalue ; } } return nbvalue ; } Thanks in advance for your help and happy new year ;-) |
Unable to remove a HTML5 class using JQuery Posted: 31 Dec 2021 04:18 AM PST I have made an album carousel component which will switch between two album on user click. There are two album divs and the classes currAlbum and hiddenAlbum to identify the current and hidden album respectively. I am using JQuery to switch the two classes whenever the albums get changed. But the removeClass function is not working and the existing classes are not removed. I am showing the relevent code snippets <!-- Viewer to display photos of the album --> <div class="viewer currAlbum"> <img src="./src/assets/images/gallery-images/dc.jpg" class="album-image"> <img src="./src/assets/images/gallery-images/gconvo.jpg" class="album-image"> <img src="./src/assets/images/gallery-images/bconvo.jpg" class="album-image"> <img src="./src/assets/images/gallery-images/sconvo.jpg" class="album-image"> </div> <div class="viewer hiddenAlbum"> <img src="./src/assets/images/gallery-images/cs.jpg" class="album-image"> <img src="./src/assets/images/gallery-images/ee.jpg" class="album-image"> <img src="./src/assets/images/gallery-images/mech.jpg" class="album-image"> <img src="./src/assets/images/gallery-images/btech14-18ch.jpg" class="album-image"> <img src="./src/assets/images/gallery-images/btech14-18ce.jpg" class="album-image"> </div> Javascript: $('.scroller .album').click((e) => { $('.scroller .album').unbind(); $('.scroller .album.active').removeClass('active'); $('.viewer.currAlbum').removeClass('.currAlbum').addClass('hiddenAlbum'); //getting issue here $('.viewer.hiddenAlbum').removeClass('.hiddenAlbum').addClass('currAlbum'); //getting issue here $(e.currentTarget).addClass('active'); album_images = {} $('.currAlbum .album-image').each((i, el) => { album_images[i] = el; }); num = Object.keys(album_images).length; prev = num - 1; active = 0; next = 1; slider(); init_carousel(prev, active, next); }) Please anyone help me to figure out my error |
Using AWS Transcribe Posted: 31 Dec 2021 04:17 AM PST I have uploaded an audio file to a S3 bucket in AWS with these permissions I upload a audio file successfully to this S3 I then call the boto3 transcription of this audio file as follows . The file URL refers to the file in the appropriate S3 transcribe_client = boto3.client('transcribe', region_name='us-east-2') transcribe_request = request.json file_uri = transcribe_request['file_uri'] item_or_location = transcribe_request['item_or_location'] session_id = transcribe_request['session_id'] time_in_secs_since = TimestampMillisec64() job_name = str(time_in_secs_since) transcript_file_uri = transcribe_m4a_file(job_name, file_uri, transcribe_client) data = {"location": transcript_file_uri} url = transcript_file_uri json_data = urllib.request.urlopen(url).read().decode() But i get a error as "botocore.exceptions.NoCredentialsError: Unable to locate credentials "` - My questions are
- What permissions should i set for the S3 bucket in which the audio files are stored ?
- Do i have to subscribe to the AWS Transcribe service before using it ?
- What could be the cause of this error ?
Update:- I ran aws-configure, but now i get the error botocore.exceptions.ClientError: An error occurred (UnrecognizedClientException) when calling the StartTranscriptionJob operation: The security token included in the request is invalid. |
Firebase v9 and Nuxt 2.15.8 - SyntaxError: Cannot use import statement outside a module Posted: 31 Dec 2021 04:19 AM PST I'm migrating my codebase to use the firebase version 9 SDK and started to get this error once I started using v9 firestore. I've already migrated the auth part of my and that works perfectly. I should note, this only happens when I'm statically generating my website (npm run generate ) but not when building the site for SSR (npm run build ). During development (npm run dev ) I get no errors. The error turns up for every page that has to be generated. It seems to be referencing the messaging module but I'm not using messaging on every page. See an example of the error below: ERROR /faqs C:\Users\simeon.ramjit\Documents\projects\covid19-tt\node_modules\@firebase\messaging\dist\index.sw.esm2017.js:1 import '@firebase/installations'; ^^^^^^ SyntaxError: Cannot use import statement outside a module at Object.compileFunction (node:vm:352:18) at wrapSafe (node:internal/modules/cjs/loader:1031:15) at Module._compile (node:internal/modules/cjs/loader:1065:27) at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10) at Module.load (node:internal/modules/cjs/loader:981:32) at Function.Module._load (node:internal/modules/cjs/loader:822:12) at Module.require (node:internal/modules/cjs/loader:1005:19) at require (node:internal/modules/cjs/helpers:102:18) at Object.<anonymous> (C:\Users\simeon.ramjit\Documents\projects\covid19-tt\node_modules\@firebase\messaging-compat\dist\index.cjs.js:8:10) at Module._compile (node:internal/modules/cjs/loader:1101:14) at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10) at Module.load (node:internal/modules/cjs/loader:981:32) at Function.Module._load (node:internal/modules/cjs/loader:822:12) at Module.require (node:internal/modules/cjs/loader:1005:19) at require (node:internal/modules/cjs/helpers:102:18) at Object.<anonymous> (C:\Users\simeon.ramjit\Documents\projects\covid19-tt\node_modules\firebase\compat\messaging\dist\index.cjs.js:3:1) nuxt.config.js plugins: [ {src: '@/plugins/firebase',ssr: true }, ] plugins/firebase.js import firebase from 'firebase/compat/app' import 'firebase/compat/firestore' import 'firebase/compat/storage' import 'firebase/compat/messaging' import 'firebase/compat/functions' /*********************************** VERSION NINE ********************************** */ import { initializeApp, getApps } from "firebase/app"; import { getAuth } from "firebase/auth"; import { getAnalytics } from "firebase/analytics"; import { getFirestore } from "firebase/firestore" const firebaseConfig = { apiKey: '', authDomain: '', databaseURL: '', projectId: '', storageBucket: '', messagingSenderId: '', appId: '', measurementId: '' }; let firebaseApp; const apps = getApps(); if (!apps.length) { firebaseApp = initializeApp(firebaseConfig); } else { firebaseApp = apps[0]; } const db = getFirestore(firebaseApp, {}); const auth = getAuth(firebaseApp); if(process.browser){ const analytics = getAnalytics(); //enable analytics } /*********************************** END OF VERSION NINE ********************************** */ /*********************************** VERSION EIGHT ********************************** */ if(!firebase.apps.length){ const config = { apiKey: '', authDomain: '', databaseURL: '', projectId: '', storageBucket: '', messagingSenderId: '', appId: '', measurementId: '' }; firebase.initializeApp(config); } const fireDb = firebase.firestore(); const fireStorage =firebase.storage(); const fireFunctions =firebase.functions(); let fireMessage = ''; if(process.browser){ if(firebase.messaging.isSupported()){ fireMessage= firebase.messaging(); } else{ console.warn('[WARNING] Firebase Cloud messaging not supported'); } } /*********************************** END OF VERSION EIGHT ********************************** */ export{fireMessage, fireDb, fireStorage, fireFunctions, auth, db} I'd really appreciate some guidance on this matter. I've appended what was left of the build log below (it was really long so the terminal doesn't have the full log): i Full static generation activated i Generating output directory: dist/ i Generating pages with full static mode ERROR /about C:\Users\simeon.ramjit\Documents\projects\covid19-tt\node_modules\@firebase\messaging\dist\index.sw.esm2017.js:1 import '@firebase/installations'; ^^^^^^ SyntaxError: Cannot use import statement outside a module at Object.compileFunction (node:vm:352:18) at wrapSafe (node:internal/modules/cjs/loader:1031:15) at Module._compile (node:internal/modules/cjs/loader:1065:27) at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10) at Module.load (node:internal/modules/cjs/loader:981:32) at Function.Module._load (node:internal/modules/cjs/loader:822:12) at Module.require (node:internal/modules/cjs/loader:1005:19) at require (node:internal/modules/cjs/helpers:102:18) at Object.<anonymous> (C:\Users\simeon.ramjit\Documents\projects\covid19-tt\node_modules\@firebase\messaging-compat\dist\index.cjs.js:8:10) at Module._compile (node:internal/modules/cjs/loader:1101:14) at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10) at Module.load (node:internal/modules/cjs/loader:981:32) at Function.Module._load (node:internal/modules/cjs/loader:822:12) at Module.require (node:internal/modules/cjs/loader:1005:19) at require (node:internal/modules/cjs/helpers:102:18) at Object.<anonymous> (C:\Users\simeon.ramjit\Documents\projects\covid19-tt\node_modules\firebase\compat\messaging\dist\index.cjs.js:3:1) ERROR /faqs C:\Users\simeon.ramjit\Documents\projects\covid19-tt\node_modules\@firebase\messaging\dist\index.sw.esm2017.js:1 import '@firebase/installations'; ^^^^^^ SyntaxError: Cannot use import statement outside a module at Object.compileFunction (node:vm:352:18) at wrapSafe (node:internal/modules/cjs/loader:1031:15) at Module._compile (node:internal/modules/cjs/loader:1065:27) at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10) at Module.load (node:internal/modules/cjs/loader:981:32) at Function.Module._load (node:internal/modules/cjs/loader:822:12) at Module.require (node:internal/modules/cjs/loader:1005:19) at require (node:internal/modules/cjs/helpers:102:18) at Object.<anonymous> (C:\Users\simeon.ramjit\Documents\projects\covid19-tt\node_modules\@firebase\messaging-compat\dist\index.cjs.js:8:10) at Module._compile (node:internal/modules/cjs/loader:1101:14) at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10) at Module.load (node:internal/modules/cjs/loader:981:32) at Function.Module._load (node:internal/modules/cjs/loader:822:12) at Module.require (node:internal/modules/cjs/loader:1005:19) at require (node:internal/modules/cjs/helpers:102:18) at Object.<anonymous> (C:\Users\simeon.ramjit\Documents\projects\covid19-tt\node_modules\firebase\compat\messaging\dist\index.cjs.js:3:1) ERROR /legislation C:\Users\simeon.ramjit\Documents\projects\covid19-tt\node_modules\@firebase\messaging\dist\index.sw.esm2017.js:1 import '@firebase/installations'; ^^^^^^ SyntaxError: Cannot use import statement outside a module at Object.compileFunction (node:vm:352:18) at wrapSafe (node:internal/modules/cjs/loader:1031:15) at Module._compile (node:internal/modules/cjs/loader:1065:27) at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10) at Module.load (node:internal/modules/cjs/loader:981:32) at Function.Module._load (node:internal/modules/cjs/loader:822:12) at Module.require (node:internal/modules/cjs/loader:1005:19) at require (node:internal/modules/cjs/helpers:102:18) at Object.<anonymous> (C:\Users\simeon.ramjit\Documents\projects\covid19-tt\node_modules\@firebase\messaging-compat\dist\index.cjs.js:8:10) at Module._compile (node:internal/modules/cjs/loader:1101:14) at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10) at Module.load (node:internal/modules/cjs/loader:981:32) at Function.Module._load (node:internal/modules/cjs/loader:822:12) at Module.require (node:internal/modules/cjs/loader:1005:19) at require (node:internal/modules/cjs/helpers:102:18) at Object.<anonymous> (C:\Users\simeon.ramjit\Documents\projects\covid19-tt\node_modules\firebase\compat\messaging\dist\index.cjs.js:3:1) ERROR /references C:\Users\simeon.ramjit\Documents\projects\covid19-tt\node_modules\@firebase\messaging\dist\index.sw.esm2017.js:1 import '@firebase/installations'; ^^^^^^ SyntaxError: Cannot use import statement outside a module at Object.compileFunction (node:vm:352:18) at wrapSafe (node:internal/modules/cjs/loader:1031:15) at Module._compile (node:internal/modules/cjs/loader:1065:27) at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10) at Module.load (node:internal/modules/cjs/loader:981:32) at Function.Module._load (node:internal/modules/cjs/loader:822:12) at Module.require (node:internal/modules/cjs/loader:1005:19) at require (node:internal/modules/cjs/helpers:102:18) at Object.<anonymous> (C:\Users\simeon.ramjit\Documents\projects\covid19-tt\node_modules\@firebase\messaging-compat\dist\index.cjs.js:8:10) at Module._compile (node:internal/modules/cjs/loader:1101:14) at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10) at Module.load (node:internal/modules/cjs/loader:981:32) at Function.Module._load (node:internal/modules/cjs/loader:822:12) at Module.require (node:internal/modules/cjs/loader:1005:19) at require (node:internal/modules/cjs/helpers:102:18) at Object.<anonymous> (C:\Users\simeon.ramjit\Documents\projects\covid19-tt\node_modules\firebase\compat\messaging\dist\index.cjs.js:3:1) ERROR /vaccinationsites C:\Users\simeon.ramjit\Documents\projects\covid19-tt\node_modules\@firebase\messaging\dist\index.sw.esm2017.js:1 import '@firebase/installations'; ^^^^^^ SyntaxError: Cannot use import statement outside a module at Object.compileFunction (node:vm:352:18) at wrapSafe (node:internal/modules/cjs/loader:1031:15) at Module._compile (node:internal/modules/cjs/loader:1065:27) at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10) at Module.load (node:internal/modules/cjs/loader:981:32) at Function.Module._load (node:internal/modules/cjs/loader:822:12) at Module.require (node:internal/modules/cjs/loader:1005:19) at require (node:internal/modules/cjs/helpers:102:18) at Object.<anonymous> (C:\Users\simeon.ramjit\Documents\projects\covid19-tt\node_modules\@firebase\messaging-compat\dist\index.cjs.js:8:10) at Module._compile (node:internal/modules/cjs/loader:1101:14) at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10) at Module.load (node:internal/modules/cjs/loader:981:32) at Function.Module._load (node:internal/modules/cjs/loader:822:12) at Module.require (node:internal/modules/cjs/loader:1005:19) at require (node:internal/modules/cjs/helpers:102:18) at Object.<anonymous> (C:\Users\simeon.ramjit\Documents\projects\covid19-tt\node_modules\firebase\compat\messaging\dist\index.cjs.js:3:1) ERROR /admin/addevent C:\Users\simeon.ramjit\Documents\projects\covid19-tt\node_modules\@firebase\messaging\dist\index.sw.esm2017.js:1 import '@firebase/installations'; ^^^^^^ SyntaxError: Cannot use import statement outside a module at Object.compileFunction (node:vm:352:18) at wrapSafe (node:internal/modules/cjs/loader:1031:15) at Module._compile (node:internal/modules/cjs/loader:1065:27) at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10) at Module.load (node:internal/modules/cjs/loader:981:32) at Function.Module._load (node:internal/modules/cjs/loader:822:12) at Module.require (node:internal/modules/cjs/loader:1005:19) at require (node:internal/modules/cjs/helpers:102:18) at Object.<anonymous> (C:\Users\simeon.ramjit\Documents\projects\covid19-tt\node_modules\@firebase\messaging-compat\dist\index.cjs.js:8:10) at Module._compile (node:internal/modules/cjs/loader:1101:14) at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10) at Module.load (node:internal/modules/cjs/loader:981:32) at Function.Module._load (node:internal/modules/cjs/loader:822:12) at Module.require (node:internal/modules/cjs/loader:1005:19) at require (node:internal/modules/cjs/helpers:102:18) at Object.<anonymous> (C:\Users\simeon.ramjit\Documents\projects\covid19-tt\node_modules\firebase\compat\messaging\dist\index.cjs.js:3:1) ERROR /admin/addinitiative C:\Users\simeon.ramjit\Documents\projects\covid19-tt\node_modules\@firebase\messaging\dist\index.sw.esm2017.js:1 import '@firebase/installations'; ^^^^^^ SyntaxError: Cannot use import statement outside a module at Object.compileFunction (node:vm:352:18) at wrapSafe (node:internal/modules/cjs/loader:1031:15) at Module._compile (node:internal/modules/cjs/loader:1065:27) at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10) at Module.load (node:internal/modules/cjs/loader:981:32) at Function.Module._load (node:internal/modules/cjs/loader:822:12) at Module.require (node:internal/modules/cjs/loader:1005:19) at require (node:internal/modules/cjs/helpers:102:18) at Object.<anonymous> (C:\Users\simeon.ramjit\Documents\projects\covid19-tt\node_modules\@firebase\messaging-compat\dist\index.cjs.js:8:10) at Module._compile (node:internal/modules/cjs/loader:1101:14) at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10) at Module.load (node:internal/modules/cjs/loader:981:32) at Function.Module._load (node:internal/modules/cjs/loader:822:12) at Module.require (node:internal/modules/cjs/loader:1005:19) at require (node:internal/modules/cjs/helpers:102:18) at Object.<anonymous> (C:\Users\simeon.ramjit\Documents\projects\covid19-tt\node_modules\firebase\compat\messaging\dist\index.cjs.js:3:1) ERROR /admin/addsite C:\Users\simeon.ramjit\Documents\projects\covid19-tt\node_modules\@firebase\messaging\dist\index.sw.esm2017.js:1 import '@firebase/installations'; ^^^^^^ SyntaxError: Cannot use import statement outside a module at Object.compileFunction (node:vm:352:18) at wrapSafe (node:internal/modules/cjs/loader:1031:15) at Module._compile (node:internal/modules/cjs/loader:1065:27) at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10) at Module.load (node:internal/modules/cjs/loader:981:32) at Function.Module._load (node:internal/modules/cjs/loader:822:12) at Module.require (node:internal/modules/cjs/loader:1005:19) at require (node:internal/modules/cjs/helpers:102:18) at Object.<anonymous> (C:\Users\simeon.ramjit\Documents\projects\covid19-tt\node_modules\@firebase\messaging-compat\dist\index.cjs.js:8:10) at Module._compile (node:internal/modules/cjs/loader:1101:14) at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10) at Module.load (node:internal/modules/cjs/loader:981:32) at Function.Module._load (node:internal/modules/cjs/loader:822:12) at Module.require (node:internal/modules/cjs/loader:1005:19) at require (node:internal/modules/cjs/helpers:102:18) at Object.<anonymous> (C:\Users\simeon.ramjit\Documents\projects\covid19-tt\node_modules\firebase\compat\messaging\dist\index.cjs.js:3:1) ERROR /admin/dashboard C:\Users\simeon.ramjit\Documents\projects\covid19-tt\node_modules\@firebase\messaging\dist\index.sw.esm2017.js:1 import '@firebase/installations'; ^^^^^^ SyntaxError: Cannot use import statement outside a module at Object.compileFunction (node:vm:352:18) at wrapSafe (node:internal/modules/cjs/loader:1031:15) at Module._compile (node:internal/modules/cjs/loader:1065:27) at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10) at Module.load (node:internal/modules/cjs/loader:981:32) at Function.Module._load (node:internal/modules/cjs/loader:822:12) at Module.require (node:internal/modules/cjs/loader:1005:19) at require (node:internal/modules/cjs/helpers:102:18) at Object.<anonymous> (C:\Users\simeon.ramjit\Documents\projects\covid19-tt\node_modules\@firebase\messaging-compat\dist\index.cjs.js:8:10) at Module._compile (node:internal/modules/cjs/loader:1101:14) at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10) at Module.load (node:internal/modules/cjs/loader:981:32) at Function.Module._load (node:internal/modules/cjs/loader:822:12) at Module.require (node:internal/modules/cjs/loader:1005:19) at require (node:internal/modules/cjs/helpers:102:18) at Object.<anonymous> (C:\Users\simeon.ramjit\Documents\projects\covid19-tt\node_modules\firebase\compat\messaging\dist\index.cjs.js:3:1) ERROR /admin/deploy C:\Users\simeon.ramjit\Documents\projects\covid19-tt\node_modules\@firebase\messaging\dist\index.sw.esm2017.js:1 import '@firebase/installations'; ^^^^^^ SyntaxError: Cannot use import statement outside a module at Object.compileFunction (node:vm:352:18) at wrapSafe (node:internal/modules/cjs/loader:1031:15) at Module._compile (node:internal/modules/cjs/loader:1065:27) at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10) at Module.load (node:internal/modules/cjs/loader:981:32) at Function.Module._load (node:internal/modules/cjs/loader:822:12) at Module.require (node:internal/modules/cjs/loader:1005:19) at require (node:internal/modules/cjs/helpers:102:18) at Object.<anonymous> (C:\Users\simeon.ramjit\Documents\projects\covid19-tt\node_modules\@firebase\messaging-compat\dist\index.cjs.js:8:10) at Module._compile (node:internal/modules/cjs/loader:1101:14) at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10) at Module.load (node:internal/modules/cjs/loader:981:32) at Function.Module._load (node:internal/modules/cjs/loader:822:12) at Module.require (node:internal/modules/cjs/loader:1005:19) at require (node:internal/modules/cjs/helpers:102:18) at Object.<anonymous> (C:\Users\simeon.ramjit\Documents\projects\covid19-tt\node_modules\firebase\compat\messaging\dist\index.cjs.js:3:1) ERROR /admin/login C:\Users\simeon.ramjit\Documents\projects\covid19-tt\node_modules\@firebase\messaging\dist\index.sw.esm2017.js:1 import '@firebase/installations'; ^^^^^^ SyntaxError: Cannot use import statement outside a module at Object.compileFunction (node:vm:352:18) at wrapSafe (node:internal/modules/cjs/loader:1031:15) at Module._compile (node:internal/modules/cjs/loader:1065:27) at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10) at Module.load (node:internal/modules/cjs/loader:981:32) at Function.Module._load (node:internal/modules/cjs/loader:822:12) at Module.require (node:internal/modules/cjs/loader:1005:19) at require (node:internal/modules/cjs/helpers:102:18) at Object.<anonymous> (C:\Users\simeon.ramjit\Documents\projects\covid19-tt\node_modules\@firebase\messaging-compat\dist\index.cjs.js:8:10) at Module._compile (node:internal/modules/cjs/loader:1101:14) at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10) at Module.load (node:internal/modules/cjs/loader:981:32) at Function.Module._load (node:internal/modules/cjs/loader:822:12) at Module.require (node:internal/modules/cjs/loader:1005:19) at require (node:internal/modules/cjs/helpers:102:18) at Object.<anonymous> (C:\Users\simeon.ramjit\Documents\projects\covid19-tt\node_modules\firebase\compat\messaging\dist\index.cjs.js:3:1) ERROR /admin/notifications C:\Users\simeon.ramjit\Documents\projects\covid19-tt\node_modules\@firebase\messaging\dist\index.sw.esm2017.js:1 import '@firebase/installations'; ^^^^^^ SyntaxError: Cannot use import statement outside a module at Object.compileFunction (node:vm:352:18) at wrapSafe (node:internal/modules/cjs/loader:1031:15) at Module._compile (node:internal/modules/cjs/loader:1065:27) at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10) at Module.load (node:internal/modules/cjs/loader:981:32) at Function.Module._load (node:internal/modules/cjs/loader:822:12) at Module.require (node:internal/modules/cjs/loader:1005:19) at require (node:internal/modules/cjs/helpers:102:18) at Object.<anonymous> (C:\Users\simeon.ramjit\Documents\projects\covid19-tt\node_modules\@firebase\messaging-compat\dist\index.cjs.js:8:10) at Module._compile (node:internal/modules/cjs/loader:1101:14) at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10) at Module.load (node:internal/modules/cjs/loader:981:32) at Function.Module._load (node:internal/modules/cjs/loader:822:12) at Module.require (node:internal/modules/cjs/loader:1005:19) at require (node:internal/modules/cjs/helpers:102:18) at Object.<anonymous> (C:\Users\simeon.ramjit\Documents\projects\covid19-tt\node_modules\firebase\compat\messaging\dist\index.cjs.js:3:1) ERROR /admin/sitelocations C:\Users\simeon.ramjit\Documents\projects\covid19-tt\node_modules\@firebase\messaging\dist\index.sw.esm2017.js:1 import '@firebase/installations'; ^^^^^^ SyntaxError: Cannot use import statement outside a module at Object.compileFunction (node:vm:352:18) at wrapSafe (node:internal/modules/cjs/loader:1031:15) at Module._compile (node:internal/modules/cjs/loader:1065:27) at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10) at Module.load (node:internal/modules/cjs/loader:981:32) at Function.Module._load (node:internal/modules/cjs/loader:822:12) at Module.require (node:internal/modules/cjs/loader:1005:19) at require (node:internal/modules/cjs/helpers:102:18) at Object.<anonymous> (C:\Users\simeon.ramjit\Documents\projects\covid19-tt\node_modules\@firebase\messaging-compat\dist\index.cjs.js:8:10) at Module._compile (node:internal/modules/cjs/loader:1101:14) at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10) at Module.load (node:internal/modules/cjs/loader:981:32) at Function.Module._load (node:internal/modules/cjs/loader:822:12) at Module.require (node:internal/modules/cjs/loader:1005:19) at require (node:internal/modules/cjs/helpers:102:18) at Object.<anonymous> (C:\Users\simeon.ramjit\Documents\projects\covid19-tt\node_modules\firebase\compat\messaging\dist\index.cjs.js:3:1) ERROR /admin/updatestatistics C:\Users\simeon.ramjit\Documents\projects\covid19-tt\node_modules\@firebase\messaging\dist\index.sw.esm2017.js:1 import '@firebase/installations'; ^^^^^^ SyntaxError: Cannot use import statement outside a module at Object.compileFunction (node:vm:352:18) at wrapSafe (node:internal/modules/cjs/loader:1031:15) at Module._compile (node:internal/modules/cjs/loader:1065:27) at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10) at Module.load (node:internal/modules/cjs/loader:981:32) at Function.Module._load (node:internal/modules/cjs/loader:822:12) at Module.require (node:internal/modules/cjs/loader:1005:19) at require (node:internal/modules/cjs/helpers:102:18) at Object.<anonymous> (C:\Users\simeon.ramjit\Documents\projects\covid19-tt\node_modules\@firebase\messaging-compat\dist\index.cjs.js:8:10) at Module._compile (node:internal/modules/cjs/loader:1101:14) at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10) at Module.load (node:internal/modules/cjs/loader:981:32) at Function.Module._load (node:internal/modules/cjs/loader:822:12) at Module.require (node:internal/modules/cjs/loader:1005:19) at require (node:internal/modules/cjs/helpers:102:18) at Object.<anonymous> (C:\Users\simeon.ramjit\Documents\projects\covid19-tt\node_modules\firebase\compat\messaging\dist\index.cjs.js:3:1) ERROR / C:\Users\simeon.ramjit\Documents\projects\covid19-tt\node_modules\@firebase\messaging\dist\index.sw.esm2017.js:1 import '@firebase/installations'; ^^^^^^ SyntaxError: Cannot use import statement outside a module at Object.compileFunction (node:vm:352:18) at wrapSafe (node:internal/modules/cjs/loader:1031:15) at Module._compile (node:internal/modules/cjs/loader:1065:27) at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10) at Module.load (node:internal/modules/cjs/loader:981:32) at Function.Module._load (node:internal/modules/cjs/loader:822:12) at Module.require (node:internal/modules/cjs/loader:1005:19) at require (node:internal/modules/cjs/helpers:102:18) at Object.<anonymous> (C:\Users\simeon.ramjit\Documents\projects\covid19-tt\node_modules\@firebase\messaging-compat\dist\index.cjs.js:8:10) at Module._compile (node:internal/modules/cjs/loader:1101:14) at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10) at Module.load (node:internal/modules/cjs/loader:981:32) at Function.Module._load (node:internal/modules/cjs/loader:822:12) at Module.require (node:internal/modules/cjs/loader:1005:19) at require (node:internal/modules/cjs/helpers:102:18) at Object.<anonymous> (C:\Users\simeon.ramjit\Documents\projects\covid19-tt\node_modules\firebase\compat\messaging\dist\index.cjs.js:3:1) √ Client-side fallback created: 200.html √ Static manifest generated i Generating sitemaps √ Generated /sitemap.xml √ Generated /sitemap.xml.gz |
How to make an enumerating in a foreach command along with its positioning in TikZ? Posted: 31 Dec 2021 04:18 AM PST I am using TikZ in LaTeX . I want to make a foreach to enumerate text in several position. Example; Text 'Statement 1' in coordinate A; Text 'Statement 2' in coordinate B; Text 'Statement 3' in coordinate C; Text 'Statement 4' in coordinate D; Here is my code \documentclass[12pt]{article} \usepackage[utf8]{inputenc} \usepackage{tikz} \usetikzlibrary{intersections, angles, quotes} \usepackage{pgffor} \usepackage{amsfonts} \usepackage{amsmath} \usepackage{amssymb} \begin{document} \begin{center} \begin{tikzpicture} \draw[very thick] (7,5) rectangle (11,6.5); \coordinate (A) at (9,5.75); \node at (A) {IF-CONDITIONAL}; \draw[very thick, ->] (9,5)--(9,3); \foreach \s in {3, -2.5, -8, -13.5} \draw[very thick] (9,\s)--(6,{\s-2})--(9,{\s-4})--(12,{\s-2})--cycle; \node at (9,1) {Condition 1 (\textit{true?})}; \node at (9,-4.5) {Condition 2 (\textit{true?})}; \node at (9,-10){Condition ... (\textit{true?})}; \node at (9,-15.5){Else (\textit{true?})}; \foreach \s in {-1, -6.5, -12} \draw[very thick, ->] (9,\s)--(9,{\s-1.5}) node[fill=white, midway]{NO}; \foreach \s in {1, -4.5, -10, -15.5} \draw[very thick, ->] (12,\s)--(14,\s) node[fill=white, midway]{YES}; \foreach \s in {1, -4.5, -10, -15.5} \draw[very thick, ->] (19, \s)--(20, \s); \foreach \x in {0,-5.5, -11, -16.5} \draw[very thick] (14,\x) rectangle (19,{\x+2}); \draw[very thick, ->] (9, -17.5)--(9,-19)--(20, -19); \node[fill=white] at (9, -18.25){NO}; \draw[very thick, ->] (20, 1)--(20, -21); \node at (16.5,1){Statement 1}; \end{tikzpicture} \end{center} \end{document} This code produce the output How to write the text 'Statement 1/2/3/4' in the blank boxes using foreach ? |
How do I setup prisma, nexus, apollo in TS project? Posted: 31 Dec 2021 04:18 AM PST This is my current setup. But for this setup, I can't access the prisma client for some good reason in the resolvers. The goal here is to access the context with their types in all the resolvers. The code below contains my server.ts file contents and the context.ts file contents. What am i missing here? server.ts file import { schema } from './schema' import { context } from './context' //auth context const authContext = async ({ req }: { req: Request }) => { let authUser = {} const token = (req.headers && req.headers.authorization) || '' if (token !== null) { try { const payload: any = verify(token, authConfig.JWT.JWT_SECRET_1!) authUser = payload.user } catch (error) { console.log(error) } } return { authUser, context, } } export const server = new ApolloServer({ schema, context: authContext, }) server.listen({ port: appConfig.port }).then(async ({ url }) => { console.log(`🚀 Server ready at: ${url}${appConfig.graphqlPath}`) }) context.ts import { PrismaClient, User } from '@prisma/client' import { SmsAPI } from './datasources/SMS/SmsAPI' import { typesSMS } from './datasources/SMS/typeDefs' export interface Context { prisma: PrismaClient authUser: Pick<User, 'id' | 'nidNumber'> dataSources: { smsAPI: typesSMS } } // datasource instance export const prisma = new PrismaClient({ log: ['query', 'error'], }) // prisma instance export const dataSources = () => ({ smsAPI: new SmsAPI() }) export const context: Context = { prisma: prisma, authUser: { id: 0, nidNumber: '' }, dataSources: { smsAPI: dataSources, }, } |
why spinner disappear sometimes and reappear again after Minimizing the app? Posted: 31 Dec 2021 04:17 AM PST i am trying to make web devoloping app but i am facing problem in the spinner, its disappear some times and i dont know the reason.. this when i set the adapter to the spinner:- and this when i minimize the app and open it again:- xml:- https://anotepad.com/notes/kxcp7n2h |
Cloud Run For Anthos With Terraform Posted: 31 Dec 2021 04:18 AM PST We would like to achieve is create a Kubernetes cluster in Google Cloud Platform that enables Cloud Run addon; then instantiate the cluster with a custom helm chart release, all this via Terraform From terraform documentation, only show how to create kubernetes cluster but not how to install Cloud Run . resource "google_container_cluster" "primary" { name = "my-gke-cluster" location = "us-central1" # We can't create a cluster with no node pool defined, but we want to only use # separately managed node pools. So we create the smallest possible default # node pool and immediately delete it. remove_default_node_pool = true initial_node_count = 1 } resource "google_container_node_pool" "primary_preemptible_nodes" { name = "my-node-pool" location = "us-central1" cluster = google_container_cluster.primary.name node_count = 1 node_config { preemptible = true machine_type = "e2-medium" # Google recommends custom service accounts that have cloud-platform scope and permissions granted via IAM Roles. service_account = google_service_account.default.email oauth_scopes = [ "https://www.googleapis.com/auth/cloud-platform" ] } } What should we change inorder for terraform to create a cluster that has Istio and KNative installed in the master node |
How to transform each element from Flow<List<User>> and return new Flow<List<UserWithNumber>> Posted: 31 Dec 2021 04:18 AM PST The difficulty is that I get the number wrapped in a flow. Implementation of UserWithNumber data class UserWithNumber(val user: User, val number: Int) Implementation of users functions: fun getUsers(): Flow<List<User>> { //return users } fun getNumberForUser(userId: Long): Flow<Int> { //return number } fun getUsersWithNumber(): Flow<List<UserWithNumber>> { return getUsers() //TODO transform every User to UserWithNumber } in RxJava i can easily achieve that with flatMapIterable and toList(). fun getUsersWithNumber(): Observable<List<UserWithNumber>> { return getUsers() // return Observable<List<User>> .flatMapIterable { it } // unfolds list in Observable<User> .flatMap { it.getNumberForUser(it.id) } // make transform function to every user .toList() // wrap to list } How to do that with kotlin coroutines? |
Mindmeld gazetteer build failes with 'list' object has no attribute 'get' Posted: 31 Dec 2021 04:18 AM PST Following docs from mindmeld.com(Step 7): from mindmeld.components.nlp import NaturalLanguageProcessor nlp = NaturalLanguageProcessor('.') nlp.build() Results in error: self.build_gazetteer(gaz_name, force_reload=force_reload) File "/home/sar/test/lib/python3.6/site-packages/mindmeld/resource_loader.py", line 214, in build_gazetteer mapping.get("entities", []), self.query_factory.normalize AttributeError: 'list' object has no attribute 'get' Obviously, list has no .get(), I assume nlp.build() should have made a dictionary, but fails to do so. Anyone else experienced this? Tested on Ubuntu 18.04, Python 3.6.9. EDIT: Found this old post of mine, worked it out. I don't remember details, but nlp doesn't support Python > 3.7, custom Python version in virtual environment fixed this. |
Find and kill a process in one line using bash and regex Posted: 31 Dec 2021 04:18 AM PST I often need to kill a process during programming. The way I do it now is: [~]$ ps aux | grep 'python csp_build.py' user 5124 1.0 0.3 214588 13852 pts/4 Sl+ 11:19 0:00 python csp_build.py user 5373 0.0 0.0 8096 960 pts/6 S+ 11:20 0:00 grep python csp_build.py [~]$ kill 5124 How can I extract the process id automatically and kill it in the same line? Like this: [~]$ ps aux | grep 'python csp_build.py' | kill <regex that returns the pid> |
No comments:
Post a Comment