How to reject filter for a measure in Power Bi Posted: 25 Aug 2021 08:30 AM PDT I have a measure average example that gathers the average of all values. Average = AVERAGEX ( VALUES ( Table[ID]), CALCULATE ( COUNTX(SUMMARIZE(TABLE,TABLE[ID],TABLE[ID2]), TABLE[ID2]) )) I am satisfied with the result but what I would like is to block the measure from being filtered completely. I want a stagnant result but that updates as I add more data. |
Azure Logic Apps - Issues with trigger being when Item is created in SQL Posted: 25 Aug 2021 08:30 AM PDT I use logic apps frequently, but always with a time based trigger. Trying to set one up that triggers when an item is added to a SQL table. Below are parameters - it just doesn't seem to be working. I am positive there are items being added to these query results at least every half hour, but it never seems to trigger. Any thoughts on what i might be doing wrong? |
Why object.prototype is undefined? Posted: 25 Aug 2021 08:30 AM PDT I'm new to Object Oriented JavaScript. I learned that, function has built in prototype object and we can access it by function.prototype . As, functions are objects in JavaScript, I thought object.prototype will work too. But, instead, I got undefined . Here is my code snippet: function Person(name, age){ let person = {}; person.name = name; person.age = age; return person; } console.log(Person.prototype); //prototype of Person() // But, let obj = {}; console.log(obj.prototype); // undefined I tried this solution too, but it didn't help. Can you explain, why I'm getting undefined ? Thanks in advance. |
Login to site with httpclient Posted: 25 Aug 2021 08:30 AM PDT I'm trying to login to a site through java and the java.net.http.HttpClient library. I can not understand why I check in the response to the request <div id="signin-container"></div>
Your OneDrive version is not supported Upgrade now by installing the OneDrive for Business Next Generation Sync Client to login to Okta Learn how to upgrade Cookies are required Cookies are disabled on your browser. Please enable Cookies and refresh this page. Refresh and if I only take out the body I have (POST https://dev-74822591.okta.com) 200 i can't manage this library. Does anyone have any advice on how to deal with the situation or some more detailed explanation on the library this is my code public bhu(String username, String password) { this.client= HttpClient.newBuilder().build(); this.site="https://dev-74822591.okta.com"; this.request= HttpRequest.newBuilder() .uri(URI.create(this.site)) .POST(BodyPublishers.ofString("some body text")) .header("okta-signin-username",username) .header("okta-signin-password",password) .build(); try { response = this.client.send(this.request, BodyHandlers.ofString()); } catch(IOException e) { e.printStackTrace(); } catch(InterruptedException e) { e.printStackTrace(); } String body=response.body().toString(); System.out.println(body); System.out.println("\n\n\n"); System.out.println(response); } |
Why is websocket taking 20-30 seconds to get into the while loop Posted: 25 Aug 2021 08:29 AM PDT I am trying to make it find certain messages as soon as it is sent, but when the message is sent it takes about 20-30 seconds after for the code to finish. Where I have print("entered while loop") it waits right before that. ws.connect('wss://gateway.discord.gg/?v=6&encording=json') print("Connected") event = recieve_json_response(ws) heartbeat_interval = event['d']['heartbeat_interval'] / 1000 threading._start_new_thread(heartbeat, (heartbeat_interval, ws)) print("Interval Set") token = dtoken payload = { 'op': 2, "d": { "token": token, "properties": { "$os": "windows", "$browser": "chrome", "$device": 'pc' } } } send_json_request(ws, payload) print("Sent Request") while True: event = recieve_json_response(ws) print("Entered While Loop") try: print("Entered Try Loop") if event['d']["channel_id"] == channelid: if "https" in event['d']['content']: pair = event['d']['content'].rsplit('/', 1)[1] print("U R DUMB") break |
How to specify an equality constraint of decision variables in GA in R? Posted: 25 Aug 2021 08:29 AM PDT Objective and Data I have disutilities values by percentage for off-peak and peak hours as shown below. I want to optimize the percent values for each hour so that the sum of disutilities (shown in columns with the x prefix e.g. x0506am_td ) is the minimum. ## Off-Peak hours TD_OffPeak2 <- structure(list(percent = c( 0, 0.01, 0.02, 0.03, 0.04, 0.05, 0.06, 0.07, 0.08, 0.09 ), x0506am_td = c( 0, 6579, 13159, 19738, 26317, 32896, 39476, 46055, 52634, 59213 ), x0607am_td = c( 272800, 277632, 282464, 287298, 292132, 296967, 301803, 306639, 311477, 316314 ), x0708am_td = c( 6202903, 6208203, 6213504, 6218807, 6224111, 6229417, 6234724, 6240033, 6245344, 6250656 ), x0910am_td = c( 4061151, 4064495, 4067840, 4071185, 4074530, 4077876, 4081222, 4084568, 4087915, 4091262 ), x1011am_td = c( 599364, 604822, 610281, 615743, 621206, 626671, 632139, 637608, 643079, 648552 ), x1112am_td = c( 500565, 507908, 515252, 522597, 529943, 537291, 544640, 551989, 559340, 566693 )), row.names = c(NA, -10L), class = c( "tbl_df", "tbl", "data.frame" )) ## Peak Hour TD_Peak2 <- structure(list(percent = c( 0, 0.01, 0.02, 0.03, 0.04, 0.05, 0.06, 0.07, 0.08, 0.09, 0.1, 0.11, 0.12, 0.13, 0.14, 0.15, 0.16, 0.17, 0.18, 0.19, 0.2, 0.21, 0.22, 0.23, 0.24, 0.25, 0.26, 0.27, 0.28, 0.29, 0.3, 0.31, 0.32, 0.33, 0.34, 0.35, 0.36, 0.37, 0.38, 0.39, 0.4, 0.41, 0.42, 0.43, 0.44, 0.45, 0.46, 0.47, 0.48, 0.49, 0.5, 0.51, 0.52, 0.53, 0.54 ), x0809am_td = c( 26838281, 26829566, 26820854, 26812145, 26803439, 26794735, 26786034, 26777336, 26768641, 26759949, 26751260, 26742573, 26733889, 26725208, 26716530, 26707855, 26699183, 26690513, 26681846, 26673182, 26664521, 26655862, 26647207, 26638554, 26629904, 26621257, 26612612, 26603971, 26595332, 26586696, 26578063, 26569433, 26560805, 26552180, 26543558, 26534939, 26526323, 26517709, 26509099, 26500491, 26491885, 26483283, 26474683, 26466087, 26457493, 26448902, 26440313, 26431727, 26423145, 26414565, 26405987, 26397413, 26388841, 26380272, 26371706 )), row.names = c(NA, -55L), class = c( "tbl_df", "tbl", "data.frame" )) Constraint The sum of percent values for each hour other than 0809am should be equal to mdp . Attempt at Solution using GA Package I used the GA package with a fitness function shown below to optimize the percent values for each hour. # Load Libraries library(GA) library(dplyr) ## Fitness Function fitness_func <- function(offpeak_data, peak_data, mdp, h56p, h67p, h78p, h910p, h1011p, h1112p ){ mdp <- round(mdp,2) h56p <- round(h56p,2) h67p <- round(h67p,2) h78p <- round(h78p,2) h910p <- round(h910p,2) h1011p <- round(h1011p, 2) h1112p <- round(h1112p, 2) h89p <- mdp ## using the constraint if ((h56p + h67p + h78p + h910p + h1011p + h1112p) - mdp <= 0.0001) { uval_56 <- offpeak_data$x0506am_td[which(offpeak_data$percent == h56p)] uval_67 <-offpeak_data$x0607am_td[which(offpeak_data$percent == h67p)] uval_78 <-offpeak_data$x0708am_td[which(offpeak_data$percent == h78p)] uval_910 <-offpeak_data$x0910am_td[which(offpeak_data$percent == h910p)] uval_1011 <-offpeak_data$x1011am_td[which(offpeak_data$percent == h1011p)] uval_1112 <-offpeak_data$x1112am_td[which(offpeak_data$percent == h1112p)] uval_89 <-peak_data$x0809am_td[which(peak_data$percent == h89p)] total_utility <- uval_56 + uval_67 + uval_78 + uval_910 + uval_1011 + uval_1112 + uval_89 } else { total_utility <- 10000000 } total_utility } ## Using the GA package: ga_result2 <- ga( type = "real-valued", fitness = function(offpeak_data, peak_data, x) { total_utility <- -fitness_func( offpeak_data, peak_data, x[1], # mdp, x[2], # h56p, x[3], # h67p, x[4], # h78p, x[5], # h910p, x[6], # h1011p, x[7] # h1112p ) total_utility }, offpeak_data = TD_OffPeak2, peak_data = TD_Peak2, lower = c(0, 0, 0, 0, 0, 0, 0), upper = c(0.54, 0.09, 0.09, 0.09, 0.09, 0.09, 0.09), popSize = 50, maxiter = 100, monitor = TRUE ) GA | iter = 1 | Mean = -26971157 | Best = -10000000 GA | iter = 2 | Mean = -17364812 | Best = -10000000 GA | iter = 3 | Mean = -11135468 | Best = -10000000 GA | iter = 4 | Mean = -10567804 | Best = -10000000 GA | iter = 5 | Mean = -10568223 | Best = -10000000 GA | iter = 6 | Mean = -11130456 | Best = -10000000 GA | iter = 7 | Mean = -1e+07 | Best = -1e+07 GA | iter = 8 | Mean = -1e+07 | Best = -1e+07 GA | iter = 9 | Mean = -1e+07 | Best = -1e+07 GA | iter = 10 | Mean = -10563539 | Best = -10000000 GA | iter = 11 | Mean = -11129491 | Best = -10000000 GA | iter = 12 | Mean = -1e+07 | Best = -1e+07 GA | iter = 13 | Mean = -10565386 | Best = -10000000 GA | iter = 14 | Mean = -10564288 | Best = -10000000 GA | iter = 15 | Mean = -1e+07 | Best = -1e+07 GA | iter = 16 | Mean = -1e+07 | Best = -1e+07 GA | iter = 17 | Mean = -1e+07 | Best = -1e+07 GA | iter = 18 | Mean = -11129238 | Best = -10000000 GA | iter = 19 | Mean = -1e+07 | Best = -1e+07 GA | iter = 20 | Mean = -10566658 | Best = -10000000 GA | iter = 21 | Mean = -10566871 | Best = -10000000 GA | iter = 22 | Mean = -1e+07 | Best = -1e+07 GA | iter = 23 | Mean = -1e+07 | Best = -1e+07 GA | iter = 24 | Mean = -1e+07 | Best = -1e+07 GA | iter = 25 | Mean = -10564532 | Best = -10000000 GA | iter = 26 | Mean = -1e+07 | Best = -1e+07 GA | iter = 27 | Mean = -1e+07 | Best = -1e+07 GA | iter = 28 | Mean = -1e+07 | Best = -1e+07 GA | iter = 29 | Mean = -1e+07 | Best = -1e+07 GA | iter = 30 | Mean = -1e+07 | Best = -1e+07 GA | iter = 31 | Mean = -1e+07 | Best = -1e+07 GA | iter = 32 | Mean = -10565518 | Best = -10000000 GA | iter = 33 | Mean = -1e+07 | Best = -1e+07 GA | iter = 34 | Mean = -10564593 | Best = -10000000 GA | iter = 35 | Mean = -1e+07 | Best = -1e+07 GA | iter = 36 | Mean = -10565003 | Best = -10000000 GA | iter = 37 | Mean = -10567136 | Best = -10000000 GA | iter = 38 | Mean = -1e+07 | Best = -1e+07 GA | iter = 39 | Mean = -1e+07 | Best = -1e+07 GA | iter = 40 | Mean = -1e+07 | Best = -1e+07 GA | iter = 41 | Mean = -11132602 | Best = -10000000 GA | iter = 42 | Mean = -1e+07 | Best = -1e+07 GA | iter = 43 | Mean = -1e+07 | Best = -1e+07 GA | iter = 44 | Mean = -1e+07 | Best = -1e+07 GA | iter = 45 | Mean = -1e+07 | Best = -1e+07 GA | iter = 46 | Mean = -11133596 | Best = -10000000 GA | iter = 47 | Mean = -1e+07 | Best = -1e+07 GA | iter = 48 | Mean = -1e+07 | Best = -1e+07 GA | iter = 49 | Mean = -1e+07 | Best = -1e+07 GA | iter = 50 | Mean = -10563668 | Best = -10000000 GA | iter = 51 | Mean = -1e+07 | Best = -1e+07 GA | iter = 52 | Mean = -1e+07 | Best = -1e+07 GA | iter = 53 | Mean = -1e+07 | Best = -1e+07 GA | iter = 54 | Mean = -1e+07 | Best = -1e+07 GA | iter = 55 | Mean = -1e+07 | Best = -1e+07 GA | iter = 56 | Mean = -1e+07 | Best = -1e+07 GA | iter = 57 | Mean = -1e+07 | Best = -1e+07 GA | iter = 58 | Mean = -1e+07 | Best = -1e+07 GA | iter = 59 | Mean = -1e+07 | Best = -1e+07 GA | iter = 60 | Mean = -1e+07 | Best = -1e+07 GA | iter = 61 | Mean = -10564274 | Best = -10000000 GA | iter = 62 | Mean = -1e+07 | Best = -1e+07 GA | iter = 63 | Mean = -10566723 | Best = -10000000 GA | iter = 64 | Mean = -1e+07 | Best = -1e+07 GA | iter = 65 | Mean = -1e+07 | Best = -1e+07 GA | iter = 66 | Mean = -11133478 | Best = -10000000 GA | iter = 67 | Mean = -10565362 | Best = -10000000 GA | iter = 68 | Mean = -1e+07 | Best = -1e+07 GA | iter = 69 | Mean = -1e+07 | Best = -1e+07 GA | iter = 70 | Mean = -1e+07 | Best = -1e+07 GA | iter = 71 | Mean = -1e+07 | Best = -1e+07 GA | iter = 72 | Mean = -10565288 | Best = -10000000 GA | iter = 73 | Mean = -1e+07 | Best = -1e+07 GA | iter = 74 | Mean = -11132318 | Best = -10000000 GA | iter = 75 | Mean = -1e+07 | Best = -1e+07 GA | iter = 76 | Mean = -11701470 | Best = -10000000 GA | iter = 77 | Mean = -11131800 | Best = -10000000 GA | iter = 78 | Mean = -10564773 | Best = -10000000 GA | iter = 79 | Mean = -10567488 | Best = -10000000 GA | iter = 80 | Mean = -1e+07 | Best = -1e+07 GA | iter = 81 | Mean = -1e+07 | Best = -1e+07 GA | iter = 82 | Mean = -1e+07 | Best = -1e+07 GA | iter = 83 | Mean = -1e+07 | Best = -1e+07 GA | iter = 84 | Mean = -10564653 | Best = -10000000 GA | iter = 85 | Mean = -1e+07 | Best = -1e+07 GA | iter = 86 | Mean = -1e+07 | Best = -1e+07 GA | iter = 87 | Mean = -1e+07 | Best = -1e+07 GA | iter = 88 | Mean = -1e+07 | Best = -1e+07 GA | iter = 89 | Mean = -1e+07 | Best = -1e+07 GA | iter = 90 | Mean = -1e+07 | Best = -1e+07 GA | iter = 91 | Mean = -1e+07 | Best = -1e+07 GA | iter = 92 | Mean = -1e+07 | Best = -1e+07 GA | iter = 93 | Mean = -1e+07 | Best = -1e+07 GA | iter = 94 | Mean = -10564223 | Best = -10000000 GA | iter = 95 | Mean = -1e+07 | Best = -1e+07 GA | iter = 96 | Mean = -10567577 | Best = -10000000 GA | iter = 97 | Mean = -10566136 | Best = -10000000 GA | iter = 98 | Mean = -1e+07 | Best = -1e+07 GA | iter = 99 | Mean = -1e+07 | Best = -1e+07 GA | iter = 100 | Mean = -1e+07 | Best = -1e+07 Solution values ga_result2@solution x1 x2 x3 x4 x5 x6 x7 [1,] 0.16634145 0.04334977 0.03966984 0.04517375 0.04751721 0.04560775 0.05269130 [2,] 0.16687678 0.04621923 0.05054675 0.04705156 0.04730716 0.04867062 0.05250494 Problem and Questions I specified the constraint with an if statement in the function. But because of so many number of decimal places, the constraint condition is satisfied rarely. Ideally, the constraint should always be satisfied. How can I make sure that the constraint is satisfied and genetic algorithm ga function picks the values to decimal places only? |
Django: Include a html on ajax request Posted: 25 Aug 2021 08:29 AM PDT I am using Django as my Webframework togehter with Ajax for async calls. When a button is pressed I want an entire HTML file to be loaded in (like normal includes). This is the AJAX code: $.ajax({ url: "{% url 'project-detail' project_object.id %}", type: 'get', data: { ... }, success: function (response) { $("#div1").html("{% include 'projects/recommendations.html' %}") } }) As you can see I try to wrap {% include 'projects/recommendations.html' %} with ".". This unfortunatley doesnt work. As a work around I thought of reading the file in and output the string. As the to be included file is also relatively large ~150 LOC I try to avoid having it all in one file. Is there a way to neatly load this in? |
create a play/pause function inside a react component Posted: 25 Aug 2021 08:29 AM PDT I want to build a function similar to the play and pause button of videos, records and dp are both arrays for storing data. isOn is a part of rootState, on is a local hook, I tried to use them to control the loop, now I want to figure out a way to activate the loop to increment idx( also a part of rootState) , and pause the loop if needed. there are some posts regarding play/pause function for videos, but I feel those might not suit my component. function App() { const [on,setOn] = useState<boolean>(false); const dispatch = useAppDispatch(); const len = useAppSelector(state => state.length); const isOn = useAppSelector(state => state.isOn); const isOver = useAppSelector(state => state.isOver); const records = useAppSelector(state => state.records); const dp = useAppSelector(state => state.dp); const idx = useAppSelector(state => state.idx); const position = useAppSelector(state => state.position); const val = isOver?dp.length === 0?[-1,-1,-1,-1]:[dp[position],-1,-1,-1]:records[idx]; const chessBoard: number[][] = new Array(len).fill(-1).map(() => new Array(len).fill(-1) ); if (val[0] !== -1){ let v = val[0]; for (let i = 0; i < len; i++){ if (v === 0) break; chessBoard[i][v%10 - 1] = 1; v=~~(v/10); } } if (val[1] !== -1){ if (val[3] === 1){ chessBoard[val[1]][val[2]] = 1; }else{ chessBoard[val[1]][val[2]] = 0; } } function run(){ setOn(!on); function loop(on:boolean){ console.log(on); if (!on) return; if (on) dispatch(forward()); if (on){ setTimeout((on)=>loop(on),100);} } loop(on); } return ( <div className="App"> <Tiles board = {chessBoard}/> <Button onClick = {() => dispatch(backward())}>backward</Button> <Button onClick = {() => run()}>start</Button> <Button onClick = {() => dispatch(forward())}>forward</Button> <Button onClick = {() => dispatch(reset())}>reset</Button> <Button onClick = {() => dispatch(change())}>change</Button> </div> ); } |
D3js v4 Update pattern to filter graph multiple times, can not get nodes to correctly reset to original data Posted: 25 Aug 2021 08:29 AM PDT I am building a timeline with using a force directed graph where I am filtering events based on various event types and times. I am able to filter the graph successfully, but I want to recalculate the y position of the nodes (based on the d.eventLevel in the JSON data). When I recalculate the eventLevel (see the filter function) I get what looks like duplicate nodes in my data when I use the reset() function. You can trigger this behavior by running the example and filtering the dates on 1150 - 1200. Run the filter once, hit reset and then run the exact same filter a second time, hit reset. On the second reset I get the unexpected result. If I do not recalculate the eventLevel the graph filter and reset functions behave as I expect them to. Any help is appreciated. I'm still learning the ins and outs of d3js so this may not be the best way to accomplish what I'm hoping to accomplish. var graph = { "nodes": [ { "name": "Event mentioned by Nuʿaym b. Ḥammād.", "recid": "https://medievalmideast.org/place/14658", "label": "Event: before 843 CE<br \\/>Composition: c. 820-843 CE<br \\/>Manuscript: 687 A.H. / 1288-9 CE<br \\/>Edition: 1993", "eventType": "event", "date": "1-1-600", "startDate": "1-1-600", "endDate": "1-1-843", "displayType": "before", "display": "none", "position": "start", "level": "1", "eventLevel": "11", "eventID": "d4e212", "id": "d4e222a1100" }, { "name": "Event mentioned by Nuʿaym b. Ḥammād.", "recid": "https://medievalmideast.org/place/14658", "label": "Event: before 843 CE<br \\/>Composition: c. 820-843 CE<br \\/>Manuscript: 687 A.H. / 1288-9 CE<br \\/>Edition: 1993", "eventType": "event", "date": "1-1-843", "startDate": "1-1-600", "endDate": "1-1-843", "displayType": "before", "display": "end", "position": "end", "level": "1", "eventLevel": "11", "eventID": "d4e212", "id": "d4e222a1103" }, { "name": "Event mentioned by Nuʿaym b. Ḥammād.", "recid": "https://medievalmideast.org/place/14658", "label": "Composition: c. 820-843 CE", "eventType": "composition", "date": "1-1-815", "startDate": "1-1-815", "endDate": "1-1-843", "displayType": "circa", "display": "none", "position": "start", "level": "6", "eventLevel": "16", "eventID": "d4e212", "id": "d4e228a1100" }, { "name": "Event mentioned by Nuʿaym b. Ḥammād.", "recid": "https://medievalmideast.org/place/14658", "label": "Composition: c. 820-843 CE", "eventType": "composition", "date": "01-01-829", "startDate": "1-1-815", "endDate": "1-1-843", "displayType": "circa", "display": "point", "position": "center", "level": "6", "eventLevel": "16", "eventID": "d4e212", "id": "d4e228a1100c" }, { "name": "Event mentioned by Nuʿaym b. Ḥammād.", "recid": "https://medievalmideast.org/place/14658", "label": "Composition: c. 820-843 CE", "eventType": "composition", "date": "1-1-843", "startDate": "1-1-815", "endDate": "1-1-843", "displayType": "circa", "display": "none", "position": "end", "level": "6", "eventLevel": "16", "eventID": "d4e212", "id": "d4e228a1101" }, { "name": "Event mentioned by Nuʿaym b. Ḥammād.", "recid": "https://medievalmideast.org/place/14658", "label": "Manuscript: 687 A.H. / 1288-9 CE", "eventType": "manuscript", "date": "2-5-1288", "startDate": "2-5-1288", "endDate": "1-24-1289", "displayType": "between", "display": "start", "position": "start", "level": "3", "eventLevel": "13", "eventID": "d4e212", "id": "d4e234a1100" }, { "name": "Event mentioned by Nuʿaym b. Ḥammād.", "recid": "https://medievalmideast.org/place/14658", "label": "Manuscript: 687 A.H. / 1288-9 CE", "eventType": "manuscript", "date": "1-24-1289", "startDate": "2-5-1288", "endDate": "1-24-1289", "displayType": "between", "display": "end", "position": "end", "level": "3", "eventLevel": "13", "eventID": "d4e212", "id": "d4e234a1101" }, { "name": "Event mentioned by Nuʿaym b. Ḥammād.", "recid": "https://medievalmideast.org/place/14658", "label": "Edition: 1993", "eventType": "edition", "date": "1-1-1993", "startDate": "1-1-1993", "endDate": "1-1-1993", "displayType": "point", "display": "point", "position": "start", "level": "4", "eventLevel": "14", "eventID": "d4e212", "id": "d4e240a1099" }, { "name": "Events mentioned by Michael the Syrian", "recid": "https://medievalmideast.org/place/14658", "label": "Event: before 1199<br \\/>Composition: 1195-1199?<br \\/>Manuscript: 1598<br \\/>Edition: 2009", "eventType": "event", "date": "1-1-600", "startDate": "1-1-600", "endDate": "1-1-1199", "displayType": "before", "display": "none", "position": "start", "level": "1", "eventLevel": "21", "eventID": "d4e245", "id": "d4e255a1100" }, { "name": "Events mentioned by Michael the Syrian", "recid": "https://medievalmideast.org/place/14658", "label": "Event: before 1199<br \\/>Composition: 1195-1199?<br \\/>Manuscript: 1598<br \\/>Edition: 2009", "eventType": "event", "date": "1-1-1199", "startDate": "1-1-600", "endDate": "1-1-1199", "displayType": "before", "display": "end", "position": "end", "level": "1", "eventLevel": "21", "eventID": "d4e245", "id": "d4e255a1103" }, { "name": "Events mentioned by Michael the Syrian", "recid": "https://medievalmideast.org/place/14658", "label": "Composition: 1195-1199?", "eventType": "composition", "date": "1-1-1195", "startDate": "1-1-1195", "endDate": "1-1-1199", "displayType": "circa", "display": "none", "position": "start", "level": "6", "eventLevel": "26", "eventID": "d4e245", "id": "d4e261a1100" }, { "name": "Events mentioned by Michael the Syrian", "recid": "https://medievalmideast.org/place/14658", "label": "Composition: 1195-1199?", "eventType": "composition", "date": "01-01-1197", "startDate": "1-1-1195", "endDate": "1-1-1199", "displayType": "circa", "display": "point", "position": "center", "level": "6", "eventLevel": "26", "eventID": "d4e245", "id": "d4e261a1100c" }, { "name": "Events mentioned by Michael the Syrian", "recid": "https://medievalmideast.org/place/14658", "label": "Composition: 1195-1199?", "eventType": "composition", "date": "1-1-1199", "startDate": "1-1-1195", "endDate": "1-1-1199", "displayType": "circa", "display": "none", "position": "end", "level": "6", "eventLevel": "26", "eventID": "d4e245", "id": "d4e261a1101" }, { "name": "Events mentioned by Michael the Syrian", "recid": "https://medievalmideast.org/place/14658", "label": "Manuscript: 1598", "eventType": "manuscript", "date": "1-1-1598", "startDate": "1-1-1598", "endDate": "1-1-1598", "displayType": "point", "display": "point", "position": "start", "level": "3", "eventLevel": "23", "eventID": "d4e245", "id": "d4e267a1099" }, { "name": "Events mentioned by Michael the Syrian", "recid": "https://medievalmideast.org/place/14658", "label": "Edition: 2009", "eventType": "edition", "date": "1-1-2009", "startDate": "1-1-2009", "endDate": "1-1-2009", "displayType": "point", "display": "point", "position": "start", "level": "4", "eventLevel": "24", "eventID": "d4e245", "id": "d4e273a1099" } ], "links": [ { "source": "d4e222a1100", "target": "d4e222a1103", "eventType": "event", "eventID": "d4e212", "linkType": "dashed" }, { "source": "d4e222a1103", "target": "d4e228a1100c", "eventType": "event", "eventID": "d4e212", "linkType": "solidNoArrow" }, { "source": "d4e228a1100", "target": "d4e228a1100c", "eventType": "composition", "eventID": "d4e212", "linkType": "dashed" }, { "source": "d4e228a1100c", "target": "d4e228a1101", "eventType": "composition", "eventID": "d4e212", "linkType": "dashed" }, { "source": "d4e228a1100c", "target": "d4e234a1101", "eventType": "composition", "eventID": "d4e212", "linkType": "solidNoArrow" }, { "source": "d4e234a1100", "target": "d4e234a1101", "eventType": "manuscript", "eventID": "d4e212", "linkType": "dashed" }, { "source": "d4e234a1101", "target": "d4e240a1099", "eventType": "manuscript", "eventID": "d4e212", "linkType": "solid" }, { "source": "d4e255a1100", "target": "d4e255a1103", "eventType": "event", "eventID": "d4e245", "linkType": "dashed" }, { "source": "d4e255a1103", "target": "d4e261a1100c", "eventType": "event", "eventID": "d4e245", "linkType": "solidNoArrow" }, { "source": "d4e261a1100", "target": "d4e261a1100c", "eventType": "composition", "eventID": "d4e245", "linkType": "dashed" }, { "source": "d4e261a1100c", "target": "d4e261a1101", "eventType": "composition", "eventID": "d4e245", "linkType": "dashed" }, { "source": "d4e261a1100c", "target": "d4e267a1099", "eventType": "composition", "eventID": "d4e245", "linkType": "solid" }, { "source": "d4e267a1099", "target": "d4e273a1099", "eventType": "manuscript", "eventID": "d4e245", "linkType": "solid" } ] }; //Set visualization variables var margin = { top: 30, right: 30, bottom: 30, left: 30 }, width = 800 - margin.left - margin.right, height = 500 - margin.top - margin.bottom, radius = 6, store = $.extend(true, {}, graph); filteredData = $.extend(true, {}, graph); // create a list of keys var keys =["event", "composition", "manuscript", "edition"] //Colors based on above keys var color = d3.scaleOrdinal().domain(keys).range(d3.schemeCategory20); //filtered types typeFilterList = []; //filter button event handlers $(".filter-btn").on("click", function() { var type = $('select#filterMenu option:selected').val(); var start = $('input#filterStart').val(); var end = $('input#filterEnd').val(); filter(type, start, end); update(); }); //Reset filtered graph $(".reset").on("click", function() { reset(); update(); }); /* Time format */ var parseTime = d3.timeParse("%m-%d-%Y"); /* Simulation */ var simulation = d3.forceSimulation().force("link", d3.forceLink().id(function (d) { return d.id; })) .force("charge", d3.forceManyBody()) .force("center", d3.forceCenter(width / 2, height / 2)); /* SVG */ var svg = d3.select('#vis').append('svg').attr("width", width).attr("height", height + margin.top + margin.bottom); var chart = svg.append('g').attr('class', 'listener-rect').attr("width", width).attr("height", height + margin.top + margin.bottom).style('opacity', 1); //Set up node/link for update pattern var link = chart.append("g").attr('class', 'links').selectAll(".link"); var node = chart.append("g").attr('class', 'node-group').selectAll(".node"); var label = chart.append('g').attr('class', 'label').selectAll(".label"); /* Scales */ /* ====== */ /* xScale */ var xDomain = d3.extent(filteredData.nodes, function (d) { return parseTime(d.date); }); var xScale = d3.scaleTime() .domain(xDomain) .range([margin.right, (width - margin.left)]).nice(); /* yScale */ var yDomain = d3.extent(filteredData.nodes, function (d) { return parseInt(d.eventLevel); }); var yScale = d3.scaleLinear() .domain([0, yDomain[1]]) .range([height, (margin.top + 25)]); /* Axes components */ /* --------------- */ var xAxis = d3.axisTop(xScale).tickSize(10).tickFormat(d3.timeFormat("%Y")).ticks(20); var xAxisBackground = d3.axisTop(xScale).tickSize(-(margin.top + height * + 3), 0, 0).tickFormat("").ticks(20); /* Axes draw */ /* --------- */ // Drawing the axis var xAxisDraw = chart.append('g') .attr('class', 'x axis') .call(xAxis); var xAxisBackgroundDraw = chart .append('g').attr('class', 'timeline-tick') .attr("opacity", ".15") .call(xAxisBackground); xAxisDraw.attr('transform', 'translate(0, ' + margin.top + ')'); xAxisBackgroundDraw.attr('transform', 'translate(0, ' + margin.top + ')'); update(); //general update pattern for updating the graph function update() { //Update Axis and scales xDomain = d3.extent(filteredData.nodes, function (d) {return parseTime(d.date);}); xScale = d3.scaleTime().domain(xDomain).range([margin.right, (width - margin.left)]).nice(); yDomain = d3.extent(filteredData.nodes, function (d) {return parseInt(d.eventLevel);}); yScale = d3.scaleLinear().domain([0, yDomain[1]]).range([height, (margin.top + 25)]); // Semantically zoom and pan the axis xAxis.scale(xScale); xAxisDraw.call(xAxis); xAxisBackground.scale(xScale); xAxisBackgroundDraw.call(xAxisBackground); // UPDATE link = link.data(filteredData.links, function(d) { return d.id;}); // EXIT link.exit().remove(); // ENTER var newLink = link.enter() .append("line") .attr("class", function (d) { return d.linkType }) .style("stroke-dasharray", function (d) { ("3,3") }); // ENTER + UPDATE link = link.merge(newLink); //define group and join node = node.data(filteredData.nodes, function(d) { return d.id;}); //exit, remove node.exit().remove(); //enter var newNode = node.enter().append("g") .attr("class", function (d) { if (d.display === 'none') { return d.position; } else { return d.display; } }); newNode.append("circle") .attr("r", radius) .attr("stroke", function (d) { return d3.rgb(color(d.eventType)).darker(); }) .attr("fill", function (d) { if (d.display === 'none') { return "white"; } else { return color(d.eventType); } }) .attr("opacity", function (d) { if (d.display === 'none') { return .1; } else { return 1; } }); //merge node = node.merge(newNode); // UPDATE // ENTER + UPDATE label = label.data(filteredData.nodes, function(d) { return d.id;}); // EXIT label.exit().remove(); // ENTER var newLabel = label.enter().append("g").attr("class", "labelText"); newLabel.filter(function(d) { return (d.eventType === 'event' && d.position === 'start' ) ; }) .append("text").attr("class", "labelText") .text(function (d) { return d.name; }); label = label.merge(newLabel); // update simulation nodes, links, and alpha simulation.nodes(filteredData.nodes).on("tick", ticked); simulation.force("link").links(filteredData.links); simulation.alpha(1).alphaTarget(0).restart(); } //tick event handler with bounded box function ticked() { //Reposition nodes on the timeline and yAxis filteredData.nodes.forEach (function (nodePos, i) { return nodePos.x = xScale(parseTime(nodePos.date)); }) filteredData.nodes.forEach (function (nodePos, i) { return nodePos.y = yScale(nodePos.eventLevel); }) //position links link.attr("x1", function (d) { return d.source.x; }).attr("y1", function (d) { return d.source.y; }).attr("x2", function (d) { return d.target.x; }).attr("y2", function (d) { return d.target.y; }); //position nodes node.attr("transform", function (d) { return "translate(" + d.x + "," + d.y + ")"; }) label.attr("transform", function (d) { return "translate(0," + d.y + ")"; }); //end tick } //Reset filtered graph function reset(){ //Reset form $('#filterForm')[0].reset(); //reset filterList typeFilterList = []; filteredData.nodes = []; filteredData.links = []; store.links.forEach(function(l) { filteredData.links.push(l); }); store.nodes.forEach(function(n) { filteredData.nodes.push(n); }); }; //Filter based on type and year, only accept full years function filter(type, start, end) { var parseTime = d3.timeParse("%m-%d-%Y"); var parseYear = d3.timeParse("%Y"); //Add matching point matching time and time restrictions to typeFilterList typeFilterList = []; filteredData.nodes.forEach(function(n) { var id = n.eventID if(n.eventType === type){ if((parseYear(start) != null && parseYear(end) == null) && (parseTime(n.date) >= parseYear(start))) { typeFilterList.push(id); } else if((parseYear(start) == null && parseYear(end) != null) && (parseTime(n.date) <= parseYear(end))) { typeFilterList.push(id); } else if((parseYear(start) != null && parseYear(end) != null) && (n.displayType === 'point') && parseTime(n.date) >= parseYear(start) && parseTime(n.date) <= parseYear(end)){ typeFilterList.push(id); } else if(((parseTime(n.date) >= parseYear(start) && parseTime(n.date) <= parseYear(end)) || (parseYear(start) >= parseTime(n.startDate) && parseYear(end) <= parseTime(n.endDate)))) { typeFilterList.push(id); } } //end forEach loop }); //add and remove links from data based on availability of nodes store.links.forEach(function(l) { if (!typeFilterList.includes(l.eventID)) { filteredData.links.forEach(function(d, i) { if (l.eventID === d.eventID) { filteredData.links.splice(i, 1); } }); } }); store.nodes.forEach(function(n) { if (!typeFilterList.includes(n.eventID)) { filteredData.nodes.forEach(function(d, i) { if (n.eventID === d.eventID) { filteredData.nodes.splice(i, 1); } }); } else { filteredData.nodes.forEach(function(d, i) { if (n.eventID === d.eventID) { //Update eventLevel so filtered events are closer together var eventID = d.eventID var level = d.level var index = typeFilterList.indexOf(d.eventID); d.eventLevel = ((index + 1) * 10) + parseInt(d.level); } }); } }); } #eventVis { text-align: center; } #vis { max-height: 500px; border: 1px solid #eee; padding: 20px; overflow-y: scroll; } #vis::-webkit-scrollbar { -webkit-appearance: none; width: 7px; } #vis::-webkit-scrollbar-thumb { border-radius: 4px; background-color: rgba(0, 0, 0, .5); -webkit-box-shadow: 0 0 1px rgba(255, 255, 255, .5); } .labelText { font-weight: normal; } .links line { stroke: #666666; } .links line.dashed { stroke: #666666; stroke-opacity: 0.5; stroke-dasharray: 3, 3; } <script src="https://cdnjs.cloudflare.com/ajax/libs/d3/4.13.0/d3.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <div id="eventVis"> <h3>Event Timeline</h3> <div> <form id="filterForm"> <input id="filterStart" name="start" /> to <input id="filterEnd" name="end" /> <select name="filterMenu" id="filterMenu"> <option value="composition">Composition</option> </select> <button type="button" class="filter-btn">Filter</button> <button type="button" class="reset" id="resetGraph">Reset</button> </form> </div> <div id="vis"></div> </div> |
Angular 12 routing issue with slash in path Posted: 25 Aug 2021 08:29 AM PDT I've got a problem with Angular 12.2.2 application's routing. Basically it seems like for some reason I cannot use '/' in path. If my routes definition looks like the one below everything works fine when I go to http://localhost:4200/home const appRoutes: Routes = [ { path: 'home', component: WelcomeComponent }, ] But when I define it like const appRoutes: Routes = [ { path: 'home/something', component: WelcomeComponent }, ] or const appRoutes: Routes = [ { path: 'home/:something', component: WelcomeComponent }, ] and go to http://localhost:4200/home/something I get blank page and following errors in browser's console: GET http://localhost:4200/home/runtime.js net::ERR_ABORTED 404 (Not Found) something:1 GET http://localhost:4200/home/polyfills.js net::ERR_ABORTED 404 (Not Found) something:1 GET http://localhost:4200/home/styles.js net::ERR_ABORTED 404 (Not Found) something:1 GET http://localhost:4200/home/scripts.js net::ERR_ABORTED 404 (Not Found) something:1 GET http://localhost:4200/home/vendor.js net::ERR_ABORTED 404 (Not Found) something:1 GET http://localhost:4200/home/main.js net::ERR_ABORTED 404 (Not Found) something:1 Do you have an idea what is the reason of this behavior? |
Flutter cannot show JSON image on ListTile Posted: 25 Aug 2021 08:30 AM PDT I am parsing the informations like texts or titles without any problem but when I try to show a JSON image in ListTile I am getting this error on emulator: Invalid argument, No host specified in URL When I test it in console I can see the URL is correct. child: ListTile( title: Text( 'Title: ${articles[index].title}', ), subtitle: Text('Category: ${articles[index].category?.name}'), trailing: Image.network('articles[index].imageUrl'), onTap: () { Navigator.push( |
Crud GET: React js axios Posted: 25 Aug 2021 08:29 AM PDT I'm currently working on a personal project and I had an issue Im trying to getAll the cars data from my database using reactjs and axios so in the console I get all of them but in my page no, it was blank. knowing that working in the server side. Here is the code : Component.jsx constructor(props) { super(props); this.onChangeName = this.onChangeName.bind(this); this.onChangeModel = this.onChangeModel.bind(this); this.retrieveCars = this.retrieveCars.bind(this); this.saveCar = this.saveCar.bind(this); this.newCar = this.newCar.bind(this); this.state = { idCars: null, carName: "", carModel: "", cars: [], submitted: false }; } componentDidMount() { this.retrieveCars(); } retrieveCars() { DataService.getAll() .then(response => { this.setState({ carsList: response.data }); console.log(response.data); }) .catch(e => { console.log(e); }); } render() { const { cars } = this.state; return ( <div > <h2>List of cars</h2> <ul className="list-group"> { cars.map(data => ( <li> {data.carName} </li> ))} </ul> <button className="m-3 btn btn-sm btn-danger" onClick={this.retrieveCars} > display All </button> DataService.js getAll() { return http.get("/get"); } http.js export default axios.create({ baseURL: "http://localhost:3000/api", headers: { "Content-type": "application/json", "Access-Control-Allow-Origin" : "*", "Access-Control-Allow-Methods": "GET,PUT,POST,PATCH,DELETE", "Access-Control-Allow-Headers": "Origin, X-Requested-With, Content-Type, Accept" } }); Please can someone guide me to fix this issue |
Add or multiply any size of integer in a vector using SIMD Posted: 25 Aug 2021 08:30 AM PDT someone can give me a little help with 1 problem, I'm trying to learn Assembly and I don't understand how to solve this problem: Using SIMD instructions and pure assembly, make a function to add efficiently any size of integer vectors or Using SIMD instructions and pure assembly, make a function to multiply efficiently any size of integer vectors Thanks ! |
How to regain sudo permissions? Posted: 25 Aug 2021 08:29 AM PDT I'm using WSL1 and at some point I did something that means I can no longer use the 'sudo' command at all (unfortunately, I can't remember what I did or when that caused this issue but it definitely used to work – I'm very new to all this, so apologies!). When I run anything beginning with 'sudo' I get the following errors: sudo: /etc/sudoers is owned by uid 1000, should be 0 sudo: no valid sudoers sources found, quitting sudo: unable to initialize policy plugin I've spent a while looking for solutions but nothing seems to work so far. E.g. I've tried using pkexec visudo But anything like that throws this error: Error getting authority: Error initializing authority: Could not connect: No such file or directory I saw another thread that suggested going into the Windows command line and entering the following: wsl -u root But that simply returns User not found. Is there any way to get back my sudo permissions or have I done something that's unsalvageable, requiring me to uninstall WSL and start again? Thanks. |
How do we access an output @Output on ngOnInit in Angular? Posted: 25 Aug 2021 08:30 AM PDT I have dataServiceEvent output from Component B to Component A , How do I get or access the dataServiceEvent data inside ngOnit on Component A ? I can access it outside ngOinit as function but I wanna access it inside ngOnit cause I wanna use the data from dataServiceEvent as params to getListOfDeals . Thanks for any help or idea. Regards. #Component A ts code ngOnInit(): void { //access the dataServiceEvent here this.getListOfDeals() } // I can access it here but I want to access the data on ngOnInit dataServiceEvent(item: any) { this.tableElements = item; // this.getListOfDeals(); } private getListOfDeals() { this.searchInput = ''; this.isLoading = true; console.log("getting deals") this.dealService .getAllDeals( this.accountId, this.transaction.id, this.tableElements.pageIndex + 1, this.tableElements.pageSize, this.searchInput, this.tableElements.sortParams = ['name'], this.tableElements.sortDirs = ['asc'] ) .pipe(finalize(() => (this.isLoading = false))) .subscribe({ error: (err) => this.notificationService.showError(err), next: (res) => { // this.dealsListData[totalElements] = res.items.length; this.dealsListData = res.totalItemCount; this.dealsListData = res.lastItemOnPage; this.dealsListData = res.items; console.log('res', this.dealsListData); }, complete: noop, }); } #Component A html code <app-table-multi-sort (dataServiceEvent)="dataServiceEvent($event)" [tableOptions]="tableOptions" [tableData]="dealsListData" (tableActionsEvent)="tableActions($event)"></app-table-multi-sort> #Component B code - dataServiceEvent is the Output from this Component To Component A export class TableMultiSortComponent implements OnInit { @Output() dataServiceEvent = new EventEmitter<any>() ; @Input() tableOptions:any; @Input() tableData:any = []; @Input() isClientSide:boolean = false; @Input() isLoading: boolean = false; @Output() tableActionsEvent = new EventEmitter<any>(); @ViewChild(MatMultiSort, { static: false }) sort: MatMultiSort; tableConfig: any = TABLE_MULTI_SORT_OPTIONS.DEFAULT; table:TableData<any>; displayedColumns: any; constructor() { } ngOnInit(): void { this.initTableMultiSort(); } initTableMultiSort(){ this.tableConfig = { ...this.tableConfig, ...this.tableOptions } this.table = new TableData<any>(this.tableConfig.columns,this.tableConfig.sortParams); this.table.pageSize = this.tableConfig.pageSize; this.table.pageIndex = this.tableConfig.pageIndex; this.table.nextObservable.subscribe(() => { this.getData(); }); this.table.sortObservable.subscribe(() => { this.getData(); }); this.table.previousObservable.subscribe(() => { this.getData(); }); this.table.sizeObservable.subscribe(() => { this.getData(); }); setTimeout(()=>{ this.table.dataSource = new MatMultiSortTableDataSource(this.sort, this.isClientSide); this.getData(); },0); } ngOnChanges(changes: SimpleChanges) { if (changes.tableData && changes.tableData.currentValue){ this.initTableMultiSort() } } getData(){ //Todo: get totalelement, pageindex, pagesize from api service response this.table.totalElements = 1; this.table.pageIndex = 0; this.table.pageSize = 10; this.table.data = this.tableData; if(this.dataServiceEvent) { this.dataServiceEvent.emit(this.table); } } |
split based on the last dot and create a new column with the last part of the string Posted: 25 Aug 2021 08:29 AM PDT I have a file with 2 columns. In the first column, there are several strings (IDs) and in the second values. In the strings, there are a number of dots that can be variable. I would like to split these strings based on the last dot. I found in the forum how remove the last past after the last dot, but I don't want to remove it. I would like to create a new column with the last part of the strings, using bash command (e.g. awk) Example of strings: 5_8S_A.3-C_1.A 50 6_FS_B.L.3-O_1.A 20 H.YU-201.D 80 UI-LP.56.2011.A 10 Example of output: 5_8S_A.3-C_1 A 50 6_FS_B.L.3-O_1 A 20 H.YU-201 D 80 UI-LP.56.2011 A 10 I tried to solve it by using the following command but it works if I have just 1 dot in the string: awk -F' ' '{{split($1, arr, "."); print arr[1] "\t" arr[2] "\t" $2}}' file.txt |
Binding data from a library to XAML Posted: 25 Aug 2021 08:29 AM PDT I'm working on a project that uses ModernWPF. I want to bind the TitleBar.Background to GetBG. Here's my code: using System.Windows.Documents; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Imaging; using System.Windows.Navigation; using System.Windows.Shapes; using ModernWpf; namespace TestApp.Desktop { /// <summary> /// Interaction logic for MainWindow.xaml /// </summary> public partial class MainWindow : Window { public MainWindow() { InitializeComponent(); Color GetBG() { var bc = new BrushConverter(); if (ModernWpf.ThemeManager.GetRequestedTheme(window).ToString() == "Black" || ModernWpf.ThemeManager.GetRequestedTheme(window).ToString() == "Dark") { return (Color)ColorConverter.ConvertFromString("#1E1E1E"); } else { return (Color)ColorConverter.ConvertFromString("#E6E6E6"); } } } } } <Window x:Name="window" x:Class="OpenRelease.Desktop.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:local="clr-namespace:TestApp" mc:Ignorable="d" ui:ThemeManager.RequestedTheme="Light" <!---Here's where i want to use the binding.---> ui:TitleBar.Background="{GetBG}" ui:TitleBar.IsIconVisible="False" ui:ThemeManager.IsThemeAware="True" xmlns:ui="http://schemas.modernwpf.com/2019" ui:WindowHelper.UseModernWindowStyle="True" Title="TestApp" Height="850" Width="1260"> <Grid> </Grid> Edit, I renamed GetBG and made it public in the MainWindow.cs file: public Color ThemeAwareBackground() { var bc = new BrushConverter(); if (ModernWpf.ThemeManager.GetRequestedTheme(window).ToString() == "Black" || ModernWpf.ThemeManager.GetRequestedTheme(window).ToString() == "Dark") { return (Color)ColorConverter.ConvertFromString("#1E1E1E"); } else { return (Color)ColorConverter.ConvertFromString("#E6E6E6"); } } Thanks. |
deploying flask with gunicorn Posted: 25 Aug 2021 08:29 AM PDT I have made a flask api and I run it using python manage.py run in the command line, Now I want to deploy it to heroku, how do I convert python manage.py run to web:gunicorn wsgi:app as required in Procfile. My folder structure is like this . ├── app |--main |--controller |--model |--service |--__init__.py |--config.py |--test |--__init__.py |--manage.py ├── Procfile ├── requirements.txt ├── wsgi.py manage.py import unittest from flask_script import Manager, Server from main.config import config_by_name from main import create_app config = config_by_name['dev'] app = create_app('dev') app.app_context().push() manager = Manager(app) @manager.command def run(): app.run() @manager.command def test(): """Runs the unit tests.""" tests = unittest.TestLoader().discover('app/test', pattern='test*.py') result = unittest.TextTestRunner(verbosity=2).run(tests) if result.wasSuccessful(): return 0 return 1 if __name__ == '__main__': manager.run() wsgi.py from app import manage if __name__ == "__main__": manage.run() when I deploy it to heroku Im getting this error Application error An error occurred in the application and your page could not be served. If you are the application owner, check your logs for details. You can do this from the Heroku CLI with the command heroku logs --tail I checked in logs but there I found no error -----> Building on the Heroku-20 stack -----> Using buildpack: heroku/python -----> Python app detected -----> No Python version was specified. Using the same version as the last build: python-3.9.6 To use a different version, see: https://devcenter.heroku.com/articles/python-runtimes -----> No change in requirements detected, installing from cache -----> Using cached install of python-3.9.6 -----> Installing pip 20.2.4, setuptools 47.1.1 and wheel 0.36.2 -----> Installing SQLite3 -----> Installing requirements with pip -----> Discovering process types Procfile declares types -> web -----> Compressing... Done: 61.9M -----> Launching... Released v10 https://earnitapi.herokuapp.com/ deployed to Heroku Thanks for the help |
New folders made inside flask static folder are not detected in git control but new files are detected Posted: 25 Aug 2021 08:30 AM PDT I am making a simple flask app that requires a file output.jpg file in static/images/ folder. After testing the app locally, I pushed to production, but the app kept timing out. On further inspection, I came to realize that the app was looking for the file, but the parent folder images/ was not present in static/ or anywhere else. When I check the repo on github, the folder is not present there. The folder is present locally. I tried renaming the folder and did a git status check and got clean working tree. I tried creating other folders with other names in the same static folder, but none of them showed up on git status check. At the same location there is a styles/ folder which is added to git. Creating a folder in any subfolders in static/ , including in styles makes them invisible to git. Interestingly, when a regular file is created in static and any subfolders in it, the file will show up in git as untracked. At this point I am at my wit's end. I can't figure out how to fix this because I don't know what is causing it. My .gitignore : *.vscode/ *.json !*products.json *.p *.jpg *.png !overlay.png *__pycache__/ .venv randomimage.py *.txt *.log *.checkpoint instagram.py Folder tree: . ├── templates │ └── index.html ├── static │ ├── styles │ │ └── index.css │ ├── __pycache__ │ │ └── __init__.cpython-39.pyc │ ├── __init__.py │ └── images ├── server.py ├── __pycache__ │ ├── server.cpython-39.pyc │ ├── __init__.cpython-39.pyc │ └── dreambubble.cpython-39.pyc ├── __init__.py ├── dreambubble.py └── data ├── temp.png ├── settings.p ├── __pycache__ │ └── __init__.cpython-39.pyc ├── products.json ├── overlay.png ├── output.jpg ├── __init__.py ├── history.p └── chosen_product.p |
How to host multiple websites on different folders on a VPS? Posted: 25 Aug 2021 08:31 AM PDT I have a domain1.com pointing to my VPS server (I just specified the IP address in an A entry). More specifically the domain1.com is pointing to folder /var/www/html of my VPS. I want to host another website on this VPS with domain name: domain2.com My idea is to create a new directory: /var/www/html2 , put the code of the new website in it, and then to redirect domain2.com to this folder. But, I don't see how to do this by adding a A (DNS) entry. Also, is there not a solution to work with .htaccess ? |
Android Kernel Compiling - cp: cannot create regular file '..img/zImage': No such file or directory error Posted: 25 Aug 2021 08:29 AM PDT I'm trying to compile kernel from source but I'm facing a simple problem which is annoying. My enviroment: Ubuntu 18.04 x86_64 / Kernel source ver: 3.0.40 / CC: arm-linux-androideabi-4.8 when i try to get kernel image with "make" I'm getting this output: SHIPPED arch/arm/boot/compressed/lib1funcs.S AS arch/arm/boot/compressed/lib1funcs.o LD arch/arm/boot/compressed/vmlinux OBJCOPY arch/arm/boot/zImage Kernel: arch/arm/boot/zImage is ready => zImage, copy to ../img/zImage cp: cannot create regular file '../img/zImage': No such file or directory /home/username/Desktop/KERNEL/src/arch/arm/boot/Makefile:58: recipe for target 'arch/arm/boot/zImage' failed make[1]: *** [arch/arm/boot/zImage] Error 1 /home/username/Desktop/KERNEL/src/arch/arm/Makefile:280: recipe for target 'zImage' failed make: *** [zImage] Error 2 Image file is creating in arch/arm/boot/ directory but it has lock icon on it. What i tried? I tried to compile as superuser (same error) can someone help me about that? |
Mongodb update pipeline update a field of a element inside a nested array Posted: 25 Aug 2021 08:30 AM PDT I have a collection that contains objects such as this. { materials: { "m1": { inventory: [ { price: 100, amount: 65 } ] } } } As you can see inventory is an array deep inside the hierarchy. I want to update the amount field of it. From the client I receive the material id ("m1" ) and the inventory index (0 ). I have to use an update pipeline because I am setting and unsetting some other fields in this document. This is what I tried: await products.findOneAndUpdate(filters, [ { $set: { "materials.m1.inventory.0.amount": 100, }, }, ]); But it creates a new field named 0 inside the 0th element and sets the amount inside that object. So the resulting document looks like this. { materials: { "m1": { inventory: [ { 0: { amount: 100 } price: 100, amount: 65 } ] } } } Whereas what I want is this: { materials: { "m1": { inventory: [ { price: 100, amount: 100 } ] } } } The only way for me to identify which element in the array to update is the index of it. I am using nodejs mongodb driver. How to write the $set stage for this update pipeline? |
How to highlight on words of content editable area text without affecting its structure like paragraph Posted: 25 Aug 2021 08:29 AM PDT Am creating a simple spelling correction website but I have managed to deal with the backend and I can get suggestions for a specific word but the main problem is the frontend. I want to borrow the idea of https://languagetool.org/ of highlighting the word that has been spelled wrongly by adding a floating div with a bottom border, transparent color, and negative z-index by finding the position of the word in text var editor = document.querySelector("#sp-editor"); var myrange; $(".sp-editor").click(function (e) { var x = e.clientX - 30; var y = e.clientY - 15; $("#slp-dropdown").attr("style", "margin-left: " + x + "px; margin-top: " + y + "px"); var selection = window.getSelection(); if (!selection || selection.rangeCount < 1) return true; var range = selection.getRangeAt(0); var node = selection.anchorNode; var word_regexp = /^\w*$/; // Extend the range backward until it matches word beginning while ((range.startOffset > 0) && range.toString().match(word_regexp)) { range.setStart(node, (range.startOffset - 1)); } // Restore the valid word match after overshooting if (!range.toString().match(word_regexp)) { range.setStart(node, range.startOffset + 1); } // Extend the range forward until it matches word ending while ((range.endOffset < node.length) && range.toString().match(word_regexp)) { range.setEnd(node, range.endOffset + 1); } // Restore the valid word match after overshooting if (!range.toString().match(word_regexp)) { range.setEnd(node, range.endOffset - 1); } var word = range.toString(); checkClickedWord(word, range); }); function changeTextNode(word) { myrange.deleteContents(); myrange.insertNode(document.createTextNode(word)); $("#slp-dropdown").hide(); } function checkClickedWord(word, range) { if (word.length > 0) { $("#slp-dropdown").show(); myrange = range; } } .sp-editor{ height: 260px; } /* Style The Dropdown Button */ .word { cursor: pointer; } .word.underline{ border-bottom: 2px solid #3e8e41; } /* The container <div> - needed to position the dropdown content */ .dropdown { position: absolute; display: none; } .underline-text{ position: absolute; width: 160px; height: 30px; border-bottom: 2px solid #3e8e41; background-color: rgba(19, 180, 54, 0.2); z-index: -99; } /* Dropdown Content (Hidden by Default) */ .word-list { display: cancle; position: absolute; background-color: #f9f9f9; min-width: 160px; box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2); } /* Links inside the dropdown */ .word-list a { color: black; padding: 12px 16px; text-decoration: none; display: block; } /* Change color of dropdown links on hover */ .word-list a:hover { background-color: #f1f1f1; cursor: pointer; } /* Show the dropdown menu on hover */ .dropdown:hover .word-list { display: block; } <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <!doctype html> <html> <head> <meta charset="utf-8"> <meta content="width=device-width,initial-scale=1,minimal-ui" name="viewport"> <link rel="stylesheet" href="spelling.css"> </head> <body> <div class="container"> <div id="updating-indicator"></div><br> <div class="sp-editor-wrapper"> <!--DROPDOWNstyle="margin-left: 385px; margin-top: 68px"--> <div id="slp-dropdown" class="dropdown"> <div class="word-list"> <a onclick="changeTextNode('world')" class="item-word" href="#">world</a> <a onclick="changeTextNode('word')" class="item-word" href="#">word</a> <a onclick="changeTextNode('wood')" class="item-word" href="#">wood</a> </div> </div> <!-- <div id="underline-text" style="margin-left: 385px; margin-top: 30px" class="underline-text"></div> --> <!--DROPDOWN--> <div id="sp-editor" contenteditable="true" autocomplete="off" autocorrect="off" autocapiatlise="off" spellcheck="false" class="sp-editor"> The Project Gutenberg eBook of Alice's Adventures in Wonderland, by Lewis Carroll<br> <br> This eBook is for the use of anyone anywhere in the United States and most other parts of the world at no costs and with almost no restrections whatsoever. You may copy it, give it away or re-use it under the terms of the Project Gutenberg License included with this eBook or online at www.gutenberg.org. If you are not lokated in the United States, you will have to check the laws of the country where you are located before using this eBook. </div> </div> </div> </body> </html> . I have managed to handle replacing of words in the text in this JSfiddle https://jsfiddle.net/Lh3bxuo7/1/ that have been clicked on by the user but I need to find a way of highlighting target words in the text without affecting the paragraph and new lines and check if the clicked word is in the list of the marked words that are have been spelled wrongly like var wrongwords = ["restrections", "lokated"] and are supposed to be marked in text |
React: Infinite loop when using custom hook inside of useEffect? Posted: 25 Aug 2021 08:30 AM PDT I am trying to create a custom hook to wrap about Notistack (https://github.com/iamhosseindhv/notistack), a library for snackbars. My hook looks like this: import { useCallback } from 'react'; import { useSnackbar as useNotistackSnackbar } from 'notistack'; import { SNACKBAR_TYPES } from '../constants/properties'; const useSnackbar = () => { const { enqueueSnackbar } = useNotistackSnackbar(); const showSnackbarVariant = useCallback( ({ text, action_text, onActionClick, variant }) => enqueueSnackbar( { variant, text, action_text, onActionClick, }, { autoHideDuration: action_text && onActionClick ? 9000 : 4000 } ), [enqueueSnackbar] ); return { showSuccessSnackbar: ({ text, action_text, onActionClick }) => showSnackbarVariant({ variant: SNACKBAR_TYPES.SUCCESS, text, action_text, onActionClick, }), showErrorSnackbar: ({ text, action_text, onActionClick }) => showSnackbarVariant({ variant: SNACKBAR_TYPES.ERROR, text, action_text, onActionClick, }), showWarningSnackbar: ({ text, action_text, onActionClick }) => showSnackbarVariant({ variant: SNACKBAR_TYPES.WARNING, text, action_text, onActionClick, }), showDownloadSnackbar: ({ text, action_text, onActionClick }) => showSnackbarVariant({ variant: SNACKBAR_TYPES.DOWNLOAD, text, action_text, onActionClick, }), showPlainSnackbar: ({ text, action_text, onActionClick }) => showSnackbarVariant({ variant: SNACKBAR_TYPES.PLAIN, text, action_text, onActionClick, }), }; }; export default useSnackbar; I need to use it in 2 places: - outside of useEffect (but still within the component)
- inside of useEffect
However, even if I just add it as just a dependency on useEffect, it causes the infinite loop inside useEffect: export default function MyComponent() { const { showSuccessSnackbar, showErrorSnackbar } = useSnackbar(); const { mutate: activateConnectedAccount } = useCustomHook({ onSuccess: async () => { showSuccessSnackbar({ text: 'Direct deposit has been enabled.', }); }, onError: () => { showErrorSnackbar({ text: 'An error occurred. Please double check your bank information.', }); }, }); useEffect( () => { activateConnectedAccount() console.log("yooo"); }, [ // showSuccessSnackbar ] ); return ( <div> Foobar </div> ); } Codesandbox link: If you comment in line 30, it will cause the browser to freeze because it keeps running that loop https://codesandbox.io/s/currying-browser-5vomm?file=/src/MyComponent.js |
How can you force @google-cloud/datastore to use 'http' when you query your datastore emulator Posted: 25 Aug 2021 08:29 AM PDT I have a node + vuejs app from which I'm trying to query my local db (created using datastore emulator). My code is something like this const { Datastore } = require('@google-cloud/datastore') const datastore = new Datastore({ apiEndpoint: "http://localhost:<port>", projectId: <my_project_name> }) I then try to run one of the sample queries on Google's documentation My output shows there is a successful connection but then I get the following error in the console POST https://localhost:<port>/$rpc/google.datastore.v1.Datastore/RunQuery net::ERR_SSL_PROTOCOL_ERROR From the error, I see that it has changed http://localhost:<port> to https://localhost:<port> i.e it is forcing a protocol of https for my local host which then obviously fails. Is there something/option that I have to specify to ensure that it uses http when I'm making local calls or using the datastore emulator? |
How to reply to a existing message in Microsoft Teams channel via Rest API(incoming webhook)? Posted: 25 Aug 2021 08:29 AM PDT I am able to post a message to a team channel using incoming webhook(code sample below). What I am trying to achieve next is to reply to the same message whenever I have a new update. It's just a simple message in reply and need not to be conversational bot. I tried searching and found some options like teams bot and microsoft graph api. I wanted to know if there is a straightforward way to do it using incoming webhook or something else before exploring this options. import requests import json from urllib.request import Request, urlopen, URLError, HTTPError webhookurl = "https://factset.webhook.office.com/webhookb2/******************" message = { "@type": "MessageCard", "@context": "http://schema.org/extensions", "themeColor": "FF0000", "summary": "Event Happened", "sections": [ { "activityTitle": "Main Title", "activitySubtitle": "Sub title", "markdown": True, "facts": [ { "name": "Start Time (UTC)", "value": "2021-06-11 05:48:10" }, { "name": "Last Updated Time (UTC)", "value": "2021-06-11 06:16:15" } ] }, } req = Request(webhookurl, data=json.dumps(message).encode("utf-8"), headers={"content-type": "application/json"}) try: response = urlopen(req) response.read() except HTTPError as e: print("Request failed : ", e.code, e.reason) except URLError as e: print("Server connection failed: ", e.reason, e.reason) |
Discord Bot | Ranking (Leaderboard?) System with discord.js and MongoDB Posted: 25 Aug 2021 08:29 AM PDT I have a few questions to ask about a ranking (leaderboard...?) system in discord.js using MongoDB. I am following a tutorial made by CodeLyon for the setup of MongoDB, but afterwards I went ahead and created my own XP system. I know that I can sort the profile models, but I don't know how. Also, how would I give each profile model a rank? For example, if a user called Dummy was 5th on the list, how would I give him a rank of 5? Please read the parts after the code please, as well. Here are the files that I think are important: profileSchema.js: Creates profile model const mongoose = require('mongoose'); const profileSchema = new mongoose.Schema({ userID: { type: String, require: true, unique: true}, serverID: { type: String, require: true}, coins: { type: Number, default: 1000}, bank: { type: Number }, username: {type: String, require: true }, discriminator: { type: String, require: true }, xp: { type: Number, default: 1 }, xpShow: { type: Number }, level: { type: Number, default: 1}, xpReq: { type: Number} }) const model = mongoose.model('ProfileModels', profileSchema); module.exports = model; message.js: Message event require('dotenv').config(); const profileModel = require("../../models/profileSchema"); //create cooldowns map const cooldowns = new Map(); module.exports = async (Discord, client, message) => { const prefix = process.env.PREFIX; if (!message.content.startsWith(prefix) || message.author.bot) return; let profileData; try{ profileData = await profileModel.findOne({ userID: message.author.id }); if(!profileData){ let profile = await profileModel.create({ userID: message.author.id, serverID: message.guild.id, coins: 1000, bank: 0, username: message.author.username, discriminator: message.author.discriminator, xp: 1, xpShow: 1, level: 1, xpReq: 100, }); } }catch(err){ console.log(err); } try{ const levex = Math.floor(((Math.sqrt(2500 + (200 * profileData.xp))) - 50) / 100) + 1; const reqXP = levex * 100; const roundXP = 50 * (levex * (levex - 1)); const showXP = profileData.xp - roundXP; const response3 = await profileModel.findOneAndUpdate({ userID: message.author.id, }, { level: levex, xpShow: showXP, xpReq: reqXP, }); } catch(err){ console.log("------------------------------------------"); console.log(" ERROR (Probably an invalid variable)"); console.log("------------------------------------------"); console.log(err); } const args = message.content.slice(prefix.length).split(/ +/) const cmd = args.shift().toLowerCase(); const command = client.commands.get(cmd) || client.commands.find((a) => a.aliases && a.aliases.includes(cmd)); const validPermissions = [ "CREATE_INSTANT_INVITE", "KICK_MEMBERS", "BAN_MEMBERS", "ADMINISTRATOR", "MANAGE_CHANNELS", "MANAGE_GUILD", "ADD_REACTIONS", "VIEW_AUDIT_LOG", "PRIORITY_SPEAKER", "STREAM", "VIEW_CHANNEL", "SEND_MESSAGES", "SEND_TTS_MESSAGES", "MANAGE_MESSAGES", "EMBED_LINKS", "ATTACH_FILES", "READ_MESSAGE_HISTORY", "MENTION_EVERYONE", "USE_EXTERNAL_EMOJIS", "VIEW_GUILD_INSIGHTS", "CONNECT", "SPEAK", "MUTE_MEMBERS", "DEAFEN_MEMBERS", "MOVE_MEMBERS", "USE_VAD", "CHANGE_NICKNAME", "MANAGE_NICKNAMES", "MANAGE_ROLES", "MANAGE_WEBHOOKS", "MANAGE_EMOJIS", ] try{ if(command.permissions.length){ let invalidPerms = [] for(const perm of command.permissions){ if(!validPermissions.includes(perm)){ return console.log(`Invalid Permissions ${perm}`); } if(!message.member.hasPermission(perm)){ invalidPerms.push(perm); } } if (invalidPerms.length){ return message.channel.send(`Missing Permissions: \`${invalidPerms}\``); } } } catch (err){ console.log("------------------------------------------"); console.log(" ERROR (Probably an invalid command)"); console.log("------------------------------------------"); console.log(err); } // If cooldowns map doesn't have a command.name key then create one. try{ if(!cooldowns.has(command.name)){ cooldowns.set(command.name, new Discord.Collection()); } } catch (err) { return message.reply("my commands are limited. I can\'t find that command!"); } const current_time = Date.now(); const time_stamps = cooldowns.get(command.name); const cooldown_amount = (command.cooldown) * 1000; //If time_stamps has a key with the author's id then check the expiration time to send a message to a user. if(time_stamps.has(message.author.id)){ const expiration_time = time_stamps.get(message.author.id) + cooldown_amount; if(current_time < expiration_time){ const time_left = (expiration_time - current_time) / 1000; return message.reply(`Please wait ${time_left.toFixed(1)} more seconds before using ${command.name}`); } } //If the author's id is not in time_stamps then add them with the current time. time_stamps.set(message.author.id, current_time); //Delete the user's id once the cooldown is over. setTimeout(() => time_stamps.delete(message.author.id), cooldown_amount); try{ //execute command command.execute(client, message, cmd, args, Discord, profileData); } catch (err){ message.reply("There was an error trying to execute this command!"); console.log(err); } } I want to create a 'rank' profile variable in the profileSchema and profileData, then I want to set the rank of the user to this profile variable. If extra clarification is needed, please tell me in the comments below. |
How to retrieve well formatted JSON from AWS Lambda using Python Posted: 25 Aug 2021 08:30 AM PDT I have a function in AWS Lambda that connects to the Twitter API and returns the tweets which match a specific search query I provided via the event. A simplified version of the function is below. There's a few helper functions I use like get_secret to manage API keys and process_tweet which limits what data gets sent back and does things like convert the created at date to a string. The net result is that I should get back a list of dictionaries. def lambda_handler(event, context): twitter_secret = get_secret("twitter") auth = tweepy.OAuthHandler(twitter_secret['api-key'], twitter_secret['api-secret']) auth.set_access_token(twitter_secret['access-key'], twitter_secret['access-secret']) api = tweepy.API(auth) cursor = tweepy.Cursor(api.search, q=event['search'], include_entities=True, tweet_mode='extended', lang='en') tweets = list(cursor.items()) tweets = [process_tweet(t) for t in tweets if not t.retweeted] return json.dumps({"tweets": tweets}) From my desktop then, I have code which invokes the lambda function. aws_lambda = boto3.client('lambda', region_name="us-east-1") payload = {"search": "paint%20protection%20film filter:safe"} lambda_response = aws_lambda.invoke(FunctionName="twitter-searcher", InvocationType="RequestResponse", Payload=json.dumps(payload)) results = lambda_response['Payload'].read() tweets = results.decode('utf-8') The problem is that somewhere between json.dumps ing the output in lambda and reading the payload in Python, the data has gotten screwy. For example, a line break which should be \n becomes \\\\n , all of the double quotes are stored as \\" and Unicode characters are all prefixed by \\ . So, everything that was escaped, when it was received by Python on my desktop with the escaping character being escaped. Consider this element of the list that was returned (with manual formatting). '{\\"userid\\": 190764134, \\"username\\": \\"CapitalGMC\\", \\"created\\": \\"2018-09-02 15:00:00\\", \\"tweetid\\": 1036267504673337344, \\"text\\": \\"Protect your vehicle\'s paint! Find out how on this week\'s blog. \\\\ud83d\\\\udc47\\\\n\\\\nhttps://url/XYMxPhVhdH https://url/mFL2Zv8nWW\\"}' I can use regex to fix some problems (\\" and \\\\n ) but the Unicode is tricky because even if I match it, how do I replace it with a properly escaped character? When I do this in R, using the aws.lambda package, everything is fine, no weird escaped escapes. What am I doing wrong on my desktop with the response from AWS Lambda that's garbling the data? Update The process tweet function is below. It literally just pulls out the bits I care to keep, formats the datetime object to be a string and returns a dictionary. def process_tweet(tweet): bundle = { "userid": tweet.user.id, "username": tweet.user.screen_name, "created": str(tweet.created_at), "tweetid": tweet.id, "text": tweet.full_text } return bundle Just for reference, in R the code looks like this. payload = list(search="paint%20protection%20film filter:safe") results = aws.lambda::invoke_function("twitter-searcher" ,payload = jsonlite::toJSON(payload ,auto_unbox=TRUE) ,type = "RequestResponse" ,key = creds$key ,secret = creds$secret ,session_token = creds$session_token ,region = creds$region) tweets = jsonlite::fromJSON(results) str(tweets) #> 'data.frame': 133 obs. of 5 variables: #> $ userid : num 2231994854 407106716 33553091 7778772 782310 ... #> $ username: chr "adaniel_080213" "Prestige_AdamL" "exclusivedetail" "tedhu" ... #> $ created : chr "2018-09-12 14:07:09" "2018-09-12 11:31:56" "2018-09-12 10:46:55" "2018-09-12 07:27:49" ... #> $ tweetid : num 1039878080968323072 1039839019989983232 1039827690151444480 1039777586975526912 1039699310382931968 ... #> $ text : chr "I liked a @YouTube video https://url/97sRShN4pM Tesla Model 3 - Front End Package - Suntek Ultra Paint Protection Film" "Another #Corvette #ZO6 full body clearbra wrap completed using @xpeltech ultimate plus PPF ... Paint protection"| __truncated__ "We recently protected this Tesla Model 3 with Paint Protection Film and Ceramic Coating.#teslamodel3 #charlotte"| __truncated__ "Tesla Model 3 - Front End Package - Suntek Ultra Paint Protection Film https://url/AD1cl5dNX3" ... tweets[131,] #> userid username created tweetid #> 131 190764134 CapitalGMC 2018-09-02 15:00:00 1036267504673337344 #> text #> 131 Protect your vehicle's paint! Find out how on this week's blog.👇\n\nhttps://url/XYMxPhVhdH https://url/mFL2Zv8nWW |
"Error while trying to run project: Unable to start program". Can run program only once. Then VS needs restart Posted: 25 Aug 2021 08:29 AM PDT I'm running my .NET 4.0 (C#) project in debug mode after I start VS2013. It runs just fine. The second time I start it from VS, I get the Dialog box that says "Error while trying to run project: Unable to start program C:\path\to\file.exe" The process is still alive in the Taskmanager when I dismiss the dialog box. From Windows Explorer, I can run the program just fine. And after closing it, the process is gone too from the Task Manager. A rebuild doesn't help. Is this a common problem with a known solution? |
Trim spaces in string - LTRIM RTRIM not working Posted: 25 Aug 2021 08:30 AM PDT I tried this code - UPDATE Table SET Name = RTRIM(LTRIM(Name)) Data type of Name is varchar(25) None of the leading and trailing spaces get removed. When I copy-paste one such Name , i get this - "big dash" "space symbol" ABC001 Why is this happening and how do trim the spaces ? EDIT - The question has already been answered. I found one more table with this problem. I get "- value" when i copy a column of a row. When I press the enter key at end of this copy-pasted value, i see more dashes. See image below - |
No comments:
Post a Comment