Cant seem to get code running, how are we suppose to use if statements and elif statements in python Posted: 07 Nov 2021 07:53 AM PST |
Eurodns + Django + Dynamic Ip Posted: 07 Nov 2021 07:52 AM PST I bought an domain from Eurodns and wanted connect it with my first website on my computer at home. (I'm a noob - just starting to understand how programming works.) Long story short, when I write my URL it doesn't reach my website, nor if I type www.site.com nor if I type only site.com. (when I type with www. it shows me some kind of default page by eurodns I think. The none www. shows this site can't be reached) What I have tried. I installed a VM ubuntu server on a proxmox with django project and apache2. Then as a first test I used an free domain from noip with their dynamic-Ip tool. It worked just fine without doing any special setup (I might changed a port in apache settings but don't remember for sure). I portforwarded port 80 and 443 from router to my port from the webhost. Then I tried to make the website be rendered by accessing my custom domain bought from Eurodns, via a ddclient/Dynamic DNS offered by Eurodns. For some reason this doesn't work at all. I tried in the meantime to solve the SSL certificate - did this screw things up? Also activated the DNSsec and modified the Ip address of the A tag in the DNS Zone to match my routers Ip address. (The Ip should automatically update by their dynamicDNS right?) I installed their tool for dynamicDNS configured it with the credentials and the network interface which I wrote from terminal, but still isn't working. Can you guys help me solve the problem please? I've seen that I might need to use wsgi? (Never used it. All my tests were done with noip free domain and it worked good). Many thanks. |
Fetch Api .then functions runs even if response.ok is false Posted: 07 Nov 2021 07:52 AM PST I'm trying to fetch a resource from my local network using the fetch api After fetching i want to check the response type and act accordingly But when i receive a status of 500 and i try to return an error callback, the .then() function which was supposed to run only when the response.ok was false runs either way fetch(testUrl, { headers, method: "POST" }) .then(response => { if (response.status === 200) { return response.json() } if (response.status === 401) { Logout() } if (response.status === 500) { return setTestApiFetchError({ 'error_type': "SERVER_ERROR", "error": true }) } }) .then(data => console.log(Data)) the function.then(data => console.log(data)) runs irrespectively |
Generating all possible DAGs using R Posted: 07 Nov 2021 07:52 AM PST I'm using R to generate DAGs with 4 nodes. I need to generate all the possible DAGs without using any packages. Because there are 6 pairs and each pair has 3 options: no egde, or two directions, the total possibilities are 3**6 = 729. I think it's a sort of dfs problem but I can't implement in R. This is my code, but it is too long, and still use build in function expand.grid. Is there any simple way to solve the problem? Thanks! A <- matrix(c(0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0),nrow=4,byrow=T) bases=c('A','B','C') all = expand.grid(bases, bases, bases,bases,bases,bases) nrow(all) res = list() for (i in (1:nrow(all))){ if (all$Var1[i] == 'A'){ A[1,2] = 0 A[2,1] = 0 } if (all$Var1[i] == 'B'){ A[1,2] = 1 A[2,1] = 0 } if (all$Var1[i] == 'C'){ A[1,2] = 0 A[2,1] = 1 } if (all$Var2[i] == 'A'){ A[1,3] = 0 A[3,1] = 0 } if (all$Var2[i] == 'B'){ A[1,3] = 1 A[3,1] = 0 } if (all$Var2[i] == 'C'){ A[1,3] = 0 A[3,1] = 1 } if (all$Var3[i] == 'A'){ A[1,4] = 0 A[4,1] = 0 } if (all$Var3[i] == 'B'){ A[1,4] = 1 A[4,1] = 0 } if (all$Var3[i] == 'C'){ A[1,4] = 0 A[4,1] = 1 } if (all$Var4[i] == 'A'){ A[2,3] = 0 A[3,2] = 0 } if (all$Var4[i] == 'B'){ A[2,3] = 1 A[3,2] = 0 } if (all$Var4[i] == 'C'){ A[2,3] = 0 A[3,2] = 1 } if (all$Var5[i] == 'A'){ A[2,4] = 0 A[4,2] = 0 } if (all$Var5[i] == 'B'){ A[2,4] = 1 A[4,2] = 0 } if (all$Var5[i] == 'C'){ A[2,4] = 0 A[4,2] = 1 } if (all$Var6[i] == 'A'){ A[3,4] = 0 A[4,3] = 0 } if (all$Var6[i] == 'B'){ A[3,4] = 1 A[4,3] = 0 } if (all$Var6[i] == 'C'){ A[3,4] = 0 A[4,3] = 1 } res[[i]] = A } |
Backward Slice Weiser Posted: 07 Nov 2021 07:52 AM PST I have to do a Weiser` Backward Slice for UNI, but I didn't really understand how it works and what I have to do. I also didn't find anything useful on the internet, so I hope that on here someone could help me. Thank you in advance. |
Html not showing list from Component in Angular Posted: 07 Nov 2021 07:52 AM PST As the Title shows, that is basically my problem. I get my list of objects in my component from the Api. The list is loaded with the correct data as I show it on the console to check it. When the table is created with the *ngFor, recognizes the amount of objects inside but not the attributes. I have an interface to map the objects received from the api. I tried building an array already loaded on the component and the table gets loaded correctly, so the problem is with the list that i load from the Api response. This is what i have on my service: (This works fine) @Injectable({ providedIn: 'root' }) export class UserService { private baseUrl: string = environment.baseUrl + 'api/'; constructor(private http: HttpClient) { } public getUsers(): Observable<ShowUserModel[]> { return this.http.get<ShowUserModel[]>(this.baseUrl + `users`); } } This is my component: @Component({ selector: 'app-user-list', styleUrls: ['./user-list.component.css'], providers: [UserService], templateUrl: './user-list.component.html', }) export class UserListComponent implements OnInit { public users: ShowUserModel[] = []; constructor(private router: Router, private service: UserService) { } ngOnInit(){ this.getUsers(); } public getUsers(){ this.service.getUsers().subscribe(data =>{ this.users = data; console.log(data) } ); } And this is the html template: <div class="jumbtron"> <h1 class="display-4 text-center">Users</h1> </div> <div class="container"> <button type="button" class="btn btn-success" (click)="addUser()">New User</button> <hr /> <table class="table table-dark table-condensed table-bordered table-striped table-hover"> <thead> <tr> <th scope="col">Username</th> <th scope="col">Id</th> <th scope="col">Role</th> </tr> </thead> <tbody> <tr *ngFor="let user of users"> <th scope = "row">{{user.Username}} <td>{{user.Id}}</td> <td>{{user.Role}}</td> </tr> </tbody> </table> </div> Thanks! This is the table This is the console log from the array |
How do I turn a comma separated string column to individual factors with Pandas? Posted: 07 Nov 2021 07:52 AM PST I have a dataset which looks like this: movie url genres 0 Paranormal Activity: Next of Kin /movie-reviews/paranormal-activity-next-of-kin Horror,Mystery,Thriller 1 Antlers /movie-reviews/antlers Drama,Horror,Mystery 2 Heart of Champions /movie-reviews/heart-of-champions Drama 3 13 Minutes /movie-reviews/13-minutes Action,Drama,Thriller 4 Tango Shalom /movie-reviews/tango-shalom Comedy,Drama,Family Each movie has multiple genres, and I would like to see all the unique genres. I tried doing this: >>> df['genres'].unique() array(['Horror,Mystery,Thriller', 'Drama,Horror,Mystery', 'Drama', 'Action,Drama,Thriller', 'Comedy,Drama,Family'], dtype=object) It returns an array of comma-separated items, and not the individual items themselves. How can I do this? I have thought of converting the dataset from wide to long, with each genre in its own row but that would expand the dataset to rows that would be too many to handle. |
Is it possible to configure USD payment to brazil bank account in Woocommerce? Posted: 07 Nov 2021 07:52 AM PST This is for an online tutorial site with Woocommerce. Client is US based. He needs payment to be made in USD and to connect with his Brazil account. Is it doable? |
There is a way to modify the api id and/or api hash without being logged in to Telegram Posted: 07 Nov 2021 07:51 AM PST I need to alternate an api id and/or api hash to stop an application, but I am not logged on the telegram account that is the hash and id owner. any idea? |
How to list out file names from dropbox in PHP Posted: 07 Nov 2021 07:51 AM PST I have checked the docs of Dropbox API which had the following code: curl -X POST https://api.dropboxapi.com/2/files/list_folder \ --header "Authorization: Bearer " \ --header "Content-Type: application/json" \ --data "{\"path\": \"/Homework/math\",\"recursive\": false,\"include_media_info\": false,\"include_deleted\": false,\"include_has_explicit_shared_members\": false,\"include_mounted_folders\": true,\"include_non_downloadable_files\": true}" But how am I to use this code in PHP. I know how to use the header thing. Its like this $headers = array( 'Authorization: Bearer 0tXsy9OsJNEAAAAAAAAAAThz0u5GSonbXXN2EwAe6Folfoeus643iyWWGQ6UcrF7', 'Content-Type: application/json') But how to use the data part. When i input it like "Data" : ..... , then it gives me this error " Error in call to API function "files/list_folder": request body: could not decode input as JSON". What should I do? |
convert a txt data file to structured JSON using PHP Posted: 07 Nov 2021 07:51 AM PST I have one large plain text file which its data is like this: 65781>foo-98503>bar-12783>baz-71284>foobar I want to convert it to JSON format so the content should be a valid JSON: { "65781":"foo", "98503":"bar", "12783":"baz", "71284":"foobar" } Because I could not find any tools on the internet that would do this for me properly, I didn't know what to do. I decided to write a PHP function to convert my file. Here is my code: <?php function txt_to_json_converter($sep1, $sep2, $input_file, $output_file) { $data = file_get_contents($input_file) or die("Unable to open file..."); $exploded = explode($sep1, $data); $array = array(); foreach ($exploded as $item) { $pair = explode($sep2, $item); $array[$pair[0]] = $pair[1]; } $j = json_encode($array); // save to disk $myfile = fopen($output_file, "w") or die("Unable to open file..."); fwrite($myfile, $j); fclose($myfile); echo 'Done!'; } txt_to_json_converter("-", ">", "my_exported_data.txt", "structured_data.json") ?> Then, I receive this error: Fatal Error: Out of memory (allocated number) (tried to allocate another number bytes) in script.php I tried to add this line in the top of my code, but it's not solving my problem: ini_set('memory_limit', '2048M'); I have also changed this line in my php.ini file: ; Maximum amount of memory a script may consume ; http://php.net/memory-limit memory_limit=2048M Any helps here? |
How do I know where the mines are? [closed] Posted: 07 Nov 2021 07:53 AM PST Haha hello again. I'm not sure how I would know, because in the top right corner, where there is a 2, 3, 2, going down, the bottom two needs to touch two mines and so does the top. But if I did the immediate right boxes and middle one, the three would be touching four. All help is appreciated.[! Edit: and how could I apply what I learn to future situations? |
Rotate text in markdown Posted: 07 Nov 2021 07:51 AM PST I want to rotate the letter C in markdown by 180° in accordance to Peano's notation of the material implication. I would also like to rotate some text by 90° in a table. Would someone know how to do it? Thank you very much in advance for your help! |
React - Adding a line break; Posted: 07 Nov 2021 07:51 AM PST So I have a function for adding a line break every 60 characters. Now what I don't understand is why the \n doesnt work. function countStr (str1){ let str2=""; let charCount=0; for(let i=0; i<str.length; i++){ if(i%60===0){ str2=str2.concat(str1.substring(charCount,i)); str2+="\n"; charCount=i; } } return str2; } |
optimize for loop in python Posted: 07 Nov 2021 07:51 AM PST I have 2 pandas dataframes (dfA, dfB) with 2 columns each (gender, first name). dfA are data to be cleaned (bad first name / gender) by looking for the right value in dfB. Below is my code which works but is extremely slow for millions of pieces of data. Is there a way to do it faster? (without using a database or other) thank you for rowIndex in range(len(dfA)): firstname = dfA.loc[rowIndex,'firstname'] try: dfA.loc[rowIndex,'genderNew'] = dfB.loc[dfB['firstname'] == firstname].gender.values[0] except Exception as e: dfA.loc[rowIndex,'genderNew'] = "unknown" |
Cannot use import outside of a module Posted: 07 Nov 2021 07:52 AM PST I'm currently rewriting my discord bot from JavaScript to TypeScript. While doing so I encountered a SyntaxError:Cannot use import statement outside a module . From other questions it seemed that adding "type" : "module", in package.json should fix it. However this results in another TypeError:Unknown file extension ".ts" . What is proper way of fixing this so I can use import statements in index.ts and other files? index.ts: import {Client, Intents} from "discord.js"; import dotenv from "dotenv"; dotenv.config(); const token = process.env.TOKEN; const client = new Client({ intents: [Intents.FLAGS.GUILDS] }); client.once('ready', () => { console.log('Ready!'); }); client.login(token); package.json: { "name": "wdr", "version": "1.0.0", "description": "A discord bot", "main": "index.ts", "type" : "module", "scripts": { "test": "echo \"Error: no test specified\" && exit 1" }, "author": "wdr", "license": "ISC", "dependencies": { "@discordjs/rest": "^0.1.0-canary.0", "discord-api-types": "^0.24.0", "discord.js": "^13.3.1", "dotenv": "^10.0.0" } } tsconfig.json: { "compilerOptions": { "lib": ["ESNext"], "target": "ESNext", "module": "commonjs", "moduleResolution": "Node", "strict": true, "allowSyntheticDefaultImports": true, "esModuleInterop": true, "forceConsistentCasingInFileNames": true }, "include": [ "*.ts" ], "exclude": ["node_modules"] } |
Why upon reloading the page I am unable to go to the initial URL? Posted: 07 Nov 2021 07:51 AM PST I am using react-router-dom for routing. When I start the application using npm start then my application opens with URL ashttp://localhost:3000/ then by clicking a link I route to http://localhost:3000/buyer ( Till here everything works according to my intention ). Now when I try to reload the page the URL does not set to http://localhost:3000/ rather it remains as http://localhost:3000/buyer . I am unable to understand why upon reloading the page my URL is not set to the initial URL i.e http://localhost:3000/ Please someone guide me on how I could fix it. |
How to hint homogenous list of instances of same subclass? Posted: 07 Nov 2021 07:52 AM PST class A: pass class A1(A): pass class A2(A): pass def help_here(s: WHAT_SHOULD_I_TYPE_HERE ): # How to hint this function that accepts list, # where all elements should be instances of same subclass of A. # Example 1: [A1(), A1(), A1()] - good # all components all elements are same class, # and it is subclass of A # Example 2: [A2(), A2(), A2(), A2()] - valid. Same reason. # Example 3: [A1(), A1(), A2()] - invalid, not same classes. # Example 4: [1, 2] - invalid. Same class, but not subclass of A. if isinstance(s[0], A1): # If I use Union[List[A1], List[A2]] as type hint, # next line will have no warnings. # But if where will be List[A] then warning arrives: # Expected type 'List[A1]', got 'List[A]' instead. # It's Pycharm IDE. process_a1_list(s) def process_a1_list(lst: List[A1]): pass The only idea I have is: Union[List[A1], List[A2]] . But what if I don't know all subclasses of A ? Are there any beautiful way to hint it? Update: Not beautiful, but let IDE (Pycharm) check types the way I want. |
How do I Use "Symbol = Numeric" and "Character = Numeric" in Ggplot2 Label Posted: 07 Nov 2021 07:52 AM PST I want the column header and row header of this plot to be phi = 0.8, phi = 0.9, phi = 0.95 and sd = 1, sd = 3, sd = 5, sd = 10 respectively. The phi should appear as the Greek letter symbol while the sd remains the English letter. ## simulate ARIMA(1, 0, 0) set.seed(289805) x1 <- arima.sim(n = 10, model = list(ar = 0.8, order = c(1, 0, 0)), sd = 1) set.seed(671086) x2 <- arima.sim(n = 10, model = list(ar = 0.9, order = c(1, 0, 0)), sd = 1) set.seed(799837) x3 <- arima.sim(n = 10, model = list(ar = 0.95, order = c(1, 0, 0)), sd = 1) set.seed(289805) x4 <- arima.sim(n = 10, model = list(ar = 0.8, order = c(1, 0, 0)), sd = 3) set.seed(671086) x5 <- arima.sim(n = 10, model = list(ar = 0.9, order = c(1, 0, 0)), sd = 3) set.seed(799837) x6 <- arima.sim(n = 10, model = list(ar = 0.95, order = c(1, 0, 0)), sd = 3) set.seed(289805) x7 <- arima.sim(n = 10, model = list(ar = 0.8, order = c(1, 0, 0)), sd = 5) set.seed(671086) x8 <- arima.sim(n = 10, model = list(ar = 0.9, order = c(1, 0, 0)), sd = 5) set.seed(799837) x9 <- arima.sim(n = 10, model = list(ar = 0.95, order = c(1, 0, 0)), sd = 5) set.seed(289805) x10 <- arima.sim(n = 10, model = list(ar = 0.8, order = c(1, 0, 0)), sd = 10) set.seed(671086) x11 <- arima.sim(n = 10, model = list(ar = 0.9, order = c(1, 0, 0)), sd = 10) set.seed(799837) x12 <- arima.sim(n = 10, model = list(ar = 0.95, order = c(1, 0, 0)), sd = 10) xx <- 1:10 df <- data.frame(xx, x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12) reshapp <- reshape2::melt(df, id = "xx") NEWDAT <- data.frame(y = reshapp$value, x = reshapp$xx, sd = rep(rep(c(sd=1, sd=3, sd=5, sd=10), each = 10), each = 3),phi = rep(rep(c(.8, .9, .95), each = 10), 4)) ggplot(NEWDAT, aes(x = x, y = y)) + geom_line() + geom_point() + labs(x = 'lb', y = 'RMSE') + facet_grid(sd ~ phi, scales = "free_y") + theme_bw() + ggplot2::scale_y_continuous(expand = c(0.0, 0.00)) |
Trying a looping to continue the "your own story" code [closed] Posted: 07 Nov 2021 07:52 AM PST I'm trying to create a loop, or any way to back to the first value (here called 'attack' from (if attack_yaztromo == 'no':) If I tried there to do a print(attack) to back to the original 'attack' value it doesn't work, it print the word, no the value. Any help to back to 'attack = input('Yaztromo House, you enter in the house. \n Type Attack or Ask')' again? This is the easy way I think of to continue the story because then I have more conditions and the story continue.. print(f'Welcome {name} Introduction. ') south = input('Do you choose south or any other direction?\n Type "south", "north, "east" or "west"') if south == 'south': attack = input('Yaztromo House, you enter in the house. \n Type Attack or Ask') if attack == 'attack': attack_yaztromo = input('You sure want to attack Yaztromo? \n Type yes or no') if attack_yaztromo == 'yes': print('You frog now, you lose') if attack_yaztromo == 'no': #back to attack value if attack == 'ask': yaztromo_help = input('Yaztromo tell you about hammer. You go West or East?\n Type West or East') if yaztromo_help == 'west': gnome = input('You found a gnome. \n Type Attack or Talk') if gnome == 'attack': attack_gnome = input('The Gnome is a Shapeshifting. He turns in to a human shape, he is an Herald of the forest.\n Type Attack or Mercy') if attack_gnome == 'attack': print('You are not worth the hammer. The Herald turns you into stone.') |
Animating multiple headers that have same class Posted: 07 Nov 2021 07:51 AM PST Problem I want to apply the same animation to multiple headers. I have five headers with class fancy1, currently the animation is only being applied to the first header. This jsFiddle contains the code I use to get one header animated, although the animation isn't seeming to work in jsFiddle. You can see in the screenshot below, the animation is mid way through running for the Las Vegas header. Old solution that animates one header const text1 = document.querySelector('.fancy1'); const strText1 = text1.textContent; const splitText1 = strText1.split(""); text1.textContent = ""; for(let i=0; i<splitText1.length; i++){ text1.innerHTML += "<span>"+ splitText1[i] + "</span>"; } let char1 = 0; let timer1 = setInterval(onTick,150); function onTick(){ const span1 = text1.querySelectorAll('span')[char1]; span1.classList.add('fade'); char1++; if (char1 === splitText1.length){ complete1(); return; } } function complete1(){ clearInterval(timer1); timer1 = null; } Failed solution 1 I tried giving the five headers seperate class names - fancy1, fancy2, fancy3, fancy 4 and fancy5. const text = document.getElementsByClassName(".fancy1"); Split(text) const text = document.getElementsByClassName(".fancy2"); Split(text) function Split(text){ const strText = text.textContent; const splitText = strText.split(""); text.textContent = ""; for(let i=0; i<splitText.length; i++){ text.innerHTML += "<span>"+ splitText[i] + "</span>"; } let char = 0; let timer = setInterval(onTick,150); } function onTick(){ const span = text.querySelectorAll('span')[char]; span.classList.add('fade'); char++; if (char === splitText.length){ complete(); return; } } function complete(){ clearInterval(timer); timer = null; } Failed Solution 2 I tried using global variables const window.text = document.getElementsByClassName(".fancy1"); Split() const window.text = document.getElementsByClassName(".fancy2"); Split() const window.text = document.getElementsByClassName(".fancy3"); Split() const window.text = document.getElementsByClassName(".fancy4"); Split() function Split(){ const strText = (window.text).textContent; const splitText = strText.split(""); text.textContent = ""; for(let i=0; i<splitText.length; i++){ text.innerHTML += "<span>"+ splitText[i] + "</span>"; } let char = 0; let timer = setInterval(onTick,150); } function onTick(){ const span = text.querySelectorAll('span')[char]; span.classList.add('fade'); char++; if (char === splitText.length){ complete(); return; } } function complete(){ clearInterval(timer); timer = null; } Failed solution 3 (based on Nalin Ranjan's reponse) After making a number of tweaks to Nalin Ranjan's soltuion, I was no longer getting erorr messages in the console log. But none of the animations were happening. const headers = document.querySelectorAll('.fancy1'); headers.forEach(text => Split(text)); function Split(text){ const strText = text.textContent; const splitText = strText.split(""); text.textContent = ""; for(let i=0; i<splitText.length; i++){ text.innerHTML += "<span>"+ splitText[i] + "</span>"; } window.char = 0; window.timer = setInterval(onTick,1500); window.text = text window.splitText = splitText } function onTick(){ const span = window.text.querySelectorAll('span')[window.char]; span.classList.add('fade'); window.char++; console.log(window.char) console.log(window.splitText.length) if (window.char === window.splitText.length){ console.log("is it working?") complete(); return; } } function complete(){ clearInterval(timer); window.timer = null; } |
Master/details query with details in a list object Posted: 07 Nov 2021 07:52 AM PST In my Sql database I have tables Order and Detail following this model, where Detail.order is a foreign key to Order.id : public class Order { public int id { get; set;} } public class Detail { public int id { get; set;} public int order { get; set; } public int quantity { get; set; } } I am able to form a join query to return order-details in a flat list, for example: from order in db.Orders join detail in db.Details on order.id equals detail.order select new { order = order.id, detail = detail } The result is flat in that if there are 10 Detail items, the result will have 10 rows. How do I construct a Linq query to return the result similar to the class OrderDetails ? public class OrderDetails { public int orderId { get; set;} public List<Detail> details { get; set;} } where all the Detail items of an Order are in one list as a property of an OrderDetails item. |
Firebase authentication disappears on page refresh Posted: 07 Nov 2021 07:51 AM PST I have a simple react app using firebase authentication. After successful Login the firebase:authUser is stored in localStorage. But on every page refresh localStorage is being cleared and the session is lost. Browsing through other pages doesn't clear localStorage though. Here is what it looks like in code: - Index.js
import React from 'react'; import ReactDOM from 'react-dom'; import './index.css'; import App from './App'; import reportWebVitals from './reportWebVitals'; ReactDOM.render( <React.StrictMode> <App /> </React.StrictMode>, document.getElementById('root') ); reportWebVitals(); - App.js
import { BrowserRouter as Router, Route, Routes } from "react-router-dom"; import Login from './Login'; import Main from './Main'; import Info from './Info'; import './App.css'; function App() { return ( <div className="App"> <Router> <Routes> <Route path="/login" element={<Login/>} /> <Route path="/" element={<Main/>} /> <Route path="/info" element={<Info/>} /> </Routes> </Router> </div> ); } export default App; - Info.js → random page that I can view without authentication needed. Refreshing while on this page (http://localhost:3000/info) also clears localStorage
import { useNavigate } from "react-router-dom"; function Info() { const navigate = useNavigate(); return ( <div> <div> Info page </div> <button onClick={() => { navigate('/'); } }> Go to Main </button> </div> ); } export default Info; Here is firebase.js I use to authenticate user import { initializeApp } from 'firebase/app'; import { getAuth, createUserWithEmailAndPassword, signInWithEmailAndPassword, signOut, setPersistence, browserLocalPersistence } from 'firebase/auth'; const firebaseConfig = { // Here is my config }; initializeApp(firebaseConfig); // Auth const auth = getAuth(); var email; var password; // Auth - set persistance setPersistence(auth, browserLocalPersistence); // Auth - create createUserWithEmailAndPassword(auth, email, password) .then((userCredential) => { // Signed in const user = userCredential.user; }) .catch((error) => { const errorCode = error.code; const errorMessage = error.message; }); // Auth - Login signInWithEmailAndPassword(auth, email, password) .then((userCredential) => { // Signed in const user = userCredential.user; }) .catch((error) => { const errorCode = error.code; const errorMessage = error.message; }); // Auth - signOut signOut(auth).then(() => { // Sign-out successful. }).catch((error) => { // An error happened. }); export { auth, db, createUserWithEmailAndPassword, signInWithEmailAndPassword, signOut }; |
Array declaration syntax Posted: 07 Nov 2021 07:51 AM PST I have some questions regarding array declarations in C99 standard. int n; scanf("%d", &n); int v[n]; Does this create an array that has different size? I know that it can be a constant or a constant variable. But I think it has to have a known value at compile time, and the size should not change. But I saw the above mentioned syntax multiple times, and I do not know that is a defenitive bug. The second question is in relation to arrays passed to functions. void printing(int v[]) and void printing(int *v) Is there a difference between the two declarations? |
I can't install or purge anything in apt Posted: 07 Nov 2021 07:52 AM PST I'm not sure what I did, but this is the error I got while trying to install a package, or remove a package using apt. beni@Sector-Z:~$ sudo apt install rename Reading package lists... Done Building dependency tree Reading state information... Done The following NEW packages will be installed rename 0 to upgrade, 1 to newly install, 0 to remove and 1 not to upgrade. 1 not fully installed or removed. Need to get 16.1 kB/139 kB of archives. After this operation, 48.1 kB of additional disk space will be used. Get:1 http://bn.archive.ubuntu.com/ubuntu focal/universe amd64 rename all 1.10-1 [16.1 kB] Fetched 16.1 kB in 1s (12.4 kB/s) Selecting previously unselected package rename. (Reading database ... 257365 files and directories currently installed.) Preparing to unpack .../archives/rename_1.10-1_all.deb ... Unpacking rename (1.10-1) ... Setting up rename (1.10-1) ... update-alternatives: using /usr/bin/file-rename to provide /usr/bin/rename (rena me) in auto mode dpkg: error processing package node-lodash-packages (--configure): package is in a very bad inconsistent state; you should reinstall it before attempting configuration Processing triggers for man-db (2.9.1-1) ... Errors were encountered while processing: node-lodash-packages E: Sub-process /usr/bin/dpkg returned an error code (1) Please help me resolve this. This issue started while I was working with Node-JS, now I don't really need it so, it's fine if I need to remove it. |
Is there any performance downside when passing a struct to a kernel? Posted: 07 Nov 2021 07:52 AM PST I have a kernel that takes several arrays as input. To improve readability it would be nice to group them into a struct and (after proper memory allocation and copy for each input) pass the struct to the kernel instead of the long list of pointers. Is it going to be the same in the 2 cases, memory-wise, when accessing the arrays inside the kernel? Can anyone recommend me some documentation on this topic (Couldn't find it on the programming guide) |
Cannot make a request to the GraphQL with the wrapper in QueryVariables Posted: 07 Nov 2021 07:51 AM PST I am trying to make a request to GraphQl. I can do it in the playground. Request in the playground When I try to make a request using flutter, I cannot make a wrapper LogIn in Query variables. This is my code from Flutter: InviteCodeRepository.dart import 'package:fauna/data/api/graphql_api_client.dart'; import 'package:get/get.dart'; import 'package:graphql_flutter/graphql_flutter.dart'; abstract class InviteCodeRepository { Future<void> inviteCode(String inviteCode, String phone); } class InviteRepositoryImplementation extends GetxController implements InviteCodeRepository { String login = r''' mutation login($Login: Login){ login(login: $Login) { token } } final _gqlClient = Get.put(GraphQLApiClient(), permanent: true); @override Future<void> inviteCode(String inviteCode, String phone) async { final variables = {'phone': phone, 'accessCode': inviteCode}; final QueryResult result = await _gqlClient.mutation( login, variables: variables, ); print(result.data); } } |
How can I create a csv file on blob storage azure with Object c# .NET Core Posted: 07 Nov 2021 07:52 AM PST I am trying to create a CSV file from an object and upload it on blob storage. I also want the column to have the same name as the property in the object. (.NET Core 5.0/C#) |
Is there a Google authenticator API Posted: 07 Nov 2021 07:52 AM PST I am trying to create a web app that is using a two-factor authenticator using the google authenticator, so my question is, is there an api for google authenticator? |
How to obtain first Friday from a given QDate? Posted: 07 Nov 2021 07:51 AM PST Consider a Qdate from QDate Mydate = ui->dateEdit->date(); For example, suppose we choose 2018/07/14 (today). How to obtain the day of the first Friday (in this case, 6) on the chosen month (in this case, July)? I suspect we have to use Mydate.dayOfWeek() computations. |
No comments:
Post a Comment