[Solved] Auto increasing numbers in array

There are too many magic numbers in this code, but here you go: // Build an Array of keys @[@”item_1_type_1″, @”item_1_type_2″, …, @”item_1_type_9″] programmatically const int numberOfElements = 9; NSMutableArray *keys = [NSMutableArray arrayWithCapacity:numberOfElements]; for (int i = 1; i <= numberOfElements; i++) { [keys addObject:[NSString stringWithFormat:@”item_1_type_%d”, i]]; } // Extract chosen keys from JSON … Read more

[Solved] Extract date and time from datetime field in R

If I understood well, R can read correctly your dates and times as you import your data (because they are in POSIXct format), but you can not extract the date and the time in the right format from your date-time column. Considering that you have a data.frame in R, like this: date_time Sold 1 2020-01-01 … Read more

[Solved] Change drawable color on button on click

Drawable img = getContext().getResources().getDrawable( R.drawable.smiley ); img.setBounds( 0, 0, 60, 60 ); txtVw.setCompoundDrawables( img, null, null, null ); With this code, you can change a left drawable programatically. For the text color, please see Android documentation solved Change drawable color on button on click

[Solved] bootstrap fixed nav in single page site links issue

What you’re trying to achieve here is impossible without Javascript. You’ve changed the scrollTop but you need to do it after some milliseconds to get it working, e.g: $(“.nav a”).click(function(){ setTimeout(function() { $(window).scrollTop($(window).scrollTop() – 50); }, 10); }); If you don’t want to wait those milliseconds, you can also prevent the default behavior and simulate … Read more

[Solved] Need algorithm to solve shifting in C [closed]

like this (error handling is omitted, strtok_r removed if strtok_r can use): #include <stdio.h> #include <stdlib.h> #include <string.h> char *strtok_r(char *str, const char *delims, char **store){ char *p, *wk; if(str != NULL){ *store = str; } if(*store == NULL) return NULL; *store += strspn(*store, delims);//skip delimiter if(**store == ‘\0’) return NULL; p=strpbrk(wk=*store, delims); if(p != … Read more

[Solved] Iphone right to left displaying [closed]

Have a look at this answer for how to display right to left text in a UILabel, which is the label class that is used throughout Cocoa touch, including in UITableView cells. You can create the right-to-left string like this (copy & pasted from linked answer): NSString *str = “1. בבוקר”; //This could be any … Read more

[Solved] Trying to not have repeating data (MySQL, php) [closed]

I’m not sure what are you trying to do, but you don’t want to use the GROUP BY clause. If you want to select all entries, use: mysql_query(“SELECT * FROM `testimonials`”); If you want to select one random entry, use: mysql_query(“SELECT * FROM `testimonials` ORDER BY RAND() LIMIT 1”); and get rid of the while … Read more

[Solved] Reading a file and output in a particular format in Perl [closed]

I think I know what you want: perl -F’\s’ -anE’BEGIN{$/=”\n\n”;}$i=$F[6];say”$_ – “,$i–for($F[0]..$F[2])’ Simple, isn’t it? BTW, your example output is wrong. I see the image (copy) mirrored. Left value is bigger than right. So values in second column should go down. If it can vary in your input data you have to use little bit … Read more

[Solved] How do I make an image repeatedly show and hide every x seconds?

Taking your question quite literal, I think this is what you want. Image shows for 10s hides for 10s, then shows for 10s and hides for 7s, repeat. function promoFade() { $(‘#promo’).delay(x).fadeOut(150).delay(x).fadeIn(150).delay(x).fadeOut(150).delay(x).fadeIn(150); }; setInterval(“promoFade()”, 0); Added setInterval in case you need to wait for the page to load. There are better ways and personally, I … Read more