Posts

Showing posts from August 28, 2018

Deleting a specific item on a list with react js

Image
Clash Royale CLAN TAG #URR8PPP Deleting a specific item on a list with react js So I am trying to remove a todo item from its current array and it is not working. When server starts, I tried console.log but no argument is being passed. Todos returns an array . Here's my code: handleTodoDelete = (deleteTodo) => const remainingItems = this.state.todo.filter (todo => return todo !== deleteTodo; ); this.setState( todos: remainingItems ); My return code has this: return ( <li className=completeClass onClick=() => this.handleTodoClick(todo)> todo.description <button onClick= (todo)=>this.handleTodoDelete(todo)>delete</button> </li> It's seems that you're setting the filtering the todo array in state, but you're setting todos . Should you just be messing with todo or todos ? – skylerfenn Aug 13 at 2:34 todo todos todo todos it works when im passing thru ... :( done !=isdone - {this.state.todos.map(todo => { l

Cannot switch focus into a dynamically loaded iframe in Safari using webdriver.io

Image
Clash Royale CLAN TAG #URR8PPP Cannot switch focus into a dynamically loaded iframe in Safari using webdriver.io I am writing automated E2E tests using webdriver.io but I am having trouble when trying to run the tests on safari. The page that I am trying to test has a bunch of different iframes on it and I need to be able to switch focus between all of these iframes to access the elements I need. The problem I am running into is that, in safari, if a frame is loaded dynamically (not loaded at the same time as the page) I cannot switch focus into that frame. The test suite I am using works well on Chrome and Firefox, I am only seeing this issue in safari. I am assuming it is a bug in the safari driver bundled with the browser but I haven't had a whole lot of luck with apple support on this issue. I am hoping there might be a way to work around this issue without a fix from apple. Here is the page I am trying to test: http://test.spotx.tv/test/ad/js/ados/ima/test.html?vpaid=JS&

EntityManager from LocalContainerEntityManagerFactoryBean does not persist entities into the database

Image
Clash Royale CLAN TAG #URR8PPP EntityManager from LocalContainerEntityManagerFactoryBean does not persist entities into the database The problem is that the EntityManager injected with @PersistenceContext in a Spring managed bean does not persist the entities to the database. I have tried using @Transactional on the AddDao bean, where entityManager.persist() is called (I have enabled annotation-driven transactions). EntityManager @PersistenceContext @Transactional AddDao entityManager.persist() The transaction begins in another bean which is instantiated by Camel with .transacted() in the Camel Java DSL. That bean has an @Autowired property which is the DAO and has the EntityManager injected with @PersistenceContext . .transacted() @Autowired EntityManager @PersistenceContext As transaction manager Bitronix is used. A portion of the Spring xml configuration file looks like this: <bean id="localContainerEntityManagerFactoryBean" depends-on="btmConfig"

generate time series dataframe based on a given dataframe [duplicate]

Image
Clash Royale CLAN TAG #URR8PPP generate time series dataframe based on a given dataframe [duplicate] This question already has an answer here: There is a dataframe, which includes one column of time and another column of bill . As can be seen from the table, there can have multiple records for a single day. The order of time can be random time bill time time bill 2006-1-18 10.11 2006-1-18 9.02 2006-1-19 12.34 2006-1-20 6.86 2006-1-12 10.05 Based on these information, I would like to generate a time series dataframe, which has two columns Time and total bill Time total bill The time column will save the date in order, the total bill will save the sum of multiple bill records belonging to one day. This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question. df.groupby('Time').bill.sum() – Wen Aug 13 at 2:42 1 Answer 1 newdf = pd.DataFrame(df.groupby('time').bill.sum()) ne

nested for loop value of not initialized

Image
Clash Royale CLAN TAG #URR8PPP nested for loop value of not initialized I know question sounds dumb, I can't really figure out what is wrong in this code? void sort(int *arr, int size) int min = 0; for (int i = 0; i < size - 1; i++) for (int j = i; i < size; j++) if (arr[min] > arr[j]) min = j; if (min != i) Swap(&arr[i], &arr[min]); The following code should sort the arr but it is giving segmentation fault. I ran this code via debugger and it says the value of j at line arr j for (int j = i; i < size; j++) something like 3234 (not initialized) and program ends. But j should be 0 . 3234 j 0 debuger screenshort In for(int j = i;i<size;j++) the value of i never changes, so it spins forever.. – David C. Rankin Aug 13 at 2:59 for(int j = i;i<size;j++) i 2 Answers 2 In your second for loop, it should be j < size , not i < size . for j < size i < size There are 3 problems in your sort function: sort for i j j

Android google places API exceeded daily quota

