Posts

Showing posts from August, 2018

warning: passing argument 2 of ‘getsockname’ from incompatible pointer type

I can't figure this out. Can anyone tell me why I am getting this error: warning: passing argument 2 of ‘getsockname’ from incompatible pointer type In the following code: #include #include #include #include #include #include int main() { int sd; struct sockaddr_in my_addr; bzero(&my_addr,sizeof(my_addr)); my_addr.sin_family = AF_INET; my_addr.sin_addr.s_addr = inet_addr("127.0.0.1"); my_addr.sin_port = htons(0); my_addr.sin_addr.s_addr = INADDR_ANY; socklen_t my_addr_size = sizeof my_addr; if((sd = socket(AF_INET, SOCK_STREAM, 0)) Solved The second argument to getsockname should be a struct sockaddr * . You're passing the address of a struct sockaddr_in .

Finding groups of increasing numbers in a list

The aim is to find groups of increasing/monotonic numbers given a list of integers. Each item in the resulting group must be of a +1 increment from the previous item Given an input: x = [7, 8, 9, 10, 6, 0, 1, 2, 3, 4, 5] I need to find groups of increasing numbers and achieve: increasing_numbers = [(7,8,9,10), (0,1,2,3,4,5)] And eventually also the number of increasing numbers: len(list(chain(*increasing_numbers))) And also the len of the groups: increasing_num_groups_length = [len(i) for i in increasing_numbers] I have tried the following to get the number of increasing numbers: >>> from itertools import tee, chain >>> def pairwise(iterable): ... a, b = tee(iterable) ... next(b, None) ... return zip(a, b) ... >>> x = [8, 9, 10, 11, 7, 1, 2, 3, 4, 5, 6] >>> set(list(chain(*[(i,j) for i,j in pairwise(x) if j-1==i]))) set([1, 2, 3, 4, 5, 6, 8, 9, 10, 11]) >>> len(set(list(chain(*[(i,j) for i,j in pairwise(x)...

How to use IN clause in THEN part of CASE statement without errors?

I want to use IN Clause in Then part of CASE statement. This is giving me some errors. declare @Role varchar(10),@Region_Code varchar(100) set @Role='AB' SEt @Region_Code='003,002,004,005' select * from [tableName] BM where CASE WHEN @Role='AB' THEN BM.[Region code] in (Select * from dbo.Split (@Region_Code, ',')) WHEN @Role='XYZ' THEN BM.Branch_code in (Select * from dbo.Split (@Region_Code, ',')) end Solved Why not use IF ELSE IF statement IF @Role='AB' select * from [tableName] BM where BM.[Region code] in (Select RegionCode from dbo.Split (@Region_Code, ',')) ELSE IF @Role='XYZ' select * from [tableName] BM where BM.[Branch_code] in (Select RegionCode from dbo.Split (@Region_Code, ',')) Also try this select * from [tableName] BM where ( @Role='AB' AND BM.[Region code] in (Select RegionCode from dbo.Split(@Region_Code, ',')) ) OR ( @Role='XYZ'...

how to watermark mp4 video with ffmpeg php

I need to watermark a mp4 video , Currently i am using this code, but it is not working , please solve this Solved You need to put the filter code within double quotes. If you could share more about the error you're facing, I'll be able to help you better.