[Solved] Adding a number to the day or month or year in a date [duplicate]

In .NET you could do use the AddMonths method: DateTime date = new DateTime(2013, 5, 19); DateTime newDate = date.AddMonths(14); As far as parsing a date from a string using a specified format you could use the TryParseExact method: string dateStr = “19/05/2013”; DateTime date; if (DateTime.TryParseExact(dateStr, “dd/MM/yyyy”, CultureInfo.InvariantCulture, DateTimeStyles.None, out date)) { // successfully … Read more

[Solved] For loop not executed

I’m not sure what you are going for exactly but this is your problem in your loop t == 5 it should be something like for(int t = 1; t <= 5; t = t+1) { t is never 5 here so it will never iterate. Also, you can simplify the last part so it … Read more

[Solved] Remove all duplicate characters from a string (STL)

Solution simple as always: void RemoveDuplicates (std::string& input) { std::string::iterator it = std::unique(input.begin(), input.end()); input.erase(it, input.end()); std::cout << “New input = “<< input << std::endl; } Another solution to return a new string: std::string RemoveDuplicates (const std::string& input) { std::string newT(input); std::string::iterator it = std::unique(newT.begin(), newT.end()); newT.erase(it, newT.end()); return newT; } If desired result is … Read more

[Solved] Java: split text [duplicate]

You can use Pattern and Matcher: String input = “Java: split text [duplicate],[description blablablablablabla]”; Pattern pattern = Pattern.compile(“\\[(.*?)\\]”); Matcher matcher = pattern.matcher(input); ArrayList<String> stringList = new ArrayList<String>(); while(matcher.find()) { stringList.add(matcher.group(1)); } //If you just need the results to be stored in an array of Strings anyway. String[] stringArray = stringList.toArray(new String[stringList.size()]); 1 solved Java: split … Read more

[Solved] Mouse position with Ajax in PHP [closed]

You can use this code for getting mouse position and posting request: $(“#target”).mousemove(function(event) { $.post(“test.php”, {x: event.pageX, y: event.pageY}); }); If you need help with doing something with position in PHP, you can ask me. solved Mouse position with Ajax in PHP [closed]

[Solved] Finding largest number in array [closed]

Try using std::max_element from <algorithm>: #include <algorithm> int i[] = { 1, 84, 11, 31 }; // for C++11 and later: int max = *std::max_element(std::begin(i), std::end(i)); // for C++03 or earlier: int max2 = *std::max_element(i, i + (sizeof(i) / sizeof(*i))); or if your array is static, you can just use an C++11 initializer list: auto … Read more

[Solved] Saving the current view as a bitmap

You try to add this listener to the onCreate event: myCustomView.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() { @Override public void onGlobalLayout() { myCustomView.getViewTreeObserver().removeOnGlobalLayoutListener(this); do_your_logic_to_save_bitmap_from_view; } }); addOnGlobalLayoutListener will register a callback to be invoked when the global layout state or the visibility of views within the view tree changes. For example when the view is rendered completely. 3 solved … Read more

[Solved] How to replace a pattern in a string

I would do this for the links <%= ([1,2,3]- [params[:x]]).each do |link_number| %> <%= link_to “Version #{link_number}”, “/page?x=#{link_number}” %> <% end %> This way everytime the page is loaded the link to the other 2 versions will exist. You could handle the partials through the controller (which seems better) or use something like: <%= render … Read more

[Solved] How can i create Highchart xAxis labels centered and enclosed?

I would use Highcharts.SVGRenderer to draw rect elements, based on the ticks from the second xAxis and translate the labels. Please check the example below: chart: { events: { render: function() { var ticks = this.xAxis[1].ticks, x = this.plotLeft, y = 378, width, color=”blue”, textColor=”yellow”, height = 28; if (!this.customTicks) { this.customTicks = []; } … Read more

[Solved] Regex: find word with extra characters

I’m going to demonstrate required steps to cook a regex for word help but the requirements are not clear, rules are not strict hence some drawbacks are usual. \bh+[a-z&&[^e]]*e+[a-z&&[^le]]*l+[a-z&&[^ p l e ]]*p+\b ^ ^^ ^ ^ ^ | || | |–|-> [#2] | || |-> [#1] | ||-> Previous char(s) [#2] | |-> [#1] … Read more