prompt
stringlengths
49
4.73k
response
stringlengths
238
35k
array type is not assignable I need to create two references to an array which could be refer to the same array. I tried the following: ``` extern int (&a)[]; extern int (&b)[]; int main() { b = a; // error: array type 'int []' is not assignable } ``` Is there a way to do that in c++?
Two things: first [arrays](http://en.cppreference.com/w/cpp/language/array) cannot appear on the left hand of an assignment operator. cppreference probably takes its text directly from the standard, particularly: § 8.3.4 > > 5 Objects of array types cannot be modified, see 3.10. > > > Also, like cppreference...
Linq to objects Predicate Builder What is the best way to do a conditional query using linq to objects(not linq to sql). Currently I am using the Predicate builder found here <http://www.albahari.com/nutshell/predicatebuilder.aspx> and passing the compiled predicate to the IEnumerable.Where and it seems to work nicel...
Just change `PredicateBuilder` to use delegates instead of expression trees and use lambdas to build the results: ``` public static class DelegatePredicateBuilder { public static Func<T, bool> True<T>() { return f => true; } public static Func<T, bool> False<T>() { return f => false; } public static Func<T,...
Cache SSD shutdown data loss Most SSD have a cache to provide fast write speed. But what happens when I shutdown the computer with full cache? Is that cache volatile? How fast ist the cache processed and persisted? Do I need to wait some seconds before I shutdown my computer after transferring a lot of data? Do I need ...
During a controlled shutdown, the OS/filesystem flushes all pending writes to stable storage, issuing a final write barrier (ie: ATA FLUSH) to be sure no data remains in the volatile write cache. This can need some time, but you don't have to do anything: just wait for the operation to complete (and the system to power...
Add levels selector class to wordpress nav menu I would like to add level classes to each li when echoing the results of wp\_list\_pages. Currently, I'm using: ``` <?php wp_nav_menu(array('theme_location' => 'main_menu', 'container' => '', 'menu_class' => 'fR clearfix', 'menu_id' => 'nav')); <?php } ?> ``` Th...
There isn't a direct way to do this. You can use the wp\_nav\_menu\_objects filter and manipulate the menu item's classes. Here is the code for you: ``` <?php add_filter('wp_nav_menu_objects' , 'my_menu_class'); function my_menu_class($menu) { $level = 0; $stack = array('0'); foreach($menu as $key =>...
Convert Date to another timezone in JavaScript and Print with Correct Timezone I need to convert a local timezone to Pacific/Los angeles. Example, if user in Hawaii **Code:** taken here from <https://stackoverflow.com/a/54127122/15358601> ``` function convertTZ(date, tzString) { return new Date((typeof date ...
A few things: - The approach in the answer you linked to for the `convertTZ` is flawed. One should not parse the output of `toLocalString` with the `Date` constructor. Please read the comments following that answer. - The `Date` object *can not* be converted to another time zone, because it is not actually in *any* t...
In a UITableView, best method to cancel GCD operations for cells that have gone off screen? I have a `UITableView` that loads images from a URL into cells asynchronously using GCD. Problem is if a user flicks past 150 rows, 150 operations queue up and execute. What I want is to dequeue/cancel the ones that blew past an...
First, don't queue operations while scrolling. Instead, load images for just the visible rows in `viewDidLoad` and when the user stops scrolling: ``` -(void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView { for (NSIndexPath *indexPath in [self.tableView indexPathsForVisibleRows]) { [self loadImag...
CSS Polygon Shadow I'm using the `clip-path` property to shape my block element. ``` clip-path: polygon(0 0, 100% 0, 100% 100px, 50% 100%, 0 100px); ``` I would like to put a "drop shadow" in that element. So, I've tried some techniques, like: ``` box-shadow: 0 15px 30px 0 rgba(0, 0, 0, 0.5); ``` Or... ```...
As it was said in the comments, you need 2 nested elements for this, the inner for the clipping and the outer for the shadow. ``` body { background-color: gray; } .navigation { filter: drop-shadow(0 15px 30px rgba(0, 0, 200, 0.5)); } .innernav { /* PATH */ clip-path: polygon(0 0, 100% 0, 100% 1...
Opening multiple windows with Applescript I am trying to write an Applescript to open three VLC windows in different screen positions. The script opens three instances of VLC but has them one on top of the other (using the position for window 1). Help with the code appreciated: ``` do shell script "open -n /Applicat...
@khagler's comment provides the right pointer: the VLC instances must be distinguished by their PIDs (process IDs; called `unix id` in AppleScript) in the `System Events` context. The code below should do what you want, arrived at after much toil and trouble -- par for the [AppleScript obstacle] course. One obstacle ...
Filling missing levels I have the following type of dataframe: ``` Country <- rep(c("USA", "AUS", "GRC"),2) Year <- 2001:2006 Level <- c("rich","middle","poor",rep(NA,3)) df <- data.frame(Country, Year,Level) df Country Year Level 1 USA 2001 rich 2 AUS 2002 middle 3 GRC 2003 poor 4 USA 20...
We can group by 'Country' and get the non-NA unique value ``` library(dplyr) df %>% group_by(Country) %>% dplyr::mutate(Level = Level[!is.na(Level)][1]) # A tibble: 6 x 3 # Groups: Country [3] # Country Year Level # <fctr> <int> <fctr> #1 USA 2001 rich #2 AUS 2002 middle #3 GRC 2003 ...