problem
stringlengths
26
131k
labels
class label
2 classes
Shrinking a String to substrings : <p>I am new to android and working on a project, and in a part of that I need to shrink a string to smaller substrings.</p> <p>For example let's assume the string is "A-87B9C143D24E940|jOmbFACBBAAAAADB2" and length of this string is not fixed. The thing I want is that put characters from A to B to a string variable (like S0 = 87), from B to C to another one (like S1 = 9) from D to E to another one (like S3 = 143) from E to | to another one (like S4 = 940) and everything after | goes to another substring (like S5 = jOmbFACBBAAAAADB2);</p>
0debug
Finding difficulty in creating SQL Trigger : I am writing a SQL query (2012) to create a trigger but it gives me an error. I have tried several different ways. Find the code that I am using CREATE TRIGGER after_table_update After_hsi.keyrecorddata202_UPDATE FOR EACH ROW Begin UPDATE hsi.keyrecorddata202 set kg563 = hsi.keyrecorddata202.kg275 * ['Price_List$'].Unitprice FROM hsi.keyrecorddata202 INNER JOIN ['Price_List$'] ON hsi.keyrecorddata202.kg487 = ['Price_List$'].NO# where kg568 = 'FOOD' END;
0debug
static void dvbsub_parse_page_segment(AVCodecContext *avctx, const uint8_t *buf, int buf_size) { DVBSubContext *ctx = avctx->priv_data; DVBSubRegionDisplay *display; DVBSubRegionDisplay *tmp_display_list, **tmp_ptr; const uint8_t *buf_end = buf + buf_size; int region_id; int page_state; if (buf_size < 1) return; ctx->time_out = *buf++; page_state = ((*buf++) >> 2) & 3; av_dlog(avctx, "Page time out %ds, state %d\n", ctx->time_out, page_state); if (page_state == 2) { delete_state(ctx); } tmp_display_list = ctx->display_list; ctx->display_list = NULL; ctx->display_list_size = 0; while (buf + 5 < buf_end) { region_id = *buf++; buf += 1; display = tmp_display_list; tmp_ptr = &tmp_display_list; while (display && display->region_id != region_id) { tmp_ptr = &display->next; display = display->next; } if (!display) display = av_mallocz(sizeof(DVBSubRegionDisplay)); display->region_id = region_id; display->x_pos = AV_RB16(buf); buf += 2; display->y_pos = AV_RB16(buf); buf += 2; *tmp_ptr = display->next; display->next = ctx->display_list; ctx->display_list = display; ctx->display_list_size++; av_dlog(avctx, "Region %d, (%d,%d)\n", region_id, display->x_pos, display->y_pos); } while (tmp_display_list) { display = tmp_display_list; tmp_display_list = display->next; av_free(display); } }
1threat
Fnding names with a specif letter on parser server : I am currently working on android platform using parse server. i am making a function in which if i enter a character key it shows all the entries which are having that letter in it. For example - i will be getting all the names starting or having character "p" in them. I would really appreciate if u can suggest, find or give me some examples of them.
0debug
replace the value in one table conditional on the value in another table : I have the following data frames: df_1 <- data.frame(f1= c(1,3,4,5,7,8), f2 = c(2,3,4,1,4,5)) df_2 <- data.frame(f1= c(0.1,0.3,0.04,0.015,0.7,0.8), f2 = c(0.02,0.13,0.4,1.4,0.04,0.5)) so they look like > df_1 f1 f2 1 1 2 2 3 3 3 4 4 4 5 1 5 7 4 6 8 5 > df_2 f1 f2 1 0.100 0.02 2 0.300 0.13 3 0.040 0.40 4 0.015 1.40 5 0.700 0.04 6 0.800 0.50 The replacement I wish to perform is: If one figure in df2 is higher than 0.05, I wish to replace the figure in df1 at the corresponding position with NA. The resulting data frame df1 should look like f1 f2 1 NA 2 2 NA NA 3 4 NA 4 5 NA 5 NA 4 6 NA NA I have tried to solve it using a for loop but it will take a long time when applied to my actual large table. I know there could be a quicker way using data.table but I don't actually know how. Can someone help me with this? Many thanks! Bill
0debug
def binary_search(item_list,item): first = 0 last = len(item_list)-1 found = False while( first<=last and not found): mid = (first + last)//2 if item_list[mid] == item : found = True else: if item < item_list[mid]: last = mid - 1 else: first = mid + 1 return found
0debug
Getting First unix number in array php : i have array [1,2,1,2,3,4,5,] and i want make function in php that will return first Unix number in those array is 3 or how we can remove all double array and will return [3,4,5]
0debug
(JAVA) I need to validate that an index is valid of a user entered string : When a user enters a word they then are prompt to enter the first and second index of a substring. I have that much sorted but when I try to validate that the index entered with my if statements below I am getting errors regarding those if statements , any help is greatly appreciated Here is my code... import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); String inputString; int startIndex; int endIndex; System.out.println("Enter a string : "); inputString = scanner.nextLine(); System.out.println("Enter the first index of the substring : "); startIndex = scanner.nextInt(); if (int startIndex > inputSting.length) { System.out.println("Index is not in string length, try again."); } System.out.println("Enter the second index of the substring : "); endIndex = scanner.nextInt(); if (int endIndex > inputSting.length) { System.out.println("Index is not in string length, try again."); } char[] ch = new char[endIndex - startIndex + 1]; inputString.getChars(startIndex, endIndex + 1, ch, 0); System.out.println("Output : " + String.valueOf(ch)); } }
0debug
'temp' is undeclared, first use this function. : #include<iostream> #include<conio.h> #include<string> #include<cstring> #include<stdlib.h> using namespace std; bool rgstr_stdnt(struct student *stud,struct list *ls); double calculate_aggregate(struct student *); void srch_student(struct student * next); void addToList(struct student *stud, struct list *l); void display(struct student *stud, struct list *l); struct student { char name[20]; int matric_marks, inter_marks, aptitude_marks; int temp; student *next; }; struct list { char name[20]; double aggr; list *next; }; this is where the problem shows up, it says temp undeclared, first use this function and I'm not able to rectify it void srch_stdnt(struct student *stud) { char name[60]; cout << "Enter Student to search :"; cin>>name; cout << name; down here, the error comes and whatever i knew, i have tried to solve it but could not while (temp!=NULL){ if(strcmp(temp->name, name)==0){ } temp = temp->next; } cout << "No match found"; } int main() { student * temp=new student(); student *s; s = (struct student *) malloc(sizeof(struct student)); struct list *ls; ls = (struct list *) malloc(sizeof(struct list)); strcpy(ls->name,""); ls->aggr = 0; ls->next= NULL; do { cout<<" STUDENT ENROLLMENT AND RECORDS MANAGEMENT"<<endl; cout<<"1- To Enroll A New Sudent."<<endl; cout<<"2- To View The Enrolled Students."<<endl; cout<<"3- To Search Through The Already Enrolled Students."<<endl; cout<<"4- Exit."<<endl; int input; cin>>input; if (input == 1) { rgstr_stdnt(s, ls); } else if (input == 2) { display(s, ls); } else if(input == 3) { void srch_student(struct student * stud); } else if (input == 4) exit(0); cout<<endl; } while(1); getch(); } bool rgstr_stdnt(struct student *stud,struct list *ls) { student *s = stud; cout<<"Enter Name Of The Student: "<<endl; cin>>s->name; cout<<"Enter Percentage in 10th Grade: "<<endl; cin>>s->matric_marks; cout<<"Enter Intermediate Percentage:"<<endl; cin>>s->inter_marks; cout<<"Enter Percentage In Aptitude Test: "<<endl; cin>>s->aptitude_marks; double aggregate; aggregate = calculate_aggregate(s); cout<<"Aggregate Percentage Is: "<< aggregate<<"%"<<endl; if (aggregate >= 70) { cout<<"-> Student Enrolled In BSCS. <-"<<endl; addToList(s,ls); return true; } else if (aggregate >= 60) { cout<<"-> Student Enrolled In BE. <-"<<endl; addToList(s,ls); return true; } else if (aggregate >=50) { cout<<"-> Student Enrolled In MS. <-"<<endl; addToList(s,ls); return true; } else { cout<<"Sorry, Low Percentage. Student Can't Be Enrolled!"<<endl; return false; } } double calculate_aggregate(struct student *stud) { student *s = stud; double aggr; aggr = s->matric_marks * 10/100 + s->inter_marks * 50/100 + s->aptitude_marks * 40/100; return aggr; } void addToList(struct student *stud, struct list *l) { list *pointer = l; while (pointer->next != NULL) { pointer = pointer->next; } pointer->next = (struct list *) malloc(sizeof(struct list)); pointer = pointer->next; strcpy(pointer->name , stud->name); pointer->aggr = calculate_aggregate(stud); pointer->next = NULL; } void display(struct student *stud, struct list *l) { list *pointer = l; if (pointer->next == NULL) cout<<"No Students Enrolled Yet."<<endl; else { cout<<" !- - - - - - - - -. STUDENTS RECORDS .- - - - - - - - - -! " <<endl; while (pointer->next != NULL) { pointer = pointer->next; cout<<"Name Of Student: "<<pointer->name<<endl; cout<<"Aggregate Is: "<<pointer->aggr<<endl; if (pointer->aggr >= 70) cout<<"-> Student Enrolled In BSCS. <-"<<endl; else if(pointer->aggr >=60) cout<<"-> Student Enrolled In BE. <-"<<endl; else cout<<"-> Student Enrolled In MS. <-"<<endl; cout<<endl; } } } Any who could help me solve this, i'd really be grateful.
0debug
Spring-boot: required a bean named 'entityManagerFactory' that could not be found : <p>I am developing a Spring Boot application using JPA and encountering this error. I am not certain if I am using the correct annotations or missing dependencies. Any help would be greatly appreciated.</p> <p><strong>This is the error message</strong></p> <pre><code>1:05:28 AM: Executing external task 'bootRun'... :compileJava :processResources UP-TO-DATE :classes :findMainClass :bootRun 01:05:35.198 [main] DEBUG org.springframework.boot.devtools.settings.DevToolsSettings - Included patterns for restart : [] 01:05:35.201 [main] DEBUG org.springframework.boot.devtools.settings.DevToolsSettings - Excluded patterns for restart : [/spring-boot-starter/target/classes/, /spring-boot-autoconfigure/target/classes/, /spring-boot-starter-[\w-]+/, /spring-boot/target/classes/, /spring-boot-actuator/target/classes/, /spring-boot-devtools/target/classes/] 01:05:35.201 [main] DEBUG org.springframework.boot.devtools.restart.ChangeableUrls - Matching URLs for reloading : [file:/C:/Users/zahid/IdeaProjects/giflib/build/classes/main/, file:/C:/Users/zahid/IdeaProjects/giflib/build/resources/main/] . ____ _ __ _ _ /\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \ ( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \ \\/ ___)| |_)| | | | | || (_| | ) ) ) ) ' |____| .__|_| |_|_| |_\__, | / / / / =========|_|==============|___/=/_/_/_/ :: Spring Boot :: (v1.5.3.RELEASE) 2018-01-24 01:05:35.539 INFO 14840 --- [ restartedMain] com.sweng.giflib.Application : Starting Application on DESKTOP-EKFI3C8 with PID 14840 (C:\Users\zahid\IdeaProjects\giflib\build\classes\main started by zahid in C:\Users\zahid\IdeaProjects\giflib) 2018-01-24 01:05:35.540 INFO 14840 --- [ restartedMain] com.sweng.giflib.Application : No active profile set, falling back to default profiles: default 2018-01-24 01:05:35.828 INFO 14840 --- [ restartedMain] ationConfigEmbeddedWebApplicationContext : Refreshing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@396ad740: startup date [Wed Jan 24 01:05:35 CST 2018]; root of context hierarchy 2018-01-24 01:05:37.685 INFO 14840 --- [ restartedMain] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat initialized with port(s): 8080 (http) 2018-01-24 01:05:37.697 INFO 14840 --- [ restartedMain] o.apache.catalina.core.StandardService : Starting service Tomcat 2018-01-24 01:05:37.699 INFO 14840 --- [ restartedMain] org.apache.catalina.core.StandardEngine : Starting Servlet Engine: Apache Tomcat/8.5.14 2018-01-24 01:05:37.800 INFO 14840 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext 2018-01-24 01:05:37.801 INFO 14840 --- [ost-startStop-1] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 1976 ms 2018-01-24 01:05:37.991 INFO 14840 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'characterEncodingFilter' to: [/*] 2018-01-24 01:05:37.992 INFO 14840 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'hiddenHttpMethodFilter' to: [/*] 2018-01-24 01:05:37.992 INFO 14840 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'httpPutFormContentFilter' to: [/*] 2018-01-24 01:05:37.992 INFO 14840 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'requestContextFilter' to: [/*] 2018-01-24 01:05:37.993 INFO 14840 --- [ost-startStop-1] .s.DelegatingFilterProxyRegistrationBean : Mapping filter: 'springSecurityFilterChain' to: [/*] 2018-01-24 01:05:37.994 INFO 14840 --- [ost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean : Mapping servlet: 'dispatcherServlet' to [/] 2018-01-24 01:05:38.291 WARN 14840 --- [ restartedMain] ationConfigEmbeddedWebApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'securityConfig': Unsatisfied dependency expressed through field 'userService'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'userServiceImpl': Unsatisfied dependency expressed through field 'userRepository'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userRepository': Cannot create inner bean '(inner bean)#64397422' of type [org.springframework.orm.jpa.SharedEntityManagerCreator] while setting bean property 'entityManager'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name '(inner bean)#64397422': Cannot resolve reference to bean 'entityManagerFactory' while setting constructor argument; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'entityManagerFactory' available 2018-01-24 01:05:38.294 INFO 14840 --- [ restartedMain] o.apache.catalina.core.StandardService : Stopping service Tomcat 2018-01-24 01:05:38.321 INFO 14840 --- [ restartedMain] utoConfigurationReportLoggingInitializer : Error starting ApplicationContext. To display the auto-configuration report re-run your application with 'debug' enabled. 2018-01-24 01:05:38.444 ERROR 14840 --- [ restartedMain] o.s.b.d.LoggingFailureAnalysisReporter : *************************** APPLICATION FAILED TO START *************************** Description: Field userRepository in com.sweng.giflib.service.UserServiceImpl required a bean named 'entityManagerFactory' that could not be found. Action: Consider defining a bean named 'entityManagerFactory' in your configuration. BUILD SUCCESSFUL Total time: 9.681 secs 1:05:38 AM: External task execution finished 'bootRun'. </code></pre> <p><strong>build.gradle</strong></p> <pre><code>buildscript { ext { springBootVersion = '1.5.3.RELEASE' } repositories { mavenCentral() } dependencies { classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}") } } group 'com.sweng' version '1.0-SNAPSHOT' apply plugin: 'java' apply plugin: 'idea' apply plugin: 'org.springframework.boot' apply plugin: 'war' repositories { mavenCentral() } springBoot { mainClass = "com.sweng.giflib.Application" } dependencies { compile "org.springframework.boot:spring-boot-starter-data-jpa:$springBootVersion" compile "org.springframework.boot:spring-boot-starter-web:$springBootVersion" compile "org.springframework.boot:spring-boot-starter-thymeleaf:$springBootVersion" compile "org.springframework.boot:spring-boot-devtools:$springBootVersion" compile "mysql:mysql-connector-java" compile "org.springframework.boot:spring-boot-starter-security:$springBootVersion" compile "org.thymeleaf.extras:thymeleaf-extras-springsecurity4:2.1.2.RELEASE" providedRuntime 'org.springframework.boot:spring-boot-starter-tomcat' } </code></pre> <p><strong>application.properties</strong></p> <pre><code>spring.datasource.url== jdbc:mysql://localhost:3306/giflib spring.db.driver= com.mysql.jdbc.Driver spring.datasource.username = su spring.datasource.password = spring.jpa.show-sql = true #spring.jpa.hibernate.ddl-auto = update spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.MySQL5Dialect spring.jpa.hibernate.naming.strategy = org.hibernate.cfg.ImprovedNamingStrategy </code></pre> <p><strong>Application.java</strong></p> <pre><code>package com.sweng.giflib; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration; import org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration; import org.springframework.boot.builder.SpringApplicationBuilder; import org.springframework.boot.web.support.SpringBootServletInitializer; import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; import org.springframework.data.jpa.repository.config.EnableJpaRepositories; @ComponentScan @Configuration @EnableAutoConfiguration(exclude = {DataSourceAutoConfiguration.class, HibernateJpaAutoConfiguration.class}) @EnableJpaRepositories(basePackages = "com.sweng.giflib.repository") @SpringBootApplication(scanBasePackages= "com.sweng.giflib") public class Application extends SpringBootServletInitializer { @Override protected SpringApplicationBuilder configure(SpringApplicationBuilder application) { return application.sources(Application.class); } public static void main(String[] args) throws Exception { SpringApplication.run(Application.class, args); } } </code></pre> <p><strong>UserService.java</strong></p> <pre><code>package com.sweng.giflib.service; import com.sweng.giflib.model.User; import org.springframework.security.core.userdetails.UserDetailsService; public interface UserService extends UserDetailsService { User findByUsername(String username); } </code></pre> <p><strong>UserServiceImpl.java</strong></p> <pre><code>package com.sweng.giflib.service; import com.sweng.giflib.repository.UserRepository; import com.sweng.giflib.model.User; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.security.core.userdetails.UserDetails; import org.springframework.security.core.userdetails.UsernameNotFoundException; import org.springframework.stereotype.Service; @Service public class UserServiceImpl implements UserService { @Autowired private UserRepository userRepository; @Override public User findByUsername(String username) { return userRepository.findByusername(username); } @Override public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException { // Load user from the database (throw exception if not found) User user = userRepository.findByusername(username); if(user == null) { throw new UsernameNotFoundException("User not found"); } // Return user object return user; } } </code></pre> <p><strong>UserRepository.java</strong></p> <pre><code>package com.sweng.giflib.repository; import com.sweng.giflib.model.User; import org.springframework.data.repository.CrudRepository; import org.springframework.stereotype.Repository; @Repository public interface UserRepository extends CrudRepository&lt;User, Long&gt;{ User findByusername(String name); } </code></pre> <p><strong>User.java</strong></p> <pre><code>package com.sweng.giflib.model; import org.springframework.security.core.GrantedAuthority; import org.springframework.security.core.authority.SimpleGrantedAuthority; import org.springframework.security.core.userdetails.UserDetails; import javax.persistence.*; import javax.validation.constraints.Size; import java.util.ArrayList; import java.util.Collection; import java.util.List; @Entity public class User implements UserDetails { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) private Long id; @Column(unique = true) @Size(min = 8, max = 20) private String username; @Column(length = 100) private String password; @Column(nullable = false) private boolean enabled; @OneToOne @JoinColumn(name = "role_id") private Role role; @Override public Collection&lt;? extends GrantedAuthority&gt; getAuthorities() { List&lt;GrantedAuthority&gt; authorities = new ArrayList&lt;&gt;(); authorities.add(new SimpleGrantedAuthority(role.getName())); return authorities; } public Long getId() { return id; } public void setId(Long id) { this.id = id; } @Override public String getPassword() { return password; } @Override public String getUsername() { return username; } @Override public boolean isAccountNonExpired() { return true; } @Override public boolean isAccountNonLocked() { return true; } @Override public boolean isCredentialsNonExpired() { return true; } @Override public boolean isEnabled() { return enabled; } } </code></pre>
0debug
Twitching Blur effect css : When I try to use blur effect it will twitching my element slightly. Can anyone help me to fix this problem. [Check Codepen link][1] [1]: https://codepen.io/mcraig218/pen/uqIae
0debug
This code is not running properly. : I tried to run the following code but after one input, the rest of the input is initialized to zero and is displayed on the screen automatically. where did I go wrong? #include<iostream> #define N 50 using namespace std; struct movies_t { char title[60]; int year; }user[N]; void printmovie(movies_t); int main() { for(int i = 0; i < N; i++) { cout << "Enter title: "; cin.get(user[i].title, 60); cout << "Enter year: "; cin >> user[i].year; } cout << "\nYou have entered these movie: \n"; for(int i = 0; i < N; i++) printmovie(user[i]); return 0; } void printmovie(movies_t m) { cout << m.title; cout << " (" << m.year << ")\n"; }
0debug
How to extract everything until first occurrence of pattern : <p>I'm trying to use the <a href="https://github.com/tidyverse/stringr" rel="noreferrer">stringr</a> package in R to extract everything from a string up until the first occurrence of an underscore.</p> <p><strong>What I've tried</strong></p> <pre><code>str_extract("L0_123_abc", ".+?(?&lt;=_)") &gt; "L0_" </code></pre> <p>Close but no cigar. How do I get this one? Also, Ideally I'd like something that's easy to extend so that I can get the information in between the 1st and 2nd underscore and get the information after the 3rd underscore.</p>
0debug
Shoukd I use JSON for my posting and commenting system? : <p>I am building a social networking website and should i use JSON instead of database for storing users posts and comments? Is it good and secure?</p>
0debug
VB.NET and MySQL: How to display the count value on label? : I have a monitoring in datagridview that has a display of list of vehicles and their types. I want to count the number of each type of the vehicle. Example : there are 8 Sedans and 5 Motorcycles in the datagridview and I want it to display in the label. here is my code: Dim table As New DataTable() Dim command As New MySqlCommand("select count(ctype) from tblreport where ctype='SUV'", conn) command.Parameters.Add("count(ctype)", MySqlDbType.VarChar).Value = Label6.Text Dim adapter As New MySqlDataAdapter(command) adapter.Fill(table) DataGridView2.DataSource = table Thanks in Advance
0debug
My code for rotating arrays gives error for large array size(around 50) help me? : **Problem**: I was trying to solve this problem from geeksforgeeks on array rotation code seems to be working fine for small array size but for large array size it displays some garbage values and then stops working. The question is on this link: https://practice.geeksforgeeks.org/problems/rotate-and-delete/0 and my code is: # include<iostream> using namespace std; void rotate_clockwise(int *arr, int size) { int temp = *(arr + size -1); for(int i = 0;i < size;++i ) { *(arr +(size -1) - i) = *(arr + (size-1) -(i+1));//*(arr +(size -1)) } *arr = temp; } void initialize_array(int *arr,int size) { for(int i ; i < size; ++i) { cin>>*(arr +i); } } void print_array(int *arr,int size) { for(int i = 0; i< size; i++) { cout<<*(arr + i)<<" "; } cout<<endl; } void remove_ith_fend(int i, int *arr, int *ptr_size) { int size = *ptr_size; int *last = (arr + size -1); i = i-1; if(i < size) { for(int j =0 ;j<size;j++) { *(last - i + j) = *(last -i + j+1); } } else { for(int j = 0;j<size;++j) { *(arr + j) = *(arr + j +1); } } --size; *ptr_size = size; } int main() { int size; cout<<"Enter size of array: "; cin>>size; int *ptr_size; ptr_size = &size; int arr[size]; initialize_array(arr, size); print_array(arr, size); for(int i =1;size!=1;++i) { cout<<"rotating"<<endl; rotate_clockwise(arr,size); print_array(arr,size); remove_ith_fend(i, arr, ptr_size); cout<<"removing "<<i<<"th element from the end"<<endl; print_array(arr,size); } return 0; } I was only trying this out so I don't take input for test cases which they are giving in the question. Sorry I have not commented the code but I was in the process of solving this and was going to do it later after getting the solution right. Here is the error I was getting when I entered the array size: 54 Enter size of array: 54 4741824 0 -1 0 4744768 0 4503683 0 1 0 4745728 0 8 0 4751362 0 4744784 0 7339432 0 7339436 0 1 0 0 0 -1 0 4741824 0 -1 0 4741824 0 10 0 4254288 16777216 0 54 8390488 0 224 0 -1 0 4200452 0 0 0 0 0 8 0 rotating 0 4741824 0 -1 0 4744768 0 4503683 0 1 0 4745728 0 8 0 4751362 0 4744784 0 7339432 0 7339436 0 1 0 0 0 -1 0 4741824 0 -1 0 4741824 0 10 0 4254288 16777216 0 54 8390488 0 224 0 -1 0 4200452 0 0 0 0 0 8 removing 1th element from the end It didn't asked for any input and just exited after printing this thing above. Also please point out some issues that I have with the way code is written as I am new to programming and like to learn the better way of writing.
0debug
show data from SQLite to Custom ListView is android studio : I Want to show my data from SQLite to Custom ListView (java , Android studio , SQLite ). But it's force stop. picture from my Main Activity: picture from my Database class: picture from my custom list view class: Please Help me!!!! (my English is not good sorry but can i understand your words)
0debug
static inline void RENAME(bgr32ToUV)(uint8_t *dstU, uint8_t *dstV, uint8_t *src1, uint8_t *src2, int width) { int i; assert(src1 == src2); for(i=0; i<width; i++) { const int a= ((uint32_t*)src1)[2*i+0]; const int e= ((uint32_t*)src1)[2*i+1]; const int l= (a&0xFF00FF) + (e&0xFF00FF); const int h= (a&0x00FF00) + (e&0x00FF00); const int b= l&0x3FF; const int g= h>>8; const int r= l>>16; dstU[i]= ((RU*r + GU*g + BU*b)>>(RGB2YUV_SHIFT+1)) + 128; dstV[i]= ((RV*r + GV*g + BV*b)>>(RGB2YUV_SHIFT+1)) + 128; } }
1threat
Get first and second element of array : <p>How I get first and second element in this array?</p> <p><a href="https://i.stack.imgur.com/hkxB5.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/hkxB5.png" alt="enter image description here"></a></p> <p>for example the first "AF" and second "Afghanistan", I need to put the value in html select tag</p>
0debug
respondsToSelector can't recognize Selector with more than one parameters in Swift : <p>I have a <code>protocol</code> with some <code>optional</code> functions. My goal is to check if a delegate function is implemented by the delegate object, if yes execute it, otherwise do some default stuff.</p> <p>I am using <code>respondsToSelector</code> for this purpose, it works fine for functions that with none or only one parameters, but doesn't work for two parameters.</p> <p>Could anyone help? Thanks in advance.</p> <p>Note that all the functions have been implemented by the delegate object, here is my code:</p> <pre><code>@objc protocol ViewControllerDelegate: NSObjectProtocol { optional func doSomethingWithoutParams() optional func doSomethingWithOneParam(controller: ViewController) optional func doSomethingWithTwoParams(controller: ViewController, secondParam: String) } class ViewController: UIViewController { weak var delegate: ViewControllerDelegate? @IBAction func onButtonClicked(sender: AnyObject){ if (delegate != nil &amp;&amp; delegate!.respondsToSelector(Selector("doSomethingWithoutParams"))) { // Entered here } else{ NSLog("doSomethingWithoutParams is not implemented") } if (delegate != nil &amp;&amp; delegate!.respondsToSelector(Selector("doSomethingWithOneParam:"))) { // Entered here } else{ NSLog("doSomethingWithOneParam is not implemented") } if (delegate != nil &amp;&amp; delegate!.respondsToSelector(Selector("doSomethingWithTwoParams::"))) { NSLog("doSomethingWithTwoParams is implemented") } else{ // Entered here NSLog("doSomethingWithTwoParams is not implemented") } } } </code></pre>
0debug
C# Checking number range not working : private bool DataValidation(string Checker) { int i; if (Int32.TryParse(Checker, out i)) { return true; } else { return false; } } private void NumberChecker() { if (int.Parse(txtRank.Text) >= 0 || int.Parse(txtRank.Text) <= 50) { errorProvider1.SetError(txtRank, string.Empty); errorProvider1.Clear(); } else { errorProvider1.SetError(txtRank, "Between 1 and 50 please!"); } } private void txtRank_Validating(object sender, CancelEventArgs e) { if (DataValidation(txtRank.Text) == false) { errorProvider1.SetError(txtRank, "Must be numeric!"); } else { errorProvider1.SetError(txtRank, string.Empty); errorProvider1.Clear(); } NumberChecker(); } I've been trying to get this to work for about 4 hours, can someone please tell me why it keeps saying "String in the wrong format" I've tried all of this inside the the validation event, nothing I do is working. I am not understanding why.
0debug
long do_rt_sigreturn(CPUAlphaState *env) { abi_ulong frame_addr = env->ir[IR_A0]; struct target_rt_sigframe *frame; sigset_t set; if (!lock_user_struct(VERIFY_READ, frame, frame_addr, 1)) { goto badframe; } target_to_host_sigset(&set, &frame->uc.tuc_sigmask); sigprocmask(SIG_SETMASK, &set, NULL); if (restore_sigcontext(env, &frame->uc.tuc_mcontext)) { goto badframe; } if (do_sigaltstack(frame_addr + offsetof(struct target_rt_sigframe, uc.tuc_stack), 0, env->ir[IR_SP]) == -EFAULT) { goto badframe; } unlock_user_struct(frame, frame_addr, 0); return env->ir[IR_V0]; badframe: unlock_user_struct(frame, frame_addr, 0); force_sig(TARGET_SIGSEGV); }
1threat
Strings within strings in Haskell : In natural language it is quite common to have quotation marks within quotation marks, as in, for example: (1) "This sentence is not a "sentence" " (2) "‘S’ is true in language L iff S" (2) is in fact important for any Tarskian truth-definition (Tarski argued the truth of every instance of (2) was necessary for the material adequacy of a truth definition). Other examples arise in the study of paradoxes; for example, in Quine's paradox https://en.wikipedia.org/wiki/Quine%27s_paradox we are led to consider (3) (3) "The statement "'yields falsehood when preceded by its quotation' yields falsehood when preceded by its quotation" is false" I am interested in how quotations within quotations can be implemented in Haskell. A simple type search for (3), `:t ("The statement "'yields falsehood when preceded by its quotation' yields falsehood when preceded by its quotation" is false")` yields (no pun intended!) <interactive>:1:18: error: • Syntax error on 'yields Perhaps you intended to use TemplateHaskell or TemplateHaskellQuotes • In the Template Haskell quotation 'yields and perhaps for obvious reasons. Would allowing strings such as (1)-(3) necessitate modifying elements of the syntax of Haskell, or is there some way they can be accommodated? Can anyone suggest how we can accomodate quotations within quotations within Haskell?
0debug
START_TEST(escaped_string) { int i; struct { const char *encoded; const char *decoded; int skip; } test_cases[] = { { "\"\\\"\"", "\"" }, { "\"hello world \\\"embedded string\\\"\"", "hello world \"embedded string\"" }, { "\"hello world\\nwith new line\"", "hello world\nwith new line" }, { "\"single byte utf-8 \\u0020\"", "single byte utf-8 ", .skip = 1 }, { "\"double byte utf-8 \\u00A2\"", "double byte utf-8 \xc2\xa2" }, { "\"triple byte utf-8 \\u20AC\"", "triple byte utf-8 \xe2\x82\xac" }, {} }; for (i = 0; test_cases[i].encoded; i++) { QObject *obj; QString *str; obj = qobject_from_json(test_cases[i].encoded); fail_unless(obj != NULL); fail_unless(qobject_type(obj) == QTYPE_QSTRING); str = qobject_to_qstring(obj); fail_unless(strcmp(qstring_get_str(str), test_cases[i].decoded) == 0); if (test_cases[i].skip == 0) { str = qobject_to_json(obj); fail_unless(strcmp(qstring_get_str(str), test_cases[i].encoded) == 0); qobject_decref(obj); } QDECREF(str); } }
1threat
Replacing zeros after period : I have a string a="1,2,3,4.2300" I need to replace the last two zeros which follows after '.' for an example, it has to replace the values this way. If "1,2,3,4.2300" then 1,2,3,4.23 If "1,2,3,4.20300" then 1,2,3,4.203 How could I do this in Ruby? I tried with converting into Float but it terminates the string when I encounter a ','. Can I write any regular expression for this?
0debug
Mysterious Issue in Replicating Binary files in C : <p>Hey community i'm having trouble in replicating binary files from the command line have a look at my try. The code under copies the first character on the srcFile and stops somehow, can you guys help me figure the way i can fix this and the reason it happens?</p> <pre><code>#include &lt;stdio.h&gt; #include &lt;stdlib.h&gt; #define BUFSIZE 8500 int main(int argc, char** argv) { char buffer[BUFSIZE]; size_t currBit; FILE *srcFile = fopen(argv[1], "r+b"); if (!srcFile) { printf("source file doesnt exist or problem with allocating the memory"); return 1; } FILE *dstFile = fopen(argv[2], "r+b"); if (dstFile) { printf("Destination file already exists\nfor overwriting enter 1 \nfor exit enter 2\n"); _flushall(); switch (getchar()) { case '1': fclose(dstFile); dstFile = fopen(argv[2], "w+b"); if (!dstFile) { printf("Problem with allocating the memory"); } while ((currBit = fread(buffer, sizeof(char),BUFSIZE, srcFile) &gt; 0)) { fwrite(buffer, sizeof(char), currBit, dstFile); } break; case '2': system("pause"); return 0; break; default: printf("next time you should enter numbers as following"); } } else { dstFile = fopen(argv[2], "w+b"); while ((currBit = fread(buffer, sizeof(char), BUFSIZE, srcFile) &gt; 0)) { fwrite(buffer, sizeof(char), currBit, dstFile); } if (!dstFile) { printf("Problem with allocating the memory"); } } fclose(srcFile); fclose(dstFile); getchar(); return 0; } </code></pre> <p>Input Source file: 10100101</p> <p>Expected Output From Destination File: 10100101</p> <p>Destination File Output: 1</p>
0debug
I wanna to add a photo on sphere ARKit Swift 4 just like this photo in bio : [enter image description here][1]**enter image description here** I wanna to add a photo on sphere ARKit Swift 4 just like this photo in bio [1]: https://i.stack.imgur.com/lAnaA.png
0debug
static int nbd_receive_options(NBDClient *client) { int csock = client->sock; uint32_t flags; if (read_sync(csock, &flags, sizeof(flags)) != sizeof(flags)) { LOG("read failed"); return -EIO; } TRACE("Checking client flags"); be32_to_cpus(&flags); if (flags != 0 && flags != NBD_FLAG_C_FIXED_NEWSTYLE) { LOG("Bad client flags received"); return -EIO; } while (1) { int ret; uint32_t tmp, length; uint64_t magic; if (read_sync(csock, &magic, sizeof(magic)) != sizeof(magic)) { LOG("read failed"); return -EINVAL; } TRACE("Checking opts magic"); if (magic != be64_to_cpu(NBD_OPTS_MAGIC)) { LOG("Bad magic received"); return -EINVAL; } if (read_sync(csock, &tmp, sizeof(tmp)) != sizeof(tmp)) { LOG("read failed"); return -EINVAL; } if (read_sync(csock, &length, sizeof(length)) != sizeof(length)) { LOG("read failed"); return -EINVAL; } length = be32_to_cpu(length); TRACE("Checking option"); switch (be32_to_cpu(tmp)) { case NBD_OPT_LIST: ret = nbd_handle_list(client, length); if (ret < 0) { return ret; } break; case NBD_OPT_ABORT: return -EINVAL; case NBD_OPT_EXPORT_NAME: return nbd_handle_export_name(client, length); default: tmp = be32_to_cpu(tmp); LOG("Unsupported option 0x%x", tmp); nbd_send_rep(client->sock, NBD_REP_ERR_UNSUP, tmp); return -EINVAL; } } }
1threat
PHP-I need to use the explode function for white spaces in the $str, after loading content of txt file to $str.But it dont seem to work well : $filename='acct.txt'; $str=file_get_contents($filename); print_r (explode("\t",$str)); Output Array ( [0] => 101 [1] => 345.23 102 [2] => 43.2 103 [3] => 0 104 [4] => 33 ) print_r (explode(" ",$str)); output Array ( [0] => 101 [1] => 345.23 102 [2] => 43.2 103 [3] => 0 104 [4] => 33 ) file contains this: 101 345.23 102 43.2 103 0 104 33 How should I change it to get one element at a time: ie: Array ( [0] => 101 [1] => 345.23 [2] => 102 ....[8]=>33) Thanks for any Help!
0debug
static int decode_header(SnowContext *s){ int plane_index, tmp; uint8_t kstate[32]; memset(kstate, MID_STATE, sizeof(kstate)); s->keyframe= get_rac(&s->c, kstate); if(s->keyframe || s->always_reset){ ff_snow_reset_contexts(s); s->spatial_decomposition_type= s->qlog= s->qbias= s->mv_scale= s->block_max_depth= 0; } if(s->keyframe){ GET_S(s->version, tmp <= 0U) s->always_reset= get_rac(&s->c, s->header_state); s->temporal_decomposition_type= get_symbol(&s->c, s->header_state, 0); s->temporal_decomposition_count= get_symbol(&s->c, s->header_state, 0); GET_S(s->spatial_decomposition_count, 0 < tmp && tmp <= MAX_DECOMPOSITIONS) s->colorspace_type= get_symbol(&s->c, s->header_state, 0); if (s->colorspace_type == 1) { s->avctx->pix_fmt= AV_PIX_FMT_GRAY8; s->nb_planes = 1; } else if(s->colorspace_type == 0) { s->chroma_h_shift= get_symbol(&s->c, s->header_state, 0); s->chroma_v_shift= get_symbol(&s->c, s->header_state, 0); if(s->chroma_h_shift == 1 && s->chroma_v_shift==1){ s->avctx->pix_fmt= AV_PIX_FMT_YUV420P; }else if(s->chroma_h_shift == 0 && s->chroma_v_shift==0){ s->avctx->pix_fmt= AV_PIX_FMT_YUV444P; }else if(s->chroma_h_shift == 2 && s->chroma_v_shift==2){ s->avctx->pix_fmt= AV_PIX_FMT_YUV410P; } else { av_log(s, AV_LOG_ERROR, "unsupported color subsample mode %d %d\n", s->chroma_h_shift, s->chroma_v_shift); s->chroma_h_shift = s->chroma_v_shift = 1; s->avctx->pix_fmt= AV_PIX_FMT_YUV420P; return AVERROR_INVALIDDATA; } s->nb_planes = 3; } else { av_log(s, AV_LOG_ERROR, "unsupported color space\n"); s->chroma_h_shift = s->chroma_v_shift = 1; s->avctx->pix_fmt= AV_PIX_FMT_YUV420P; return AVERROR_INVALIDDATA; } s->spatial_scalability= get_rac(&s->c, s->header_state); GET_S(s->max_ref_frames, tmp < (unsigned)MAX_REF_FRAMES) s->max_ref_frames++; decode_qlogs(s); } if(!s->keyframe){ if(get_rac(&s->c, s->header_state)){ for(plane_index=0; plane_index<FFMIN(s->nb_planes, 2); plane_index++){ int htaps, i, sum=0; Plane *p= &s->plane[plane_index]; p->diag_mc= get_rac(&s->c, s->header_state); htaps= get_symbol(&s->c, s->header_state, 0)*2 + 2; if((unsigned)htaps >= HTAPS_MAX || htaps==0) return AVERROR_INVALIDDATA; p->htaps= htaps; for(i= htaps/2; i; i--){ p->hcoeff[i]= get_symbol(&s->c, s->header_state, 0) * (1-2*(i&1)); sum += p->hcoeff[i]; } p->hcoeff[0]= 32-sum; } s->plane[2].diag_mc= s->plane[1].diag_mc; s->plane[2].htaps = s->plane[1].htaps; memcpy(s->plane[2].hcoeff, s->plane[1].hcoeff, sizeof(s->plane[1].hcoeff)); } if(get_rac(&s->c, s->header_state)){ GET_S(s->spatial_decomposition_count, 0 < tmp && tmp <= MAX_DECOMPOSITIONS) decode_qlogs(s); } } s->spatial_decomposition_type+= get_symbol(&s->c, s->header_state, 1); if(s->spatial_decomposition_type > 1U){ av_log(s->avctx, AV_LOG_ERROR, "spatial_decomposition_type %d not supported\n", s->spatial_decomposition_type); return AVERROR_INVALIDDATA; } if(FFMIN(s->avctx-> width>>s->chroma_h_shift, s->avctx->height>>s->chroma_v_shift) >> (s->spatial_decomposition_count-1) <= 1){ av_log(s->avctx, AV_LOG_ERROR, "spatial_decomposition_count %d too large for size\n", s->spatial_decomposition_count); return AVERROR_INVALIDDATA; } if (s->avctx->width > 65536-4) { av_log(s->avctx, AV_LOG_ERROR, "Width %d is too large\n", s->avctx->width); return AVERROR_INVALIDDATA; } s->qlog += get_symbol(&s->c, s->header_state, 1); s->mv_scale += get_symbol(&s->c, s->header_state, 1); s->qbias += get_symbol(&s->c, s->header_state, 1); s->block_max_depth+= get_symbol(&s->c, s->header_state, 1); if(s->block_max_depth > 1 || s->block_max_depth < 0 || s->mv_scale > 256U){ av_log(s->avctx, AV_LOG_ERROR, "block_max_depth= %d is too large\n", s->block_max_depth); s->block_max_depth= 0; s->mv_scale = 0; return AVERROR_INVALIDDATA; } if (FFABS(s->qbias) > 127) { av_log(s->avctx, AV_LOG_ERROR, "qbias %d is too large\n", s->qbias); s->qbias = 0; return AVERROR_INVALIDDATA; } return 0; }
1threat
Why we are using equals() method in HashMap and HashSet without implementing comparator interface? : <p>Why we are using equals() method in HashMap and HashSet without implementing the comparator interface?. I have seen some example programs in the above concept. But there without comparator interface, they are using equals() and hashcode() method. My question is ,can we use those methods without comparator interface? And also can we use equals() and hashcode() and compareTo() methods with comparable interface ?</p>
0debug
can someone explain output of this program? : output of this program is: XBCDO HELLE can someone explain why this is so? #include<stdio.h> void swap(char ** p,char **q){ char *temp=*p; *p=*q; *q=temp; } int main(){ int i=10; char a[10]="HELLO"; char b[10]="XBCDE"; swap(&a,&b); printf("%s %s",a,b); }
0debug
static inline void gen_branch_cond(DisasContext *ctx, TCGCond cond, TCGv r1, TCGv r2, int16_t address) { int jumpLabel; jumpLabel = gen_new_label(); tcg_gen_brcond_tl(cond, r1, r2, jumpLabel); gen_goto_tb(ctx, 1, ctx->next_pc); gen_set_label(jumpLabel); gen_goto_tb(ctx, 0, ctx->pc + address * 2); }
1threat
Java server application needs 2 GB heap size : <p>Is it normal that Java server application deployed on application server (WildFly) needs 2 GB heap size because otherwise sometimes it crashes with OutOfMemoryError? It has ~1.5k users daily, max 100 users on page at the same time. Application doesn't use HTTP session.</p>
0debug
Angular-CLI ng new: "Error: EPERM: operation not permitted..." : <p>I am trying to use Angular-CLI to install a new Angular2 app, but keep running into the following issue:</p> <p><code>ng new payment-calc-app</code></p> <p>After "Installing packages for tooling via npm", I get the following Error codes:</p> <pre><code>npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@^1.0.0 (node_modules\chokidar\node_modules\fsevents): npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.1.1: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"}) npm ERR! path C:\Users\jweston\Documents\Apps\payment-calc-app\node_modules\.staging\rxjs-ccea9159 npm ERR! code EPERM npm ERR! errno -4048 npm ERR! syscall rename npm ERR! Error: EPERM: operation not permitted, rename 'C:\Users\jweston\Documents\Apps\payment-calc-app\node_modules\.staging\rxjs-ccea9159' -&gt; 'C:\Users\jweston\Documents\Apps\payment-calc-app\node_modules\rxjs' npm ERR! at destStatted (C:\Users\jweston\AppData\Roaming\npm\node_modules\npm\lib\install\action\finalize.js:29:7) npm ERR! at C:\Users\jweston\AppData\Roaming\npm\node_modules\npm\node_modules\graceful-fs\polyfills.js:284:29 npm ERR! at FSReqWrap.oncomplete (fs.js:123:15) npm ERR! npm ERR! Error: EPERM: operation not permitted, rename 'C:\Users\jweston\Documents\Apps\payment-calc-app\node_modules\.staging\rxjs-ccea9159' -&gt; 'C:\Users\jweston\Documents\Apps\payment-calc-app\node_modules\rxjs' npm ERR! at Error (native) npm ERR! { Error: EPERM: operation not permitted, rename 'C:\Users\jweston\Documents\Apps\payment-calc-app\node_modules\.staging\rxjs-ccea9159' -&gt; 'C:\Users\jweston\Documents\Apps\payment-calc-app\node_modules\rxjs' npm ERR! at destStatted (C:\Users\jweston\AppData\Roaming\npm\node_modules\npm\lib\install\action\finalize.js:29:7) npm ERR! at C:\Users\jweston\AppData\Roaming\npm\node_modules\npm\node_modules\graceful-fs\polyfills.js:284:29 npm ERR! at FSReqWrap.oncomplete (fs.js:123:15) npm ERR! npm ERR! Error: EPERM: operation not permitted, rename 'C:\Users\jweston\Documents\Apps\payment-calc-app\node_modules\.staging\rxjs-ccea9159' -&gt; 'C:\Users\jweston\Documents\Apps\payment-calc-app\node_modules\rxjs' npm ERR! at Error (native) parent: 'payment-calc-app' } npm ERR! npm ERR! Please try running this command again as root/Administrator. npm ERR! A complete log of this run can be found in: npm ERR! C:\Users\jweston\AppData\Roaming\npm-cache\_logs\2017-03-23T19_17_36_190Z-debug.log Package install failed, see above. </code></pre> <p>I've tried <code>npm clean cache</code> and running Command Prompt as an Administrator (I'm on Windows) to no avail. </p> <p>Oddly enough, when I go to try to delete the folders that the failed installation created, Windows prevents me from deleting them, saying I need to be an Administrator to delete them, even though I am an administrator. I need to go into each individual folder and delete each individual file one at a time.</p>
0debug
static void dec_sru(DisasContext *dc) { if (dc->format == OP_FMT_RI) { LOG_DIS("srui r%d, r%d, %d\n", dc->r1, dc->r0, dc->imm5); } else { LOG_DIS("sru r%d, r%d, r%d\n", dc->r2, dc->r0, dc->r1); } if (!(dc->env->features & LM32_FEATURE_SHIFT)) { if (dc->format == OP_FMT_RI) { } else { if (dc->imm5 != 1) { cpu_abort(dc->env, "hardware shifter is not available\n"); } } } if (dc->format == OP_FMT_RI) { tcg_gen_shri_tl(cpu_R[dc->r1], cpu_R[dc->r0], dc->imm5); } else { TCGv t0 = tcg_temp_new(); tcg_gen_andi_tl(t0, cpu_R[dc->r1], 0x1f); tcg_gen_shr_tl(cpu_R[dc->r2], cpu_R[dc->r0], t0); tcg_temp_free(t0); } }
1threat
Write data in JSON file, send JSON file from client to server, read JSON. Android - Java : i have this question for you: I have a client/server application, the Client is an Android Java Application developed with Android Studio and and Server is a classic Java Application for PC. Here the screens of interested parts: Client: [Client][1] Server: [Server][2] Now i what i need is that when i click on button "RICHIEDI" in android application (client), the fields Nome and Cognome gone write on a JSON file and this JSON sent to PC Java application (server) and then the Nome and Cognome shows in the two jtextfield of the server application, how can i do it? can you help me? [1]: https://i.stack.imgur.com/ofLGY.png [2]: https://i.stack.imgur.com/unXi5.png
0debug
How to set the workdir of a container launched by Kubernetes : <p>Is it possible to set the working directory when launching a container with Kubernetes ?</p>
0debug
Prevent coercion of pandas data frames while indexing and inserting rows : <p>I'm working with individual rows of pandas data frames, but I'm stumbling over coercion issues while indexing and inserting rows. Pandas seems to always want to coerce from a mixed int/float to all-float types, and I can't see any obvious controls on this behaviour.</p> <p>For example, here is a simple data frame with <code>a</code> as <code>int</code> and <code>b</code> as <code>float</code>:</p> <pre><code>import pandas as pd pd.__version__ # '0.25.2' df = pd.DataFrame({'a': [1], 'b': [2.2]}) print(df) # a b # 0 1 2.2 print(df.dtypes) # a int64 # b float64 # dtype: object </code></pre> <p>Here is a coercion issue while indexing one row:</p> <pre><code>print(df.loc[0]) # a 1.0 # b 2.2 # Name: 0, dtype: float64 print(dict(df.loc[0])) # {'a': 1.0, 'b': 2.2} </code></pre> <p>And here is a coercion issue while inserting one row:</p> <pre><code>df.loc[1] = {'a': 5, 'b': 4.4} print(df) # a b # 0 1.0 2.2 # 1 5.0 4.4 print(df.dtypes) # a float64 # b float64 # dtype: object </code></pre> <p>In both instances, I want the <code>a</code> column to remain as an integer type, rather than being coerced to a float type.</p>
0debug
static void sd_reset(SDState *sd, BlockDriverState *bdrv) { uint64_t size; uint64_t sect; if (bdrv) { bdrv_get_geometry(bdrv, &sect); } else { sect = 0; } sect <<= 9; size = sect + 1; sect = (size >> (HWBLOCK_SHIFT + SECTOR_SHIFT + WPGROUP_SHIFT)) + 1; sd->state = sd_idle_state; sd->rca = 0x0000; sd_set_ocr(sd); sd_set_scr(sd); sd_set_cid(sd); sd_set_csd(sd, size); sd_set_cardstatus(sd); sd_set_sdstatus(sd); sd->bdrv = bdrv; if (sd->wp_groups) qemu_free(sd->wp_groups); sd->wp_switch = bdrv ? bdrv_is_read_only(bdrv) : 0; sd->wp_groups = (int *) qemu_mallocz(sizeof(int) * sect); memset(sd->function_group, 0, sizeof(int) * 6); sd->erase_start = 0; sd->erase_end = 0; sd->size = size; sd->blk_len = 0x200; sd->pwd_len = 0; }
1threat
Retrofit 2 void return : <p>In Retrofit 2, service methods representing http methods must return <code>Call</code>. </p> <p><code>Call</code> is a generic which must take the type representing the return object of the http method. </p> <p>For example, </p> <pre><code>@GET("/members/{id}") Call&lt;Member&gt; getMember(@Path("id") Long id); </code></pre> <p>For http methods such as delete, no content is returned. In cases like this, what parameter should be provided to <code>Call</code>?</p>
0debug
Inserting next row field into first row field meeting conditions using SQL : I need to insert corresponding row EditedDate to NextDate and so on such that when status = Passive for ID=502 corresponding row EditedDate i.e 2017-07-31 14:17:14.000 should be inserted into NextDate for ID=502 and When status = Passive for last line for ID=1702 then same EditedDate i.e 2017-08-01 17:30:55.000 should be inserted into NextDate of last line for ID=1702 [Image Here][1] [1]: https://i.stack.imgur.com/e09Ki.jpg
0debug
Difference between "vue create NewProjectsName" and "vue init webpack NewProjectsName"? : <p>What is the difference between <code>vue create NewProjectsName</code> and <code>vue init webpack NewProjectsName</code> commands in vue cli. </p>
0debug
Installing guppy with pip3 issues : <p>I am trying to install <a href="https://pypi.python.org/pypi/guppy/" rel="noreferrer">guppy</a>. My program uses python3 so I must use pip3 exclusively. When I run:</p> <pre><code>pip3 install guppy </code></pre> <p>I get:</p> <pre><code>src/sets/sets.c:77:1: error: expected function body after function declarator INITFUNC (void) ^ src/sets/sets.c:39:18: note: expanded from macro 'INITFUNC' #define INITFUNC initsetsc ^ 1 error generated. error: command 'clang' failed with exit status 1 </code></pre> <p>I tried doing <a href="https://stackoverflow.com/questions/10238458/cant-install-orange-error-command-clang-failed-with-exit-status-1">this</a>, even thourgh it wasn't the same and exported gcc and g++:</p> <pre><code>➜ ~ export CC=gcc ➜ ~ export CXX=g++ </code></pre> <p>Running again:</p> <pre><code>src/sets/sets.c:77:1: error: expected function body after function declarator INITFUNC (void) ^ src/sets/sets.c:39:18: note: expanded from macro 'INITFUNC' #define INITFUNC initsetsc ^ 1 error generated. error: command 'gcc' failed with exit status 1 </code></pre> <p>Most who had this issue used <code>sudo apt-get python-dev</code> or something of the like to resolve this issue, I couldn't find an equivalent for Mac. Is there a way to resolve this issue?</p>
0debug
Proper way to use PDO/PHP to insert data into a preset database and table in mySQL : <p>So, I've been using PDO/PHP to build a login/sign-up form for my website. Now that I've managed to use PDO to connect and build a complete database and table that I want the data to go in. I want to know what would the proper way to insert data into that table using the $_POST superglobal. Thanks.</p>
0debug
What is returned in std::smatch and how are you supposed to use it? : <p>string <code>"I am 5 years old"</code></p> <p>regex <code>"(?!am )\d"</code></p> <p>if you go to <a href="http://regexr.com/" rel="noreferrer">http://regexr.com/</a> and apply regex to the string you'll get 5. I would like to get this result with std::regex, but I do not understand how to use match results and probably regex has to be changed as well.</p> <pre><code>std::regex expression("(?!am )\\d"); std::smatch match; std::string what("I am 5 years old."); if (regex_search(what, match, expression)) { //??? } </code></pre>
0debug
How to use destructuring assignment to define enumerations in ES6? : <p>You can use destructuring assignment to define enumerations in ES6 as follows:</p> <pre class="lang-js prettyprint-override"><code>var [red, green, blue] = [0, 1, 2]; </code></pre> <p>Instead, I'd like the right hand side of the destructuring assignment to be dynamic. For example:</p> <pre class="lang-js prettyprint-override"><code>var MAX_ENUM_SIZE = 32; var ENUM = new Array(MAX_ENUM_SIZE); for (var i = 0; i &lt; MAX_ENUM_SIZE; i++) ENUM[i] = i; var [red, green, blue] = ENUM; </code></pre> <p>Unfortunately, this seems like a hack. What if I want a bigger enumeration in the future? Hence, I was thinking of using destructuring assignment with an iterator as follows:</p> <pre class="lang-js prettyprint-override"><code>var [red, green, blue] = enumeration(/* I don't want to specify size */); </code></pre> <p>However, I don't think it's possible to use destructuring assignment with iterators<sup>[citation needed]</sup>. Is there any way to accomplish this goal?</p>
0debug
static void iv_Decode_Chunk(Indeo3DecodeContext *s, uint8_t *cur, uint8_t *ref, int width, int height, const uint8_t *buf1, long cb_offset, const uint8_t *hdr, const uint8_t *buf2, int min_width_160) { uint8_t bit_buf; unsigned long bit_pos, lv, lv1, lv2; long *width_tbl, width_tbl_arr[10]; const signed char *ref_vectors; uint8_t *cur_frm_pos, *ref_frm_pos, *cp, *cp2; uint32_t *cur_lp, *ref_lp; const uint32_t *correction_lp[2], *correctionloworder_lp[2], *correctionhighorder_lp[2]; uint8_t *correction_type_sp[2]; struct ustr strip_tbl[20], *strip; int i, j, k, lp1, lp2, flag1, cmd, blks_width, blks_height, region_160_width, rle_v1, rle_v2, rle_v3; unsigned short res; bit_buf = 0; ref_vectors = NULL; width_tbl = width_tbl_arr + 1; i = (width < 0 ? width + 3 : width)/4; for(j = -1; j < 8; j++) width_tbl[j] = i * j; strip = strip_tbl; for(region_160_width = 0; region_160_width < (width - min_width_160); region_160_width += min_width_160); strip->ypos = strip->xpos = 0; for(strip->width = min_width_160; width > strip->width; strip->width *= 2); strip->height = height; strip->split_direction = 0; strip->split_flag = 0; strip->usl7 = 0; bit_pos = 0; rle_v1 = rle_v2 = rle_v3 = 0; while(strip >= strip_tbl) { if(bit_pos <= 0) { bit_pos = 8; bit_buf = *buf1++; } bit_pos -= 2; cmd = (bit_buf >> bit_pos) & 0x03; if(cmd == 0) { strip++; if(strip >= strip_tbl + FF_ARRAY_ELEMS(strip_tbl)) { av_log(s->avctx, AV_LOG_WARNING, "out of range strip\n"); break; } memcpy(strip, strip-1, sizeof(*strip)); strip->split_flag = 1; strip->split_direction = 0; strip->height = (strip->height > 8 ? ((strip->height+8)>>4)<<3 : 4); continue; } else if(cmd == 1) { strip++; if(strip >= strip_tbl + FF_ARRAY_ELEMS(strip_tbl)) { av_log(s->avctx, AV_LOG_WARNING, "out of range strip\n"); break; } memcpy(strip, strip-1, sizeof(*strip)); strip->split_flag = 1; strip->split_direction = 1; strip->width = (strip->width > 8 ? ((strip->width+8)>>4)<<3 : 4); continue; } else if(cmd == 2) { if(strip->usl7 == 0) { strip->usl7 = 1; ref_vectors = NULL; continue; } } else if(cmd == 3) { if(strip->usl7 == 0) { strip->usl7 = 1; ref_vectors = (const signed char*)buf2 + (*buf1 * 2); buf1++; continue; } } cur_frm_pos = cur + width * strip->ypos + strip->xpos; if((blks_width = strip->width) < 0) blks_width += 3; blks_width >>= 2; blks_height = strip->height; if(ref_vectors != NULL) { ref_frm_pos = ref + (ref_vectors[0] + strip->ypos) * width + ref_vectors[1] + strip->xpos; } else ref_frm_pos = cur_frm_pos - width_tbl[4]; if(cmd == 2) { if(bit_pos <= 0) { bit_pos = 8; bit_buf = *buf1++; } bit_pos -= 2; cmd = (bit_buf >> bit_pos) & 0x03; if(cmd == 0 || ref_vectors != NULL) { for(lp1 = 0; lp1 < blks_width; lp1++) { for(i = 0, j = 0; i < blks_height; i++, j += width_tbl[1]) ((uint32_t *)cur_frm_pos)[j] = ((uint32_t *)ref_frm_pos)[j]; cur_frm_pos += 4; ref_frm_pos += 4; } } else if(cmd != 1) return; } else { k = *buf1 >> 4; j = *buf1 & 0x0f; buf1++; lv = j + cb_offset; if((lv - 8) <= 7 && (k == 0 || k == 3 || k == 10)) { cp2 = s->ModPred + ((lv - 8) << 7); cp = ref_frm_pos; for(i = 0; i < blks_width << 2; i++) { int v = *cp >> 1; *(cp++) = cp2[v]; } } if(k == 1 || k == 4) { lv = (hdr[j] & 0xf) + cb_offset; correction_type_sp[0] = s->corrector_type + (lv << 8); correction_lp[0] = correction + (lv << 8); lv = (hdr[j] >> 4) + cb_offset; correction_lp[1] = correction + (lv << 8); correction_type_sp[1] = s->corrector_type + (lv << 8); } else { correctionloworder_lp[0] = correctionloworder_lp[1] = correctionloworder + (lv << 8); correctionhighorder_lp[0] = correctionhighorder_lp[1] = correctionhighorder + (lv << 8); correction_type_sp[0] = correction_type_sp[1] = s->corrector_type + (lv << 8); correction_lp[0] = correction_lp[1] = correction + (lv << 8); } switch(k) { case 1: case 0: for( ; blks_height > 0; blks_height -= 4) { for(lp1 = 0; lp1 < blks_width; lp1++) { for(lp2 = 0; lp2 < 4; ) { k = *buf1++; cur_lp = ((uint32_t *)cur_frm_pos) + width_tbl[lp2]; ref_lp = ((uint32_t *)ref_frm_pos) + width_tbl[lp2]; switch(correction_type_sp[0][k]) { case 0: *cur_lp = le2me_32(((le2me_32(*ref_lp) >> 1) + correction_lp[lp2 & 0x01][k]) << 1); lp2++; break; case 1: res = ((le2me_16(((unsigned short *)(ref_lp))[0]) >> 1) + correction_lp[lp2 & 0x01][*buf1]) << 1; ((unsigned short *)cur_lp)[0] = le2me_16(res); res = ((le2me_16(((unsigned short *)(ref_lp))[1]) >> 1) + correction_lp[lp2 & 0x01][k]) << 1; ((unsigned short *)cur_lp)[1] = le2me_16(res); buf1++; lp2++; break; case 2: if(lp2 == 0) { for(i = 0, j = 0; i < 2; i++, j += width_tbl[1]) cur_lp[j] = ref_lp[j]; lp2 += 2; } break; case 3: if(lp2 < 2) { for(i = 0, j = 0; i < (3 - lp2); i++, j += width_tbl[1]) cur_lp[j] = ref_lp[j]; lp2 = 3; } break; case 8: if(lp2 == 0) { RLE_V3_CHECK(buf1,rle_v1,rle_v2,rle_v3) if(rle_v1 == 1 || ref_vectors != NULL) { for(i = 0, j = 0; i < 4; i++, j += width_tbl[1]) cur_lp[j] = ref_lp[j]; } RLE_V2_CHECK(buf1,rle_v2, rle_v3,lp2) break; } else { rle_v1 = 1; rle_v2 = *buf1 - 1; } case 5: LP2_CHECK(buf1,rle_v3,lp2) case 4: for(i = 0, j = 0; i < (4 - lp2); i++, j += width_tbl[1]) cur_lp[j] = ref_lp[j]; lp2 = 4; break; case 7: if(rle_v3 != 0) rle_v3 = 0; else { buf1--; rle_v3 = 1; } case 6: if(ref_vectors != NULL) { for(i = 0, j = 0; i < 4; i++, j += width_tbl[1]) cur_lp[j] = ref_lp[j]; } lp2 = 4; break; case 9: lv1 = *buf1++; lv = (lv1 & 0x7F) << 1; lv += (lv << 8); lv += (lv << 16); for(i = 0, j = 0; i < 4; i++, j += width_tbl[1]) cur_lp[j] = lv; LV1_CHECK(buf1,rle_v3,lv1,lp2) break; default: return; } } cur_frm_pos += 4; ref_frm_pos += 4; } cur_frm_pos += ((width - blks_width) * 4); ref_frm_pos += ((width - blks_width) * 4); } break; case 4: case 3: if(ref_vectors != NULL) return; flag1 = 1; for( ; blks_height > 0; blks_height -= 8) { for(lp1 = 0; lp1 < blks_width; lp1++) { for(lp2 = 0; lp2 < 4; ) { k = *buf1++; cur_lp = ((uint32_t *)cur_frm_pos) + width_tbl[lp2 * 2]; ref_lp = ((uint32_t *)cur_frm_pos) + width_tbl[(lp2 * 2) - 1]; switch(correction_type_sp[lp2 & 0x01][k]) { case 0: cur_lp[width_tbl[1]] = le2me_32(((le2me_32(*ref_lp) >> 1) + correction_lp[lp2 & 0x01][k]) << 1); if(lp2 > 0 || flag1 == 0 || strip->ypos != 0) cur_lp[0] = ((cur_lp[-width_tbl[1]] >> 1) + (cur_lp[width_tbl[1]] >> 1)) & 0xFEFEFEFE; else cur_lp[0] = le2me_32(((le2me_32(*ref_lp) >> 1) + correction_lp[lp2 & 0x01][k]) << 1); lp2++; break; case 1: res = ((le2me_16(((unsigned short *)ref_lp)[0]) >> 1) + correction_lp[lp2 & 0x01][*buf1]) << 1; ((unsigned short *)cur_lp)[width_tbl[2]] = le2me_16(res); res = ((le2me_16(((unsigned short *)ref_lp)[1]) >> 1) + correction_lp[lp2 & 0x01][k]) << 1; ((unsigned short *)cur_lp)[width_tbl[2]+1] = le2me_16(res); if(lp2 > 0 || flag1 == 0 || strip->ypos != 0) cur_lp[0] = ((cur_lp[-width_tbl[1]] >> 1) + (cur_lp[width_tbl[1]] >> 1)) & 0xFEFEFEFE; else cur_lp[0] = cur_lp[width_tbl[1]]; buf1++; lp2++; break; case 2: if(lp2 == 0) { for(i = 0, j = 0; i < 4; i++, j += width_tbl[1]) cur_lp[j] = *ref_lp; lp2 += 2; } break; case 3: if(lp2 < 2) { for(i = 0, j = 0; i < 6 - (lp2 * 2); i++, j += width_tbl[1]) cur_lp[j] = *ref_lp; lp2 = 3; } break; case 6: lp2 = 4; break; case 7: if(rle_v3 != 0) rle_v3 = 0; else { buf1--; rle_v3 = 1; } lp2 = 4; break; case 8: if(lp2 == 0) { RLE_V3_CHECK(buf1,rle_v1,rle_v2,rle_v3) if(rle_v1 == 1) { for(i = 0, j = 0; i < 8; i++, j += width_tbl[1]) cur_lp[j] = ref_lp[j]; } RLE_V2_CHECK(buf1,rle_v2, rle_v3,lp2) break; } else { rle_v2 = (*buf1) - 1; rle_v1 = 1; } case 5: LP2_CHECK(buf1,rle_v3,lp2) case 4: for(i = 0, j = 0; i < 8 - (lp2 * 2); i++, j += width_tbl[1]) cur_lp[j] = *ref_lp; lp2 = 4; break; case 9: av_log(s->avctx, AV_LOG_ERROR, "UNTESTED.\n"); lv1 = *buf1++; lv = (lv1 & 0x7F) << 1; lv += (lv << 8); lv += (lv << 16); for(i = 0, j = 0; i < 4; i++, j += width_tbl[1]) cur_lp[j] = lv; LV1_CHECK(buf1,rle_v3,lv1,lp2) break; default: return; } } cur_frm_pos += 4; } cur_frm_pos += (((width * 2) - blks_width) * 4); flag1 = 0; } break; case 10: if(ref_vectors == NULL) { flag1 = 1; for( ; blks_height > 0; blks_height -= 8) { for(lp1 = 0; lp1 < blks_width; lp1 += 2) { for(lp2 = 0; lp2 < 4; ) { k = *buf1++; cur_lp = ((uint32_t *)cur_frm_pos) + width_tbl[lp2 * 2]; ref_lp = ((uint32_t *)cur_frm_pos) + width_tbl[(lp2 * 2) - 1]; lv1 = ref_lp[0]; lv2 = ref_lp[1]; if(lp2 == 0 && flag1 != 0) { #ifdef WORDS_BIGENDIAN lv1 = lv1 & 0xFF00FF00; lv1 = (lv1 >> 8) | lv1; lv2 = lv2 & 0xFF00FF00; lv2 = (lv2 >> 8) | lv2; #else lv1 = lv1 & 0x00FF00FF; lv1 = (lv1 << 8) | lv1; lv2 = lv2 & 0x00FF00FF; lv2 = (lv2 << 8) | lv2; #endif } switch(correction_type_sp[lp2 & 0x01][k]) { case 0: cur_lp[width_tbl[1]] = le2me_32(((le2me_32(lv1) >> 1) + correctionloworder_lp[lp2 & 0x01][k]) << 1); cur_lp[width_tbl[1]+1] = le2me_32(((le2me_32(lv2) >> 1) + correctionhighorder_lp[lp2 & 0x01][k]) << 1); if(lp2 > 0 || strip->ypos != 0 || flag1 == 0) { cur_lp[0] = ((cur_lp[-width_tbl[1]] >> 1) + (cur_lp[width_tbl[1]] >> 1)) & 0xFEFEFEFE; cur_lp[1] = ((cur_lp[-width_tbl[1]+1] >> 1) + (cur_lp[width_tbl[1]+1] >> 1)) & 0xFEFEFEFE; } else { cur_lp[0] = cur_lp[width_tbl[1]]; cur_lp[1] = cur_lp[width_tbl[1]+1]; } lp2++; break; case 1: cur_lp[width_tbl[1]] = le2me_32(((le2me_32(lv1) >> 1) + correctionloworder_lp[lp2 & 0x01][*buf1]) << 1); cur_lp[width_tbl[1]+1] = le2me_32(((le2me_32(lv2) >> 1) + correctionloworder_lp[lp2 & 0x01][k]) << 1); if(lp2 > 0 || strip->ypos != 0 || flag1 == 0) { cur_lp[0] = ((cur_lp[-width_tbl[1]] >> 1) + (cur_lp[width_tbl[1]] >> 1)) & 0xFEFEFEFE; cur_lp[1] = ((cur_lp[-width_tbl[1]+1] >> 1) + (cur_lp[width_tbl[1]+1] >> 1)) & 0xFEFEFEFE; } else { cur_lp[0] = cur_lp[width_tbl[1]]; cur_lp[1] = cur_lp[width_tbl[1]+1]; } buf1++; lp2++; break; case 2: if(lp2 == 0) { if(flag1 != 0) { for(i = 0, j = width_tbl[1]; i < 3; i++, j += width_tbl[1]) { cur_lp[j] = lv1; cur_lp[j+1] = lv2; } cur_lp[0] = ((cur_lp[-width_tbl[1]] >> 1) + (cur_lp[width_tbl[1]] >> 1)) & 0xFEFEFEFE; cur_lp[1] = ((cur_lp[-width_tbl[1]+1] >> 1) + (cur_lp[width_tbl[1]+1] >> 1)) & 0xFEFEFEFE; } else { for(i = 0, j = 0; i < 4; i++, j += width_tbl[1]) { cur_lp[j] = lv1; cur_lp[j+1] = lv2; } } lp2 += 2; } break; case 3: if(lp2 < 2) { if(lp2 == 0 && flag1 != 0) { for(i = 0, j = width_tbl[1]; i < 5; i++, j += width_tbl[1]) { cur_lp[j] = lv1; cur_lp[j+1] = lv2; } cur_lp[0] = ((cur_lp[-width_tbl[1]] >> 1) + (cur_lp[width_tbl[1]] >> 1)) & 0xFEFEFEFE; cur_lp[1] = ((cur_lp[-width_tbl[1]+1] >> 1) + (cur_lp[width_tbl[1]+1] >> 1)) & 0xFEFEFEFE; } else { for(i = 0, j = 0; i < 6 - (lp2 * 2); i++, j += width_tbl[1]) { cur_lp[j] = lv1; cur_lp[j+1] = lv2; } } lp2 = 3; } break; case 8: if(lp2 == 0) { RLE_V3_CHECK(buf1,rle_v1,rle_v2,rle_v3) if(rle_v1 == 1) { if(flag1 != 0) { for(i = 0, j = width_tbl[1]; i < 7; i++, j += width_tbl[1]) { cur_lp[j] = lv1; cur_lp[j+1] = lv2; } cur_lp[0] = ((cur_lp[-width_tbl[1]] >> 1) + (cur_lp[width_tbl[1]] >> 1)) & 0xFEFEFEFE; cur_lp[1] = ((cur_lp[-width_tbl[1]+1] >> 1) + (cur_lp[width_tbl[1]+1] >> 1)) & 0xFEFEFEFE; } else { for(i = 0, j = 0; i < 8; i++, j += width_tbl[1]) { cur_lp[j] = lv1; cur_lp[j+1] = lv2; } } } RLE_V2_CHECK(buf1,rle_v2, rle_v3,lp2) break; } else { rle_v1 = 1; rle_v2 = (*buf1) - 1; } case 5: LP2_CHECK(buf1,rle_v3,lp2) case 4: if(lp2 == 0 && flag1 != 0) { for(i = 0, j = width_tbl[1]; i < 7; i++, j += width_tbl[1]) { cur_lp[j] = lv1; cur_lp[j+1] = lv2; } cur_lp[0] = ((cur_lp[-width_tbl[1]] >> 1) + (cur_lp[width_tbl[1]] >> 1)) & 0xFEFEFEFE; cur_lp[1] = ((cur_lp[-width_tbl[1]+1] >> 1) + (cur_lp[width_tbl[1]+1] >> 1)) & 0xFEFEFEFE; } else { for(i = 0, j = 0; i < 8 - (lp2 * 2); i++, j += width_tbl[1]) { cur_lp[j] = lv1; cur_lp[j+1] = lv2; } } lp2 = 4; break; case 6: lp2 = 4; break; case 7: if(lp2 == 0) { if(rle_v3 != 0) rle_v3 = 0; else { buf1--; rle_v3 = 1; } lp2 = 4; } break; case 9: av_log(s->avctx, AV_LOG_ERROR, "UNTESTED.\n"); lv1 = *buf1; lv = (lv1 & 0x7F) << 1; lv += (lv << 8); lv += (lv << 16); for(i = 0, j = 0; i < 8; i++, j += width_tbl[1]) cur_lp[j] = lv; LV1_CHECK(buf1,rle_v3,lv1,lp2) break; default: return; } } cur_frm_pos += 8; } cur_frm_pos += (((width * 2) - blks_width) * 4); flag1 = 0; } } else { for( ; blks_height > 0; blks_height -= 8) { for(lp1 = 0; lp1 < blks_width; lp1 += 2) { for(lp2 = 0; lp2 < 4; ) { k = *buf1++; cur_lp = ((uint32_t *)cur_frm_pos) + width_tbl[lp2 * 2]; ref_lp = ((uint32_t *)ref_frm_pos) + width_tbl[lp2 * 2]; switch(correction_type_sp[lp2 & 0x01][k]) { case 0: lv1 = correctionloworder_lp[lp2 & 0x01][k]; lv2 = correctionhighorder_lp[lp2 & 0x01][k]; cur_lp[0] = le2me_32(((le2me_32(ref_lp[0]) >> 1) + lv1) << 1); cur_lp[1] = le2me_32(((le2me_32(ref_lp[1]) >> 1) + lv2) << 1); cur_lp[width_tbl[1]] = le2me_32(((le2me_32(ref_lp[width_tbl[1]]) >> 1) + lv1) << 1); cur_lp[width_tbl[1]+1] = le2me_32(((le2me_32(ref_lp[width_tbl[1]+1]) >> 1) + lv2) << 1); lp2++; break; case 1: lv1 = correctionloworder_lp[lp2 & 0x01][*buf1++]; lv2 = correctionloworder_lp[lp2 & 0x01][k]; cur_lp[0] = le2me_32(((le2me_32(ref_lp[0]) >> 1) + lv1) << 1); cur_lp[1] = le2me_32(((le2me_32(ref_lp[1]) >> 1) + lv2) << 1); cur_lp[width_tbl[1]] = le2me_32(((le2me_32(ref_lp[width_tbl[1]]) >> 1) + lv1) << 1); cur_lp[width_tbl[1]+1] = le2me_32(((le2me_32(ref_lp[width_tbl[1]+1]) >> 1) + lv2) << 1); lp2++; break; case 2: if(lp2 == 0) { for(i = 0, j = 0; i < 4; i++, j += width_tbl[1]) { cur_lp[j] = ref_lp[j]; cur_lp[j+1] = ref_lp[j+1]; } lp2 += 2; } break; case 3: if(lp2 < 2) { for(i = 0, j = 0; i < 6 - (lp2 * 2); i++, j += width_tbl[1]) { cur_lp[j] = ref_lp[j]; cur_lp[j+1] = ref_lp[j+1]; } lp2 = 3; } break; case 8: if(lp2 == 0) { RLE_V3_CHECK(buf1,rle_v1,rle_v2,rle_v3) for(i = 0, j = 0; i < 8; i++, j += width_tbl[1]) { ((uint32_t *)cur_frm_pos)[j] = ((uint32_t *)ref_frm_pos)[j]; ((uint32_t *)cur_frm_pos)[j+1] = ((uint32_t *)ref_frm_pos)[j+1]; } RLE_V2_CHECK(buf1,rle_v2, rle_v3,lp2) break; } else { rle_v1 = 1; rle_v2 = (*buf1) - 1; } case 5: case 7: LP2_CHECK(buf1,rle_v3,lp2) case 6: case 4: for(i = 0, j = 0; i < 8 - (lp2 * 2); i++, j += width_tbl[1]) { cur_lp[j] = ref_lp[j]; cur_lp[j+1] = ref_lp[j+1]; } lp2 = 4; break; case 9: av_log(s->avctx, AV_LOG_ERROR, "UNTESTED.\n"); lv1 = *buf1; lv = (lv1 & 0x7F) << 1; lv += (lv << 8); lv += (lv << 16); for(i = 0, j = 0; i < 8; i++, j += width_tbl[1]) ((uint32_t *)cur_frm_pos)[j] = ((uint32_t *)cur_frm_pos)[j+1] = lv; LV1_CHECK(buf1,rle_v3,lv1,lp2) break; default: return; } } cur_frm_pos += 8; ref_frm_pos += 8; } cur_frm_pos += (((width * 2) - blks_width) * 4); ref_frm_pos += (((width * 2) - blks_width) * 4); } } break; case 11: if(ref_vectors == NULL) return; for( ; blks_height > 0; blks_height -= 8) { for(lp1 = 0; lp1 < blks_width; lp1++) { for(lp2 = 0; lp2 < 4; ) { k = *buf1++; cur_lp = ((uint32_t *)cur_frm_pos) + width_tbl[lp2 * 2]; ref_lp = ((uint32_t *)ref_frm_pos) + width_tbl[lp2 * 2]; switch(correction_type_sp[lp2 & 0x01][k]) { case 0: cur_lp[0] = le2me_32(((le2me_32(*ref_lp) >> 1) + correction_lp[lp2 & 0x01][k]) << 1); cur_lp[width_tbl[1]] = le2me_32(((le2me_32(ref_lp[width_tbl[1]]) >> 1) + correction_lp[lp2 & 0x01][k]) << 1); lp2++; break; case 1: lv1 = (unsigned short)(correction_lp[lp2 & 0x01][*buf1++]); lv2 = (unsigned short)(correction_lp[lp2 & 0x01][k]); res = (unsigned short)(((le2me_16(((unsigned short *)ref_lp)[0]) >> 1) + lv1) << 1); ((unsigned short *)cur_lp)[0] = le2me_16(res); res = (unsigned short)(((le2me_16(((unsigned short *)ref_lp)[1]) >> 1) + lv2) << 1); ((unsigned short *)cur_lp)[1] = le2me_16(res); res = (unsigned short)(((le2me_16(((unsigned short *)ref_lp)[width_tbl[2]]) >> 1) + lv1) << 1); ((unsigned short *)cur_lp)[width_tbl[2]] = le2me_16(res); res = (unsigned short)(((le2me_16(((unsigned short *)ref_lp)[width_tbl[2]+1]) >> 1) + lv2) << 1); ((unsigned short *)cur_lp)[width_tbl[2]+1] = le2me_16(res); lp2++; break; case 2: if(lp2 == 0) { for(i = 0, j = 0; i < 4; i++, j += width_tbl[1]) cur_lp[j] = ref_lp[j]; lp2 += 2; } break; case 3: if(lp2 < 2) { for(i = 0, j = 0; i < 6 - (lp2 * 2); i++, j += width_tbl[1]) cur_lp[j] = ref_lp[j]; lp2 = 3; } break; case 8: if(lp2 == 0) { RLE_V3_CHECK(buf1,rle_v1,rle_v2,rle_v3) for(i = 0, j = 0; i < 8; i++, j += width_tbl[1]) cur_lp[j] = ref_lp[j]; RLE_V2_CHECK(buf1,rle_v2, rle_v3,lp2) break; } else { rle_v1 = 1; rle_v2 = (*buf1) - 1; } case 5: case 7: LP2_CHECK(buf1,rle_v3,lp2) case 4: case 6: for(i = 0, j = 0; i < 8 - (lp2 * 2); i++, j += width_tbl[1]) cur_lp[j] = ref_lp[j]; lp2 = 4; break; case 9: av_log(s->avctx, AV_LOG_ERROR, "UNTESTED.\n"); lv1 = *buf1++; lv = (lv1 & 0x7F) << 1; lv += (lv << 8); lv += (lv << 16); for(i = 0, j = 0; i < 4; i++, j += width_tbl[1]) cur_lp[j] = lv; LV1_CHECK(buf1,rle_v3,lv1,lp2) break; default: return; } } cur_frm_pos += 4; ref_frm_pos += 4; } cur_frm_pos += (((width * 2) - blks_width) * 4); ref_frm_pos += (((width * 2) - blks_width) * 4); } break; default: return; } } if(strip < strip_tbl) return; for( ; strip >= strip_tbl; strip--) { if(strip->split_flag != 0) { strip->split_flag = 0; strip->usl7 = (strip-1)->usl7; if(strip->split_direction) { strip->xpos += strip->width; strip->width = (strip-1)->width - strip->width; if(region_160_width <= strip->xpos && width < strip->width + strip->xpos) strip->width = width - strip->xpos; } else { strip->ypos += strip->height; strip->height = (strip-1)->height - strip->height; } break; } } } }
1threat
How does a substitution cipher work in C? : <p>I've been researching the topic of encryption and I'm currently experimenting with using C. Does such a cipher work well in this programming language</p>
0debug
print_insn_sparc (bfd_vma memaddr, disassemble_info *info) { FILE *stream = info->stream; bfd_byte buffer[4]; unsigned long insn; sparc_opcode_hash *op; static int opcodes_initialized = 0; static unsigned long current_mach = 0; bfd_vma (*getword) (const unsigned char *); if (!opcodes_initialized || info->mach != current_mach) { int i; current_arch_mask = compute_arch_mask (info->mach); if (!opcodes_initialized) sorted_opcodes = malloc (sparc_num_opcodes * sizeof (sparc_opcode *)); for (i = 0; i < sparc_num_opcodes; ++i) sorted_opcodes[i] = &sparc_opcodes[i]; qsort ((char *) sorted_opcodes, sparc_num_opcodes, sizeof (sorted_opcodes[0]), compare_opcodes); build_hash_table (sorted_opcodes, opcode_hash_table, sparc_num_opcodes); current_mach = info->mach; opcodes_initialized = 1; } { int status = (*info->read_memory_func) (memaddr, buffer, sizeof (buffer), info); if (status != 0) { (*info->memory_error_func) (status, memaddr, info); return -1; } } if (info->endian == BFD_ENDIAN_BIG || info->mach == bfd_mach_sparc_sparclite) getword = bfd_getb32; else getword = bfd_getl32; insn = getword (buffer); info->insn_info_valid = 1; info->insn_type = dis_nonbranch; info->branch_delay_insns = 0; info->target = 0; for (op = opcode_hash_table[HASH_INSN (insn)]; op; op = op->next) { const sparc_opcode *opcode = op->opcode; if (! (opcode->architecture & current_arch_mask)) continue; if ((opcode->match & insn) == opcode->match && (opcode->lose & insn) == 0) { int imm_added_to_rs1 = 0; int imm_ored_to_rs1 = 0; int found_plus = 0; if (opcode->match == 0x80102000) imm_ored_to_rs1 = 1; if (opcode->match == 0x80002000) imm_added_to_rs1 = 1; if (X_RS1 (insn) != X_RD (insn) && strchr (opcode->args, 'r') != NULL) continue; if (X_RS2 (insn) != X_RD (insn) && strchr (opcode->args, 'O') != NULL) continue; (*info->fprintf_func) (stream, opcode->name); { const char *s; if (opcode->args[0] != ',') (*info->fprintf_func) (stream, " "); for (s = opcode->args; *s != '\0'; ++s) { while (*s == ',') { (*info->fprintf_func) (stream, ","); ++s; switch (*s) { case 'a': (*info->fprintf_func) (stream, "a"); ++s; continue; case 'N': (*info->fprintf_func) (stream, "pn"); ++s; continue; case 'T': (*info->fprintf_func) (stream, "pt"); ++s; continue; default: break; } } (*info->fprintf_func) (stream, " "); switch (*s) { case '+': found_plus = 1; default: (*info->fprintf_func) (stream, "%c", *s); break; case '#': (*info->fprintf_func) (stream, "0"); break; #define reg(n) (*info->fprintf_func) (stream, "%%%s", reg_names[n]) case '1': case 'r': reg (X_RS1 (insn)); break; case '2': case 'O': reg (X_RS2 (insn)); break; case 'd': reg (X_RD (insn)); break; #undef reg #define freg(n) (*info->fprintf_func) (stream, "%%%s", freg_names[n]) #define fregx(n) (*info->fprintf_func) (stream, "%%%s", freg_names[((n) & ~1) | (((n) & 1) << 5)]) case 'e': freg (X_RS1 (insn)); break; case 'v': case 'V': fregx (X_RS1 (insn)); break; case 'f': freg (X_RS2 (insn)); break; case 'B': case 'R': fregx (X_RS2 (insn)); break; case 'g': freg (X_RD (insn)); break; case 'H': case 'J': fregx (X_RD (insn)); break; #undef freg #undef fregx #define creg(n) (*info->fprintf_func) (stream, "%%c%u", (unsigned int) (n)) case 'b': creg (X_RS1 (insn)); break; case 'c': creg (X_RS2 (insn)); break; case 'D': creg (X_RD (insn)); break; #undef creg case 'h': (*info->fprintf_func) (stream, "%%hi(%#x)", ((unsigned) 0xFFFFFFFF & ((int) X_IMM22 (insn) << 10))); break; case 'i': case 'I': case 'j': { int imm; if (*s == 'i') imm = X_SIMM (insn, 13); else if (*s == 'I') imm = X_SIMM (insn, 11); else imm = X_SIMM (insn, 10); if (found_plus) imm_added_to_rs1 = 1; if (imm <= 9) (*info->fprintf_func) (stream, "%d", imm); else (*info->fprintf_func) (stream, "%#x", imm); } break; case 'X': case 'Y': { int imm = X_IMM (insn, *s == 'X' ? 5 : 6); if (imm <= 9) (info->fprintf_func) (stream, "%d", imm); else (info->fprintf_func) (stream, "%#x", (unsigned) imm); } break; case '3': (info->fprintf_func) (stream, "%ld", X_IMM (insn, 3)); break; case 'K': { int mask = X_MEMBAR (insn); int bit = 0x40, printed_one = 0; const char *name; if (mask == 0) (info->fprintf_func) (stream, "0"); else while (bit) { if (mask & bit) { if (printed_one) (info->fprintf_func) (stream, "|"); name = sparc_decode_membar (bit); (info->fprintf_func) (stream, "%s", name); printed_one = 1; } bit >>= 1; } break; } case 'k': info->target = memaddr + SEX (X_DISP16 (insn), 16) * 4; (*info->print_address_func) (info->target, info); break; case 'G': info->target = memaddr + SEX (X_DISP19 (insn), 19) * 4; (*info->print_address_func) (info->target, info); break; case '6': case '7': case '8': case '9': (*info->fprintf_func) (stream, "%%fcc%c", *s - '6' + '0'); break; case 'z': (*info->fprintf_func) (stream, "%%icc"); break; case 'Z': (*info->fprintf_func) (stream, "%%xcc"); break; case 'E': (*info->fprintf_func) (stream, "%%ccr"); break; case 's': (*info->fprintf_func) (stream, "%%fprs"); break; case 'o': (*info->fprintf_func) (stream, "%%asi"); break; case 'W': (*info->fprintf_func) (stream, "%%tick"); break; case 'P': (*info->fprintf_func) (stream, "%%pc"); break; case '?': if (X_RS1 (insn) == 31) (*info->fprintf_func) (stream, "%%ver"); else if ((unsigned) X_RS1 (insn) < 17) (*info->fprintf_func) (stream, "%%%s", v9_priv_reg_names[X_RS1 (insn)]); else (*info->fprintf_func) (stream, "%%reserved"); break; case '!': if ((unsigned) X_RD (insn) < 17) (*info->fprintf_func) (stream, "%%%s", v9_priv_reg_names[X_RD (insn)]); else (*info->fprintf_func) (stream, "%%reserved"); break; case '$': if ((unsigned) X_RS1 (insn) < 32) (*info->fprintf_func) (stream, "%%%s", v9_hpriv_reg_names[X_RS1 (insn)]); else (*info->fprintf_func) (stream, "%%reserved"); break; case '%': if ((unsigned) X_RD (insn) < 32) (*info->fprintf_func) (stream, "%%%s", v9_hpriv_reg_names[X_RD (insn)]); else (*info->fprintf_func) (stream, "%%reserved"); break; case '/': if (X_RS1 (insn) < 16 || X_RS1 (insn) > 25) (*info->fprintf_func) (stream, "%%reserved"); else (*info->fprintf_func) (stream, "%%%s", v9a_asr_reg_names[X_RS1 (insn)-16]); break; case '_': if (X_RD (insn) < 16 || X_RD (insn) > 25) (*info->fprintf_func) (stream, "%%reserved"); else (*info->fprintf_func) (stream, "%%%s", v9a_asr_reg_names[X_RD (insn)-16]); break; case '*': { const char *name = sparc_decode_prefetch (X_RD (insn)); if (name) (*info->fprintf_func) (stream, "%s", name); else (*info->fprintf_func) (stream, "%ld", X_RD (insn)); break; } case 'M': (*info->fprintf_func) (stream, "%%asr%ld", X_RS1 (insn)); break; case 'm': (*info->fprintf_func) (stream, "%%asr%ld", X_RD (insn)); break; case 'L': info->target = memaddr + SEX (X_DISP30 (insn), 30) * 4; (*info->print_address_func) (info->target, info); break; case 'n': (*info->fprintf_func) (stream, "%#x", SEX (X_DISP22 (insn), 22)); break; case 'l': info->target = memaddr + SEX (X_DISP22 (insn), 22) * 4; (*info->print_address_func) (info->target, info); break; case 'A': { const char *name; if ((info->mach == bfd_mach_sparc_v8plusa) || ((info->mach >= bfd_mach_sparc_v9) && (info->mach <= bfd_mach_sparc_v9b))) name = sparc_decode_asi_v9 (X_ASI (insn)); else name = sparc_decode_asi_v8 (X_ASI (insn)); if (name) (*info->fprintf_func) (stream, "%s", name); else (*info->fprintf_func) (stream, "(%ld)", X_ASI (insn)); break; } case 'C': (*info->fprintf_func) (stream, "%%csr"); break; case 'F': (*info->fprintf_func) (stream, "%%fsr"); break; case 'p': (*info->fprintf_func) (stream, "%%psr"); break; case 'q': (*info->fprintf_func) (stream, "%%fq"); break; case 'Q': (*info->fprintf_func) (stream, "%%cq"); break; case 't': (*info->fprintf_func) (stream, "%%tbr"); break; case 'w': (*info->fprintf_func) (stream, "%%wim"); break; case 'x': (*info->fprintf_func) (stream, "%ld", ((X_LDST_I (insn) << 8) + X_ASI (insn))); break; case 'y': (*info->fprintf_func) (stream, "%%y"); break; case 'u': case 'U': { int val = *s == 'U' ? X_RS1 (insn) : X_RD (insn); const char *name = sparc_decode_sparclet_cpreg (val); if (name) (*info->fprintf_func) (stream, "%s", name); else (*info->fprintf_func) (stream, "%%cpreg(%d)", val); break; } } } } if (imm_ored_to_rs1 || imm_added_to_rs1) { unsigned long prev_insn; int errcode; if (memaddr >= 4) errcode = (*info->read_memory_func) (memaddr - 4, buffer, sizeof (buffer), info); else errcode = 1; prev_insn = getword (buffer); if (errcode == 0) { if (is_delayed_branch (prev_insn)) { if (memaddr >= 8) errcode = (*info->read_memory_func) (memaddr - 8, buffer, sizeof (buffer), info); else errcode = 1; prev_insn = getword (buffer); } } if (errcode == 0) { if ((prev_insn & 0xc1c00000) == 0x01000000 && X_RD (prev_insn) == X_RS1 (insn)) { (*info->fprintf_func) (stream, "\t! "); info->target = ((unsigned) 0xFFFFFFFF & ((int) X_IMM22 (prev_insn) << 10)); if (imm_added_to_rs1) info->target += X_SIMM (insn, 13); else info->target |= X_SIMM (insn, 13); (*info->print_address_func) (info->target, info); info->insn_type = dis_dref; info->data_size = 4; } } } if (opcode->flags & (F_UNBR|F_CONDBR|F_JSR)) { if (opcode->flags & F_UNBR) info->insn_type = dis_branch; if (opcode->flags & F_CONDBR) info->insn_type = dis_condbranch; if (opcode->flags & F_JSR) info->insn_type = dis_jsr; if (opcode->flags & F_DELAYED) info->branch_delay_insns = 1; } return sizeof (buffer); } } info->insn_type = dis_noninsn; (*info->fprintf_func) (stream, _("unknown")); return sizeof (buffer); }
1threat
static QDict *qmp_dispatch_check_obj(const QObject *request, Error **errp) { const QDictEntry *ent; const char *arg_name; const QObject *arg_obj; bool has_exec_key = false; QDict *dict = NULL; dict = qobject_to_qdict(request); if (!dict) { error_setg(errp, QERR_QMP_BAD_INPUT_OBJECT, "request is not a dictionary"); return NULL; } for (ent = qdict_first(dict); ent; ent = qdict_next(dict, ent)) { arg_name = qdict_entry_key(ent); arg_obj = qdict_entry_value(ent); if (!strcmp(arg_name, "execute")) { if (qobject_type(arg_obj) != QTYPE_QSTRING) { error_setg(errp, QERR_QMP_BAD_INPUT_OBJECT_MEMBER, "execute", "string"); return NULL; } has_exec_key = true; } else if (!strcmp(arg_name, "arguments")) { if (qobject_type(arg_obj) != QTYPE_QDICT) { error_setg(errp, QERR_QMP_BAD_INPUT_OBJECT_MEMBER, "arguments", "object"); return NULL; } } else { error_setg(errp, QERR_QMP_EXTRA_MEMBER, arg_name); return NULL; } } if (!has_exec_key) { error_setg(errp, QERR_QMP_BAD_INPUT_OBJECT, "execute"); return NULL; } return dict; }
1threat
How to clear CrashLoopBackOff : <p>When a Kubernetes pod goes into <code>CrashLoopBackOff</code> state, you will fix the underlying issue. How do you force it to be rescheduled?</p>
0debug
How to animate a path in flutter? : <p>I'd like to achieve the path animation effect as seen over here : </p> <p><a href="https://cdn-images-1.medium.com/max/800/1*OH8yRHjfJhBvRxLlUAqT4Q.gif" rel="noreferrer">This animation (I couldn't include it because the gif is too big)</a></p> <p>I only want to achieve the path on the map animation, I know I need to use a stacked, place my map, then use a Painter to paint such path, but how can I animate it ?</p>
0debug
static int flac_decode_frame(AVCodecContext *avctx, void *data, int *data_size, uint8_t *buf, int buf_size) { FLACContext *s = avctx->priv_data; int metadata_last, metadata_type, metadata_size; int tmp = 0, i, j = 0, input_buf_size = 0; int16_t *samples = data; if(s->max_framesize == 0){ s->max_framesize= 8192; s->bitstream= av_fast_realloc(s->bitstream, &s->allocated_bitstream_size, s->max_framesize); } if(1 && s->max_framesize){ buf_size= FFMIN(buf_size, s->max_framesize - s->bitstream_size); input_buf_size= buf_size; if(s->bitstream_index + s->bitstream_size + buf_size > s->allocated_bitstream_size){ memmove(s->bitstream, &s->bitstream[s->bitstream_index], s->bitstream_size); s->bitstream_index=0; } memcpy(&s->bitstream[s->bitstream_index + s->bitstream_size], buf, buf_size); buf= &s->bitstream[s->bitstream_index]; buf_size += s->bitstream_size; s->bitstream_size= buf_size; if(buf_size < s->max_framesize){ return input_buf_size; } } init_get_bits(&s->gb, buf, buf_size*8); if (show_bits_long(&s->gb, 32) == bswap_32(ff_get_fourcc("fLaC"))) { skip_bits(&s->gb, 32); av_log(s->avctx, AV_LOG_DEBUG, "STREAM HEADER\n"); do { metadata_last = get_bits(&s->gb, 1); metadata_type = get_bits(&s->gb, 7); metadata_size = get_bits_long(&s->gb, 24); av_log(s->avctx, AV_LOG_DEBUG, " metadata block: flag = %d, type = %d, size = %d\n", metadata_last, metadata_type, metadata_size); if(metadata_size){ switch(metadata_type) { case METADATA_TYPE_STREAMINFO:{ int bits_count= get_bits_count(&s->gb); metadata_streaminfo(s); buf= &s->bitstream[s->bitstream_index]; init_get_bits(&s->gb, buf, buf_size*8); skip_bits(&s->gb, bits_count); dump_headers(s); break;} default: for(i=0; i<metadata_size; i++) skip_bits(&s->gb, 8); } } } while(!metadata_last); } else { tmp = show_bits(&s->gb, 16); if(tmp != 0xFFF8){ av_log(s->avctx, AV_LOG_ERROR, "FRAME HEADER not here\n"); while(get_bits_count(&s->gb)/8+2 < buf_size && show_bits(&s->gb, 16) != 0xFFF8) skip_bits(&s->gb, 8); goto end; } skip_bits(&s->gb, 16); if (decode_frame(s) < 0){ av_log(s->avctx, AV_LOG_ERROR, "decode_frame() failed\n"); s->bitstream_size=0; s->bitstream_index=0; return -1; } } #if 0 if (s->order == MID_SIDE) { short *left = samples; short *right = samples + s->blocksize; for (i = 0; i < s->blocksize; i += 2) { uint32_t x = s->decoded[0][i]; uint32_t y = s->decoded[0][i+1]; right[i] = x - (y / 2); left[i] = right[i] + y; } *data_size = 2 * s->blocksize; } else { for (i = 0; i < s->channels; i++) { switch(s->order) { case INDEPENDENT: for (j = 0; j < s->blocksize; j++) samples[(s->blocksize*i)+j] = s->decoded[i][j]; break; case LEFT_SIDE: case RIGHT_SIDE: if (i == 0) for (j = 0; j < s->blocksize; j++) samples[(s->blocksize*i)+j] = s->decoded[0][j]; else for (j = 0; j < s->blocksize; j++) samples[(s->blocksize*i)+j] = s->decoded[0][j] - s->decoded[i][j]; break; } *data_size += s->blocksize; } } #else switch(s->decorrelation) { case INDEPENDENT: for (j = 0; j < s->blocksize; j++) { for (i = 0; i < s->channels; i++) *(samples++) = s->decoded[i][j]; } break; case LEFT_SIDE: assert(s->channels == 2); for (i = 0; i < s->blocksize; i++) { *(samples++) = s->decoded[0][i]; *(samples++) = s->decoded[0][i] - s->decoded[1][i]; } break; case RIGHT_SIDE: assert(s->channels == 2); for (i = 0; i < s->blocksize; i++) { *(samples++) = s->decoded[0][i] + s->decoded[1][i]; *(samples++) = s->decoded[1][i]; } break; case MID_SIDE: assert(s->channels == 2); for (i = 0; i < s->blocksize; i++) { int mid, side; mid = s->decoded[0][i]; side = s->decoded[1][i]; #if 1 mid -= side>>1; *(samples++) = mid + side; *(samples++) = mid; #else mid <<= 1; if (side & 1) mid++; *(samples++) = (mid + side) >> 1; *(samples++) = (mid - side) >> 1; #endif } break; } #endif *data_size = (int8_t *)samples - (int8_t *)data; end: i= (get_bits_count(&s->gb)+7)/8;; if(i > buf_size){ av_log(s->avctx, AV_LOG_ERROR, "overread: %d\n", i - buf_size); s->bitstream_size=0; s->bitstream_index=0; return -1; } if(s->bitstream_size){ s->bitstream_index += i; s->bitstream_size -= i; return input_buf_size; }else return i; }
1threat
static int alloc_buffer(FrameBuffer **pool, AVCodecContext *s, FrameBuffer **pbuf) { const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(s->pix_fmt); FrameBuffer *buf; int i, ret; int pixel_size; int h_chroma_shift, v_chroma_shift; int edge = 32; int w = s->width, h = s->height; if (!desc) return AVERROR(EINVAL); pixel_size = desc->comp[0].step_minus1 + 1; buf = av_mallocz(sizeof(*buf)); if (!buf) return AVERROR(ENOMEM); if (!(s->flags & CODEC_FLAG_EMU_EDGE)) { w += 2*edge; h += 2*edge; } avcodec_align_dimensions(s, &w, &h); if ((ret = av_image_alloc(buf->base, buf->linesize, w, h, s->pix_fmt, 32)) < 0) { av_freep(&buf); return ret; } memset(buf->base[0], 128, ret); av_pix_fmt_get_chroma_sub_sample(s->pix_fmt, &h_chroma_shift, &v_chroma_shift); for (i = 0; i < FF_ARRAY_ELEMS(buf->data); i++) { const int h_shift = i==0 ? 0 : h_chroma_shift; const int v_shift = i==0 ? 0 : v_chroma_shift; if (s->flags & CODEC_FLAG_EMU_EDGE) buf->data[i] = buf->base[i]; else if (buf->base[i]) buf->data[i] = buf->base[i] + FFALIGN((buf->linesize[i]*edge >> v_shift) + (pixel_size*edge >> h_shift), 32); } buf->w = s->width; buf->h = s->height; buf->pix_fmt = s->pix_fmt; buf->pool = pool; *pbuf = buf; return 0; }
1threat
How do I remove an image a certain amount of time after its been created in Javascript? : <p>I'm trying to make an image disappear after like 2 seconds but I don't know how to do it.</p> <p>I've looked online but haven't really found anything useful.</p> <pre><code>function rockImage() { var img = document.createElement("img"); img.src = "rock.png"; var src = document.getElementById("compChoiceImage"); img.setAttribute("width", "100"); src.appendChild(img); } </code></pre> <p>That's the function to create the image I want to add the timer thing into the function.</p>
0debug
Timeout expired after calling stocked procedure : I keep getting this error after the calling the stored procedure on mysql database : "MySql.Data.MySqlClient.MySqlException (0x80004005): Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding. ---> System.TimeoutException: Timeout in IO operation" I know that the problem is related to the query it takes to long to execute so my question is this query it is good ? is there another way to improve this stocked procedure : CREATE DEFINER=`mysql`@`%` PROCEDURE `UpadtePriceToCalibre`(IN Dos int(6), IN Var varchar(50), IN PRIX double(10,4) , IN Cal int(6)) BEGIN insert into xxpch select `NuméroDossier`,`NuméroLot`,`Variété`,`Client`,`NF`,`Calibre`,`PrixKg`,PRIX,`NetFacture`,(PRIX * PoidNet),NOW() from detaildossier where NuméroDossier = Dos AND Variété LIKE CONCAT('%',Var,'%') AND Calibre= Cal; update detaildossier SET PrixKg = PRIX , NetFacture = (PRIX * PoidNet) , PrixColis = (( PoidNet / NombreColis) * PRIX) WHERE NuméroDossier = Dos AND Variété LIKE CONCAT('%',Var,'%') AND Calibre= Cal; update aff_e ,cpv_d set aff_e.netcpv =(select sum(cpv_d.prxtot) from cpv_d where cpv_d.numdos = Dos AND cpv_d.numlot = aff_e.numlot) ,aff_e.mntvnt =(select sum(cpv_d.prxtot) from cpv_d where cpv_d.numdos = Dos AND cpv_d.numlot = aff_e.numlot) where aff_e.numdos = Dos AND cpv_d.numlot = aff_e.numlot; END
0debug
static int qcow2_amend_options(BlockDriverState *bs, QemuOpts *opts, BlockDriverAmendStatusCB *status_cb, void *cb_opaque) { BDRVQcow2State *s = bs->opaque; int old_version = s->qcow_version, new_version = old_version; uint64_t new_size = 0; const char *backing_file = NULL, *backing_format = NULL; bool lazy_refcounts = s->use_lazy_refcounts; const char *compat = NULL; uint64_t cluster_size = s->cluster_size; bool encrypt; int refcount_bits = s->refcount_bits; Error *local_err = NULL; int ret; QemuOptDesc *desc = opts->list->desc; Qcow2AmendHelperCBInfo helper_cb_info; while (desc && desc->name) { if (!qemu_opt_find(opts, desc->name)) { desc++; continue; } if (!strcmp(desc->name, BLOCK_OPT_COMPAT_LEVEL)) { compat = qemu_opt_get(opts, BLOCK_OPT_COMPAT_LEVEL); if (!compat) { } else if (!strcmp(compat, "0.10")) { new_version = 2; } else if (!strcmp(compat, "1.1")) { new_version = 3; } else { error_report("Unknown compatibility level %s", compat); return -EINVAL; } } else if (!strcmp(desc->name, BLOCK_OPT_PREALLOC)) { error_report("Cannot change preallocation mode"); return -ENOTSUP; } else if (!strcmp(desc->name, BLOCK_OPT_SIZE)) { new_size = qemu_opt_get_size(opts, BLOCK_OPT_SIZE, 0); } else if (!strcmp(desc->name, BLOCK_OPT_BACKING_FILE)) { backing_file = qemu_opt_get(opts, BLOCK_OPT_BACKING_FILE); } else if (!strcmp(desc->name, BLOCK_OPT_BACKING_FMT)) { backing_format = qemu_opt_get(opts, BLOCK_OPT_BACKING_FMT); } else if (!strcmp(desc->name, BLOCK_OPT_ENCRYPT)) { encrypt = qemu_opt_get_bool(opts, BLOCK_OPT_ENCRYPT, !!s->cipher); if (encrypt != !!s->cipher) { error_report("Changing the encryption flag is not supported"); return -ENOTSUP; } } else if (!strcmp(desc->name, BLOCK_OPT_CLUSTER_SIZE)) { cluster_size = qemu_opt_get_size(opts, BLOCK_OPT_CLUSTER_SIZE, cluster_size); if (cluster_size != s->cluster_size) { error_report("Changing the cluster size is not supported"); return -ENOTSUP; } } else if (!strcmp(desc->name, BLOCK_OPT_LAZY_REFCOUNTS)) { lazy_refcounts = qemu_opt_get_bool(opts, BLOCK_OPT_LAZY_REFCOUNTS, lazy_refcounts); } else if (!strcmp(desc->name, BLOCK_OPT_REFCOUNT_BITS)) { refcount_bits = qemu_opt_get_number(opts, BLOCK_OPT_REFCOUNT_BITS, refcount_bits); if (refcount_bits <= 0 || refcount_bits > 64 || !is_power_of_2(refcount_bits)) { error_report("Refcount width must be a power of two and may " "not exceed 64 bits"); return -EINVAL; } } else { abort(); } desc++; } helper_cb_info = (Qcow2AmendHelperCBInfo){ .original_status_cb = status_cb, .original_cb_opaque = cb_opaque, .total_operations = (new_version < old_version) + (s->refcount_bits != refcount_bits) }; if (new_version > old_version) { s->qcow_version = new_version; ret = qcow2_update_header(bs); if (ret < 0) { s->qcow_version = old_version; return ret; } } if (s->refcount_bits != refcount_bits) { int refcount_order = ctz32(refcount_bits); if (new_version < 3 && refcount_bits != 16) { error_report("Different refcount widths than 16 bits require " "compatibility level 1.1 or above (use compat=1.1 or " "greater)"); return -EINVAL; } helper_cb_info.current_operation = QCOW2_CHANGING_REFCOUNT_ORDER; ret = qcow2_change_refcount_order(bs, refcount_order, &qcow2_amend_helper_cb, &helper_cb_info, &local_err); if (ret < 0) { error_report_err(local_err); return ret; } } if (backing_file || backing_format) { ret = qcow2_change_backing_file(bs, backing_file ?: s->image_backing_file, backing_format ?: s->image_backing_format); if (ret < 0) { return ret; } } if (s->use_lazy_refcounts != lazy_refcounts) { if (lazy_refcounts) { if (new_version < 3) { error_report("Lazy refcounts only supported with compatibility " "level 1.1 and above (use compat=1.1 or greater)"); return -EINVAL; } s->compatible_features |= QCOW2_COMPAT_LAZY_REFCOUNTS; ret = qcow2_update_header(bs); if (ret < 0) { s->compatible_features &= ~QCOW2_COMPAT_LAZY_REFCOUNTS; return ret; } s->use_lazy_refcounts = true; } else { ret = qcow2_mark_clean(bs); if (ret < 0) { return ret; } s->compatible_features &= ~QCOW2_COMPAT_LAZY_REFCOUNTS; ret = qcow2_update_header(bs); if (ret < 0) { s->compatible_features |= QCOW2_COMPAT_LAZY_REFCOUNTS; return ret; } s->use_lazy_refcounts = false; } } if (new_size) { BlockBackend *blk = blk_new(BLK_PERM_RESIZE, BLK_PERM_ALL); ret = blk_insert_bs(blk, bs, &local_err); if (ret < 0) { error_report_err(local_err); blk_unref(blk); return ret; } ret = blk_truncate(blk, new_size, &local_err); blk_unref(blk); if (ret < 0) { error_report_err(local_err); return ret; } } if (new_version < old_version) { helper_cb_info.current_operation = QCOW2_DOWNGRADING; ret = qcow2_downgrade(bs, new_version, &qcow2_amend_helper_cb, &helper_cb_info); if (ret < 0) { return ret; } } return 0; }
1threat
bool qpci_msix_masked(QPCIDevice *dev, uint16_t entry) { uint8_t addr; uint16_t val; void *vector_addr = dev->msix_table + (entry * PCI_MSIX_ENTRY_SIZE); g_assert(dev->msix_enabled); addr = qpci_find_capability(dev, PCI_CAP_ID_MSIX); g_assert_cmphex(addr, !=, 0); val = qpci_config_readw(dev, addr + PCI_MSIX_FLAGS); if (val & PCI_MSIX_FLAGS_MASKALL) { return true; } else { return (qpci_io_readl(dev, vector_addr + PCI_MSIX_ENTRY_VECTOR_CTRL) & PCI_MSIX_ENTRY_CTRL_MASKBIT) != 0; } }
1threat
query help - Need to derived new column based on condition : I have below table . Please help to achieve Interview Date column . Please help me to write this query .[enter image description here][1] [1]: https://i.stack.imgur.com/Z9vbp.png Condition is * where stage is Screening and status is min of data( its date actually ) of status =( Selected / Rejected / Dropped ) as Interview date Please help Advance Thanks
0debug
why location.href does not work? : <p>I use jquery <br /> Why location.href does not work <br /> This is my code <br /></p> <pre><code>function RemoveProduct(Seolink) { $('#p' + Seolink).remove(); var LinkToGo = 'localhost:5000/Home/Compare?'; for (var i = 0; i &lt; $('#CompareSection .hoverable.grey.lighten-2').length; i++) { LinkToGo += 'Product=DKP' + $('#CompareSection .hoverable.grey.lighten-2:eq(' + i + ')').attr('id') .substring(1, $('#CompareSection .hoverable.grey.lighten-2:eq(' + i + ')').attr('id').length) + '&amp;'; } LinkToGo = LinkToGo.substring(0, LinkToGo.length - 1); location.href = LinkToGo; //window.location.href = LinkToGo; //document.location.href = LinkToGo; } </code></pre>
0debug
static int mkv_check_tag(AVDictionary *m) { AVDictionaryEntry *t = NULL; while ((t = av_dict_get(m, "", t, AV_DICT_IGNORE_SUFFIX))) if (av_strcasecmp(t->key, "title") && av_strcasecmp(t->key, "stereo_mode")) return 1; return 0; }
1threat
Spring Boot: Configuration Class is simply ignored and not loaded : <p>I have the following <code>@Configuration</code> class on the classpath of a few of my <code>@SpringBootApplication</code>s:</p> <pre><code>@Configuration @Import({MainConfig.class, RestConfig.class}) public class ApiConfig { @Bean @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) public Client client() throws ExecutionException, InterruptedException { return service.create(Client.class); } } </code></pre> <p>I have two services that use this config (with differently named <code>Client</code> classes).</p> <p>Service 1 starts correctly and loads this config. I can see during start up that a bean of type <code>ApiConfig</code> was eagerly initialized.</p> <p>Service 2 starts incorrectly: the above configuration class is simply ignored and not initialized.</p> <p>The services are started in separate JVMs.</p> <p>Ther services have nearly identical, very small <code>application.properties</code> files:</p> <pre><code>spring.application.name=xxx-api server.port=0 eureka.name=xxx.api # Only for reading properties from a central location context.initializer.classes=com.package.contextClass </code></pre> <p>I'm not even sure what kind of additional information I could write into the question. I have been going through logs for a couple of hours now and see no discernible difference, simply that it plainly ignores my <code>@Configuration</code> class. </p> <p>Has anyone had this issue before?</p>
0debug
Why doesn't appache allow access to files outside the web root --from within index.html? : As the title states.. I have the following organization to my project but am unable to access the related css and javascript files from within my html code --unless I create symbolic links from the file to my web root. Is this normal behavior for apache or does the problem lie elsewhere? **If I remove the symbolic links and correct the path in my src attributes the content of those outside files becomes inaccessible** userName@hostName:/var/www/test$ tree . ├── css │   └── style.css ├── html │   ├── code.js -> ../js/code.js │   ├── index.html │   ├── jquery-3.2.1.js -> ../libs/jquery-3.2.1.js │   └── style.css -> ../css/style.css ├── js │   └── code.js └── libs └── jquery-3.2.1.js 4 directories, 7 files userName@hostName:/var/www/test$ less html/index.html <!doctype HTML> <html> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <link rel="stylesheet" type="text/css" href="./style.css"> <title>Test</title> </head><!-- head --> <body> <h1>LOCAL TESTING SITE..</h1> </body><!-- body --> <script src="./code.js"></script> </html><!-- html --> html/index.html (END) **^ Works** userName@hostName:/var/www/test$ tree . ├── css │ └── style.css ├── html │ ├── index.html ├── js │ └── code.js └── libs └── jquery-3.2.1.js 4 directories, 7 files userName@hostName:/var/www/test$ less html/index.html <!doctype HTML> <html> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <link rel="stylesheet" type="text/css" href="../css/style.css"> <title>Test</title> </head><!-- head --> <body> <h1>LOCAL TESTING SITE..</h1> </body><!-- body --> <script src="../js/code.js"></script> </html><!-- html --> html/index.html (END) **^ Does NOT Work** userName@hostName:/var/www/test$ tree -p . ├── [drwxrwxr-x] css │   └── [-rw-rw-r--] style.css ├── [drwxrwxr-x] html │   ├── [lrwxrwxrwx] code.js -> ../js/code.js │   ├── [-rw-rw-r--] index.html │   ├── [lrwxrwxrwx] jquery-3.2.1.js -> ../libs/jquery-3.2.1.js │   └── [lrwxrwxrwx] style.css -> ../css/style.css ├── [drwxrwxr-x] js │   └── [-rw-rw-r--] code.js └── [drwxrwxr-x] libs └── [-rw-rw-r--] jquery-3.2.1.js 4 directories, 7 files **^ Permissions on files** userName@hostName:/etc/apache2$ less sites-available/test.local.conf <VirtualHost *:80> ServerAdmin myEmail@email.com DocumentRoot /var/www/test/html ServerName test.local ErrorLog ${APACHE_LOG_DIR}/test.local.error.log CustomLog ${APACHE_LOG_DIR}/test.local.access.log combined </VirtualHost> # vim: syntax=apache ts=4 sw=4 sts=4 sr noet sites-available/test.local.conf (END) **^ Virtual Host Configuration** userName@hostName:/var/www/test$ uname -v #35~16.04.1-Ubuntu userName@hostName:/var/www/test$ apache2 -v Server version: Apache/2.4.18 (Ubuntu) **^ System Info**
0debug
static int vhost_user_cleanup(struct vhost_dev *dev) { struct vhost_user *u; assert(dev->vhost_ops->backend_type == VHOST_BACKEND_TYPE_USER); u = dev->opaque; if (u->slave_fd >= 0) { close(u->slave_fd); u->slave_fd = -1; } g_free(u); dev->opaque = 0; return 0; }
1threat
Script does'nt display in page : I tried this but it does'nt display inside the page. Where is the problem ? $content =' <div class="row"> <div class="col-md-9"> <div class="form-group row"> <label for="' . $this->app->getDef('text_products_favorites') . '" class="col-5 col-form-label">' . $this->app->getDef('text_products_favorites') . '</label> <div class="col-md-5"> ' . HTML::checkboxField('products_favorites', 'yes', false) . ' </div> </div> </div> </div> '; $output = <<<EOD <script> $('#tab9Content').prepend( '{$content}' ) </script> EOD; return $output; If I change the script by this, it work fine and the information is displayed in the page $('#orange h1').after( '<h3>Brown</h3>' + '<p>Brown Brown Brown</p>' ) now in products.php <div class="adminformTitle" id="tab9Content"> </div> If I edit mycode I have this. <div class="adminformTitle" id="tab9Content"> <script> $('#tab9Content').prepend( ' <div class="row"> <div class="col-md-9"> <div class="form-group row"> <label for="text_products_favorites" class="col-5 col-form-label">text_products_favorites</label> <div class="col-md-5"> <input type="checkbox" name="products_favorite" id="products_favorite" value="yes" /> </div> </div> </div> </div> ' ) </script> </div>
0debug
An error occurs in the open part of the c code used by Android : <p>I am calling the function from C code.</p> <pre><code>FILE *temp; char command[] = "dumpsys SurfaceFlinger --latency SurfaceView"; strcat(command,"" ); temp = popen(command, "r"); </code></pre> <p>I call this once a second. But in about five minutes the process will be over. I checked the log and found that there was a problem in the open. But we don't know what caused it.</p>
0debug
int av_image_fill_pointers(uint8_t *data[4], enum PixelFormat pix_fmt, int height, uint8_t *ptr, const int linesizes[4]) { int i, total_size, size[4], has_plane[4]; const AVPixFmtDescriptor *desc = &av_pix_fmt_descriptors[pix_fmt]; memset(data , 0, sizeof(data[0])*4); memset(size , 0, sizeof(size)); memset(has_plane, 0, sizeof(has_plane)); if ((unsigned)pix_fmt >= PIX_FMT_NB || desc->flags & PIX_FMT_HWACCEL) return AVERROR(EINVAL); data[0] = ptr; if (linesizes[0] > (INT_MAX - 1024) / height) return AVERROR(EINVAL); size[0] = linesizes[0] * height; if (desc->flags & PIX_FMT_PAL) { size[0] = (size[0] + 3) & ~3; data[1] = ptr + size[0]; return size[0] + 256 * 4; } for (i = 0; i < 4; i++) has_plane[desc->comp[i].plane] = 1; total_size = size[0]; for (i = 1; i < 4 && has_plane[i]; i++) { int h, s = (i == 1 || i == 2) ? desc->log2_chroma_h : 0; data[i] = data[i-1] + size[i-1]; h = (height + (1 << s) - 1) >> s; if (linesizes[i] > INT_MAX / h) return AVERROR(EINVAL); size[i] = h * linesizes[i]; if (total_size > INT_MAX - size[i]) return AVERROR(EINVAL); total_size += size[i]; } return total_size; }
1threat
Multiple foreach statements in PHP : <p>Sorry for the beginner question I'm still learning PHP.</p> <p>I have a foreach statement which grabs some product data from an API which works as expected. I'm now trying to add in an additional foreach statement to grab the cart totals but when I add this in my text editor is throwing up a syntax error. No doubt I'm doing something wrong could anyone point me in the right direction please?</p> <p>Here's is the segment of code where I'm trying to add in the foreach totals. far.</p> <pre><code> if (!empty($data['data'])) { // Set vars $products = array(); $output = ''; // Cart Values $cartValues = $data['data']; $output .= $modx-&gt;getChunk($cartTpl, $cartValues); // Product Values foreach($data['data']['products'] as $item) { foreach($item as $key =&gt; $value) { $products[$key] = $value; } $listProducts .= $modx-&gt;getChunk($productsTpl, $products); $output = str_replace('[[+products]]', $listProducts, $output); // Total Values foreach($data['data']['totals'] as $total) { foreach($total as $key =&gt; $value) { $totals[$key] = $value; } $listTotals .= $modx-&gt;getChunk($totalsTpl, $totals); $output = str_replace('[[+totals]]', $listTotals, $output); } </code></pre>
0debug
static ssize_t vnc_tls_push(gnutls_transport_ptr_t transport, const void *data, size_t len) { struct VncState *vs = (struct VncState *)transport; int ret; retry: ret = send(vs->csock, data, len, 0); if (ret < 0) { if (errno == EINTR) goto retry; return -1; } return ret; }
1threat
Cant seem to figure out whats wrong in this android program! Help Me : I am getting errorResponse instead of the normal response i should have got. I have made a simple php file with a simple text and put it on the wamp server. And i have checked it on the browser it works fine but not in this code. public class MainActivity extends AppCompatActivity { Button button; TextView textView; String server_url="http://192.168.1.2/greetings.php"; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); button= (Button) findViewById(R.id.bn); textView= (TextView) findViewById(R.id.txt); final RequestQueue requestQueue= Volley.newRequestQueue(MainActivity.this); button.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { StringRequest stringRequest=new StringRequest(Request.Method.POST, server_url, new Response.Listener<String>() { @Override public void onResponse(String response) { textView.setText(response); requestQueue.stop(); } }, new Response.ErrorListener() { @Override public void onErrorResponse(VolleyError error) { textView.setText("something wrong happened"); error.printStackTrace(); requestQueue.stop(); } }); requestQueue.add(stringRequest); } }); } }
0debug
How can i copy to string literal in C : <pre><code>char temp1[4] = "abc"; char *temp2 = "123"; strcpy(temp1,temp2); </code></pre> <p>if I want to copy a string literal to an array, it works well, but if I do it in the opposite way, I get an error:</p> <pre><code>char temp1[4] = "abc"; char *temp2 = "123"; strcpy(temp2,temp1); </code></pre> <p>The feedback from compiler is "Segmentation fault".</p> <p>So what's the differences? Is there anyway to copy a string to a string literal?</p> <p>Thx. </p>
0debug
int cpu_signal_handler(int host_signum, void *pinfo, void *puc) { siginfo_t *info = pinfo; ucontext_t *uc = puc; uint32_t *pc = uc->uc_mcontext.sc_pc; uint32_t insn = *pc; int is_write = 0; switch (insn >> 26) { case 0x0d: case 0x0e: case 0x0f: case 0x24: case 0x25: case 0x26: case 0x27: case 0x2c: case 0x2d: case 0x2e: case 0x2f: is_write = 1; } return handle_cpu_signal(pc, (unsigned long)info->si_addr, is_write, &uc->uc_sigmask); }
1threat
static void avc_luma_vt_and_aver_dst_8x8_msa(const uint8_t *src, int32_t src_stride, uint8_t *dst, int32_t dst_stride) { int32_t loop_cnt; int16_t filt_const0 = 0xfb01; int16_t filt_const1 = 0x1414; int16_t filt_const2 = 0x1fb; v16u8 dst0, dst1, dst2, dst3; v16i8 src0, src1, src2, src3, src4, src7, src8, src9, src10; v16i8 src10_r, src32_r, src76_r, src98_r; v16i8 src21_r, src43_r, src87_r, src109_r; v8i16 out0, out1, out2, out3; v16i8 filt0, filt1, filt2; filt0 = (v16i8) __msa_fill_h(filt_const0); filt1 = (v16i8) __msa_fill_h(filt_const1); filt2 = (v16i8) __msa_fill_h(filt_const2); LD_SB5(src, src_stride, src0, src1, src2, src3, src4); src += (5 * src_stride); XORI_B5_128_SB(src0, src1, src2, src3, src4); ILVR_B4_SB(src1, src0, src2, src1, src3, src2, src4, src3, src10_r, src21_r, src32_r, src43_r); for (loop_cnt = 2; loop_cnt--;) { LD_SB4(src, src_stride, src7, src8, src9, src10); src += (4 * src_stride); XORI_B4_128_SB(src7, src8, src9, src10); ILVR_B4_SB(src7, src4, src8, src7, src9, src8, src10, src9, src76_r, src87_r, src98_r, src109_r); out0 = DPADD_SH3_SH(src10_r, src32_r, src76_r, filt0, filt1, filt2); out1 = DPADD_SH3_SH(src21_r, src43_r, src87_r, filt0, filt1, filt2); out2 = DPADD_SH3_SH(src32_r, src76_r, src98_r, filt0, filt1, filt2); out3 = DPADD_SH3_SH(src43_r, src87_r, src109_r, filt0, filt1, filt2); SRARI_H4_SH(out0, out1, out2, out3, 5); SAT_SH4_SH(out0, out1, out2, out3, 7); LD_UB4(dst, dst_stride, dst0, dst1, dst2, dst3); ILVR_D2_UB(dst1, dst0, dst3, dst2, dst0, dst1); CONVERT_UB_AVG_ST8x4_UB(out0, out1, out2, out3, dst0, dst1, dst, dst_stride); dst += (4 * dst_stride); src10_r = src76_r; src32_r = src98_r; src21_r = src87_r; src43_r = src109_r; src4 = src10; } }
1threat
static int h264_slice_header_parse(const H264Context *h, H264SliceContext *sl, const H2645NAL *nal) { const SPS *sps; const PPS *pps; int ret; unsigned int slice_type, tmp, i; int field_pic_flag, bottom_field_flag; int first_slice = sl == h->slice_ctx && !h->current_slice; int picture_structure; if (first_slice) av_assert0(!h->setup_finished); sl->first_mb_addr = get_ue_golomb_long(&sl->gb); slice_type = get_ue_golomb_31(&sl->gb); if (slice_type > 9) { av_log(h->avctx, AV_LOG_ERROR, "slice type %d too large at %d\n", slice_type, sl->first_mb_addr); return AVERROR_INVALIDDATA; } if (slice_type > 4) { slice_type -= 5; sl->slice_type_fixed = 1; } else sl->slice_type_fixed = 0; slice_type = ff_h264_golomb_to_pict_type[slice_type]; sl->slice_type = slice_type; sl->slice_type_nos = slice_type & 3; if (nal->type == H264_NAL_IDR_SLICE && sl->slice_type_nos != AV_PICTURE_TYPE_I) { av_log(h->avctx, AV_LOG_ERROR, "A non-intra slice in an IDR NAL unit.\n"); return AVERROR_INVALIDDATA; } sl->pps_id = get_ue_golomb(&sl->gb); if (sl->pps_id >= MAX_PPS_COUNT) { av_log(h->avctx, AV_LOG_ERROR, "pps_id %u out of range\n", sl->pps_id); return AVERROR_INVALIDDATA; } if (!h->ps.pps_list[sl->pps_id]) { av_log(h->avctx, AV_LOG_ERROR, "non-existing PPS %u referenced\n", sl->pps_id); return AVERROR_INVALIDDATA; } pps = (const PPS*)h->ps.pps_list[sl->pps_id]->data; if (!h->ps.sps_list[pps->sps_id]) { av_log(h->avctx, AV_LOG_ERROR, "non-existing SPS %u referenced\n", pps->sps_id); return AVERROR_INVALIDDATA; } sps = (const SPS*)h->ps.sps_list[pps->sps_id]->data; sl->frame_num = get_bits(&sl->gb, sps->log2_max_frame_num); if (!first_slice) { if (h->poc.frame_num != sl->frame_num) { av_log(h->avctx, AV_LOG_ERROR, "Frame num change from %d to %d\n", h->poc.frame_num, sl->frame_num); return AVERROR_INVALIDDATA; } } sl->mb_mbaff = 0; if (sps->frame_mbs_only_flag) { picture_structure = PICT_FRAME; } else { if (!sps->direct_8x8_inference_flag && slice_type == AV_PICTURE_TYPE_B) { av_log(h->avctx, AV_LOG_ERROR, "This stream was generated by a broken encoder, invalid 8x8 inference\n"); return -1; } field_pic_flag = get_bits1(&sl->gb); if (field_pic_flag) { bottom_field_flag = get_bits1(&sl->gb); picture_structure = PICT_TOP_FIELD + bottom_field_flag; } else { picture_structure = PICT_FRAME; } } sl->picture_structure = picture_structure; sl->mb_field_decoding_flag = picture_structure != PICT_FRAME; if (picture_structure == PICT_FRAME) { sl->curr_pic_num = sl->frame_num; sl->max_pic_num = 1 << sps->log2_max_frame_num; } else { sl->curr_pic_num = 2 * sl->frame_num + 1; sl->max_pic_num = 1 << (sps->log2_max_frame_num + 1); } if (nal->type == H264_NAL_IDR_SLICE) get_ue_golomb_long(&sl->gb); if (sps->poc_type == 0) { sl->poc_lsb = get_bits(&sl->gb, sps->log2_max_poc_lsb); if (pps->pic_order_present == 1 && picture_structure == PICT_FRAME) sl->delta_poc_bottom = get_se_golomb(&sl->gb); } if (sps->poc_type == 1 && !sps->delta_pic_order_always_zero_flag) { sl->delta_poc[0] = get_se_golomb(&sl->gb); if (pps->pic_order_present == 1 && picture_structure == PICT_FRAME) sl->delta_poc[1] = get_se_golomb(&sl->gb); } sl->redundant_pic_count = 0; if (pps->redundant_pic_cnt_present) sl->redundant_pic_count = get_ue_golomb(&sl->gb); if (sl->slice_type_nos == AV_PICTURE_TYPE_B) sl->direct_spatial_mv_pred = get_bits1(&sl->gb); ret = ff_h264_parse_ref_count(&sl->list_count, sl->ref_count, &sl->gb, pps, sl->slice_type_nos, picture_structure, h->avctx); if (ret < 0) return ret; if (sl->slice_type_nos != AV_PICTURE_TYPE_I) { ret = ff_h264_decode_ref_pic_list_reordering(sl, h->avctx); if (ret < 0) { sl->ref_count[1] = sl->ref_count[0] = 0; return ret; } } sl->pwt.use_weight = 0; for (i = 0; i < 2; i++) { sl->pwt.luma_weight_flag[i] = 0; sl->pwt.chroma_weight_flag[i] = 0; } if ((pps->weighted_pred && sl->slice_type_nos == AV_PICTURE_TYPE_P) || (pps->weighted_bipred_idc == 1 && sl->slice_type_nos == AV_PICTURE_TYPE_B)) { ret = ff_h264_pred_weight_table(&sl->gb, sps, sl->ref_count, sl->slice_type_nos, &sl->pwt, h->avctx); if (ret < 0) return ret; } sl->explicit_ref_marking = 0; if (nal->ref_idc) { ret = ff_h264_decode_ref_pic_marking(sl, &sl->gb, nal, h->avctx); if (ret < 0 && (h->avctx->err_recognition & AV_EF_EXPLODE)) return AVERROR_INVALIDDATA; } if (sl->slice_type_nos != AV_PICTURE_TYPE_I && pps->cabac) { tmp = get_ue_golomb_31(&sl->gb); if (tmp > 2) { av_log(h->avctx, AV_LOG_ERROR, "cabac_init_idc %u overflow\n", tmp); return AVERROR_INVALIDDATA; } sl->cabac_init_idc = tmp; } sl->last_qscale_diff = 0; tmp = pps->init_qp + get_se_golomb(&sl->gb); if (tmp > 51 + 6 * (sps->bit_depth_luma - 8)) { av_log(h->avctx, AV_LOG_ERROR, "QP %u out of range\n", tmp); return AVERROR_INVALIDDATA; } sl->qscale = tmp; sl->chroma_qp[0] = get_chroma_qp(pps, 0, sl->qscale); sl->chroma_qp[1] = get_chroma_qp(pps, 1, sl->qscale); if (sl->slice_type == AV_PICTURE_TYPE_SP) get_bits1(&sl->gb); if (sl->slice_type == AV_PICTURE_TYPE_SP || sl->slice_type == AV_PICTURE_TYPE_SI) get_se_golomb(&sl->gb); sl->deblocking_filter = 1; sl->slice_alpha_c0_offset = 0; sl->slice_beta_offset = 0; if (pps->deblocking_filter_parameters_present) { tmp = get_ue_golomb_31(&sl->gb); if (tmp > 2) { av_log(h->avctx, AV_LOG_ERROR, "deblocking_filter_idc %u out of range\n", tmp); return AVERROR_INVALIDDATA; } sl->deblocking_filter = tmp; if (sl->deblocking_filter < 2) sl->deblocking_filter ^= 1; if (sl->deblocking_filter) { sl->slice_alpha_c0_offset = get_se_golomb(&sl->gb) * 2; sl->slice_beta_offset = get_se_golomb(&sl->gb) * 2; if (sl->slice_alpha_c0_offset > 12 || sl->slice_alpha_c0_offset < -12 || sl->slice_beta_offset > 12 || sl->slice_beta_offset < -12) { av_log(h->avctx, AV_LOG_ERROR, "deblocking filter parameters %d %d out of range\n", sl->slice_alpha_c0_offset, sl->slice_beta_offset); return AVERROR_INVALIDDATA; } } } return 0; }
1threat
int AUD_read (SWVoiceIn *sw, void *buf, int size) { int bytes; if (!sw) { return size; } if (!sw->hw->enabled) { dolog ("Reading from disabled voice %s\n", SW_NAME (sw)); return 0; } bytes = sw->hw->pcm_ops->read (sw, buf, size); return bytes; }
1threat
static void acpi_set_cpu_present_bit(AcpiCpuHotplug *g, CPUState *cpu, Error **errp) { CPUClass *k = CPU_GET_CLASS(cpu); int64_t cpu_id; cpu_id = k->get_arch_id(cpu); if ((cpu_id / 8) >= ACPI_GPE_PROC_LEN) { error_setg(errp, "acpi: invalid cpu id: %" PRIi64, cpu_id); return; } g->sts[cpu_id / 8] |= (1 << (cpu_id % 8)); }
1threat
static void qmp_input_check_struct(Visitor *v, Error **errp) { QmpInputVisitor *qiv = to_qiv(v); StackObject *tos = &qiv->stack[qiv->nb_stack - 1]; assert(qiv->nb_stack > 0); if (qiv->strict) { GHashTable *const top_ht = tos->h; if (top_ht) { GHashTableIter iter; const char *key; g_hash_table_iter_init(&iter, top_ht); if (g_hash_table_iter_next(&iter, (void **)&key, NULL)) { error_setg(errp, QERR_QMP_EXTRA_MEMBER, key); } } } }
1threat
Android_ Java_ prevent Dialog Box from being dismissed : There is a Dialog Box, how can I prevent it from being dismissed? I want not only the user enter a username but also prevent him/her from leaving the box empty??
0debug
Undefined index: category_icon_code in line 257 : <p>Hello I am getting Notice Undefined index: in line number 257. Please help. Here is code for line number 257.</p> <pre><code>$my_query = new wp_query( $args ); while( $my_query-&gt;have_posts() ) { $my_query-&gt;the_post(); global $postID; $current++; $category = get_the_category(); $tag = get_cat_ID( $category[0]-&gt;name ); $tag_extra_fields = get_option(MY_CATEGORY_FIELDS); if (isset($tag_extra_fields[$tag])) { $category_icon_code = $tag_extra_fields[$tag]['category_icon_code']; $category_icon_color = $tag_extra_fields[$tag]['category_icon_color']; $your_image_url = $tag_extra_fields[$tag]['your_image_url']; } if (empty($category_icon_code) || empty($category_icon_color) || empty($your_image_url)) { $tag = $category[0]-&gt;category_parent; $tag_extra_fields = get_option(MY_CATEGORY_FIELDS); if (isset($tag_extra_fields[$tag])) { if (empty($category_icon_code)){ $category_icon_code = $tag_extra_fields[$tag]['category_icon_code']; } if (empty($category_icon_color)){ $category_icon_color = $tag_extra_fields[$tag]['category_icon_color']; } if (empty($your_image_url)){ $your_image_url = $tag_extra_fields[$tag]['your_image_url']; } } } ?&gt; </code></pre> <p>I am getting undefined index for these.</p> <pre><code>$category_icon_code $category_icon_color $your_image_url </code></pre> <p>Thanks in advance.</p>
0debug
Serial Number of Bootable device : <p>I have to get the serialnumber of the disk on which my operating system is installed.</p> <p>I know in order to get serial number i need to run:</p> <pre><code>&gt;wmic diskdrive get serialnumber,capabilities Capabilities SerialNumber {3, 4} AI92NXXXXXXXX2G02 {3, 4, 7} 1172XXXXXX030 </code></pre> <p>There are no attributes to check if the OS is installed on this disk.</p>
0debug
static void rtas_start_cpu(PowerPCCPU *cpu_, sPAPRMachineState *spapr, uint32_t token, uint32_t nargs, target_ulong args, uint32_t nret, target_ulong rets) { target_ulong id, start, r3; PowerPCCPU *cpu; if (nargs != 3 || nret != 1) { rtas_st(rets, 0, RTAS_OUT_PARAM_ERROR); return; } id = rtas_ld(args, 0); start = rtas_ld(args, 1); r3 = rtas_ld(args, 2); cpu = spapr_find_cpu(id); if (cpu != NULL) { CPUState *cs = CPU(cpu); CPUPPCState *env = &cpu->env; if (!cs->halted) { rtas_st(rets, 0, RTAS_OUT_HW_ERROR); return; } kvm_cpu_synchronize_state(cs); env->msr = (1ULL << MSR_SF) | (1ULL << MSR_ME); env->spr[SPR_LPCR] |= pcc->lpcr_pm; env->nip = start; env->gpr[3] = r3; cs->halted = 0; spapr_cpu_set_endianness(cpu); spapr_cpu_update_tb_offset(cpu); qemu_cpu_kick(cs); rtas_st(rets, 0, RTAS_OUT_SUCCESS); return; } rtas_st(rets, 0, RTAS_OUT_PARAM_ERROR); }
1threat
Spark ML VectorAssembler returns strange output : <p>I am experiencing a very strange behaviour from <code>VectorAssembler</code> and I was wondering if anyone else has seen this.</p> <p>My scenario is pretty straightforward. I parse data from a <code>CSV</code> file where I have some standard <code>Int</code> and <code>Double</code> fields and I also calculate some extra columns. My parsing function returns this: </p> <pre><code>val joined = countPerChannel ++ countPerSource //two arrays of Doubles joined (label, orderNo, pageNo, Vectors.dense(joinedCounts)) </code></pre> <p>My main function uses the parsing function like this:</p> <pre><code>val parsedData = rawData.filter(row =&gt; row != header).map(parseLine) val data = sqlContext.createDataFrame(parsedData).toDF("label", "orderNo", "pageNo","joinedCounts") </code></pre> <p>I then use a <code>VectorAssembler</code> like this:</p> <pre><code>val assembler = new VectorAssembler() .setInputCols(Array("orderNo", "pageNo", "joinedCounts")) .setOutputCol("features") val assemblerData = assembler.transform(data) </code></pre> <p>So when I print a row of my data before it goes into the <code>VectorAssembler</code> it looks like this:</p> <pre><code>[3.2,17.0,15.0,[0.0,0.0,0.0,0.0,3.0,0.0,0.0,1.0,0.0,0.0,0.0,0.0,4.0,0.0,0.0,2.0]] </code></pre> <p>After the transform function of VectorAssembler I print the same row of data and get this:</p> <pre><code>[3.2,(18,[0,1,6,9,14,17],[17.0,15.0,3.0,1.0,4.0,2.0])] </code></pre> <p>What on earth is going on? What has the <code>VectorAssembler</code> done? I 've double checked all the calculations and even followed the simple Spark examples and cannot see what is wrong with my code. Can you? </p>
0debug
Multithreaded is slower than singlethreaded : <p>It is not faster - it's also much slower .</p> <p>I have cpu with 4 core.</p> <p>==================================================================</p> <pre><code>Private Sub btn_Singelthreaded_Click(sender As Object, e As EventArgs) Handles btn_Singelthreaded.Click Dim Num As Long Dim sw As New Stopwatch Dim TimeAvrg As Double For i = 0 To 8 Num = 0 sw.Restart() Do Until Num &gt; 500000000 '500,000,000 Num += 1 Loop TimeAvrg += sw.Elapsed.TotalSeconds 'sw.Stop() Next Console.WriteLine($"[Singelthreaded] Avrg Time: {TimeAvrg / 8}{Environment.NewLine}") End Sub Private NumThrd As Long Private swThrd As New Stopwatch Private Sub btn_Multithreaded_Click(sender As Object, e As EventArgs) Handles btn_Multithreaded.Click Dim T1 As New Threading.Thread(AddressOf ForLoop) : T1.Start() Dim T2 As New Threading.Thread(AddressOf ForLoop) : T2.Start() Dim T3 As New Threading.Thread(AddressOf ForLoop) : T3.Start() End Sub Private Sub ForLoop() Dim TimeAvrg As Double For i = 0 To 2 TimeAvrg = 0 NumThrd = 0 swThrd.Start() Do Until NumThrd &gt; '500,000,000 NumThrd += 1 Loop TimeAvrg += swThrd.Elapsed.TotalSeconds 'swThrd.Stop() Next Console.WriteLine($"[Multithreaded] Avrg Time: {TimeAvrg / 3}{Environment.NewLine}") End Sub </code></pre> <p>Result: [Singelthreaded] Avrg Time: 2.1183545</p> <p>[Multithreaded] Avrg Time: 11.6677879333333</p>
0debug
Finding relation between code mapping from 10digits to 3 digits : I have some mapping scheme applied on numbers.. how we can found the relation in between this mapping.. 8955573624 000 8727174542 001 6144057737 001 6697647320 003 1335549467 003 6669202192 004 9276317113 004 5048034450 005 4757279524 005 1423969226 005 9729294957 005 4332046813 007 0681780168 007 8231841017 009 9809242207 009 5584677643 009 6193476760 010 7203972648 010 7286156579 013 5669792887 013 6789954237 013 8042954283 018 7426511939 018 4053045131 018 8629149977 018 2997522935 019 9363344270 019 9890870146 019 9426932555 020 5755262458 020 8327043690 020 0162545530 024 6451719711 024 5376165082 024 0595003112 024 5172323540 027 9314878787 027 6822370777 027 8236826223 027 3097377830 028
0debug
int bdrv_write_compressed(BlockDriverState *bs, int64_t sector_num, const uint8_t *buf, int nb_sectors) { BlockDriver *drv = bs->drv; if (!drv) return -ENOMEDIUM; if (!drv->bdrv_write_compressed) return -ENOTSUP; if (bdrv_check_request(bs, sector_num, nb_sectors)) return -EIO; if (bs->dirty_tracking) { set_dirty_bitmap(bs, sector_num, nb_sectors, 1); } return drv->bdrv_write_compressed(bs, sector_num, buf, nb_sectors); }
1threat
Is it possible to show the time it took a linear search to find the key you entered to find in the program? : <p>Is it possible to show the time it took a linear search to find the key you entered to find in the program? </p> <p>This is the task our teacher gave us</p> <p>Requirements: Write a C++ program that will do the following in sequence: Linear Search 1. Ask the user to input a positive integer value that we will denote as n. Here n represents the size of the problem space, specifically, the number of random elements. 2. For linear search, the user will input the key/value that will be searched. 3. Once the key/value is found it will display the value including the index value. 4. It will also display the time that it searched in milliseconds.</p>
0debug
int ff_hevc_decode_nal_pps(HEVCContext *s) { GetBitContext *gb = &s->HEVClc.gb; HEVCSPS *sps = NULL; int pic_area_in_ctbs, pic_area_in_min_cbs, pic_area_in_min_tbs; int log2_diff_ctb_min_tb_size; int i, j, x, y, ctb_addr_rs, tile_id; int ret = 0; int pps_id = 0; AVBufferRef *pps_buf; HEVCPPS *pps = av_mallocz(sizeof(*pps)); if (!pps) return AVERROR(ENOMEM); pps_buf = av_buffer_create((uint8_t *)pps, sizeof(*pps), hevc_pps_free, NULL, 0); if (!pps_buf) { av_freep(&pps); return AVERROR(ENOMEM); } av_log(s->avctx, AV_LOG_DEBUG, "Decoding PPS\n"); pps->loop_filter_across_tiles_enabled_flag = 1; pps->num_tile_columns = 1; pps->num_tile_rows = 1; pps->uniform_spacing_flag = 1; pps->disable_dbf = 0; pps->beta_offset = 0; pps->tc_offset = 0; pps_id = get_ue_golomb_long(gb); if (pps_id >= MAX_PPS_COUNT) { av_log(s->avctx, AV_LOG_ERROR, "PPS id out of range: %d\n", pps_id); ret = AVERROR_INVALIDDATA; goto err; } pps->sps_id = get_ue_golomb_long(gb); if (pps->sps_id >= MAX_SPS_COUNT) { av_log(s->avctx, AV_LOG_ERROR, "SPS id out of range: %d\n", pps->sps_id); ret = AVERROR_INVALIDDATA; goto err; } if (!s->sps_list[pps->sps_id]) { av_log(s->avctx, AV_LOG_ERROR, "SPS %u does not exist.\n", pps->sps_id); ret = AVERROR_INVALIDDATA; goto err; } sps = (HEVCSPS *)s->sps_list[pps->sps_id]->data; pps->dependent_slice_segments_enabled_flag = get_bits1(gb); pps->output_flag_present_flag = get_bits1(gb); pps->num_extra_slice_header_bits = get_bits(gb, 3); pps->sign_data_hiding_flag = get_bits1(gb); pps->cabac_init_present_flag = get_bits1(gb); pps->num_ref_idx_l0_default_active = get_ue_golomb_long(gb) + 1; pps->num_ref_idx_l1_default_active = get_ue_golomb_long(gb) + 1; pps->pic_init_qp_minus26 = get_se_golomb(gb); pps->constrained_intra_pred_flag = get_bits1(gb); pps->transform_skip_enabled_flag = get_bits1(gb); pps->cu_qp_delta_enabled_flag = get_bits1(gb); pps->diff_cu_qp_delta_depth = 0; if (pps->cu_qp_delta_enabled_flag) pps->diff_cu_qp_delta_depth = get_ue_golomb_long(gb); pps->cb_qp_offset = get_se_golomb(gb); if (pps->cb_qp_offset < -12 || pps->cb_qp_offset > 12) { av_log(s->avctx, AV_LOG_ERROR, "pps_cb_qp_offset out of range: %d\n", pps->cb_qp_offset); ret = AVERROR_INVALIDDATA; goto err; } pps->cr_qp_offset = get_se_golomb(gb); if (pps->cr_qp_offset < -12 || pps->cr_qp_offset > 12) { av_log(s->avctx, AV_LOG_ERROR, "pps_cr_qp_offset out of range: %d\n", pps->cr_qp_offset); ret = AVERROR_INVALIDDATA; goto err; } pps->pic_slice_level_chroma_qp_offsets_present_flag = get_bits1(gb); pps->weighted_pred_flag = get_bits1(gb); pps->weighted_bipred_flag = get_bits1(gb); pps->transquant_bypass_enable_flag = get_bits1(gb); pps->tiles_enabled_flag = get_bits1(gb); pps->entropy_coding_sync_enabled_flag = get_bits1(gb); if (pps->tiles_enabled_flag) { pps->num_tile_columns = get_ue_golomb_long(gb) + 1; pps->num_tile_rows = get_ue_golomb_long(gb) + 1; if (pps->num_tile_columns == 0 || pps->num_tile_columns >= sps->width) { av_log(s->avctx, AV_LOG_ERROR, "num_tile_columns_minus1 out of range: %d\n", pps->num_tile_columns - 1); ret = AVERROR_INVALIDDATA; goto err; } if (pps->num_tile_rows == 0 || pps->num_tile_rows >= sps->height) { av_log(s->avctx, AV_LOG_ERROR, "num_tile_rows_minus1 out of range: %d\n", pps->num_tile_rows - 1); ret = AVERROR_INVALIDDATA; goto err; } pps->column_width = av_malloc_array(pps->num_tile_columns, sizeof(*pps->column_width)); pps->row_height = av_malloc_array(pps->num_tile_rows, sizeof(*pps->row_height)); if (!pps->column_width || !pps->row_height) { ret = AVERROR(ENOMEM); goto err; } pps->uniform_spacing_flag = get_bits1(gb); if (!pps->uniform_spacing_flag) { uint64_t sum = 0; for (i = 0; i < pps->num_tile_columns - 1; i++) { pps->column_width[i] = get_ue_golomb_long(gb) + 1; sum += pps->column_width[i]; } if (sum >= sps->ctb_width) { av_log(s->avctx, AV_LOG_ERROR, "Invalid tile widths.\n"); ret = AVERROR_INVALIDDATA; goto err; } pps->column_width[pps->num_tile_columns - 1] = sps->ctb_width - sum; sum = 0; for (i = 0; i < pps->num_tile_rows - 1; i++) { pps->row_height[i] = get_ue_golomb_long(gb) + 1; sum += pps->row_height[i]; } if (sum >= sps->ctb_height) { av_log(s->avctx, AV_LOG_ERROR, "Invalid tile heights.\n"); ret = AVERROR_INVALIDDATA; goto err; } pps->row_height[pps->num_tile_rows - 1] = sps->ctb_height - sum; } pps->loop_filter_across_tiles_enabled_flag = get_bits1(gb); } pps->seq_loop_filter_across_slices_enabled_flag = get_bits1(gb); pps->deblocking_filter_control_present_flag = get_bits1(gb); if (pps->deblocking_filter_control_present_flag) { pps->deblocking_filter_override_enabled_flag = get_bits1(gb); pps->disable_dbf = get_bits1(gb); if (!pps->disable_dbf) { pps->beta_offset = get_se_golomb(gb) * 2; pps->tc_offset = get_se_golomb(gb) * 2; if (pps->beta_offset/2 < -6 || pps->beta_offset/2 > 6) { av_log(s->avctx, AV_LOG_ERROR, "pps_beta_offset_div2 out of range: %d\n", pps->beta_offset/2); ret = AVERROR_INVALIDDATA; goto err; } if (pps->tc_offset/2 < -6 || pps->tc_offset/2 > 6) { av_log(s->avctx, AV_LOG_ERROR, "pps_tc_offset_div2 out of range: %d\n", pps->tc_offset/2); ret = AVERROR_INVALIDDATA; goto err; } } } pps->scaling_list_data_present_flag = get_bits1(gb); if (pps->scaling_list_data_present_flag) { set_default_scaling_list_data(&pps->scaling_list); ret = scaling_list_data(s, &pps->scaling_list); if (ret < 0) goto err; } pps->lists_modification_present_flag = get_bits1(gb); pps->log2_parallel_merge_level = get_ue_golomb_long(gb) + 2; if (pps->log2_parallel_merge_level > sps->log2_ctb_size) { av_log(s->avctx, AV_LOG_ERROR, "log2_parallel_merge_level_minus2 out of range: %d\n", pps->log2_parallel_merge_level - 2); ret = AVERROR_INVALIDDATA; goto err; } pps->slice_header_extension_present_flag = get_bits1(gb); skip_bits1(gb); pps->col_bd = av_malloc_array(pps->num_tile_columns + 1, sizeof(*pps->col_bd)); pps->row_bd = av_malloc_array(pps->num_tile_rows + 1, sizeof(*pps->row_bd)); pps->col_idxX = av_malloc_array(sps->ctb_width, sizeof(*pps->col_idxX)); if (!pps->col_bd || !pps->row_bd || !pps->col_idxX) { ret = AVERROR(ENOMEM); goto err; } if (pps->uniform_spacing_flag) { if (!pps->column_width) { pps->column_width = av_malloc_array(pps->num_tile_columns, sizeof(*pps->column_width)); pps->row_height = av_malloc_array(pps->num_tile_rows, sizeof(*pps->row_height)); } if (!pps->column_width || !pps->row_height) { ret = AVERROR(ENOMEM); goto err; } for (i = 0; i < pps->num_tile_columns; i++) { pps->column_width[i] = ((i + 1) * sps->ctb_width) / pps->num_tile_columns - (i * sps->ctb_width) / pps->num_tile_columns; } for (i = 0; i < pps->num_tile_rows; i++) { pps->row_height[i] = ((i + 1) * sps->ctb_height) / pps->num_tile_rows - (i * sps->ctb_height) / pps->num_tile_rows; } } pps->col_bd[0] = 0; for (i = 0; i < pps->num_tile_columns; i++) pps->col_bd[i + 1] = pps->col_bd[i] + pps->column_width[i]; pps->row_bd[0] = 0; for (i = 0; i < pps->num_tile_rows; i++) pps->row_bd[i + 1] = pps->row_bd[i] + pps->row_height[i]; for (i = 0, j = 0; i < sps->ctb_width; i++) { if (i > pps->col_bd[j]) j++; pps->col_idxX[i] = j; } pic_area_in_ctbs = sps->ctb_width * sps->ctb_height; pic_area_in_min_cbs = sps->min_cb_width * sps->min_cb_height; pic_area_in_min_tbs = sps->min_tb_width * sps->min_tb_height; pps->ctb_addr_rs_to_ts = av_malloc_array(pic_area_in_ctbs, sizeof(*pps->ctb_addr_rs_to_ts)); pps->ctb_addr_ts_to_rs = av_malloc_array(pic_area_in_ctbs, sizeof(*pps->ctb_addr_ts_to_rs)); pps->tile_id = av_malloc_array(pic_area_in_ctbs, sizeof(*pps->tile_id)); pps->min_cb_addr_zs = av_malloc_array(pic_area_in_min_cbs, sizeof(*pps->min_cb_addr_zs)); pps->min_tb_addr_zs = av_malloc_array(pic_area_in_min_tbs, sizeof(*pps->min_tb_addr_zs)); if (!pps->ctb_addr_rs_to_ts || !pps->ctb_addr_ts_to_rs || !pps->tile_id || !pps->min_cb_addr_zs || !pps->min_tb_addr_zs) { ret = AVERROR(ENOMEM); goto err; } for (ctb_addr_rs = 0; ctb_addr_rs < pic_area_in_ctbs; ctb_addr_rs++) { int tb_x = ctb_addr_rs % sps->ctb_width; int tb_y = ctb_addr_rs / sps->ctb_width; int tile_x = 0; int tile_y = 0; int val = 0; for (i = 0; i < pps->num_tile_columns; i++) { if (tb_x < pps->col_bd[i + 1]) { tile_x = i; break; } } for (i = 0; i < pps->num_tile_rows; i++) { if (tb_y < pps->row_bd[i + 1]) { tile_y = i; break; } } for (i = 0; i < tile_x; i++) val += pps->row_height[tile_y] * pps->column_width[i]; for (i = 0; i < tile_y; i++) val += sps->ctb_width * pps->row_height[i]; val += (tb_y - pps->row_bd[tile_y]) * pps->column_width[tile_x] + tb_x - pps->col_bd[tile_x]; pps->ctb_addr_rs_to_ts[ctb_addr_rs] = val; pps->ctb_addr_ts_to_rs[val] = ctb_addr_rs; } for (j = 0, tile_id = 0; j < pps->num_tile_rows; j++) for (i = 0; i < pps->num_tile_columns; i++, tile_id++) for (y = pps->row_bd[j]; y < pps->row_bd[j + 1]; y++) for (x = pps->col_bd[i]; x < pps->col_bd[i + 1]; x++) pps->tile_id[pps->ctb_addr_rs_to_ts[y * sps->ctb_width + x]] = tile_id; pps->tile_pos_rs = av_malloc_array(tile_id, sizeof(*pps->tile_pos_rs)); if (!pps->tile_pos_rs) { ret = AVERROR(ENOMEM); goto err; } for (j = 0; j < pps->num_tile_rows; j++) for (i = 0; i < pps->num_tile_columns; i++) pps->tile_pos_rs[j * pps->num_tile_columns + i] = pps->row_bd[j] * sps->ctb_width + pps->col_bd[i]; for (y = 0; y < sps->min_cb_height; y++) { for (x = 0; x < sps->min_cb_width; x++) { int tb_x = x >> sps->log2_diff_max_min_coding_block_size; int tb_y = y >> sps->log2_diff_max_min_coding_block_size; int ctb_addr_rs = sps->ctb_width * tb_y + tb_x; int val = pps->ctb_addr_rs_to_ts[ctb_addr_rs] << (sps->log2_diff_max_min_coding_block_size * 2); for (i = 0; i < sps->log2_diff_max_min_coding_block_size; i++) { int m = 1 << i; val += (m & x ? m * m : 0) + (m & y ? 2 * m * m : 0); } pps->min_cb_addr_zs[y * sps->min_cb_width + x] = val; } } log2_diff_ctb_min_tb_size = sps->log2_ctb_size - sps->log2_min_tb_size; for (y = 0; y < sps->min_tb_height; y++) { for (x = 0; x < sps->min_tb_width; x++) { int tb_x = x >> log2_diff_ctb_min_tb_size; int tb_y = y >> log2_diff_ctb_min_tb_size; int ctb_addr_rs = sps->ctb_width * tb_y + tb_x; int val = pps->ctb_addr_rs_to_ts[ctb_addr_rs] << (log2_diff_ctb_min_tb_size * 2); for (i = 0; i < log2_diff_ctb_min_tb_size; i++) { int m = 1 << i; val += (m & x ? m * m : 0) + (m & y ? 2 * m * m : 0); } pps->min_tb_addr_zs[y * sps->min_tb_width + x] = val; } } av_buffer_unref(&s->pps_list[pps_id]); s->pps_list[pps_id] = pps_buf; return 0; err: av_buffer_unref(&pps_buf); return ret; }
1threat
What is a %2s and %2d command in C, and when i use it? : <p>I would like to know why i use %2s here:</p> <pre><code>char card_name[3]; puts ("Enter the card name: "); scanf ("%2s, card_name); </code></pre> <p>And why i use %2d:</p> <pre><code>int n = 0; scanf ("%2d", &amp;n); printf ("-&gt; %d\n", n); </code></pre>
0debug
Python: How can I enable use of kwargs when calling from command line? (perhaps with argparse) : <p>suppose I have the module myscript.py; This module is production code, and is called often as <code>%dir%&gt;python myscript.py foo bar</code>. </p> <p>I want to extend it to take keyword arguments. I know that I can take these arguments using the script below, but unfortunately one would have to call it using </p> <p><code>%dir%&gt;python myscript.py main(foo, bar)</code>.</p> <p>I know that I can use the <code>argparse</code> module, but I'm not sure how to do it. </p> <pre><code>import sys def main(foo,bar,**kwargs): print 'Called myscript with:' print 'foo = %s' % foo print 'bar = %s' % bar if kwargs: for k in kwargs.keys(): print 'keyword argument : %s' % k + ' = ' + '%s' % kwargs[k] if __name__=="__main__": exec(''.join(sys.argv[1:])) </code></pre>
0debug
void tlb_set_page(CPUArchState *env, target_ulong vaddr, hwaddr paddr, int prot, int mmu_idx, target_ulong size) { MemoryRegionSection *section; unsigned int index; target_ulong address; target_ulong code_address; uintptr_t addend; CPUTLBEntry *te; hwaddr iotlb; assert(size >= TARGET_PAGE_SIZE); if (size != TARGET_PAGE_SIZE) { tlb_add_large_page(env, vaddr, size); } section = phys_page_find(address_space_memory.dispatch, paddr >> TARGET_PAGE_BITS); #if defined(DEBUG_TLB) printf("tlb_set_page: vaddr=" TARGET_FMT_lx " paddr=0x" TARGET_FMT_plx " prot=%x idx=%d pd=0x%08lx\n", vaddr, paddr, prot, mmu_idx, pd); #endif address = vaddr; if (!memory_region_is_ram(section->mr) && !memory_region_is_romd(section->mr)) { address |= TLB_MMIO; addend = 0; } else { addend = (uintptr_t)memory_region_get_ram_ptr(section->mr) + memory_region_section_addr(section, paddr); } code_address = address; iotlb = memory_region_section_get_iotlb(env, section, vaddr, paddr, prot, &address); index = (vaddr >> TARGET_PAGE_BITS) & (CPU_TLB_SIZE - 1); env->iotlb[mmu_idx][index] = iotlb - vaddr; te = &env->tlb_table[mmu_idx][index]; te->addend = addend - vaddr; if (prot & PAGE_READ) { te->addr_read = address; } else { te->addr_read = -1; } if (prot & PAGE_EXEC) { te->addr_code = code_address; } else { te->addr_code = -1; } if (prot & PAGE_WRITE) { if ((memory_region_is_ram(section->mr) && section->readonly) || memory_region_is_romd(section->mr)) { te->addr_write = address | TLB_MMIO; } else if (memory_region_is_ram(section->mr) && !cpu_physical_memory_is_dirty( section->mr->ram_addr + memory_region_section_addr(section, paddr))) { te->addr_write = address | TLB_NOTDIRTY; } else { te->addr_write = address; } } else { te->addr_write = -1; } }
1threat
Private messages in Symfony2 : <p>I use Symfony 2.8 There are website on it where users can register. I need to add the possibility of private messages between users. Is there a plugin that will do this?</p>
0debug
AVS Adult Video Script Site - error when adding swf game file : I have an adult tube site setup using AVS. I tried to add a game (swf file), but after uploading is complete, it shows an error "Please selected a game file!" even though I have selected one. Any idea what might be happening here? THanks!
0debug
Why does my simple program ends after runs? : Here is my little program import random liste = [] char_list = ['a', 'b', "c", "d"] while True: random.shuffle(char_list) n = ''.join(char_list) if n in liste: continue elif n not in liste: print(''.join(char_list)) liste.append(n) else: break Why is this program did not stops after gives the list ?
0debug
Junk character automatically changing after commiting code into svn repository : I am facing below issue in removing junk character using java. I am using below code to remove junk character colData = colData.replace(-­,"- "); Its working fine locally before committing the code into SVN Repository. But when we commit same line of code, its not working because its changing above code to below line of code: colData = colData.replace(-Ã,­,"- "); Can anyone suggest me why this is happening? Please suggest solution on this asap. Thanks
0debug
In Julia, How do you check, list, update your packages? : <p>I'm wondering if there are utility commands in Julia that perform simple package management operations, such as:</p> <p>List a single or all packages installed Upgrade a single or all packages installed Remove a package or all packages Clean up package remnants</p> <p>These are commands that I frequently use in yarn or homebrew for example and I was wondering if there were equivalents in Julia?</p>
0debug
int kvm_arch_on_sigbus_vcpu(CPUState *env, int code, void *addr) { #ifdef KVM_CAP_MCE ram_addr_t ram_addr; target_phys_addr_t paddr; if ((env->mcg_cap & MCG_SER_P) && addr && (code == BUS_MCEERR_AR || code == BUS_MCEERR_AO)) { if (qemu_ram_addr_from_host(addr, &ram_addr) || !kvm_physical_memory_addr_from_ram(env->kvm_state, ram_addr, &paddr)) { fprintf(stderr, "Hardware memory error for memory used by " "QEMU itself instead of guest system!\n"); if (code == BUS_MCEERR_AO) { return 0; } else { hardware_memory_error(); } } kvm_mce_inject(env, paddr, code); } else #endif { if (code == BUS_MCEERR_AO) { return 0; } else if (code == BUS_MCEERR_AR) { hardware_memory_error(); } else { return 1; } } return 0; }
1threat
static unsigned acpi_data_len(GArray *table) { #if GLIB_CHECK_VERSION(2, 14, 0) assert(g_array_get_element_size(table) == 1); #endif return table->len; }
1threat
Issue running batch file in c# winforms app : As part of my program I need to run a batch file, the person I'm doing it for doesn't want anyone to be able to view the batch script, so I tried to include it in the winforms solution, but I can't get it to run, I just get a time out error
0debug
How to get the first key (not value) of immutable.js map? : <p>How to get the first key (not value) of immutable.js map?</p> <p>basically <code>myMap.first()</code> will return the value, but I am interested in the key...</p> <p>I can do a forEach and store first, but must be a better way!</p> <p>didn't see it in the docs, prob missing it... :/</p> <p>tx</p> <p>Sean</p>
0debug