Image
Clash Royale CLAN TAG #URR8PPP Android google places API exceeded daily quota I am creating android app and I have to implement maps and places so, I have created new google places API and when I send request using volley to get placeId from latitude and longitude I get error which says "error_message":"You have exceeded your daily request quota for this API.","html_attributions":,"results":,"status":"OVER_QUERY_LIMIT" But it is working fine on postman so, how can I fix this? P.S. I am beginner so please correct me if there is any mistake in my process. Thank you. 2 Answers 2 I believe Google's terms of service is restricting use of Place API from client application i.e your android app. I also have seen this in other question's comment. (As Troy Perales also has mentioned) For tutorials or example for implementing Google API click here and here. These are Codelabs examples on implementing Google Places API.

AWS Transcribe PHP API 3.0 - Can't Initialize API

Image
Clash Royale CLAN TAG #URR8PPP AWS Transcribe PHP API 3.0 - Can't Initialize API I am trying to initialize API for AWS Transcribe, but the documentation doesn't seem to be clear. My code is: <?php require 'aws-api/aws-autoloader.php'; $client = new AwsTranscribeServiceTranscribeServiceClient; $result = $client->commandName(listTranscriptionJobs([ ])); echo $result; var_dump($result); ?> but I am getting PHP Error: [Mon Aug 13 03:09:02.430628 2018] [:error] [pid 27717] [client 123.123.123.123:29660] PHP Catchable fatal error: Argument 1 passed to Aws\AwsClient::__construct() must be of the type array, none given, called in /var/www/example/public_html/wp-content/themes/example/aws-transcribe.php on line 16 and defined in /var/www/example/public_html/wp-content/themes/example/aws-api/Aws/AwsClient.php on line 146, referer: http://example.com/wp-content/themes/xxx/aws-transcribe.php I have not been able to find a code snippet for the Transcribe API and cann

Issue with simple atomic counter test in OpenGL compute shader

Image
Clash Royale CLAN TAG #URR8PPP Issue with simple atomic counter test in OpenGL compute shader I've been trying to wrap my head around memory synchronization and coherency by trying trivial examples. In this, I'm dispatching a compute shader with 8x8x1 size work groups. The number of work groups is sufficient to cover the screen, which is 720x480. Compute shader code: #version 450 core layout (local_size_x = 8, local_size_y = 8, local_size_z = 1) in; layout (binding = 0, rgba8) uniform image2D u_fboImg; layout (binding = 0, offset = 0) uniform atomic_uint u_counters[100]; void main() This is what I get: (The heights of the jagged bars are different each time, but on average about that height) This is what I would expect, and is the result of hard coding the for loop to go to 400. Strangely enough, if I decrease the number of work groups in the dispatch, say by halving the x value (would now only cover half the screen), the bars get bigger: Finally to prove there isn&#

I want to insert module in specific folder by module categories in VB.net

Image
Clash Royale CLAN TAG #URR8PPP I want to insert module in specific folder by module categories in VB.net for more understanding I want to insert module in specific folder by module categories in VB.net For example: If "modul_category" = "OPTO" Then "@modul_filePath" values "notes/OPTO" * from "ModulContents" ElseIf Is it correct? Or any suggestions? i want to call specific modules by their module categories only. Full coding : Protected Sub addSyllabusButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles addSyllabusButton.Click Dim myConnection As New SqlConnection() Dim myCommand As SqlCommand Dim str As String Dim filepath As String = Server.MapPath("notes/") 'Dim filepath As String = "C:Uploads" Dim uploadedFiles As HttpFileCollection = Request.Files Dim i As Integer = 0 Using myConnection myConnection = New SqlConnection("server=mtmwhs;uid=private;pwd=private;database=

java file not running from cron

Image
Clash Royale CLAN TAG #URR8PPP java file not running from cron I am at directory location /home/oracle/naresh Files InsertToTable.java, InsertToTable.class, runjava.sh, ojdbc6.jar are at /home/oracle/naresh directory location InsertToTable.java is a file to insert data in to table. It makes use of ojdbc6.jar at run time. When running the below shell script independently, java will run successfully and data is inserted to table. runjava.sh ----------- #!/bin/bash date >> /home/oracle/naresh/test.txt export PATH=/home/oracle/jdk1.8.0_151/bin:$PATH java -cp .:/home/oracle/naresh/ojdbc6.jar InsertToTable exit 0 When running the same shell script from cron, java file is not running .. To make sure, whether cron job kicked in or not, I am writing date value to a file and execution of java crontab: ---------- * * * * * /home/oracle/naresh/runjava.sh date value is writing to file, when cron is kicked in, but not executing java file. Can some one tell me, how to execute java file w

I want to know what is the error in this SQL query

