Uncaught Error: Maximum update depth exceeded error with useState() Posted: 11 Jul 2022 04:05 AM PDT Why am I getting this error? Uncaught Error: Maximum update depth exceeded. This can happen when a component repeatedly calls setState inside componentWillUpdate or componentDidUpdate. React limits the number of nested updates to prevent infinite loops. This is my code: const [roles, setRoles] = useState([]); useLayoutEffect(() => { setRoles(["5nxg5wvb"]); }); Note that the same error appears when I use useEffect, and that error only goes away when I change the code to this: useLayoutEffect(() => { setRoles("5nxg5wvb"); }); Any help would be appreciated... |
Whatsapp Cloud API - An unknown error occurred Posted: 11 Jul 2022 04:05 AM PDT I recently started using the new Whatsapp Cloud API. Unfortunately already the sample request in the first steps guide gives an error message. The request to the messages endpoint gives the following response: { "error": { "message": "An unknown error occurred", "type": "OAuthException", "code": 1, "error_subcode": 2593006, "is_transient": false, "error_user_title": "Account Not Exist", "error_user_msg": "Account does not exist in Facebook Hosted API, please use /register API to create an account first.", "fbtrace_id": "AX1Thf9OPBhmj7NlDV6-5IA " } } I am still using the Test WhatsApp Business Account with a Test Number. When calling the register endpoint I get You can't complete the setup process because your business doesn't meet WhatsApp's policy requirements. If you think this is incorrect, reach out to Meta Business Suite support for help . Does anyone have an idea, what the problem is? Thank you in advance, Sören |
Should I expect a client to authenticate before trying to make a request? Posted: 11 Jul 2022 04:05 AM PDT I've just integrated application insights into an application, and what is clear is that we are getting a lot of 401 error messages against an api layer. Looking at the way the sample code is written, its clear that it tries to call the service without even attempting to authenticate first, then uses the 401 to redirect to the login page, where it authenticates before reattempting the original request. Whilst is works, My question is, "Is this reasonable, and should I expect callers to authenticate before calling an endpoint"? from my perspective, it makes debugging distributed calls very difficult. The service architecture is overly chatty, and this makes it even more difficult to actually follow the callstack |
Display Form data on popup\modal when submitted in Angular Posted: 11 Jul 2022 04:04 AM PDT I have a form with submit button. On clicking the submit button, popup\modal should appear displaying the data of the form submitted. I am using Bootstrap and Angular. Please help in this. |
How to convert string to json and vice versa in flutter? Posted: 11 Jul 2022 04:04 AM PDT Hi below is the json that I need to extract data from. [ "http://activepeersai.computing.dcu.ie/feedback_participant/114", "http://activepeersai.computing.dcu.ie/peerLearningPrompter/4", "{\"0\":{\"feedback_id\":114,\"timer_used\":1,\"timer\":10.0,\"question1\":\"How to break ice with strangers (in social gathering & in formal events) ?\",\"question2\":\"How to build networking (with those from different age, culture, education background, language\\u2026)(in university & in workplace) ?\",\"question3\":\"\",\"question4\":\"\",\"question5\":\"\",\"question6\":\"\",\"question7\":\"\",\"question8\":\"\",\"question9\":\"\",\"question10\":\"\"},\"1\":{\"feedback_id\":115,\"timer_used\":1,\"timer\":10.0,\"question1\":\"How to deal with difficult teammates (dominating \\/ debater character \\/ negative \\/ lack of confidence \\/ free rider\\u2026) ?\",\"question2\":\"How to build mutual trust with teammates ?\",\"question3\":\"\",\"question4\":\"\",\"question5\":\"\",\"question6\":\"\",\"question7\":\"\",\"question8\":\"\",\"question9\":\"\",\"question10\":\"\"}}", "{\"id\":{\"0\":1,\"1\":2,\"2\":3,\"3\":4,\"4\":5,\"5\":6,\"6\":7,\"7\":8,\"8\":9,\"9\":10,\"10\":11,\"11\":12,\"12\":13,\"13\":14,\"14\":15,\"15\":16,\"16\":17,\"17\":18,\"18\":19,\"19\":20,\"20\":21,\"21\":22,\"22\":23,\"23\":24,\"24\":25,\"25\":26,\"26\":27,\"27\":28,\"28\":29,\"29\":30,\"30\":31,\"31\":32,\"32\":33,\"33\":34,\"34\":35,\"35\":40,\"36\":41,\"37\":42,\"38\":43,\"39\":44,\"40\":45,\"41\":46,\"42\":47,\"43\":48,\"44\":49,\"45\":50,\"46\":51,\"47\":52,\"48\":53,\"49\":54,\"50\":55,\"51\":56,\"52\":57,\"53\":58,\"54\":59,\"55\":60,\"56\":61,\"57\":62,\"58\":63,\"59\":36,\"60\":37,\"61\":38,\"62\":39},\"name\":{\"0\":\"Why did the sharer choose this skill as the most confident skill and why did the learner wants to improve this skill?\",\"1\":\"Can you share another situation whereby using this skill made a very big difference to the outcome? What did you do? What was the result? What might have happened if this skill wasn't brought to the situation?\",\"2\":\"What advice do you have to give to others about becoming better at using this skill in their work and in their lives generally?\",\"3\":\"What can hold people back from being better at this skill? How can you encourage them to overcome these challenges?\",\"4\":\"What would be the outcome if this session\\/series was a huge success? How would we know if this happened?\",\"5\":\"What is working for you now? What is stopping you from moving forward?\",\"6\":\"What do your role models do that you would love to learn\\/incorporate as habits\\/adopt as a mindset?\",\"7\":\"\\\"What got you here won't get you there.\\\" What is your reaction to that statement? What actions have got you to this point that may not serve you if you move forward? What new behaviours do you need to adopt?\",\"8\":\"What would be the outcome if this session\\/series was a huge success? How would we know if this happened?\",\"9\":\"If you had all the time, people, money, resources that you might possibly need, what would you do differently? Does that energise you, frighten you or a bit of both?\",\"10\":\"What do you think you need to do get a better result (or closer to your goal)?\",\"11\":\"What is the worst that could happen and how could you handle it? What is the best that could happen and how could you handle it?\",\"12\":\"What have been the most impactful decisions that you've made in your career? What led to making those decisions? Were you aware of the impact those decisions would have? What would you say to others in a similar position?\",\"13\":\"What habits have stood you in good stead? Are there things that you do regularly, daily or very often that have made a big different over time?\",\"14\":\"Can you share an experience that was transformational for you, taught you a long-lasting lesson or was particularly memorable for its benefits and challenges?\",\"15\":\"How do you think experience affects somebody's perspective, way of making decisions or their feelings about taking risks?\",\"16\":\"Can you describe your target market for your business or who might your ideal employer be?\",\"17\":\"Can you share details of a project that you worked on recently? Why were you or your business chosen to work with this client\\/employer? What were the success and challenges along the way?\",\"18\":\"What makes you\\/your product\\/your service different to others? Why would a client or employer choose what you do over others?\",\"19\":\"What might I be able to do to help you?\",\"20\":\"What is the key problem that you are facing currently?\",\"21\":\"If that problem was solved, what impact would it have?\",\"22\":\"In order to get to that outcome, what do we need to do, what resources need to be invested and any other changes to be made?\",\"23\":\"Is there a willingness to take that action to get towards that outcome?\",\"24\":\"What assumptions are being made? How likely are each one to happen? What would be the impact of those assumptions happening or not happening?\",\"25\":\"What application of the SCAMPER technique could be useful to help get another perspective?\\n*SCAMPER is an acronym formed from the abbreviation of: Substitute, Combine, Adapt, Modify (Also magnify and minify), Put to another use, Eliminate and Reverse.\",\"26\":\"If we had double the budget, half the time and were living in another country trying to make this happen, how might we think differently?\",\"27\":\"If any idea generated already in this discussion was to become a reality, what would be the impact on e year later in terms of benefits, ongoing coasts, sustained behavioural change and a launchpad for further growth?\",\"28\":\"Leadership\",\"29\":\"Communication\",\"30\":\"Adaptability\",\"31\":\"Team Work\",\"32\":\"Problem Solving\",\"33\":\"Conflict Management\",\"34\":\"Productivity\",\"35\":\"How would you describe good\\/effective communication? Please share an example of a time that you've seen it in action and an example of when you saw that good communication skills were clearly lacking.\",\"36\":\"How have you handled working under someone you felt was not good at communicating?\",\"37\":\"If you're trying to get your point across or convince somebody that your idea is the right one, what do you do?\",\"38\":\"Who do you think is a good communicator and why? What can we learn from them?\",\"39\":\"Talk about a time that you needed to adapt to a new situation. What did you find difficult and how did you work through that? How can somebody prepare to be more adaptable in future situations?\",\"40\":\"When you're in a situation where it feels like you have no control over it (i.e. a new manager, starting in a new job, government-led changes etc), what do you do to focus on what you can do?\",\"41\":\"How do you handle having multiple priorities at the same time?\",\"42\":\"How do you adjust to different work settings? For example, working with different teams, switching between logic and creativity, learning new processes, tools or technologies?\",\"43\":\"How do you feel about working in a team? What do you think are the key things that need to happen to make good teamwork?\",\"44\":\"What has been your experience of working in teams where there were problems? Did these arise due to strong personalities, somebody not sharing the workload, miscommunication, the wrong support or technology systems etc?\",\"45\":\"How do you keep a team motivated? Share your story about a rewarding team experience.\",\"46\":\"When you're in a team situation, what role do you usually play?\",\"47\":\"Describe a situation where you had to solve a problem. What did you do? what was the result? What might you have done differently?\",\"48\":\"What steps do you take before making a decision on how to solve a problem, and why?\",\"49\":\"Give an example of a situation in which you saw an opportunity in a potential problem. What did you do? What was the outcome?\",\"50\":\"Can you tell me about a situation where you overcame a problem using a creative solution?\",\"51\":\"Have you ever had a team member who kept raising objections on projects? How did you (or would you) manage them?\",\"52\":\"You have noticed that a team member is aggressive or arrogant toward the rest of the team. How would you approach this person?\",\"53\":\"What would you do if your manager gave you negative feedback on the way you approached a problem? How do give negative\\/constructive feedback to others?\",\"54\":\"How could you use a situation with conflict to have a better relationship with all involved?\",\"55\":\"How would you describe a typical working day in your current role? How you manage importance versus urgency? How do you maintain a work-life balance also?\",\"56\":\"If you have your day planned out to achieve a goal, how do you manage distractions or other things that can happen along the way?\",\"57\":\"What do you think very productive people do differently than others?\",\"58\":\"What holds people back from being more productive? How can people turn those around so that by doing the opposite, they can become more productive?\",\"59\":\"Have you ever had a team member who kept raising objections on projects? How did you (or would you) manage them?\",\"60\":\"How do you describe your leadership style?\",\"61\":\"What was a difficult decision you had to make as a leader, and how did you come to that decision?\",\"62\":\"What are the most important attributes of successful leaders today? Who do you think is a good leader and why?\"},\"session_type_id\":{\"0\":1.0,\"1\":1.0,\"2\":1.0,\"3\":1.0,\"4\":2.0,\"5\":2.0,\"6\":2.0,\"7\":2.0,\"8\":3.0,\"9\":3.0,\"10\":3.0,\"11\":3.0,\"12\":4.0,\"13\":4.0,\"14\":4.0,\"15\":4.0,\"16\":5.0,\"17\":5.0,\"18\":5.0,\"19\":5.0,\"20\":6.0,\"21\":6.0,\"22\":6.0,\"23\":6.0,\"24\":7.0,\"25\":7.0,\"26\":7.0,\"27\":7.0,\"28\":8.0,\"29\":8.0,\"30\":8.0,\"31\":8.0,\"32\":8.0,\"33\":8.0,\"34\":8.0,\"35\":null,\"36\":null,\"37\":null,\"38\":null,\"39\":null,\"40\":null,\"41\":null,\"42\":null,\"43\":null,\"44\":null,\"45\":null,\"46\":null,\"47\":null,\"48\":null,\"49\":null,\"50\":null,\"51\":null,\"52\":null,\"53\":null,\"54\":null,\"55\":null,\"56\":null,\"57\":null,\"58\":null,\"59\":null,\"60\":null,\"61\":null,\"62\":null},\"session_type_name\":{\"0\":\"Learning and Development\",\"1\":\"Learning and Development\",\"2\":\"Learning and Development\",\"3\":\"Learning and Development\",\"4\":\"Mentoring\",\"5\":\"Mentoring\",\"6\":\"Mentoring\",\"7\":\"Mentoring\",\"8\":\"Coaching\",\"9\":\"Coaching\",\"10\":\"Coaching\",\"11\":\"Coaching\",\"12\":\"Experience Sharing\",\"13\":\"Experience Sharing\",\"14\":\"Experience Sharing\",\"15\":\"Experience Sharing\",\"16\":\"Networking\",\"17\":\"Networking\",\"18\":\"Networking\",\"19\":\"Networking\",\"20\":\"Establishing Buy-In\",\"21\":\"Establishing Buy-In\",\"22\":\"Establishing Buy-In\",\"23\":\"Establishing Buy-In\",\"24\":\"Idea Exploration\",\"25\":\"Idea Exploration\",\"26\":\"Idea Exploration\",\"27\":\"Idea Exploration\",\"28\":\"Seven Soft Skills\",\"29\":\"Seven Soft Skills\",\"30\":\"Seven Soft Skills\",\"31\":\"Seven Soft Skills\",\"32\":\"Seven Soft Skills\",\"33\":\"Seven Soft Skills\",\"34\":\"Seven Soft Skills\",\"35\":null,\"36\":null,\"37\":null,\"38\":null,\"39\":null,\"40\":null,\"41\":null,\"42\":null,\"43\":null,\"44\":null,\"45\":null,\"46\":null,\"47\":null,\"48\":null,\"49\":null,\"50\":null,\"51\":null,\"52\":null,\"53\":null,\"54\":null,\"55\":null,\"56\":null,\"57\":null,\"58\":null,\"59\":null,\"60\":null,\"61\":null,\"62\":null},\"parent_id\":{\"0\":null,\"1\":null,\"2\":null,\"3\":null,\"4\":null,\"5\":null,\"6\":null,\"7\":null,\"8\":null,\"9\":null,\"10\":null,\"11\":null,\"12\":null,\"13\":null,\"14\":null,\"15\":null,\"16\":null,\"17\":null,\"18\":null,\"19\":null,\"20\":null,\"21\":null,\"22\":null,\"23\":null,\"24\":null,\"25\":null,\"26\":null,\"27\":null,\"28\":null,\"29\":null,\"30\":null,\"31\":null,\"32\":null,\"33\":null,\"34\":null,\"35\":30.0,\"36\":30.0,\"37\":30.0,\"38\":30.0,\"39\":31.0,\"40\":31.0,\"41\":31.0,\"42\":31.0,\"43\":32.0,\"44\":32.0,\"45\":32.0,\"46\":32.0,\"47\":33.0,\"48\":33.0,\"49\":33.0,\"50\":33.0,\"51\":34.0,\"52\":34.0,\"53\":34.0,\"54\":34.0,\"55\":35.0,\"56\":35.0,\"57\":35.0,\"58\":35.0,\"59\":29.0,\"60\":29.0,\"61\":29.0,\"62\":29.0}}" ] I need to extract data from the 3rd line. The below code tries to extract the first set of questions from the 3rd line. import 'dart:core'; import 'dart:convert'; import 'package:http/http.dart' as http; class Question { late final String question; Question({ required this.question}); } void getData() async{ List<Question> sample_data = []; String link = 'https://activepeersai.computing.dcu.ie/API/631'; var url = Uri.parse(link); var result = await http .get(url,headers: {"Accept": "application/json","Access-Control_Allow_Origin": "*"}); if(result.statusCode==200){ var data = jsonDecode(result.body); var res = jsonDecode(data[2]); String round1 = json.encode(res); var data1 = jsonDecode(round1); var questions = jsonDecode(data1[0]); for(var k in questions.keys){ if(((k=='question1')|| (k=='question2') || (k=='question3') || (k=='question4') || (k=='question5') || (k=='question6') || (k=='question7') || (k=='question8') || (k=='question9') || (k=='question10'))){ Question question = Question(question: res[k]); sample_data.add(question); } } print('$sample_data'); } } void main() { getData(); } Now when I print round1 I get the below output. {"0":{"feedback_id":114,"timer_used":1,"timer":10,"question1":"How to break ice with strangers (in social gathering & in formal events) ?","question2":"How to build networking (with those from different age, culture, education background, language…)(in university & in workplace) ?","question3":"","question4":"","question5":"","question6":"","question7":"","question8":"","question9":"","question10":""},"1":{"feedback_id":115,"timer_used":1,"timer":10,"question1":"How to deal with difficult teammates (dominating / debater character / negative / lack of confidence / free rider…) ?","question2":"How to build mutual trust with teammates ?","question3":"","question4":"","question5":"","question6":"","question7":"","question8":"","question9":"","question10":""}} Which when I checked on Json Checker came to be valid. But after this I get an error. Error: Expected a value of type 'String', but got one of type 'Null' at Object.throw_ [as throw] (http://localhost:56003/dart_sdk.js:5080:11) at Object.castError (http://localhost:56003/dart_sdk.js:5039:15) at Object.cast [as as] (http://localhost:56003/dart_sdk.js:5356:17) at String.as (http://localhost:56003/dart_sdk.js:46240:19) at getData (http://localhost:56003/packages/testing_for_data/main.dart.lib.js:74:56) at getData.next (<anonymous>) at http://localhost:56003/dart_sdk.js:40641:33 at _RootZone.runUnary (http://localhost:56003/dart_sdk.js:40511:59) at _FutureListener.thenAwait.handleValue (http://localhost:56003/dart_sdk.js:35438:29) at handleValueCallback (http://localhost:56003/dart_sdk.js:35999:49) at _Future._propagateToListeners (http://localhost:56003/dart_sdk.js:36037:17) at [_completeWithValue] (http://localhost:56003/dart_sdk.js:35872:23) at async._AsyncCallbackEntry.new.callback (http://localhost:56003/dart_sdk.js:35906:35) at Object._microtaskLoop (http://localhost:56003/dart_sdk.js:40778:13) at _startMicrotaskLoop (http://localhost:56003/dart_sdk.js:40784:13) at http://localhost:56003/dart_sdk.js:36261:9 Can someone tell me what I am doing wrong? Its coming due to the line var data1 = jsonDecode(round1); |
Property 'children' is missing in type 'Element' but required in type 'ReactPortal Posted: 11 Jul 2022 04:04 AM PDT I tring to setup styled-components for my new project but i get this typescript error. Type 'Element' is not assignable to type 'ReactNode'.\n Property 'children' is missing in type 'Element' but required in type 'ReactPortal'. import { render, Fragment } from "preact"; import { ThemeProvider } from "styled-components/macro"; import { App } from "./app"; import { GlobalStyle, theme } from "./styled"; render( <Fragment> <GlobalStyle /> <ThemeProvider theme={theme}> <App /> </ThemeProvider> </Fragment>, document.getElementById("app")! ); This is my App file import { h } from "preact"; export const App = () => { return <div>setup</div>; }; |
i have problem with PHP substring extraction [duplicate] Posted: 11 Jul 2022 04:05 AM PDT i want to get string "29" after "ตอนที่" from "ตอนที่ 29" i try $data = "ตอนที่ 29"; $whatIWant = substr($data, strpos($data, "ตอนที่") + 1); echo $whatIWant; But output (SS https://prnt.sc/yK7A-TWjlAbq) ��อนที่ 29 how should i fix it? i need only 29 |
Assigning a value to a JavaScript matrix inside of a forEach gone wrong Posted: 11 Jul 2022 04:05 AM PDT The bitGraph.dfs() function returns an array of strings, with a format of 'i,j' . The matrix ends up with columns of ones and zeros. The goal is to have the indexes parsed from the strings of the matrix assigned to ones. I checked the debugger and the line result[x][y] = 1 doesn't execute with each forEach iteration, but instead assigns a 1 to each element of the y column of the matrix at the end of the forEach . const result = Array(N).fill(Array(M).fill(0)); Inside of a for loop: bitGraph.dfs(`${N - 1},${j}`, visited) .forEach(node => { const [x, y] = node.split(',') .map(index => Number(index)); result[x][y] = 1; }); Example: returned array: ['5,0', '4,0', '1,5', '1,4', '1,3'] result: [ [ 1, 0, 0, 1, 1, 1 ], [ 1, 0, 0, 1, 1, 1 ], [ 1, 0, 0, 1, 1, 1 ], [ 1, 0, 0, 1, 1, 1 ], [ 1, 0, 0, 1, 1, 1 ], [ 1, 0, 0, 1, 1, 1 ] ] |
Implement horizontal recyclerview like instagram story effect listing Posted: 11 Jul 2022 04:04 AM PDT |
TypeError: Cannot read properties of undefined (reading 'split') - NextJS Posted: 11 Jul 2022 04:05 AM PDT I was doing some changes in my index.js (nothing split related that I know) file in my NextJS app and after npm run dev, I got the following error: Unhandled Runtime Error TypeError: Cannot read properties of undefined (reading 'split') Call Stack ../../node_modules/.pnpm/undici@5.5.1/node_modules/undici/lib/core/request.js webpack-internal:///./node_modules/next/dist/compiled/@edge-runtime/primitives/index.js (17232:45) __require webpack-internal:///./node_modules/next/dist/compiled/@edge-runtime/primitives/index.js (16:50) ../../node_modules/.pnpm/undici@5.5.1/node_modules/undici/lib/client.js webpack-internal:///./node_modules/next/dist/compiled/@edge-runtime/primitives/index.js (18044:19) __require webpack-internal:///./node_modules/next/dist/compiled/@edge-runtime/primitives/index.js (16:50) ../../node_modules/.pnpm/undici@5.5.1/node_modules/undici/lib/pool.js webpack-internal:///./node_modules/next/dist/compiled/@edge-runtime/primitives/index.js (19367:18) __require webpack-internal:///./node_modules/next/dist/compiled/@edge-runtime/primitives/index.js (16:50) ../../node_modules/.pnpm/undici@5.5.1/node_modules/undici/lib/agent.js webpack-internal:///./node_modules/next/dist/compiled/@edge-runtime/primitives/index.js (19476:16) __require webpack-internal:///./node_modules/next/dist/compiled/@edge-runtime/primitives/index.js (16:50) src/polyfills/undici.js webpack-internal:///./node_modules/next/dist/compiled/@edge-runtime/primitives/index.js (19607:17) __require webpack-internal:///./node_modules/next/dist/compiled/@edge-runtime/primitives/index.js (16:50) addPrimitives webpack-internal:///./node_modules/next/dist/compiled/@edge-runtime/primitives/index.js (21753:18) eval webpack-internal:///./node_modules/next/dist/compiled/@edge-runtime/primitives/index.js (21855:19) ./node_modules/next/dist/compiled/@edge-runtime/primitives/index.js file:///Users/dusankovacevic/Desktop/buksna/next/core/.next/static/chunks/pages/index.js (14475:1) options.factory /_next/static/chunks/webpack.js (661:31) __webpack_require__ file:///Users/dusankovacevic/Desktop/buksna/next/core/.next/static/chunks/webpack.js (37:33) fn /_next/static/chunks/webpack.js (316:21) eval webpack-internal:///./node_modules/next/dist/server/node-polyfill-web-streams.js (2:42) ./node_modules/next/dist/server/node-polyfill-web-streams.js file:///Users/dusankovacevic/Desktop/buksna/next/core/.next/static/chunks/pages/index.js (15152:1) options.factory /_next/static/chunks/webpack.js (661:31) __webpack_require__ file:///Users/dusankovacevic/Desktop/buksna/next/core/.next/static/chunks/webpack.js (37:33) fn /_next/static/chunks/webpack.js (316:21) eval webpack-internal:///./node_modules/next/dist/server/render.js (47:5) ./node_modules/next/dist/server/render.js file:///Users/dusankovacevic/Desktop/buksna/next/core/.next/static/chunks/pages/index.js (15207:1) options.factory /_next/static/chunks/webpack.js (661:31) __webpack_require__ file:///Users/dusankovacevic/Desktop/buksna/next/core/.next/static/chunks/webpack.js (37:33) fn /_next/static/chunks/webpack.js (316:21) eval webpack-internal:///./pages/index.js (8:81) ./pages/index.js file:///Users/dusankovacevic/Desktop/buksna/next/core/.next/static/chunks/pages/index.js (14584:1) options.factory /_next/static/chunks/webpack.js (661:31) __webpack_require__ file:///Users/dusankovacevic/Desktop/buksna/next/core/.next/static/chunks/webpack.js (37:33) fn /_next/static/chunks/webpack.js (316:21) eval webpack-internal:///./node_modules/next/dist/build/webpack/loaders/next-client-pages-loader.js (5:16) eval webpack-internal:///./node_modules/next/dist/client/route-loader.js (211:24) Any help is appreciated. I am stuck here for a while now, not able to find a solution. As stated, I haven't changed/added anything related to slice while committing the changes :) |
Server response when user was authenticated Posted: 11 Jul 2022 04:04 AM PDT I am poking around client-server communication, and I am stuck on a problem, where I don't know what the server should respond with, when the user authentication has been successful, or not. Do I want to respond with just a "True" or "False", or are there more intricate responses when designing a server? |
Unable to access field that has hyphen in it Posted: 11 Jul 2022 04:05 AM PDT I am struggling to write a firebase rule that is checking the user id that is stored in a document. Hardcoding a given value as a string works allow write: if request.auth.uid == 'user-id-hardcoded'; ,however I am unable to find a way to dynamically address it. I am left with the impression it's due to the hyphen in the document field after checking this question - Firebase security rules : How can I use dashes or hyphen in paths?. I also tried to substitute user-id with userId to no avail. allow write: if request.auth.uid == resource.data.user-id; Any help will be appreciated. |
File size check, Linux Posted: 11 Jul 2022 04:04 AM PDT File size check file_path="/home/d-vm/" cd $file_path # file_path directory file=($(cat video.txt | xargs ls -lah | awk '{ print $9}')) # get name in video.txt --- two files for example VID_141523.mp4 VID_2_141523.mp4 minimumsize=1 actualsize=$(wc -c <"$file") if [ $actualsize -ge $minimumsize ]; then echo $file size $actualsize bytes else echo error $file size 0 bytes fi VID_141523.mp4 file corrupted during conversion. its size 0 bytes Script output---- error VID_20220709_141523.mp4 size 0 bytes video.txt - VID_141523.mp4
- VID_2_141523.mp4
How to add this construct to the loop ? It should check all files in the list video.txt |
Returning IEnumerable with an anonymous type Posted: 11 Jul 2022 04:05 AM PDT I have an interface similar to this: IEnumerable<(string valueA, decimal valueB)> GetData This interface should not be changed. So I'm trying to implement it. I need to use LINQ, so I have this part of code: var fetchedData = File.ReadAllLines(filePath) .Skip(1) .Select(a => x.Split(';')) .Select(a => new { valueB= decimal.Parse(a[0]), valueA= a[1] }); return fetchedData; The problem is that fetchedData is not of the same type the interface expects. I need to return IEnumerable<(string valueA, decimal valueB)> but fetchedData is another type. |
python duplicate values and key in multiple dictionary rearrange into single dictionary Posted: 11 Jul 2022 04:04 AM PDT i have a list of dict like this list_1 = [{'id': '123', 'name': {'new': 'kevin'}}, {'id': '123', 'name': {'old': 'alan'}}, {'id': '456', 'name': {'new': 'jason'}}, {'id': '456', 'name': {'old': 'jack'}}] But I want to merge the same values together using something function The desired output is as follows list_1 = somethingfunction() output: {'id': '123', 'name': {'new': 'kevin','old': 'alan'}} {'id': '456', 'name': {'new': 'jason','old': 'jack'}} Don't know if there is any function that can quickly merge the same values and key together |
.NET variable memory ALLOCATION versus memory USAGE Posted: 11 Jul 2022 04:05 AM PDT This is a relatively simple question, but lately I've been looking into Huffman encoding and wanted to ask the pros here at SO. If I declare a variable as Int32 , does it necessarily use all the allocated memory? That is, if my Int32 has a value of 1 … Int32 myVar = 1; // binary 00000000 0000000 0000000 00000001 (4 bytes = 32 bits) …then are all 32 bits used, or are they only used as needed when the variables value requires the bits? Seemingly, unless I used a low level language like C, C++, Rust, assembly, then Huffman encoding doesn't provide any compression of my data, albeit perhaps some very basic obfuscation of the original ASCII representation. Please advise. I appreciate you thoughts on this subject. |
How to find and replace 0/0 to 0; 0/1 to 1 and 1/1 to 1, occuring in multiple rows and columns in a big datafile? Posted: 11 Jul 2022 04:04 AM PDT I have a huge input file with several columns (Column10-Column28) that contains either 0/0, 0/1 or 1/1 data entries. I want to find and replace in place the following:- 0/0 to 0; 0/1 to 1; and 1/1 to 1. input file: #CHROM POS ID REF ALT QUAL FILTER INFO FORMAT Sample-1 Sample-2 Sample-3 Sample-4 Sample-5 Sample-7 Sample-8 Sample-9 Sample-10 Sample-11 Sample-12 Sample-13 Sample-14 Sample-15 Sample-16 Sample-17 Sample-18 Sample-19 Sample-20 Sample-21 Sample-22 Sample-23 Sample-24 Sample-25 Sample-27 Sample-28 Sample-29 Sample-30 chr10 60074 . G C . PASS ADP=10;HET=1;HOM=0;NC=0;SF=1;WT=0;AN=25;AC=0 GT:ADR:RDF:ABQ:DP:FREQ:ADF:RBQ:PVAL:SDP:AD:GQ:RDR:RD 0:.:.:.:.:.:.:.:.:.:.:.:.:. 0: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.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:. 0/1:.:.:.:.:.:-69.4469,0,-78.8411:36:.:.:1092:.:.:.:.:29:997:.:69 0/0:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:. 0/0:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:. 0/0:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:. 0/0:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:. 0/0:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:. 0/0:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:. 0/0:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:. 0/0:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:. 0/0:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:. 0/0:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:. 0/0:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:. 0/0:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:. 0/0:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:. 0/0:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:. 0/1:.:.:.:.:.:-60.0267,0,-33.0544:15:.:.:491:.:.:.:.:23:799:.:38 0/0:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:. 0/1:.:.:.:.:.:-10,0,-10:19:.:.:580:.:.:.:.:18:634:.:37 output file: #CHROM POS ID REF ALT QUAL FILTER INFO FORMAT Sample-1 Sample-2 Sample-3 Sample-4 Sample-5 Sample-7 Sample-8 Sample-9 Sample-10 Sample-11 Sample-12 Sample-13 Sample-14 Sample-15 Sample-16 Sample-17 Sample-18 Sample-19 Sample-20 Sample-21 Sample-22 Sample-23 Sample-24 Sample-25 Sample-27 Sample-28 Sample-29 Sample-30 chr10 60074 . G C . PASS ADP=10;HET=1;HOM=0;NC=0;SF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 0:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:. 0:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:. 0:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:. 0:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:. 0:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:. 0:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:. 0:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:. 0:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:. 0:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:. 0:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:. 0:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:. 0:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:. 0:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:. 0:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:. 1:.:.:.:.:.:-60.0267,0,-33.0544:15:.:.:491:.:.:.:.:23:799:.:38 0:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:. 1:.:.:.:.:.:-10,0,-10:19:.:.:580:.:.:.:.:18:634:.:37 Can anyone please suggest an easy approach, perhaps awk + gsub command?? |
Is it possible to lappend to a list in a list held in array directly without using a temporary variable? Posted: 11 Jul 2022 04:05 AM PDT In the code below, is there anyway to get the same result without using the temporary variable x ? It appears that lappend will not update a list unless held in a variable and I don't know how to get something like [lindex comPorts($sock) 4] versus [lindex $comPorts($sock) 4] , which doesn't work because is a value not stored in a variable. Thank you. set sock abc set comPorts($sock) [list $sock 0 0 1 {129} {} {} {} ] set data {134 135} chan puts stdout [lindex $comPorts($sock) 4] # => 129 set x [lindex $comPorts($sock) 4] chan puts stdout [lappend x {*}$data] # => 129 134 135 chan puts stdout [lset comPorts($sock) 4 $x] # => abc 0 0 1 {129 134 135} {} {} {} ] |
Custom Repository Implementation is not being recognized Posted: 11 Jul 2022 04:04 AM PDT I am currently working on a project where I have created the following custom Repository: public interface ServiceRepository<T extends ServiceEntity> extends JpaRepository<T, UUID>, ServiceRepositoryCustom { } public interface ServiceRepositoryCustom { List<ServiceEntity> findAllContainingName(String query); } @Repository("Repo") public class ServiceRepositoryCustomImpl implements ServiceRepositoryCustom { private final EntityManager em; public ServiceRepositoryCustomImpl(EntityManager em) { System.out.println("I got constructed"); this.em = em; } @Override public List<ServiceEntity> findAllContainingName(String name) { System.out.println("I got called with: " + name); CriteriaBuilder cb = em.getCriteriaBuilder(); CriteriaQuery<ServiceEntity> cq = cb.createQuery(ServiceEntity.class); Root<ServiceEntity> serviceEntity = cq.from(ServiceEntity.class); List<Predicate> predicates = new ArrayList<>(); if(name != null) { // predicates.add(cb.equal(serviceEntity.get("name"), name)); predicates.add(cb.like(serviceEntity.get("name"), name + "%")); } cq.where(predicates.toArray(predicates.toArray(new Predicate[0]))); return em.createQuery(cq).getResultList(); } } The print statement "I got called with: " never gets called. So for whatever reason Spring Boot is not running the method through my custom implementation. Any suggestions? Any help is much appreciated Edit: Here is the code that injects and uses the Repository in question @Repository public interface PineappleServiceRepository extends ServiceRepository<PineappleServiceEntity> { } @Component("Registry") @DependsOn({"Context", "Repo"}) public class Registry { private final List<ServiceRepository<? extends ServiceEntity>> serviceRepositories = new ArrayList<>(); public Registry(PineappleServiceRepository pineappleServiceRepository) { this.serviceRepositories.add(pineappleServiceRepository); } } Edit 2: The code prints "I got constructed" Edit 3: Class where findAllContainingName is called @RestController @RequestMapping("/test") @DependsOn("Registry") public class ServiceController { private final Registry registry; public ServiceController(@NotNull Registry registry) { this.registry = registry; } @GetMapping("") List<ServiceEntity> all(@RequestParam("q") String query) { return getAllServices(query); } private @NotNull List<ServiceEntity> getAllServices(String query) { List<ServiceEntity> response = new ArrayList<>(); for(ServiceRepository<? extends ServiceEntity> repo: this.registry.getServiceRepositories()){ response.addAll(repo.findAllContainingName(query)); } return response; } } Edit 4: Here the entities: @Entity @Table(name = "services") public abstract class ServiceEntity { protected @Id UUID id = UUID.randomUUID(); protected String name; // Constructor + Getters and Setters } @Entity public class PineappleServiceEntity extends ServiceEntity { // Additional Properties, matching Constructors, Getters and Setters } |
SQL: Get the latest value from all rows but ignore nulls Posted: 11 Jul 2022 04:05 AM PDT I'm inserting a new row per order update so I can keep track of the state updates. Like this. +----------+-----------+--------+-----------------------+-----------------------+----------------------------------+ | event_id | state | amount | address | notes | timestamp | +----------+-----------+--------+-----------------------+-----------------------+----------------------------------+ | order123 | fulfilled | NULL | NULL | NULL | 2022-07-01T17:08:12.032316+00:00 | | order123 | NULL | NULL | NULL | Delivered to customer | 2022-07-01T17:07:12.032316+00:00 | | order123 | NULL | NULL | 300 Post St, CA 94108 | NULL | 2022-07-01T17:06:12.032316+00:00 | | order123 | accepted | NULL | NULL | NULL | 2022-07-01T17:05:12.032316+00:00 | | order123 | pending | 100 | NULL | NULL | 2022-07-01T17:04:12.032316+00:00 | +----------+-----------+--------+-----------------------+-----------------------+----------------------------------+ How would I write a query that pulls out the latest value from each of those columns, ignoring the NULLs. This is what I'm looking for. +----------+-----------+--------+-----------------------+-----------------------+----------------------------------+ | event_id | state | amount | address | notes | timestamp | +----------+-----------+--------+-----------------------+-----------------------+----------------------------------+ | order123 | fulfilled | 100 | 300 Post St, CA 94108 | Delivered to customer | 2022-07-01T17:08:12.032316+00:00 | +----------+-----------+--------+-----------------------+-----------------------+----------------------------------+ This is as far as I've gotten, which gives me the latest record: SELECT DISTINCT ON (event_id) event_id, state, amount, address, notes, timestamp FROM event_order ORDER BY event_id, timestamp DESC; DB Fiddle link: https://www.db-fiddle.com/f/pZFUG96oYh6ymAz99vvqWh/0 I came across this post which mentions LAST_VALUE but the solution seems like it only works with integers. Any help will be appreciated. |
Flutter parse unicode characters not working Posted: 11 Jul 2022 04:05 AM PDT I have the following string coming from my backend server \u25CF\u25CF\u25CF and when I decode it with UTF-8 it's working fine in the iOS native app, But when I try to parse it in flutter I'm not able to get the converted value. I have tried the following approaches but none worked String converted = Utf8Decoder().convert(userName.codeUnits); String uname = utf8.decode(userName.runes.toList()); String runes = String.fromCharCodes(Runes('$userName')); Does anyone know how we can fix this? The real value should be 3 dots after conversion. |
CDC using kafka and kafka streams Posted: 11 Jul 2022 04:04 AM PDT I'm trying to sync my postgres to elasticsearch. For this purpose I'm using debezium + kafka connnect, kafka and kafka streams.
For now I'm able to sync the changes perfectly to elasticsearch, including update, delete and create. But what confuses me is if my approach is correct and that if there's any other better way to do this. Here's my approach : - Stream changes for each table (9 in total) from DB to separate kafka topics using debezium + connect.
- In streams application, read those topics as KTable and join them to get complete doc.
- Write the KTable (output of join operation) to another topic and sink it using elastic search sink connector.
The reason I'm reading topic as a KTable is because it could happen that (say) some information regarding a specific record was modified after (say) 24hrs. If I read them as KStream then join operation will be windowed and that could cause issues. For example : Let's say there are 3 tables, product, product_category, categories. Then on initial sync things might work fine. But later on if another category was added for the same product (a new entry in product_category) after 24 hours. There's a possibility that the windowed join will not work if windowed option is set for 1 hr. And I'm not sure how KTable - KTable join works internally, is it efficient and will it scale properly for 8-10 Million records ? Also is it okay to create a new topic for each table ? I'll most probably have to join on all of those tables (9 tables in total). Any advice would be really appreciated :) Let me know if some more information is needed. Thanks :) |
Make .netrc authentication work with aiohttp Posted: 11 Jul 2022 04:05 AM PDT I'd like to use a .netrc file with credentials to authenticate to an API using aiohttp. As far as I can tell this should be possible, as long as the file is in the home directory (or the relevant env variable set correctly) and trust_env=True set in the aiohttp.ClientSession . But whatever I try, I get a 401 response. I've checked with requests, and it works just fine. I've browsed through the relevant code and it seems like it'll only pick up the credentials if a proxy is supplied. Can someone explain? Here's an example that reproduces the issue: First put a .netrc file in home directory: machine httpbin.org login foo password bar import aiohttp import requests url = "http://httpbin.org/basic-auth/foo/bar" with requests.Session() as sess: r = sess.get(url) r.raise_for_status() # no exception raised async with aiohttp.ClientSession(trust_env=True) as session: r = await session.get(url) r.raise_for_status() # exception raised ClientResponseError: 401, message='UNAUTHORIZED', url=URL('http://httpbin.org/basic-auth/foo/bar') |
Can't drag and drop in Ubuntu 22.04 Posted: 11 Jul 2022 04:04 AM PDT It seems like Desktop Icons NG (DING) is not instelled on my desktop. I can't drag and drop items from or in the desktop. When I try to install it manually it says something like: this is an extension enabled by your current mode. Can't be installed. But it is not installed... Even in the setting it is not showing up. |
Getting CannotPullContainerError on ECS Fargate Posted: 11 Jul 2022 04:05 AM PDT I am trying to run my microservice on ECS Fargate. I have self hosted private Docker registry. I have tried pulling the same Docker image from inside the EC2 server in the same subnet as ECS Fargate service, it's able to pull the Docker image. But, with ECS Fargate, I am getting the following error: CannotPullContainerError: inspect image has been retried 5 time(s): failed to resolve ref "xxxxxxxxxxxxxx/xxxxxxxxxx:latest": failed to do request: Head https://xxxxxxxxxxxxxx/v2/xxxxxxxxxxxxxx/mani.. If it's the networking error, then it should not be accessible from the EC2 server in the same subnet as well. Looks like some issue with Fargate itself. |
how to catch all GenericMotionEvent when a DialogFragment is shown? Posted: 11 Jul 2022 04:04 AM PDT I need to show a preference dialog that wait for Joypad keypress. I know that DialogFragment has its own Window then has its own onKeyListener . I can easily catch Joypad press by setting a listener like that. public class MyDialogFragment extends PreferenceDialogFragmentCompat { @Override protected void onPrepareDialogBuilder(AlertDialog.Builder builder) { super.onPrepareDialogBuilder(builder); builder.setOnKeyListener(new DialogInterface.OnKeyListener() { @Override public boolean onKey(DialogInterface dialogInterface, int i, KeyEvent keyEvent) { // do stuff with intercepted key press return true; } }); } } But, I have trouble catching GenericMotionEvents . In order to intercept them, I've overridden onGenericMotionEvents in the Activity class and eventually forward the Event by calling a method on MyDialogFragment class. It works 100% correctly when MyDialogFragment is not shown as when an analog trigger/direction stick is moved, I can get an event. The weird part is that IF MyDialogFragment is shown, then I can get only analog direction stick events BUT NOT left/right analog triggers events. Does someone know why and how to fix this behaviuor? |
How can I display a return in three columns (in Google Apps Script) that looks like an array, but (to me) doesn't behave like one? Posted: 11 Jul 2022 04:04 AM PDT How can I display this return in three columns on my web app, preferably with given headers? (FIGURED IT OUT!) THIS IS PROBABLY IMPORTANT! According to the writer of the gvizQuery function, which I use to find data in a referenced Google Sheet, the return is an array of arrays. Also, I now run V8 of Google Apps Script. So, this is the simplest version of the code where I provide a serial number, which is sent to the query function, and returned along with a reference to ou and most recent user. document.getElementById("btnserno1").addEventListener("click",fetchCBOU); function fetchCBOU(){ var sernum = document.getElementById("serial").value; google.script.run .withSuccessHandler(printCBOUU) .queryCBOU(sernum); } window.printCBOUU = function(CBOUU) { console.log(CBOUU); var CBOU1 = CBOUU document.getElementById('idCB').innerHTML = CBOU1[0]; document.getElementById('idCBOU').innerHTML = CBOU1[1]; document.getElementById('idCBRecent').innerHTML = CBOU1[2]; } In the Stackdriver logs the return is displayed like this. Feb 17, 2020, 12:07:22 AM Info [[[5CD725B5B0, /Grundskolor/Boras, utd8377@edu.kunskapsskolan.se]]] This is what it looks like in the console. First a perfect match. On the web app it displays the three values in one place, and leaves the other two as undefined. If I instead do a partial match, I get more arrays in console. But in the web app I get all those values in the first element and the two other elements are still undefined. If I manipulate the incoming data after it arrives, and try split it up, I get different results depending on if it's a perfect or partial match. I change the middle part of the code to this. window.printCBOUU = function(CBOUU) { console.log(CBOUU); //Creating the new variable, based off CBOUU, adding quotation marks. var str = CBOUU + ''; console.log(str); //Creating the new array, based off CBOUU, and now, since it has quotation marks, it becomes an array. var CBOU1 = str.split(","); console.log(CBOU1); document.getElementById('idCB').innerHTML = CBOU1[0]; document.getElementById('idCBOU').innerHTML = CBOU1[1]; document.getElementById('idCBRecent').innerHTML = CBOU1[2]; } For a perfect match and a partial match that only has a single matching device everything still works. But if I do a partial match and get many hits everything breaks, as it is no longer working with variables with three sets of data, but instead as many values as there are matching devices, times three values. And to display them I'd have to keep adding CBOU1[n] values for each one. Do note that this is not static data! I'm trying to display the return from a function where I search for a partial serial number from a Google sheet. Logs (I thought this was an array, with three values for each object, but apparently this could be an array of arrays) [20-02-14 16:28:16:153 CET] [[[5CD9264KBW, /Grundskolor/Boras, user1@my.domain], [5CD9264K64, /Grundskolor/Boras, user2@my.domain], [5CD9264K7V, /Grundskolor/Boras, user3@my.domain], [5CD9264K6M, /Grundskolor/Boras, user4@my.domain]] Console after I try to turn it into a usable array (here it looks to me to be a single array of only one object, with a bunch of values) ["5CD9264KBW", "/Grundskolor/Boras", "user1@my.domain", "5CD9264K64", "/Grundskolor/Boras", "user2@my.domain", "5CD9264K7V", "/Grundskolor/Boras", "user3@my.domain", "5CD9264K6M", "/Grundskolor/Boras", "user4@my.domain"] My response to @Cooper who has tried to help me. When I try your code, @Cooper , like this. document.getElementById("btnserno1").addEventListener("click",fetchCBOU); function fetchCBOU(){ document.getElementById("idCBS").innerHTML = ""; var sernum = document.getElementById("serial").value; google.script.run .withSuccessHandler(printCBOUU) .queryCBOU(sernum); document.getElementById("serial").value = ""; } window.printCBOUU = function(CBOUU) { console.log('Device info: ' + CBOUU); // function splitItUp() { // using it as part of my code, with my return const data = CBOUU let a=data.slice(3,-2).trim().replace(/\], \[/g,'~~~').split('~~~'); let b=[]; a.forEach(function(r){b.push(r.split(', '));}); let html='<style>td,th{border:1px solid black;}</style><table>'; b.forEach(function(r,i){html+='<tr><td>${r[0]}</td><td>${r[1]}</td><td>${r[2]}</td></tr>';}); html+='</table>'; document.getElementById("idCBS").innerHTML = html; } I get an error, as it can't work with the data. Uncaught TypeError: data.slice(...).trim is not a function If I instead set data to what looks like my return and submits any serial. const data='[[[5CD9264KBW, /Grundskolor/Boras, user1@my.domain], [5CD9264K64, /Grundskolor/Boras, user2@my.domain], [5CD9264K7V, /Grundskolor/Boras, user3@my.domain], [5CD9264K6M, /Grundskolor/Boras, user4@my.domain]]'; Then it runs (doesn't use my input, of course) and this is what your forEach function looks like to me, @Cooper. As you can see it doesn't display the given data. The page.html section for where the result is displayed looks like this. <table class="striped"> <tr> <td><h6>Serial</h6></td> <td><h6>Device OU</h6></td> <td><h6>Most Recent User</h6></td> </tr> <tr> <td><h6 id="idCB"></h6></td> <td><h6 id="idCBOU"></h6></td> <td><h6 id="idCBRecent"></h6></td> </tr> </table> <table id="idCBS"> </table> When I do get my many results to show here, I would, of course, like the headers to line up with the results. ALRIGHT, I NOW HAVE COME MUCH CLOSER TO A RESULT I LIKE! Now all the data is listed in columns. I borrowed some formatting suggestions from here, with a for-loop inside the array idea from another place to make the data display in a table, which probably can be done in several different nicer ways. Maybe even a way that will keep the alignment correct? This the current js. document.getElementById("btnserno2").addEventListener("click",fetchCBS); function fetchCBS(){ //This clears the results between searches. Else the html+= below will keep adding rows of data at the bottom. document.getElementById("idCBS").innerHTML = ""; var sernum = document.getElementById("serial2").value; google.script.run .withSuccessHandler(printCBS) .queryCBS(sernum); document.getElementById("serial2").value = ""; } window.printCBS = function(CBS) { console.log(CBS); var i,innerArray; var L = CBS[0].length; for (i=0;i<L;i++) { innerArray = CBS[0][i]; value1 = innerArray[0]; value2 = innerArray[1]; value3 = innerArray[2]; console.log(value1 + "__" + value2 + "__" + value3) // This creates the table in the idCBS spot. // Both <table> and <tr> bits can be removed, and result is still the same. let html='<style>td,th{border:0px solid black;}</style><table>'; html+='<tr><td>' + value1 + '</td><td>' + value2 + '</td><td>' + value3 + '</td></tr>'; html+='</table>'; document.getElementById("idCBS").innerHTML += html; } } //Code for the clearResults button document.getElementById("clearResults").addEventListener("click",clrResults); function clrResults(){ document.getElementById("idCBS").innerHTML = ""; } It is displayed in page.html like this. <h4>Results<button class="waves-effect waves-light btn-small" id="clearResults">Clear Results</button></h4> <table class="striped"> <tr> <td><h6>Serial</h6></td> <td><h6>Device OU</h6></td> <td><h6>Most Recent User</h6></td> </tr> <table id="idCBS"> </table> </table> This means I have the headers of the coming table visible before the search. But, since I use two tables, the headers aren't responsive, and don't adjust to the width of the coming columns which have wider values. It looks like this. If I try to put the headers inside the html+= creation loop in js, I of course get repeated headers. If I instead put the headers inside the idCBS table on page they are wiped by the early document.getElementById("idCBS").innerHTML = "" command. If I don't use and instead choose either or , then the data isn't looped properly, and is instead appended to the same row. Maybe I haven't tried all combinations, but I did try quite a few. I'm guessing there is a better combination of js + html to display my data in a perfectly aligned table, I just haven't found a solution yet. And, now I did! Changed the table code a bit, so I could move the idCBS to where it didn't interfere with the headers. <table> <thead> <tr> <th><h6>Serial</h6></th> <th><h6>Device OU</h6></th> <th><h6>Most Recent User</h6></th> </tr> </thead> <tbody id="idCBS"> </tbody> </table> Columns now align! So, I'm good for now, but if anyone has suggestions for improvements, feel free to comment. I was shown that there is an alternative to moving idCBS. <table id="idCBS"> <tr><!-- table header --> <th>Serial</th> <th>Device OU</th> <th>Most Recent User</th> </tr> </table> Then use: var myTable = document.getElementById("idCBS"); myTable.insertAdjacentHTML("beforeend", html); But, if I don't move idCBS to then I can use my clearResults button, as it'll wipe the entire table. with idCBS in tdbody, the insertAdjacentHTML of course works fine there too. |
Duplicate notifications - react-native-push-notification Posted: 11 Jul 2022 04:05 AM PDT I have a problem with react-native-push-notification module on Android. After correct set up the notifications are delivered for generated device token. Unfortunately, every push notification is duplicated. At that moment I do not implement the channel name and the remote push notification is delivered twice to "Other" category. When there is a channel name Android displays the push notification as "Other" and "Category Name" in the Notification Module. <meta-data android:name="com.dieam.reactnativepushnotification.notification_channel_name" android:value="Channel Name"/> <meta-data android:name="com.dieam.reactnativepushnotification.notification_channel_description" android:value="Channel description"/> Is there any possibility to leave only one push notification. I am sure that push notification is sent once. I know that the library is not supported but unfortunately I do not have time for a change. I need a quick fix. I will be glad for help! |
Spring Boot LDAP authentication and matching with database users Posted: 11 Jul 2022 04:05 AM PDT I have a Spring Boot MVC application which uses LDAP for authentication. This works fine, but now I have to match authenticated user (from LDAP repository) with users from my database. I created LDAPUser: import java.util.jar.Attributes.Name; import org.springframework.ldap.odm.annotations.Attribute; import org.springframework.ldap.odm.annotations.Entry; import org.springframework.ldap.odm.annotations.Id; @Entry( base="ou=users", objectClasses = { "person", "inetOrgPerson", "top" }) public class LDAPUser { @Id private Name id; private @Attribute(name = "cn") String username; private @Attribute(name = "sn") String password; private boolean rememberme; } And LDAPUserRepository: import org.springframework.data.ldap.repository.LdapRepository; import org.springframework.stereotype.Repository; import com.licensewatcher.model.LDAPUser; @Repository("ldapUserRespository") public interface LDAPUserRepository extends LdapRepository<LDAPUser>{ LDAPUser findByUsername(String username); LDAPUser findByUsernameAndPassword(String username, String password); /*List<LDAPUser> findByUsernameLikeIgnoreCase(String username);*/ } and AuthUserService: import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import com.licensewatcher.repository.LDAPUserRepository; @Service("authUserService") public class AuthUserService { @Autowired LDAPUserRepository ldapUserRespository; public boolean authenticate(LDAPUser ldapUser) { //TODO: implement this!!! return false; } public boolean authorize(LDAPUser ldapUser) { //TODO: implement this!!! return false; } } Class WebSecurityConfig (extends WebSecurityConfigurerAdapte) configures application to submit login controller action: @PostMapping("/login/check") public String login(Model model, LDAPUser ldapUser, RedirectAttributes redirectAttr) { //TODO: call authUserService.authenticate(LDAPUser ldapUser); return "redirect:/login"; } I want to implement authUserService.authenticate(LDAPUser ldapUser) to check LDAPUserRepository first and if user exists, check up the User from my database. If they match, add user to a session and redirect to the requested page. Is this a good approach? Do you have any suggestions how this could be implemented in a more elegant way? Thanks in advance! |
How do I send an e-mail in Java? Posted: 11 Jul 2022 04:05 AM PDT I need to send e-mails from a servlet running within Tomcat. I'll always send to the same recipient with the same subject, but with different contents. What's a simple, easy way to send an e-mail in Java? Related: How do you send email from a Java app using GMail? |
No comments:
Post a Comment