Image
Clash Royale CLAN TAG #URR8PPP I want to know what is the error in this SQL query I have updated the Query to SELECT regexp_substr(a.NAME, '[^:]+$') AS emp_req ,a.COMPLETION_STATUS ,b.USER_TYPE ,b.display_name FROM spt_result a ,spt_identity b WHERE a.name LIKE 'Join%' AND emp_req = b.display_name; I want to fetch the user type from spt_identity table which is having completion status as error or success in spt_result table . the table spt_result contains spt_result table spt_result NAME COMPLETION_STATUS ---------------------------------------------------------------- Add/Remove Role(s) for:kc051363(1503085327459) Error Joiner:sk080281 Success and spt_identity contains spt_identity contains USER_TYPE DISPLAY_NAME ----------------------------- Parttime-Regular pt092101 Parttime-Regular rm088923 Vendor wl090918 Parttime-Regular ne091924 Vendor dh090040 How can we know what the error is in your SQL query if you don't tell us? – Tim Biegeleisen Aug 13 a

Pass Java variable to JavascriptExecutor argument for jQuery function

Image
Clash Royale CLAN TAG #URR8PPP Pass Java variable to JavascriptExecutor argument for jQuery function Hi I am using selenium webdriver where I try to execute jQuery script by passing java variable to access valid id. here is the code. int move = 3; String date = "2011-03-05"; String script = "$('#date_of_birth-'+move+).datepicker('update', '+date+')"; js.executeAsyncScript(script, 1000); I want to use both move and date variable inside jQuery function. Hi, what is the source of your confusion? It seems like you are unable to concatenate strings in Java. If that's the case, have a look at this Q&A: stackoverflow.com/questions/3753869/… – Erwin Bolwidt Aug 13 at 3:28 3 Answers 3 After long struggles and debugging I found the solution. here is the right way to pass java variable to jQuery function. String script = "$('#date_of_birth-" + move + "').datepicker('update', '" + date + &q

Count number of repetition for values in JSON nested arrays with Javascript

Image
Clash Royale CLAN TAG #URR8PPP Count number of repetition for values in JSON nested arrays with Javascript I'm stuck with something I thought would be easy. Let's say I have an object like this. I'm trying to insert in the div each name of the animal tagged and the number of times that tag is in types (for example, cat = 3, etc...) var animals = ''; animals = "types": [ "id": "1", "tags": ["cat"] , "id": "2", "tags": ["dog"] , "id": "3", "tags": ["cat", "bird", "dog"] , "id": "4", "tags": , "id": "5", "tags": ["cat", "bird"] ] for (var i = 0; i < animals.length; i++) var tags = animals[i].tags; <div class="types">Number of animals:</div> I'm a beginner with complex JSON objects, any h

TCP socket doesn't throw any exception when sending messages even though network connection is dropped

Image
Clash Royale CLAN TAG #URR8PPP TCP socket doesn't throw any exception when sending messages even though network connection is dropped I have created a TCP web socket client in Java and connected it to a remote TCP server. In normal conditions it is working properly. I need to detect the socket disconnection and handle some logic once disconnection triggers. I'm planning to detect the disconnection by catching the exception when socket client writing to its output stream for sending messages. However when I turn off the wifi connection or remove the LAN cable of the socket client it doesn't identify the disconnection with the server within few seconds. It takes different time periods (seconds or minutes) for the client to identify the disconnection from the server and throw below exception when reading. java.net.SocketTimeoutException: Read timed out. My concern is during that disconnection period before socket client throws above exception, it successfully writes mess

Im keep on getting an error trying to make a session variable

Image
Clash Royale CLAN TAG #URR8PPP Im keep on getting an error trying to make a session variable I am working on a Alexa skill. Currently, I am trying to get the users name and have it as a session variable. But, whenever I go to test it, it gives me this error: "errorMessage": "RequestId: 98b4fce1-9699-11e7-a585-43e1799b56fe Process exited before completing request" Here is the TypeError in the log: TypeError: Cannot read property 'slots' of undefined Here is my code: exports.handler = function(event, context, callback) var alexa = Alexa.handler(event, context); alexa.APP_ID = APP_ID; alexa.registerHandlers(handlers); alexa.dynamoDBTableName = 'usersName'; alexa.execute(); ; var handlers = { 'LaunchRequest': function () this.emit('LaunchIntent'); , 'LaunchIntent': function () this.atttributes['myName'] = this.event.request.intent.slots.myName.value this.emit(':ask', 'Hi! Welcome to Welcoming Ala

Receive Drive content notifications in an Android app without a backend

Image
Clash Royale CLAN TAG #URR8PPP Receive Drive content notifications in an Android app without a backend I have to use Google Drive REST API due to the limitation of Android Drive API for my android app. Everything works properly until registering for change notification. From the API docs, the workflow is: example.com https://example.com/notifications Is it possible to receive push notification from Google Drive on an android app without my own backend server? you'll need an http server running on your phone. There is code on Github that will allow you to embed the server in your app. Dynamic DNS will handle the routing. However, a simple backend to convert the notifications to Firebase Cloud Messaging would probably be simpler. – pinoyyid Aug 11 at 9:30 @pinoyyid thanks for the solution, but if so, my app only receives notification when running that is not practical – thanhbinh84 Aug 11 at 9:52 Well you could run it as a Service, but nevertheless I agree which i