qid
int64
1
74.7M
question
stringlengths
0
70k
date
stringlengths
10
10
metadata
sequence
response
stringlengths
0
115k
13,869,060
I have the following code that is trying to remove some JSESSIONID cookies from my browser. ``` String[] cookieList = "/App1/,/App2/,/App3/".split(","); for (int i = 0; i < cookieList.length; i++) { String cookiePathString = cookieList[i]; response.setContentType("text/html"); Cookie cookieToKill = new Cookie("JSESSIONID", "No Data"); cookieToKill.setDomain(getCookieDomainName("myDomain.com")); cookieToKill.setMaxAge(0); cookieToKill.setPath(cookiePathString); cookieToKill.setComment("EXPIRING COOKIE at " + System.currentTimeMillis()); response.addCookie(cookieToKill); } ``` The code works fine in Firefox, and deletes the JSESSIONID. In Chrome and IE it does not. What do you have to do to expire these session cookies from IE and Chrome? This is running in an Spring MVC Application on Tomcat running Java 7
2012/12/13
[ "https://Stackoverflow.com/questions/13869060", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1408524/" ]
Cookie is completely messed up. The best practices for a server: 1. use Set-Cookie, not Set-Cookie2. 2. if there are multiple cookies, use a separate Set-Cookie header for each cookie. 3. use Expires, not Max-Age. 4. use the date format: `Sun, 06 Nov 1994 08:49:37 GMT` For example: ``` Set-Cookie: JSESSIONID=NO_DATA; Path=/App1/; Domain=myDomain.com; Expires=Thu, 01 Jan 1970 00:00:00 GMT ``` What I can recommend you to do: 1. Don't have spaces in cookie values. 2. Call `cookie.setVersion(0);` If still no luck, forget the `Cookie` class, try set the http header manually ``` response.addHeader("Set-Cookie", "JSESSIONID=NO_DATA; Path=/App1/; Domain=myDomain.com; Expires=Thu, 01 Jan 1970 00:00:00 GMT"); ```
62,853
Also, if there is truth behind Republican support to make voting more restrictive for people in general, how long ago might this party have started advocating legislation with more restrictions? Why --- Listening to the video on [this post](https://www.cnn.com/2021/03/02/politics/supreme-court-brnovich-v-dnc-case-analysis-john-roberts/index.html), there are different Republican and Democrat views on voting access. It seems to be portrayed that... 1. Democrats want more people to have access to their voting rights by fewer disqualifying restrictions. 2. Republicans want fewer people to have access to their voting rights by more disqualifying restrictions. I found the end of the audio most interesting where [Amy Coney Barrett](https://en.wikipedia.org/wiki/Amy_Coney_Barrett) asked the RNC attorney about the interest to the RNC in keeping the out-of-precinct voter ballot disqualification rule in place in Arizona. The RNC attorney's response was "*Because it puts us at a competitive disadvantage relative to Democrats. Politics is a zero-sum game*".
2021/03/03
[ "https://politics.stackexchange.com/questions/62853", "https://politics.stackexchange.com", "https://politics.stackexchange.com/users/7229/" ]
Speaking nationally, Democrats currently have a 6%-7% advantage over Republicans in terms of voter representation. In fact, Democrats have a lead among every demographic group except *white males without a college education*. However, Democratic voters tend to be clustered in urban and suburban areas, which attenuates their voting power somewhat and leaves them vulnerable to manipulations like gerrymandering. Further, they have lower SES (socio-economic status) as a group, meaning they are more affected by restrictions on registration and voting. And that's not mentioning the Electoral College, which gives a significant advantage to parties that control smaller states (which currently — for the most part — lean Republican). So yes: making voting more restrictive mainly impacts low income voters in urban areas, those who have the least free time and fewest material and financial resources to jump through bureaucratic hoops. At least some Republicans and conservatives explicitly advocate for this kind of implicit disenfranchisement in order to maintain power. I cannot speak to the intentions of the GOP as a whole, except to note that anyone in the political universe with any minimal competence is aware of the fact that there are material conditions to voting which can present obstacles. This has been well-known and thoroughly argued since the Jim Crow days, back when the Supreme Court struck down poll taxes, so anyone who talks about voting restrictions without also considering the issue of structural disenfranchisement is either deeply ignorant or purely Machiavellian. Granting that some conservatives do argue that there should be a 'civic commitment' standard applied to voting — akin to the ancient Greek practice of restricting the democratic participation to established property owners and native sons, on the grounds that such people have a firm commitment to the welfare of the community — the GOP itself has never raised that *explicitly* as a platform, for the obvious 'optics' reasons. And note that the situation is more complex than it appears on the surface. The GOP could (for instance) work to increase its voter base, thus obviating the need for voting restrictions. But that would involve creating a forward-thinking platform meant to appeal to a broader coalition, which risks insulting certain die-hard, single-issue voting blocks that the GOP has catered to since the 70s. Those voting blocks are not exactly unified, but they represent some of the most readily mobilized elements of the GOP base, so the GOP prefers a fragmented, decentered, 'talking point' style of politics, one which allows them to play both ends against the middle without committing themselves to anything. Squeezing out unwanted voters is simpler and safer.
19,585,979
I'm using ant to package a JavaFX-based application. No problem with doing the actual JavaFX stuff, except that `fx:jar` doesn't support the `if` or `condition` tags. I want to dynamically include some platform-specific libraries, depending on a variable i set. Currently I have this: ``` <fx:fileset dir="/my/classes/folder"> <include name="**/*lib1.dylib" if="??"/> <include name="**/*lib2.dll" if="??" /> <include name="**/*lib3.dll" if="??" /> </fx:fileset> ``` I want to run this target multiple times, with a different variable value depending on the platform. It seems you can not do something like: ``` <include name="**/*lib3.dll" if="platform=mac" /> ``` So I'm stuck. Please help!
2013/10/25
[ "https://Stackoverflow.com/questions/19585979", "https://Stackoverflow.com", "https://Stackoverflow.com/users/568355/" ]
Many readers of this forum expect to see *some* code that you tried.... ``` program flow version 8 // will work on almost all Stata in current use gettoken what garbage : 0 if "`what'" == "" | "`garbage'" != "" | !inlist("`what'", "e", "i") { di as err "syntax is flow e or flow i" exit 198 } if "`what'" == "e" { <code for e> } else if "`what'" == "i" { <code for i> } end ``` The last `if` condition is redundant as we've already established that the user typed `e` or `i`. Edit it out according to taste.
1,362,991
Let $\sum a\_n=a$ with terms non-negative. Let $ s\_n$ the n-nth partial sum. Prove $\sum na\_n$ converge if $\sum (a-s\_n)$ converge
2015/07/16
[ "https://math.stackexchange.com/questions/1362991", "https://math.stackexchange.com", "https://math.stackexchange.com/users/254420/" ]
$$ \begin{align} \sum\_{k=1}^nka\_k &=\sum\_{k=1}^n\sum\_{j=1}^ka\_k\\ &=\sum\_{j=1}^n\sum\_{k=j}^na\_k\\ &=\sum\_{j=1}^n(s\_n-s\_{j-1}) \end{align} $$ Taking limits, we get by [Monotone Convergence](https://en.wikipedia.org/wiki/Monotone_convergence_theorem) that $$ \begin{align} \sum\_{k=1}^\infty ka\_k &=\sum\_{j=1}^\infty(a-s\_{j-1})\\ &=a+\sum\_{j=1}^\infty(a-s\_j)\\ \end{align} $$
7,530,329
I am using jQuery and jQuery UI and i am trying to read a checkbox state through the addition of the "aria-pressed" property that jQuery UI Button toggle between false and true. ``` $('.slideButton').live('click', function() { alert($(this).attr('aria-pressed')); }); ``` This code however seems to read the aria-pressed before jQuery UI has updated aria-pressed. So i unreliable values. Can i schedule it to execute after the UI has updated or can i make it wait? [Live example here!](http://jonasbengtson.se/projects/dh/admin/)
2011/09/23
[ "https://Stackoverflow.com/questions/7530329", "https://Stackoverflow.com", "https://Stackoverflow.com/users/961325/" ]
Can't you add a listener to the actual checkbox behind the label or span? ``` $("#days_list li div div div input[type='checkbox']").change(function(){ alert("Someone just clicked checkbox with id"+$(this).attr("id")); }); ``` This should work since, once you click the label, you change the value in the checkbox. --- Alright, I've composed a [live example](http://jsfiddle.net/S5NEf/4/) for you that demonstrates the general idea of how it works, and how you retrieve the status of the checkbox. ``` $("#checkbox_container input").change(function(){ if($(this).is(":checked")) alert("Checked!"); else alert("Unchecked!"); }); ``` In your case, since the checkbox is added dynamically by JQuery you have to use the live event, but it is basically the same thing ``` $("#checkbox_container input").live("changed".... ``` [Here's an example](http://jsfiddle.net/S5NEf/8/) with some additional scripting and checking, mostly for demonstrative purposes.
7,420,940
I have a vbscript that runs on the command line in xp. It accepts one argument for the path to a directory. Is there a simple way to prompt the user in the command line box for this? If not, I can just echo what was passed in to show the user what they actually typed in case of typos. Thanks, James Aftermath: Here is the code I ended up with: On Error Resume Next strDirectory = InputBox(Message, Title, "For example - P:\Windows\") ``` If strDirectory = "" Then 'Wscript.Echo cancelledText Else 'Wscript.Echo enteredText & strDirectory etc... ``` I found some snippets and it turned out to be really simple to work with the inputBox. HTH. James
2011/09/14
[ "https://Stackoverflow.com/questions/7420940", "https://Stackoverflow.com", "https://Stackoverflow.com/users/543572/" ]
You can use the [`WScript.StdIn`](http://msdn.microsoft.com/en-us/library/1y8934a7%28v=VS.85%29.aspx) property to read from the the standard input. If you want to supply the path when invoking the script, you can pass the path as a parameter. You'll find it in the [`WScript.Arguments`](http://msdn.microsoft.com/en-us/library/z2b05k8s%28v=VS.85%29.aspx) property.
19,946,041
I recently discovered this script: [JS fiddle text swapper](http://jsfiddle.net/PMKDG/) - but I'd like to add a nice fade in and fade out. I guess this is a 2 part question. 1. Can I add fadeIn the way this is structured? 2. I'm guessing I'll also need a FadeOut? Help would be greatly appreciated! Thanks ``` $(function() { $("#all-iso, #date-iso, #actor-iso, #film-iso").on("click", function(e) { var txt = ""; switch ($(this).prop("id")) { case "all-iso": txt = "ALLE NEWS"; break; case "date-iso": txt = "DATUM"; break; case "actor-iso": txt = "SCHAUSPIELER"; break; case "film-iso": txt = "FILM"; break; } $("#news-h3-change").text(txt); }) }) ```
2013/11/13
[ "https://Stackoverflow.com/questions/19946041", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1572316/" ]
Try ``` $("#news-h3-change").fadeOut(function(){ $(this).text(txt) }).fadeIn(); ``` Demo: [Fiddle](http://jsfiddle.net/arunpjohny/93WG6/) I might suggest to use `data-*` to make it little more nice, like ``` <ul id="iso"> <li data-txt="ALLE NEWS">all-iso</li> <li data-txt="DATUM">date-iso</li> <li data-txt="SCHAUSPIELER">actor-iso</li> <li data-txt="FILM">film-iso</li> </ul> <h3 id="news-h3-change"></h3> ``` then ``` $(function () { $("#iso > li").on("click", function (e) { var txt = $(this).data('txt'); $("#news-h3-change").stop(true, true).fadeOut(function () { $(this).text(txt) }).fadeIn('slow'); }) }) ``` Demo: [Fiddle](http://jsfiddle.net/arunpjohny/dmZ5W/)
51,249,250
I'm trying to edit this code to be dynamic as I'm going to schedule it to run. Normally I would input the date in the where statement as 'YYYY-MM-DD' and so to make it dynamic I changed it to DATE(). I'm not erroring out, but I'm also not pulling data. I just need help with format and my google searching isn't helping. ``` PROC SQL; CONNECT TO Hadoop (server=disregard this top part); CREATE TABLE raw_daily_fcast AS SELECT * FROM connection to Hadoop( SELECT DISTINCT a.RUN_DATE, a.SCHEDSHIPDATE, a.SOURCE, a.DEST , a.ITEM, b.U_OPSTUDY, a.QTY, c.case_pack_qty FROM CSO.RECSHIP a LEFT JOIN CSO.UDT_ITEMPARAM b ON a.ITEM = b.ITEM LEFT JOIN SCM.DIM_PROD_PLN c ON a.ITEM = c.PLN_NBR WHERE a.RUN_DATE = DATE() AND a.SOURCE IN ('88001', '88003', '88004', '88006', '88008', '88010', '88011', '88012', '88017', '88018', '88024', '88035', '88040', '88041', '88042', '88047') ); DISCONNECT FROM Hadoop; QUIT; ```
2018/07/09
[ "https://Stackoverflow.com/questions/51249250", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7257430/" ]
Try command ``` ionic cordova build android --prod --release ```
165,197
I was once asked the following question by a student I was tutoring; and I was stumped by it: When one throws a stone why does it take the same amount of time for a stone to rise to its peak and then down to the ground? * One could say that this is an experimental observation; after one could envisage, hypothetically, where this is not the case. * One could say that the curve that the stone describes is a parabola; and the two halves are symmetric around the perpendicular line through its apex. But surely the description of the motion of a projectile as a parabola was the outcome of observation; and even if it moves along a parabola, it may (putting observation aside) move along it with its descent speed different from its ascent; or varying; and this, in part, leads to the observation or is justified by the Newtons description of time - it flows equably everywhere. * It's because of the nature of the force. It's independent of the motion of the stone. I prefer the last explanation - but is it true? And is this the best explanation?
2015/02/15
[ "https://physics.stackexchange.com/questions/165197", "https://physics.stackexchange.com", "https://physics.stackexchange.com/users/7993/" ]
I would say that it is a result of time reversal symmetry. If you consider the projectile at the apex of its trajectory then all that changes under time reversal is the direction of the horizontal component of motion. This means that the trajectory of the particle to get to that point and its trajectory after that point should be identical apart from a mirror inversion.
22,594,048
How do I apply css styles to HTML tags within a class at once instead of repeating the class name each time. ``` .container h1,.container p,.container a,.container ol,.container ul,.container li, .container fieldset,.container form,.container label,.container legend, .container table { some css rules here } ``` how do I reduce repetition of the class name?
2014/03/23
[ "https://Stackoverflow.com/questions/22594048", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1106398/" ]
Use [LESS](http://lesscss.org/). It would come out looking like this. ``` .container { h1, p, a, ol, ul, li, fieldset, form, label, legend, table { your styles here } } ``` Otherwise, you're SOL. Sorry.
3,766,138
Is there a way to call a function inside a loaded SWF file? Basically, I have a .swf file (A) that loads another .swf file (B)...I would just like to treat B as if it was any other instance added to my class .swf "A"... --- Have to recast "Loader" with the name of your .swf file class: Loaded .swf class: ``` package src { import flash.display.MovieClip; public class LoadedSWF extends MovieClip { public function LoadedSWF() { } public function helloWorld():void { trace("hello world from loaded swf!"); } } } ``` Main class: ``` package src { import flash.display.Loader; import flash.net.URLRequest; import flash.display.MovieClip; import flash.events.Event; public class Main extends MovieClip { private var loader:Loader; public function Main() { loadSWF("LoadedSWF.swf") } private function loadSWF(url:String):void { var urlRequest:URLRequest = new URLRequest(url); loader = new Loader(); loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onLoaded, false, 0, true); loader.load(urlRequest); addChild(loader); } private function onLoaded(e:Event):void { var target:LoadedSWF = e.currentTarget.loader.content as LoadedSWF; trace(target); target.helloWorld(); addChild(target); } } ``` }
2010/09/22
[ "https://Stackoverflow.com/questions/3766138", "https://Stackoverflow.com", "https://Stackoverflow.com/users/147915/" ]
In Adobe Flex, you can use the flash.display.Loader class to load another SWF, and add an event listener to it. This example is taken from the Adobe Documentation: ``` var url:String = "http://www.helpexamples.com/flash/images/image2.jpg"; var urlRequest:URLRequest = new URLRequest(url); var loader:Loader = new Loader(); loader.contentLoaderInfo.addEventListener(Event.COMPLETE, loader_complete); loader.load(urlRequest); addChild(loader); function loader_complete(evt:Event):void { var target_mc:Loader = evt.currentTarget.loader as Loader; target_mc.x = (stage.stageWidth - target_mc.width) / 2; target_mc.y = (stage.stageHeight - target_mc.height) / 2; } ``` Because contentLoaderInfo is a subclass of EventDispatcher, you can also dispatch events to the loaded SWF. This is basically like calling a function from the SWF, just a little more complicated.
31,234,459
I am trying to get the latitude and longitude values from a JSON array - `$response`, returned from Google, from their Geocoding services. The JSON array is returned as such (random address): ``` { "results":[ { "address_components":[ { "long_name":"57", "short_name":"57", "types":[ "street_number" ] }, { "long_name":"Polo Gardens", "short_name":"Polo Gardens", "types":[ "route" ] }, { "long_name":"Bucksburn", "short_name":"Bucksburn", "types":[ "sublocality_level_1", "sublocality", "political" ] }, { "long_name":"Aberdeen", "short_name":"Aberdeen", "types":[ "locality", "political" ] }, { "long_name":"Aberdeen", "short_name":"Aberdeen", "types":[ "postal_town" ] }, { "long_name":"Aberdeen City", "short_name":"Aberdeen City", "types":[ "administrative_area_level_2", "political" ] }, { "long_name":"United Kingdom", "short_name":"GB", "types":[ "country", "political" ] }, { "long_name":"AB21 9JU", "short_name":"AB21 9JU", "types":[ "postal_code" ] } ], "formatted_address":"57 Polo Gardens, Aberdeen, Aberdeen City AB21 9JU, UK", "geometry":{ "location":{ "lat":57.1912463, "lng":-2.1790257 }, "location_type":"ROOFTOP", "viewport":{ "northeast":{ "lat":57.19259528029149, "lng":-2.177676719708498 }, "southwest":{ "lat":57.18989731970849, "lng":-2.180374680291502 } } }, "partial_match":true, "place_id":"ChIJLTex1jQShEgR5UJ2DNc6N9s", "types":[ "street_address" ] } ], "status":"OK" } ``` I have tried the following: ``` json_decode($response->results->geometry->location->lat) ``` But it returns 'trying to access the property of a non-object'. Any help would be hugely appreciated.
2015/07/05
[ "https://Stackoverflow.com/questions/31234459", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
``` var_dump(json_decode($response)->results[0]->geometry->location->lat); ```
19,125
How can I implement a hook in my template file that will change the label of a field for the "group" content type from "author" to "created by"? ![screenshot of author field](https://i.stack.imgur.com/jDhMv.png)
2012/01/08
[ "https://drupal.stackexchange.com/questions/19125", "https://drupal.stackexchange.com", "https://drupal.stackexchange.com/users/3846/" ]
To rename the label of a field add the preprocess function [template\_preprocess\_node](http://api.drupal.org/api/drupal/modules--node--node.module/function/template_preprocess_node/7) to your *template.php* file: ``` function *YOUR THEME*_preprocess_node(&$vars){ //Supposing that your content type name is "group" if($vars['type'] == 'group'){ //Supposing that your field name is "field_txt_group" $vars['content']['field_txt_author']['#title'] = 'created by'; } } ```
52,679,318
I have a class Application with EmbeddedId and second column in embbbedID is forgein key and having many to one relationship with offer. ``` @Entity public class Application implements Serializable{ private Integer id; @EmbeddedId private MyKey mykey; private String resume; @Enumerated(EnumType.STRING) @NotNull private ApplicationStatus applicationStatus; @Embeddable public class MyKey implements Serializable{ private static final long serialVersionUID = 1L; @NotNull private String emailId; @ManyToOne(fetch = FetchType.LAZY) @NotNull private Offer offer; ``` in Offer class mapping is done on jobTitle. ``` @Repository interface ApplicationRepository extends JpaRepository <Application,MyKey> ``` { ``` List<Application> findAllByMyKey_Offer(String jobTitle); } ``` Trying this but getting no success... I want to fetch All application regarding a specific jobTitle. What shud be my method name in ApplicationRepository class.
2018/10/06
[ "https://Stackoverflow.com/questions/52679318", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9498745/" ]
Your methode name is wrong, the right one is `findAllByMykey_Offer` or `findAllByMykeyOffer`, as your field is named mykey. As mentionned in the documentation <https://docs.spring.io/spring-data/jpa/docs/2.1.0.RELEASE/reference/html/> using `List<Application> findAllByMykey_Offer(String jobTitle);` is better than `List<Application> findAllByMykeyOffer(String jobTitle);`
13,009,911
I want to create a list with my database field values. There are 2 columns, name and surname. I want to create a list that stores all names in name column in a field and then add to my DTO. Is this possible?
2012/10/22
[ "https://Stackoverflow.com/questions/13009911", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1759247/" ]
**Steps you can follow**: - * First you need to have a `List<String>` that will store all your names. Declare it like this: - ``` List<String> nameList = new ArrayList<String>(); ``` * Now, you have all the records fetched and stored in `ResultSet`. So I assume that you can iterate over `ResultSet` and get each `values` from it. You need to use `ResultSet#getString` to fetch the `name`. * Now, each time you fetch one record, get the `name` field and add it to your list. ``` while(resultSet.next()) { nameList.add(resultSet.getString("name")); } ``` * Now, since you haven't given enough information about your `DTO`, so that part you need to find out, how to add this `ArrayList` to your `DTO`. * The above `list` only contains `name` and not `surname` as you wanted only `name`. But if you want both, you need to create a custom DTO `(FullName)`, that contains `name` and `surname` as fields. And instantiate it from every `ResultSet` and add it to the `List<FullName>`
31,674
Keccak/SHA-3 is new NIST standard for cryptographic hash functions. However, it is much slower than BLAKE2 in software implementations. Does Keccak have compensating advantages?
2016/01/04
[ "https://crypto.stackexchange.com/questions/31674", "https://crypto.stackexchange.com", "https://crypto.stackexchange.com/users/29901/" ]
(Disclosure: I'm one of the authors of BLAKE2, but not BLAKE.) Here are the [slides from a presentation](https://blake2.net/acns/slides.html) I gave at Applied Cryptography and Network Security 2013 about this. (Note: the performance numbers in those slides are obsolete — BLAKE2 is even faster now than it was then.) The slides include quotes from NIST's 3rd-round Report on the SHA-3 Competition which show some of the advantages and disadvantages of BLAKE (not BLAKE2) compared to Keccak, in NIST's opinion. Here's a [blog post](https://leastauthority.com/blog/BLAKE2-harder-better-faster-stronger-than-MD5/) I wrote to accompany the slides. The main reason that NIST gave was that BLAKE was more similar to SHA-2 than Keccak was. When the SHA-3 contest was designed, the whole point of it was to provide a new hash function that would be ready in case SHA-2 got broken, so it made sense to require the winner to be different from SHA-2. However now, with almost a decade more of research and SHA-2 looking no weaker, a hash function being similar to SHA-2 doesn't seem bad, and might even be good. There was another reason that NIST gave that I omitted from the slides, which was that Keccak is more efficient in ASIC implementation. That reason may be more important if you are a large organization, like the U.S. military or U.S. government, who is going have special hardware built for your project, but more flexible/general-purpose performance is more important to me. (See Adam Langley's [blog post](https://www.imperialviolet.org/2012/10/21/nist.html) on this topic.) Besides, *everything* is fast in hardware! See [this catalog of hardware implementations of secure hash functions](http://ehash.iaik.tugraz.at/wiki/SHA-3_Hardware_Implementations#High-Speed_Implementations_.28ASIC.29). ASIC implementations of BLAKE can process about 12.5 GB/s, compared to Keccak, which can process about 44 GB/s. An ASIC implementation of BLAKE2 would be probably about 40% faster than a similar implementation of BLAKE, i.e. around 17.5 GB/s. But even 12.5 GB/s seems more than sufficient for most uses of a secure hash function.
39,788,564
I want for the click on the item menu, this item will change the icon. Selector for the item: button\_add\_to\_wishlist.xml ``` <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:state_checked="false" android:drawable="@drawable/ic_add_fav" /> <item android:state_checked="true" android:drawable="@drawable/ic_add_fav_fill" /> ``` Menu ``` <item android:id="@+id/add_to_wishlist" android:title="@string/book_btn_text_add_to_wishlist" android:icon="@drawable/button_add_to_wishlist" android:checkable="true" app:showAsAction="always"/> ```
2016/09/30
[ "https://Stackoverflow.com/questions/39788564", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6640003/" ]
There is no command to tell Amazon S3 to archive a specific object to Amazon Glacier. Instead, [Lifecycle Rules](https://docs.aws.amazon.com/AmazonS3/latest/dev/object-lifecycle-mgmt.html) are used to identify objects. The [Lifecycle Configuration Elements](https://docs.aws.amazon.com/AmazonS3/latest/dev/intro-lifecycle-rules.html) documentation shows each rule consisting of: * **Rule metadata** that include a rule ID, and status indicating whether the rule is enabled or disabled. If a rule is disabled, Amazon S3 will not perform any actions specified in the rule. * **Prefix** identifying objects by the key prefix to which the rule applies. * One or more **transition/expiration actions with a date or a time period** in the object's lifetime when you want Amazon S3 to perform the specified action. The only way to identify *which* objects are transitioned is via the **prefix** parameter. Therefore, you would need to specify a separate rule for each object. (The prefix can include the full object name.) However, there is a **limit of 1000 rules** per lifecycle configuration. Yes, you could move objects one-at-a-time to Amazon Glacier, but this would actually involve uploading archives to Glacier rather than 'moving' them from S3. Also, be careful -- there are **higher 'per request' charges for Glacier than S3** that might actually cost you more than the savings you'll gain in storage costs. In the meantime, consider using [Amazon S3 Standard - Infrequent Access storage class](https://aws.amazon.com/s3/storage-classes/), which can **save around 50% of S3 storage costs** for infrequently-accessed data.
618,373
I'm unable to get the following table to have even row heights with vertical alignment ``` \renewcommand\tabularxcolumn[1]{m{#1}} ... \begin{table} \renewcommand*{\arraystretch}{1} \begin{tabularx}{\textwidth}{X X} \toprule \textbf{Route} & \textbf{Funzione} \\ \midrule \lstinline$/device/:id$ & Carica menu di navigazione e toolbar principale \\ \midrule \lstinline$/device/:id/dids$ & Mostra la lista dei DID document posseduti dal device \verb+id+ \\ \midrule \lstinline$/device/:id/keys$ & Mostra la lista delle chiavi pubbliche contenute nei DID document posseduti dal dispositivo \verb+id+ \\ \midrule \lstinline$/device/:id/credentials$ & Mostra la lista delle credenziali rilasciate al dispositivo \verb+id+ \\ \midrule \lstinline$/device/:id/credentials/:id/use$ & Consente di accedere al servizio di un Verifier utilizzando la credenziale \verb+id+ \\ \midrule \lstinline$/device/:id/credentials/:id/revoke$ & Consente di inviare una richiesta di revoca della credenziale \verb+id+ \\ \midrule \lstinline$/device/:id/issuers$ & Mostra la lista degli Issuer di cui il dispositivo \verb+id+ si fida \\ \midrule \lstinline$/device/:id/verifiers$ & Mostra la lista di Verifier conosciuti dal dispositivo \verb+id+ \\ \midrule \lstinline$/device/:id/status-lists$ & Mostra la lista delle status list \\ \midrule \lstinline$/device/:id/settings$ & Espone metodi d'utilità \\ \end{tabularx} \caption{Lista delle route con relative funzionalità.} \end{table} ``` By increasing the number in `\arraystretch` the result will always be to have uneven row heights. Is there a way to have all the row heights to be set with the height of the higher one? [![enter image description here](https://i.stack.imgur.com/oDIWr.png)](https://i.stack.imgur.com/oDIWr.png)
2021/10/09
[ "https://tex.stackexchange.com/questions/618373", "https://tex.stackexchange.com", "https://tex.stackexchange.com/users/166526/" ]
By use of the `tabularray` package this is relative simple to accomplish: ``` \documentclass{article} \usepackage[skip=1ex]{caption} \usepackage{tabularray} \begin{document} \begin{table} \begin{tblr}{hline{1,Z}=1pt, hline{2}=0.8pt, hline{3-Y}=solid, colspec = {@{} Q[m, font=\ttfamily] X[m,j] @{}}, row{1} = {font=\bfseries}, row{2-Z} = {ht=3\baselineskip} } Route & Funzione \\ /device/:id & Carica menu di navigazione e toolbar principale \\ /device/:id/dids & Mostra la lista dei DID document posseduti dal device \texttt{id} \\ /device/:id/keys & Mostra la lista delle chiavi pubbliche contenute nei DID document posseduti dal dispositivo \texttt{id} \\ /device/:id/credentials & Mostra la lista delle credenziali rilasciate al dispositivo \texttt{id} \\ /device/:id/credentials/:id/use & Consente di accedere al servizio di un Verifier utilizzando la credenziale \texttt{id} \\ /device/:id/credentials/:id/revoke & Consente di inviare una richiesta di revoca della credenziale \texttt{id} \\ /device/:id/issuers & Mostra la lista degli Issuer di cui il dispositivo \texttt{id} si fida \\ /device/:id/verifiers & Mostra la lista di Verifier conosciuti dal dispositivo \texttt{id} \\ /device/:id/status-lists & Mostra la lista delle status list \\ /device/:id/settings & Espone metodi d'utilità \\ \end{tblr} \caption{Lista delle route con relative funzionalità.} \end{table} \end{document} ``` [![enter image description here](https://i.stack.imgur.com/n221i.png)](https://i.stack.imgur.com/n221i.png)
10,925,268
In java exceptions have at least these four constructors: ``` Exception() Exception(String message) Exception(String message, Throwable cause) Exception(Throwable cause) ``` If you want to define your own extensions, you just have to declare a descendent exceptions and implement each desired constructor calling the corresponden super constructor How can you achieve the same thing in scala? so far now I saw [this article](https://lizdouglass.wordpress.com/2010/12/15/scala-multiple-constructors/) and this [SO answer](https://stackoverflow.com/a/3300046/47633), but I suspect there must be an easier way to achieve such a common thing
2012/06/07
[ "https://Stackoverflow.com/questions/10925268", "https://Stackoverflow.com", "https://Stackoverflow.com/users/47633/" ]
Default value for `cause` is null. And for `message` it is either `cause.toString()` or null: ``` val e1 = new RuntimeException() e.getCause // res1: java.lang.Throwable = null e.getMessage //res2: java.lang.String = null val cause = new RuntimeException("cause msg") val e2 = new RuntimeException(cause) e.getMessage() //res3: String = java.lang.RuntimeException: cause msg ``` So you can just use default values: ``` class MyException(message: String = null, cause: Throwable = null) extends RuntimeException(MyException.defaultMessage(message, cause), cause) object MyException { def defaultMessage(message: String, cause: Throwable) = if (message != null) message else if (cause != null) cause.toString() else null } // usage: new MyException(cause = myCause) // res0: MyException = MyException: java.lang.RuntimeException: myCause msg ```
1,451,306
Attempting to do something very simple - compile basic win 32 c programs through windows cmd. This is something I should be able to do myself, but I am just so stuck here.. I keep stumbling into weird problems, vague errors. I dunno whether I should go into details. Using tcc ( tiny c compiler) 1. One simple hellowin.c example from a book required winmm.lib. How do I import it ? can someone give me the exact command for gcc/tcc /any command line compiler for windows(except cygwin) ? I did try various options after reading help , but it kept giving me a can't find stupid error. 2. a sample from platform sdk that I tried to compile gave a - winnt.h "( expected" error. this after a #define \_M\_IX86 . what it means ? 3. any general guide for compiling c programs for windows(win32 api) through command line ? . explaining what all should be #defined ..etc.. I have googled a lot but most of the c compiling guidelines for win32 programs focus on vb .I wanna do it manually , on the command line. Thanks
2009/09/20
[ "https://Stackoverflow.com/questions/1451306", "https://Stackoverflow.com", "https://Stackoverflow.com/users/161179/" ]
If I create a new project using Visual Studio it #defines the following preprocessor symbols using compiler command-line options: * `WIN32` * `_WINDOWS` * one of either `_DEBUG` or `NDEBUG` * `UNICODE` and `_UNICODE` (although the Windows headers and libraries also support non-Unicode-enabled applications, if your compiler doesn't support Unicode). <http://bellard.org/tcc/tcc-doc.html> says "For usage on Windows, see also tcc-win32.txt".
6,875,109
First of all: I want to use Java EE not Spring! I have some self defined annotations which are acting as interceptor bindings. I use the annotations on my methods like this: ```java @Logged @Secured @RequestParsed @ResultHandled public void doSomething() { // ... } ``` For some methods I want to use a single of these annotations but most methods I want to use like this: ```java @FunctionMethod public void doSomething() { // ... } ``` Can I bundle these set of annotations to a single one? I cannot write the code in a single interceptor because for some methods I want to use them seperately too. I know that there is a @Stereotype definition possible, but as far as I know, this is used to define a whole class not a single method.
2011/07/29
[ "https://Stackoverflow.com/questions/6875109", "https://Stackoverflow.com", "https://Stackoverflow.com/users/868859/" ]
The `position: absolute;` and the `right:-100px;` is pushing your element past the right edge of the viewport. Floating does not affect absolutely positioned elements. If you want the element to be `100px` away from the edge, make that a positive `100px`. Or, if you want it right up against the edge, make it `0`. If you truly want to float it, remove the absolute positioning. Hopefully I understood the question, and I hope this helps! Edit: I re-read the question and think an even better solution would be to add `position: relative;` to the wrapper. Right now, your absolutely position element is positioned relative to the viewport. If you give `wrapper` relative positioning, it will cause `imageright` to be positioned relative to `wrapper`.
20,883,696
I'm using Sitecore Webforms For Marketers in a multi-language environment (e.g. .com, .be, .nl en .de). There are 3 servers: 2 Content Delivery Servers (CDS) en 1 Content Management Server (CMS). On the CDS servers is no possibility to write data, so i have configured a webservice to forward the form data from the CDS to the CMS server. My problem is that the Web service communicates with the .com domain. By using the .com domein for webservice communication, the CMS doesn't have any know how what the site context is from the submitting domain. For example, a user submits a form on the .nl domain, the CMS server thinks it's coming form the .com domain. Does anyone know how i can get the site context (e.g. NL-nl) from the submit? Thanks a lot! Jordy
2014/01/02
[ "https://Stackoverflow.com/questions/20883696", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3129164/" ]
Similar question was asked [here](https://stackoverflow.com/questions/20800966/how-to-get-the-sitecore-current-site-object-inside-custom-save-action-wffm) and answered by [@TwentyGotoTen](https://stackoverflow.com/users/2124993/twentygototen). The place where you need to get the current site is different than in linked question, but the answer is the same. Use the code which is used by Sitecore to resolve site: ``` var url = System.Web.HttpContext.Current.Request.Url; var siteContext = Sitecore.Sites.SiteContextFactory.GetSiteContext(url.Host, url.PathAndQuery); ``` The extended version of the code for resolving sites (linked in the same question by [@MarkUrsino](https://stackoverflow.com/users/134360/mark-ursino)) can be found in article [Sitecore Context Site Resolution](http://firebreaksice.com/sitecore-context-site-resolution/). Can you use the proper domain for each web service call? If you have to call web service using `.com` domain only, maybe you can try to check `UrlReferrer` instead of current request `Url` host?
22,069,390
My Flash plugin just won't work for Firefox on Linux Mint. I am running Linux Mint 14 Nadia 64bit. * Downloaded firefox-27.0.1.tar.bz2 * Extracted it * Ran ./firefox it works fine * Downloaded install\_flash\_player\_11\_linux.x86\_64.tar.gz * Extracted it * Copied the plugin: **cp libflashplayer.so /home/gary/.mozilla/plugins/** * Copied the Flash Player Local Settings configurations: **sudo cp -r usr/\* /usr** * Generated dependency lists for Flash Player: **ldd /home/gary/.mozilla/plugins/libflashplayer.so** Plugin still doesn't work. Any help would be appreciated.
2014/02/27
[ "https://Stackoverflow.com/questions/22069390", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2818846/" ]
Rather than delay initialising the whole page it would be better to allow it all to be initialised, then initialise just the new code. In jQm v1.3.2 and earlier you could do this by adding the following code to your success callback. ``` $('#newsDescription table').trigger('create'); ``` This will allow the whole page to initialise and prevent a flash of an unstyled page to the user if they have a slow network connection which could cause your ajax request to take a while.
51,786
I got excited about Calc's power as an embedded mode. Define some variables in natural inline notation and then do operations on them. But the execution seems a bit messy: you got a separate key bindings when you're in CalcEmbed mode and mistakes are easy to make. Can the mode be tamed so that the following org-mode buffer: ``` * Calc test embed! Let $foo := 342$ and $bar := 2.2$. Now $foo*bar => $! ``` Could be evaluated to ``` * Calc test embed! Let $foo := 342$ and $bar := 2.2$. Now $foo*bar => 752.4$! ``` With a single key stroke, all the while remaining in org-mode?
2019/07/23
[ "https://emacs.stackexchange.com/questions/51786", "https://emacs.stackexchange.com", "https://emacs.stackexchange.com/users/318/" ]
Maybe not a single keystroke but you could *activate* embedded mode via `C-x * a` and then (while point is in, say, the first expression) *update* all calc expressions with `C-x * u`. I use embedded mode all the time and it's one of the most understated features of Emacs!
28,640,427
I have table in mysqli database now i want to get 1 result random This is code mysql ``` $cid = $_GET['id']; $ans = $db->query("select * from result where cat_id='$cid' limit 1"); $rowans = $ans->fetch_object(); echo" <h4>".$rowans->title."</h4><br> <img src='".$rowans->img."' style='width:400px;height:300;' /> <p>".$rowans->desc."</p>"; ``` in this code i get 1 result but not random always gives me the same result
2015/02/21
[ "https://Stackoverflow.com/questions/28640427", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
SQL: ``` SELECT * FROM result ORDER BY rand() LIMIT 1 ```
7,674,955
I am developing an asp.net application where i have a dataset having 3 tables i.e. `ds.Tables[0], Tables[1] and Tables[2]` I need to find minimum number and maximum number out of all the 3 tables of dataset. How to do that? I found similar question in SO [here](https://stackoverflow.com/questions/2442525/how-to-select-min-and-max-values-of-a-column-in-a-datatable) but not sure how that would help me getting my way? **UPDATED:** ``` double minValue = double.MinValue; double maxValue = double.MaxValue; foreach (DataRow dr in dtSMPS.Rows) { double actualValue = dr.Field<double>("TOTAL_SUM"); // This fails specifying type cast error minValue = Math.Min(minValue, actualValue); maxValue = Math.Max(maxValue, actualValue); } ``` Please guide! Thanks.
2011/10/06
[ "https://Stackoverflow.com/questions/7674955", "https://Stackoverflow.com", "https://Stackoverflow.com/users/224636/" ]
Do it on `IOrganisation`(and have `IPeople` as the return type). Something like this: ``` interface IOrganisation { IList<IPeople> GetPeople(); } ``` This is because the people of an organisation is a property of the organisation, not of the people.
34,399,423
I've got some problems with my Connection string. Seached the web for some mistakes but didn't got any further. Is there something changed between SQL Server versions? ``` <?xml version="1.0" encoding="utf-8" ?> <configuration> <configSections> </configSections> <connectionStrings> <add name="BeursTD.Properties.Settings.sdtcaptConnectionString" connectionString="Data Source=localhost\SQLEXPRESS,1433;Initial Catalog=sdtcapt;User ID=XXXX;Password=XXXX" providerName="System.Data.SqlClient" /> </connectionStrings> </configuration> ```
2015/12/21
[ "https://Stackoverflow.com/questions/34399423", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4159130/" ]
There are at least two reasons why this issue (`Client Error: Remaining data too small for BSON object`) appears: **1. PHP MongoDB driver is not compatible with MongoDB installed on the machine.** (originally mentioned in the [first answer](https://stackoverflow.com/a/34646148/309031)). Examine PHP driver version set up on your machine on `<?php phpinfo();` page: [![enter image description here](https://i.stack.imgur.com/oaB0u.jpg)](https://i.stack.imgur.com/oaB0u.jpg) Retrieve MongoDB version in use with: ``` mongod --version\ # db version v3.2.0 ``` Use [compatibility table on MongoDB website](https://docs.mongodb.org/ecosystem/drivers/php/#compatibility) to see whether examined PHP MongoDB driver version is compatible with MongoDB version: [![enter image description here](https://i.stack.imgur.com/8uMyC.jpg)](https://i.stack.imgur.com/8uMyC.jpg) If versions are not compatible, it is required to uninstall one of the existing parts and install compatible version. From my own experience, it is much easier to change PHP MongoDB driver, since only different `.so` extension file is required. **2. Two PHP MongoDB drivers are installed on the machine.** Since [`MongoClient`](http://php.net/manual/en/class.mongoclient.php) is deprecated, many tutorials and articles online (including [official mongo-php-driver repository on Github](https://github.com/mongodb/mongo-php-driver#installation)) now guides to install `mongodb`, not `mongo` PHP driver. Year+ before, everyone was pointing at `mongo` extension, however. Because of this change from `mongo` to `mongodb`, we might get both extensions defined in `php.ini` file. *Just make sure, only one extension is defined under "Dynamic Extension" section*: [![enter image description here](https://i.stack.imgur.com/4lPG6.jpg)](https://i.stack.imgur.com/4lPG6.jpg) --- Hope somebody gets this answer useful when looking for a solution to fix "Remaining data too small for BSON object" error working with MongoDB through PHP MongoDB driver.
64,569,792
These are my haves: ``` vec <- seq(1, 3, by = 1) df <- data.frame(x1 = c("a1", "a2")) ``` and this is my wants: ``` x1 x2 1 a1 1 2 a2 1 3 a1 2 4 a2 2 5 a1 3 6 a2 3 ``` I basically want to replicate the data frame according to the values in the vector vec. This is my working (possibly inefficient approach): ``` vec <- seq(1, 3, by = 1) df <- data.frame(x1 = c("a1", "a2")) results <- NULL for (v in vec) { results <- rbind(results, cbind(df, x2=v)) } results ``` Maybe there is a better way? Sorry this is more like a code review. Thanks! PS: Thanks for all your great answers. Sorry should have thought about some myself but it is early here. I will have to accept one. Sorry no hard feelings!
2020/10/28
[ "https://Stackoverflow.com/questions/64569792", "https://Stackoverflow.com", "https://Stackoverflow.com/users/283538/" ]
You can use `crossing` : ``` tidyr::crossing(df, vec) %>% dplyr::arrange(vec) # x1 vec # <chr> <dbl> #1 a1 1 #2 a2 1 #3 a1 2 #4 a2 2 #5 a1 3 #6 a2 3 ``` Also, ``` tidyr::expand_grid(df, vec) %>% dplyr::arrange(vec) ```
60,351,355
I am trying to make my nav bar sit parallel with my logo but I'm having difficulty doing this. First of all, when I enter the code for the image, the image afterwards doesn't display at the top of the page. Instead, it sits about 40px below the page. I have tried using floats, but have had no luck. I have created a negative value of -20px for the logo to sit further at the top of the page but would like to know if that is normal practice in CSS I have tried looking at youtube videos but the code they share doesn't seem to work on my project. I'm just wondering whether the image may be a bit too big for the header ![](https://i.stack.imgur.com/ep89u.png)
2020/02/22
[ "https://Stackoverflow.com/questions/60351355", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12943430/" ]
"To maintain the integrity of the data dictionary, tables in the SYS schema are manipulated only by the database. They should never be modified by any user or database administrator. You must not create any tables in the SYS schema." <https://docs.oracle.com/database/121/ADMQS/GUID-CF1CD853-AF15-41EC-BC80-61918C73FDB5.htm#ADMQS12003>
187,493
Input ----- A single hex 6-digit colour code, capital letter, without `#`. Can also be a 24-bit integer if you prefer. Output ------ The closest HTML color *name* (e.g `red`, or `dark-salmon`, as defined as <https://www.w3schools.com/colors/colors_names.asp> or see below). Distance is defined by summing the difference in red, green and blue channels. Examples -------- > > `FF04FE`: `magenta` > > > `FFFFFF`: `white` > > > `457CCB` (halfway between `steelblue` and `darkslateblue`): `steelblue` (round **up**) > > > Rules ----- * Standard loopholes apply. * Standard I/O applies * Round up to the color with the higher channel sum if halfway between two colors. If two colours have the same channel sum, output the one which is higher as a hex code: e.g `red` = `#FF0000` = 16711680 > `blue` = `#0000FF` = 256 * If one hex code has two names (e.g. `grey` and `gray`), output either. * Outputs can be capitalised and hyphenated how you like * Trailing/preceding spaces/newlines are fine * You must output the names in full. * This is [code-golf](/questions/tagged/code-golf "show questions tagged 'code-golf'"), so shortest answer in bytes wins. Colors ------ As per suggestion in the comments, here are all of the color names with respective hex values in CSV format: ``` Color Name,HEX Black,#000000 Navy,#000080 DarkBlue,#00008B MediumBlue,#0000CD Blue,#0000FF DarkGreen,#006400 Green,#008000 Teal,#008080 DarkCyan,#008B8B DeepSkyBlue,#00BFFF DarkTurquoise,#00CED1 MediumSpringGreen,#00FA9A Lime,#00FF00 SpringGreen,#00FF7F Aqua,#00FFFF Cyan,#00FFFF MidnightBlue,#191970 DodgerBlue,#1E90FF LightSeaGreen,#20B2AA ForestGreen,#228B22 SeaGreen,#2E8B57 DarkSlateGray,#2F4F4F DarkSlateGrey,#2F4F4F LimeGreen,#32CD32 MediumSeaGreen,#3CB371 Turquoise,#40E0D0 RoyalBlue,#4169E1 SteelBlue,#4682B4 DarkSlateBlue,#483D8B MediumTurquoise,#48D1CC Indigo,#4B0082 DarkOliveGreen,#556B2F CadetBlue,#5F9EA0 CornflowerBlue,#6495ED RebeccaPurple,#663399 MediumAquaMarine,#66CDAA DimGray,#696969 DimGrey,#696969 SlateBlue,#6A5ACD OliveDrab,#6B8E23 SlateGray,#708090 SlateGrey,#708090 LightSlateGray,#778899 LightSlateGrey,#778899 MediumSlateBlue,#7B68EE LawnGreen,#7CFC00 Chartreuse,#7FFF00 Aquamarine,#7FFFD4 Maroon,#800000 Purple,#800080 Olive,#808000 Gray,#808080 Grey,#808080 SkyBlue,#87CEEB LightSkyBlue,#87CEFA BlueViolet,#8A2BE2 DarkRed,#8B0000 DarkMagenta,#8B008B SaddleBrown,#8B4513 DarkSeaGreen,#8FBC8F LightGreen,#90EE90 MediumPurple,#9370DB DarkViolet,#9400D3 PaleGreen,#98FB98 DarkOrchid,#9932CC YellowGreen,#9ACD32 Sienna,#A0522D Brown,#A52A2A DarkGray,#A9A9A9 DarkGrey,#A9A9A9 LightBlue,#ADD8E6 GreenYellow,#ADFF2F PaleTurquoise,#AFEEEE LightSteelBlue,#B0C4DE PowderBlue,#B0E0E6 FireBrick,#B22222 DarkGoldenRod,#B8860B MediumOrchid,#BA55D3 RosyBrown,#BC8F8F DarkKhaki,#BDB76B Silver,#C0C0C0 MediumVioletRed,#C71585 IndianRed,#CD5C5C Peru,#CD853F Chocolate,#D2691E Tan,#D2B48C LightGray,#D3D3D3 LightGrey,#D3D3D3 Thistle,#D8BFD8 Orchid,#DA70D6 GoldenRod,#DAA520 PaleVioletRed,#DB7093 Crimson,#DC143C Gainsboro,#DCDCDC Plum,#DDA0DD BurlyWood,#DEB887 LightCyan,#E0FFFF Lavender,#E6E6FA DarkSalmon,#E9967A Violet,#EE82EE PaleGoldenRod,#EEE8AA LightCoral,#F08080 Khaki,#F0E68C AliceBlue,#F0F8FF HoneyDew,#F0FFF0 Azure,#F0FFFF SandyBrown,#F4A460 Wheat,#F5DEB3 Beige,#F5F5DC WhiteSmoke,#F5F5F5 MintCream,#F5FFFA GhostWhite,#F8F8FF Salmon,#FA8072 AntiqueWhite,#FAEBD7 Linen,#FAF0E6 LightGoldenRodYellow,#FAFAD2 OldLace,#FDF5E6 Red,#FF0000 Fuchsia,#FF00FF Magenta,#FF00FF DeepPink,#FF1493 OrangeRed,#FF4500 Tomato,#FF6347 HotPink,#FF69B4 Coral,#FF7F50 DarkOrange,#FF8C00 LightSalmon,#FFA07A Orange,#FFA500 LightPink,#FFB6C1 Pink,#FFC0CB Gold,#FFD700 PeachPuff,#FFDAB9 NavajoWhite,#FFDEAD Moccasin,#FFE4B5 Bisque,#FFE4C4 MistyRose,#FFE4E1 BlanchedAlmond,#FFEBCD PapayaWhip,#FFEFD5 LavenderBlush,#FFF0F5 SeaShell,#FFF5EE Cornsilk,#FFF8DC LemonChiffon,#FFFACD FloralWhite,#FFFAF0 Snow,#FFFAFA Yellow,#FFFF00 LightYellow,#FFFFE0 Ivory,#FFFFF0 White,#FFFFFF ```
2019/06/30
[ "https://codegolf.stackexchange.com/questions/187493", "https://codegolf.stackexchange.com", "https://codegolf.stackexchange.com/users/85546/" ]
[Node.js](https://nodejs.org), 1488 bytes ========================================= Takes input as a 24-bit integer. Outputs in lower case. ```javascript v=>(require('zlib').inflateRawSync(Buffer('TVRbm6o4EPxLE27CowziDOiIV+bwFkkrWUPCBBg/9tdvLurZFzGX7uqqrs6Z4fr2xvHv5OYEy9uZjRC3QOjY6r/oaH4X+ugqAXiWI/P1M28AzGxQPWHuBBkB6PrbpCPmyZs+GEb5Mwrag/O9sEn7TlJ+NSnCr4TRFk7z/+25mc7l5i0lnF6bQef6Pn6tiCBXkHo12yxTpo96wCbEqfbxRUjoB7tcxfvn0fJ4POgyeoYHuEo8IafINaY59co8exT1uJ+Uq/hVsn8KUykmzDTqzin6AcD8n/nb3Sur3nDSD9cmegUf5hHlhF6F6ySOviwY/bWwi/UO1ZiA4baIj1EtJL8wcbf8gspLJJyhrnE3yo6BExUbmx3/jLjFSis4pitCW83I/SrTVyEo3uQGiEh8Rpvi80U8+OMXVrXnTnTKowf7Z7i/fFsxfOdWx9l6XjdYDhLGHrxwvvkL75fqKwRHoS3RtahFsDEl5U8TRMudBbXrVP/8UsFgcOMP4xwJBPmlsVeLr8AH7J56TAiDsxR3nmTvRulHf4LotDQJzQptlsgyeFTxeUr1bYuwT/cdZlbyoDog0wRZN5TMy3wCpgS3PCNn0VPgHM927smgBvvvwhpeCRc/7GYEOq0KE2TjZ3mkIf6avPiOLd+nVVAQvXfiTmxr/ez9QlVvJa1vaLc01K6CEeBSkLDyfcvGVulk6zcp+slU5HrZUt++NfhG0Tote8p+QXpRVtgYy1mpGZb+h3Ye5npxWKQdyDF0dnUjaqEbHZzmswHzRbl4KKmmIt+ehob2A4OgLP0HfpI5r+Lm8VEzfaEgL9jVkra94GV8uGLK+7OQArnrTcfGVo3Z4TxKNt2FICgLtwbKTPYs8hj+Ba4kCedLO0eYtYK7u31p8wdlFZrWPdFz13ZdDQpmTpgHRobc32BGa+Nc92vWCA4TgTtKEvzvKCHtMSdWPd8LonsDeEBbd3YGegUvL+4NHaBvxQ2KlvKhloBbVEXXRvSDOfOCuLClOX78hflAf0YwJ6uZmiUOvKqshM86rSvQHzUNRD2rKsP2XYu1zOcPc89c/UZ2lN/cU6jYcPWoAYnyZBAtHoRfxY0Y9DGKCsPWizbWuPqq8xlae5mqPLS222Vgdk3Wz8hEVwtdlJd8d4Drphsvl+2HeuPxP8IQ2HutUO9LTzkKyjPtFbG0Vf2flOHgcGaY1w0Qg0JQoprR4QmryG6/eTZPqd434ZuazL5RtKtEv2LKlbf8yEDFKQtdLoInB/WyKR4Gtuq5uM+tSvu1KdougpD+Cjktza30Pw','base64'))+'').replace(m=/([a-z]+)([^a-z]+)/g,(_,s,d)=>[e=0,8,16].map(x=>e+=Math.abs((v>>x&255)-(t>>x&255)),t+=parseInt(d,36))|e>m||(o=s,m=e),t=0)&&o ``` [Try it online!](https://tio.run/##XZRbs5rKEsff8yl8irhZWVxFrB1XldxEQUEEFFL77OIyIMrN4c7O/uw5JqtOnST9Mj3/6V9XV0/P3LzWqwKYlPWnvAjBt2j1rV29IRA8mgQCZDqmiT@dvSZ5lHo1MLzuNOQBwjVRBCAyNW3Dz5iCFvVeFckFX3RjImjJ1kb9Trrf4dnSeY6LsWUdtmoDXWncXBbN4wErxqUjSPat3M41RxyWjXszeOqo3RwGYoUn0xe0iR/rS3LeYjqxJ9n1uOmP@lluOO7OMTr0S17PBrdCN6I/33fQizFtWYn5wkx36OGU85A2Dem@GDGUnGfBIp0neJpLjH8EEaPnTJ3w3OUuFwQ59GZZLJmO98VH5PeGdSu4RR30UZvj0Y7WtXgAhSM3YsFuvWh78Jz5MihY0JtEs0OtB3a1q5xVrOGejYL5GJOcWQcCm2O5T50aSOXCSVgGGYitaH6V06vESMxw0tqkczD/3CWYpRFusqZ9b3sjxHqnsl3gR2xclepuN1xhLlJDwXBib/lZT2E39Sadkoouk5o/s9QWO0HTHsSCao6bRLyyRtkmLG6xqLa/2PCSm7mpFF20cBcJFklVH2nhuV@mzOUWOsJV3ciw79r2ri7m0UPpDLk4UUbtXaVKENO5xZrGvgk5/wJtHWOtSooDba/Tfbfj9CytbKBCdi0vdnPGXCdC1RtUnpmt0aRyRKtFLRx347Gs0@rZQ8nsgQUJ32k6EwtCN/WHQihivDPcw9zcD1THl/GJ0vlDjtt6LO@X5KLKYq5t2@5aAt4IsMXGEbUHroikeXOp7L6NGK/VE00N0dy218f2EiVm1kMMjMtjarc7j2g9NcAJheFFwJ3uqjBEQbuxm/TOjEGJVqk1l6Fr1Sh6iK4b3CxqwJbo8VIadh07A5GVG9dHr5QD5nnZn5VjOAgSHubWzXuIvuyOWdXJo@GntKJk2bZGwbXwyTWtxaqOy1G5nUNUzVhbHCNPjNXlzb5Db0lvbLbZqAq60I5rmEMziDZ2Qbm02SuHmpS2fKzWna@YulOx1xvKefSdB6Gq4cCpHWXRUETJdmEqufCsh9JIUG4oHMvMLGPZKPyAIrmNhx6CJdme@TVtxmatiO3YKrxc70/hk2HVIq8EIHJ@SDmb52y2KkofZI9r@yOppK1yTQvOt8XLxWhPghZpfKPyqXZZsNcoXUe40@2Yxs0SS2uVR3Xdsww8tUd5tA6GQEKl0smL0xCjFugBuwwwyyXTAxZYzM0J9HOxdvLB5da1XBhR7@DOUtgofKWfk9E/N/rjwfapB@bZQ1dPJEnacXinziN7Fe2uDtNdyIa0AMtr1aYoKYNG73V2eyTlpra0pWqOd2W46bXkb3A7IqNUk@Ng4zlEhx9jfHcsSmjQxwwOGwYDpqs/Qpqi3cYb1blRK7XYkqqSPt/fIAqScqxDtdjmHHYeFIPe1M1j3uzR@tQ2hBIWTVwKKH@716NH4Xo3fZn6XgUYejqbodPnrwlBmXoBQLIVhnzxPo1/oTPky3/eHSx@Qf5@qV7C2ertC1jhL@wLwfz1mnkl0q/eALrae/X11fMrBGnf3vqP5Hw@@4TU/3NnLzW6Kj1YgW1eI@ELxcxmX8Fb9vUrUqyql2wFnhErfPbxY/EteF51kYLXtIiRqSThtCROVm@T6QSdRAjevyuz2QTDJpkXg7z2PvyGfLdfke/2jnTXpAa/AvR8wfPcz8C78g5UNQCpnza/Q7gkietfoB/KO1Q38NEUSfUbtMZ5gSJ/ht6Vd2gAaVp0MQQg/wWb/fnhQ1RAJJ@sJvifk3zyeUJ8X1F0Nvnnw2TSPvUf7YdeHhYZMpv8McF7Av9hk69P5hn0c0KEmHz@PCHp51k7e62LUw2TPEYI5vvGKksA@edgILPXKk2e80DMnsVO/191O3tW9O@3/wI "JavaScript (Node.js) – Try It Online") ### How? The compressed string is 1683 characters long and looks like that: ```javascript "black0navy3KdarkblueBmediumblue1Ublue1EdarkgreenJK1green5J4(…)lightyellow68ivoryGwhiteF" ``` The colors are ordered from lowest to highest value. Each color is encoded as its name in lower case followed by the difference between its value and the previous value in base-36 and in upper case: ``` black[0] | 0x000000 + 0 --> 0x000000 navy[3K] | 0x000000 + 128 --> 0x000080 darkblue[B] | 0x000080 + 11 --> 0x00008B mediumblue[1U] | 0x00008B + 66 --> 0x0000CD blue[1E] | 0x0000CD + 50 --> 0x0000FF darkgreen[JK1] | 0x0000FF + 25345 --> 0x006400 green[5J4] | 0x006400 + 7168 --> 0x008000 ... | ... lightyellow[68] | 0xFFFF00 + 224 --> 0xFFFFE0 ivory[G] | 0xFFFFE0 + 16 --> 0xFFFFF0 white[F] | 0xFFFFF0 + 15 --> 0xFFFFFF ``` ### Commented ```javascript v => // v = input ( require('zlib') // using zlib, .inflateRawSync( // inflate the Buffer( // buffer obtained by 'TVRbm(…)Pw', // converting this string 'base64' // encoded in base-64 ) // ) + '' // and coerce it back to a string ).replace( // on which we invoke replace(): m = // initialize m to a non-numeric value /([a-z]+)([^a-z]+)/g, // for each color encoded as ... (_, s, d) => // ... s = name, d = delta in base-36: [e = 0, 8, 16] // using x = 0 for blue, 8 for green and 16 for red, .map(x => // compute the error e: e += // add to e: Math.abs( // the absolute value of the difference between (v >> x & 255) - // the component of the target color (t >> x & 255) // and the component of the current color ), // t += parseInt(d, 36) // start by adding the delta to t ) | e > m || // end of map(); if e is less than or equal to m: (o = s, m = e), // update o to s and m to e t = 0 // start with t = 0 ) && o // end of replace(); return o ```
44,409
Bonjour, Normalement, on ne met pas d'article devant un nom de métier. > > Je suis professeur. Je suis boulanger. > > > Mais imaginons le dialogue suivant : > > A : Es-tu boulanger ? > > > B : Non, je suis (**un**) maçon. > > > Dans ce cas, faut-il mettre l'article indéfini devant *maçon*, ceci parce que la phrase de B sous-entend *Non, je ne suis pas (**un**) boulanger, je suis (**un**) maçon* ?
2021/01/28
[ "https://french.stackexchange.com/questions/44409", "https://french.stackexchange.com", "https://french.stackexchange.com/users/26093/" ]
Je ne vois pas de nécessité d'ajouter un article indéfini, ni dans un cas, ni dans l'autre : > > A : Es-tu boulanger ? > > B : Non, je suis maçon. > > A : Mais on m'a bien dit que tu étais un boulanger… > > B : Oui, c'est mon nom de famille, je suis bien un Boulanger. Et toi ? > > A : Oh, pardon ! C'est amusant, car moi qui suis boulanger, je suis un Masson. > > > Évidemment, à l'écrit, tout de suite, ça saute aux yeux. À l'oral, par contre, la différence vient de l'article ; mais ça reste une source de quiproquos pour les inattentifs :-). Une petite remarque : je n'ai jamais rencontré la graphie Maçon en nom de famille, et fr.Wikipédia n'en cite aucun. NB: la forme « **je suis un·e** /*nomDeFamille*/ » n'est typiquement utilisé que dans un contexte de zones géographiques où ces noms de famille sont courants, ce qui n'est pas rare dans les villages en régions rurales. Sinon, on utilisera plutôt le classique « **je m'appelle** ». En fait, on retrouve la même nuance qu'entre « *je suis française* » et « *je suis **une** française* », ou leur variante masculine : la première forme est un qualificatif, alors que la seconde réfère incidemment à un groupe spécifique, et éventuellement insiste sur l'appartenance à ce groupe. Du coup, on peut très bien imaginer une situation où l'article indéfini prend sens devant un nom de métier. Par exemple :   « *Je suis boulanger. Mais ne vous méprenez pas, je ne suis pas juste un pétrisseur et un cuiseur. Nous, les boulangers, avons bien plus en tête qu'une simple recette d'assemblage et de manipulation qu'on reproduirait chaque jour, chaque nuit. Selon le météo, selon la saison, et selon les envies du moment de la clientèle, nous savons composer. C'est pour ça que n'importe quelle échoppe qui vend /du pain/, ne peut pas marquer « boulangerie » sur sa vitrine ; boulanger est un titre, et un métier, reconnu : oui, je suis bien un boulanger.* »
14,489,876
I have a table `HRTC` in SQL Server. I want to import data which is in Excel into this table. But my Excel file does not have all the columns which match the `HRTC` table. Is there anyway I can do this? I am thinking something like in the import wizard ``` Insert into SQLServerTable Select * FROM OPENROWSET('Microsoft.Jet.OLEDB.4.0', 'Excel 8.0;Database=D:\testing.xls;HDR=YES', 'SELECT * FROM [SheetName$]') select column1, column2 from HRTC ```
2013/01/23
[ "https://Stackoverflow.com/questions/14489876", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1723572/" ]
Try this Create a temp table ``` Select * INTO TmpTable FROM OPENROWSET('Microsoft.Jet.OLEDB.4.0', 'Excel 8.0;Database=D:\testing.xls;HDR=YES', 'SELECT * FROM [SheetName$]') ``` Then to insert row into hrtc using temptable, any missing columns will have null ``` INSERT INTO hrtc(column1, column2) select col1, col2 from TmpTable ```
19,034,871
Hi I was wondering whether someone would be able to help me with a query. I am trying to select from an EAV type table where the value is not multiple values. Using the example below I am trying to retrieve rows where tag\_id != 1 and tag\_id != 2. So based on the data I want to return just the row containing contact\_id 3 ``` Tags Table: contact_id tag_id 1 1 1 2 2 1 2 4 3 4 ``` The desire result is to return a single row: ``` contact_id -> 3 ``` I have tried the following queries which don't return what I am looking for so are obviously are not correct: ``` select `contact_id` from `contact_tags` where tag_id !=1 and tag_id != 2 select `contact_id` from `contact_tags` where tag_id NOT IN(1,2) ``` Any help on this. Or just a pointer in the right direction would be great.
2013/09/26
[ "https://Stackoverflow.com/questions/19034871", "https://Stackoverflow.com", "https://Stackoverflow.com/users/460824/" ]
You can use `NOT EXISTS()` in which the statement inside selects all records where it has tags of `1` or `2`. ``` SELECT contact_id FROM contact_tags a WHERE NOT EXISTS ( SELECT 1 FROM contact_tags b WHERE tag_id IN (1, 2) AND a.contact_id = b.contact_id ) GROUP BY contact_id ``` * [SQLFiddle Demo](http://sqlfiddle.com/#!2/b2b11/5) Another alternative is to use `LEFT JOIN` ``` SELECT a.contact_id FROM contact_tags a LEFT JOIN contact_tags b ON a.contact_id = b.contact_id AND b.tag_id IN (1, 2) WHERE b.contact_id IS NULL ``` * [SQLFiddle Demo](http://sqlfiddle.com/#!2/b2b11/13)
9,941,898
I'm new in Ruby/Rails, so, my question: what is the perfect way to upload file and save filename in database with rails? Are there any Gem? Or maybe there are good build-in feature?
2012/03/30
[ "https://Stackoverflow.com/questions/9941898", "https://Stackoverflow.com", "https://Stackoverflow.com/users/630189/" ]
Also try [carrierwave](https://github.com/jnicklas/carrierwave), Ryan has a good screencast about this [gem](http://railscasts.com/episodes/253-carrierwave-file-uploads)
48,411,072
The following query matches userID's to eachother based off of total score difference. I have two tables, survey & users. I need to join this to the users table that I have that has usernames/photo links. The columns I need displayed are users.name & users.photo. All tables currently have a unique userID, which is users.id, and survey.id that helps match users across DB's. Could anyone give me a hand as how I could get this done? I've been having a lot of trouble figuring this out, thanks in advance. ``` select a.id yourId, b.id matchId, abs(a.q1 - b.q1) + abs(a.q2 - b.q2) + abs(a.q3 - b.q3)+ abs(a.q4 - b.q4)+ abs(a.q5 - b.q5)+ abs(a.q6 - b.q6)+ abs(a.q7 - b.q7)+ abs(a.q8 - b.q8)+ abs(a.q9 - b.q9)+ abs(a.q10 - b.q10) scorediff from surveys as a inner join surveys as b on a.id != b.id WHERE a.id=1 order by scorediff asc ``` Currently this is the results of that query: ``` | yourID| matchID| scoreDiff| ---------------------------- | 5 | 2 | 14 | | 5 | 3 | 25 | | 5 | 1 | 33 | | 5 | 6 | 34 | ``` I would like this as the result: ``` | yourID| matchID| scoreDiff| name | photo | ---------------------------------------------- | 5 | 2 | 14 | john | url | 5 | 3 | 25 | steve| url | 5 | 1 | 33 | jane | url | 5 | 6 | 34 | kelly| url ``` matchID can be matched to the users.ID column, as they are all unique to the user.
2018/01/23
[ "https://Stackoverflow.com/questions/48411072", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8534513/" ]
I would just add a filter to exclude undefined events on the initial subscription: ``` ngOnInit() { this.dataService.getEvents() .filter(events => events && events.length > 0) .subscribe( (events) => { this.events = events; console.log(events); // when I try to get this is no problem it prints log to console (probably because event is var so it is not defined) console.log(events[0].name); // it didn't see that property so I'm getting ERROR TypeError: Cannot read property 'name' of undefined }); } ```
44,215,132
I have a Oracle query ``` SELECT to_timestamp('29-03-17 03:58:34.312000000 PM','DD-MM-RR HH12:MI:SS.FF AM') FROM DUAL ``` I want to convert to SQL Server where I need to retain the Oracle date string i.e `'29-03-17 03:58:34.312000000 PM'`: ``` SELECT CONVERT(DATETIME, REPLACE(REPLACE('29-03-2017 03:58:34.312000000 PM','-', '/'),'000000 ', ''), 131) ``` I tried the above query, as 131 format closely matches '29-03-17 03:58:34.312000000 PM' format 'dd/mm/yyyy hh:mi:ss:mmmAM' but only difference is with the year. In Oracle year is 17 and SQL Server the year is 2017. I need to prefix 20 to the year to make it 2017. This query converts into Hijri datetime. I need it in Gregorian datetime format. This is the documentation. <https://learn.microsoft.com/en-us/sql/t-sql/functions/cast-and-convert-transact-sql> I need to convert the date which is in string in Oracle format to SQL Server equivalent. Is there any way where the format like 'dd/mm/yyyy hh:mi:ss:mmmAM' can be mentioned instead of mentioning the date format code like 131, 101, 102 in the convert function.
2017/05/27
[ "https://Stackoverflow.com/questions/44215132", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2550324/" ]
You might try it like this: ``` DECLARE @oracleDT VARCHAR(100)='29-03-17 03:58:34.312000000 PM'; SELECT CAST('<x>' + @oracleDT + '</x>' AS XML).value(N'(/x/text())[1]','datetime'); ``` It seems, that XML is implicitly able to do this correctly... EDIT: The above is culture related! ----------------------------------- It worked on my (german) system, but if you set the correct dateformat you can force this (be aware of side effects for the current job!) Try this and then remove the `--` to try alternative date formats. Or try with `GERMAN`: ``` SET LANGUAGE ENGLISH; SET DATEFORMAT mdy; --SET DATEFORMAT ymd; --SET DATEFORMAT dmy; DECLARE @oracleDT VARCHAR(100)='01-02-03 03:58:34.312000000 PM'; SELECT CAST('<x>' + @oracleDT + '</x>' AS XML).value(N'(/x/text())[1]','datetime'); ``` Another approach ---------------- You might split the string in all parts and build a convertible format like this: ``` DECLARE @oracleDT VARCHAR(100)='29-03-17 03:58:34.312000000 PM'; WITH AllParts(Casted) AS ( SELECT CAST('<x>' + REPLACE(REPLACE(REPLACE(REPLACE(@oracleDT,'.','-'),' ','-'),':','-'),'-','</x><x>') + '</x>' AS XML) ) SELECT CONVERT (DATETIME, DATENAME(MONTH,'2000'+Casted.value(N'x[2]/text()[1]','nvarchar(max)')+'01') + ' ' + Casted.value(N'x[1]/text()[1]','nvarchar(max)') + ' ' + N'20' + Casted.value(N'x[3]/text()[1]','nvarchar(max)') + ' ' + Casted.value(N'x[4]/text()[1]','nvarchar(max)') + ':' + Casted.value(N'x[5]/text()[1]','nvarchar(max)') + ':' + Casted.value(N'x[6]/text()[1]','nvarchar(max)') + ':' + LEFT(Casted.value(N'x[7]/text()[1]','nvarchar(max)'),3) + Casted.value(N'x[8]/text()[1]','nvarchar(max)'),109) FROM AllParts ```
13,440,602
lick() is a private method of Cat. Unfortunately, Cat's this.paw is not accessible in lick(). Is there a simple way to create a private method that has access to the member variables of its containing class? ``` <!doctype html> <html> <head> <meta charset="utf-8"> </head> <body> <p id="catStatus">???</p> <script> function Cat() { this.paw; var lick = function() { alert(this.paw); if(this.paw == "sticky") { alert("meow"); document.getElementById("catStatus").innerHTML = "*Slurp*"; } }; this.beCat = function() { this.paw = "sticky"; lick(); } } var kitty = new Cat(); kitty.beCat(); </script> </body> </html> ``` ![Result](https://i.stack.imgur.com/cIpgr.png)
2012/11/18
[ "https://Stackoverflow.com/questions/13440602", "https://Stackoverflow.com", "https://Stackoverflow.com/users/724752/" ]
The value of `this` depends on how you call the method. Since you're not calling the method on the object instance, `this` becomes the global object. Instead, you need to save `this` in a variable: ``` function Cat() { this.paw = ...; var me = this; var lick = function() { alert(me.paw); if(me.paw == "sticky") { alert("meow"); document.getElementById("catStatus").innerHTML = "*Slurp*"; } }; this.beCat = function() { this.paw = "sticky"; lick(); } } ```
65,492,424
I'm working with [AI-Thermometer](https://github.com/tomek-l/ai-thermometer) project using Nvidia Jeton Nano. The project is using Pi camera v2 for video capturing. Here's the command of showing video streams using Pi camera v2. ```sh gst-launch-1.0 nvarguscamerasrc sensor_mode=0 ! 'video/x-raw(memory:NVMM),width=3264, height=2464, framerate=21/1, format=NV12' ! nvvidconv flip-method=2 ! 'video/x-raw,width=960, height=720' ! nvvidconv ! nvegltransform ! nveglglessink -e ``` I want to use the normal USB webcam (such as Logitech c930) instead of Pi camera v2. To do so, I need to stream the USB webcam data using GStreamer in the same way as above pipeline commands. I installed `v4l-utils` on Ubuntu of Jetson Nano. And tried like this, ```sh gst-launch-1.0 v4l2src device="/dev/video0" ! 'video/x-raw(memory:NVMM),width= ... ``` , but it gave a warning and didn't work. How can I show video streams from webcam?
2020/12/29
[ "https://Stackoverflow.com/questions/65492424", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12570573/" ]
There should not quotes around the device parameter i.e. `device=/dev/video0`. If the error persists, then its probably something else.
1,749,232
What naming conventions do you use for everyday code? I'm pondering this because I currently have a project in Python that contains 3 packages, each with a unique purpose. Now, I've been putting general-purpose, 'utility' methods into the first package I created for the project, however I'm contemplating moving these methods to a separate package. The question is what would I call it? Utility, Collection, Assorted? Is there any standard naming conventions you swear by, and if so can you please provide links? I'm aware each language has it's own naming conventions, however is there any particular one that you find the most useful, that you'd recommend I'd start using?
2009/11/17
[ "https://Stackoverflow.com/questions/1749232", "https://Stackoverflow.com", "https://Stackoverflow.com/users/154280/" ]
In general, you should follow the naming convention of the language you're using. It doesn't matter if you like or prefer the standards of another language. Consistency within the context of the language helps make your code more readable, maintainable, and usable by others. In Python, that means you use [PEP 8](http://www.python.org/dev/peps/pep-0008/). Using a personal example: In Python, I'd call the package "utils" -- or if I intended on redistribution, "coryutils" or something similar to avoid namespace collisions. In Java or ActionScript, I'd call the package "net.petosky.utils", regardless of whether I intended on redistribution or not.
30,779,774
I have a table like this: ``` CREATE TABLE mytable ( user_id int, device_id ascii, record_time timestamp, timestamp timeuuid, info_1 text, info_2 int, PRIMARY KEY (user_id, device_id, record_time, timestamp) ); ``` When I ask Cassandra to delete a record (an entry in the columnfamily) like this: ``` DELETE from my_table where user_id = X and device_id = Y and record_time = Z and timestamp = XX; ``` it returns without an error, but when I query again the record is still there. Now if I try to delete a whole row like this: ``` DELETE from my_table where user_id = X ``` It works and removes the whole row, and querying again immediately doesn't return any more data from that row. What I am doing wrong? How you can remove a record in Cassandra? Thanks
2015/06/11
[ "https://Stackoverflow.com/questions/30779774", "https://Stackoverflow.com", "https://Stackoverflow.com/users/697716/" ]
Ok, here is my theory as to what is going on. You have to be careful with timestamps, because they will *store* data down to the millisecond. But, they will only *display* data to the second. Take this sample table for example: ``` aploetz@cqlsh:stackoverflow> SELECT id, datetime FROM data; id | datetime --------+-------------------------- B25881 | 2015-02-16 12:00:03-0600 B26354 | 2015-02-16 12:00:03-0600 (2 rows) ``` The `datetime`s (of type timestamp) are equal, right? Nope: ``` aploetz@cqlsh:stackoverflow> SELECT id, blobAsBigint(timestampAsBlob(datetime)), datetime FROM data; id | blobAsBigint(timestampAsBlob(datetime)) | datetime --------+-----------------------------------------+-------------------------- B25881 | 1424109603000 | 2015-02-16 12:00:03-0600 B26354 | 1424109603234 | 2015-02-16 12:00:03-0600 (2 rows) ``` As you are finding out, this becomes problematic when you use timestamps as part of your PRIMARY KEY. It is possible that your timestamp is storing more precision than it is showing you. And thus, you will need to provide that hidden precision if you will be successful in deleting that single row. Anyway, you have a couple of options here. One, find a way to ensure that you are not entering more precision than necessary into your `record_time`. Or, you could define `record_time` as a timeuuid. Again, it's a theory. I could be totally wrong, but I have seen people do this a few times. Usually it happens when they insert timestamp data using `dateof(now())` like this: ``` INSERT INTO table (key, time, data) VALUES (1,dateof(now()),'blah blah'); ```
3,508,624
Got a table with 1200 rows. Added a new column which will contain incremental values - Candidate1 Candidate2 Candidate3 . . . Candidate1200 What is the best way to insert these values , non manual way. I am using SQL Server 2008
2010/08/18
[ "https://Stackoverflow.com/questions/3508624", "https://Stackoverflow.com", "https://Stackoverflow.com/users/416465/" ]
Simple: ``` $post_title = sanitize_title_with_dashes($post_title); ``` But WordPress does this for you already. I assume you need it for something different?
521
Has anyone seen this site? <http://answermagento.com/> I know this subject has been briefly discussed but this isn't another site using a StackExchange-clone platform. This site consists entirely of scraped content from Magento SE. [Frequently linked-to site ripping off Magento Stack Exchange](https://magento.meta.stackexchange.com/questions/495/frequently-linked-to-site-ripping-off-magento-stack-exchange)
2015/02/23
[ "https://magento.meta.stackexchange.com/questions/521", "https://magento.meta.stackexchange.com", "https://magento.meta.stackexchange.com/users/324/" ]
The content is CC share-alike, but this site isn't properly crediting the origin. Not important though because the domain name infringes our mark. I've sent a note to our legal team to C&D the owner.
50,327,168
I need to create perforce clients from my jenkins build scripts, and this needs to be done unattended. This is mainly because jenkins jobs run in unique folders, Perforce insists that each client has a unique root target folder, and we create new jenkins jobs all the time based on need. Right now each time I create a unique jenkins job, I have to manually create a perforce client for that job - I can do this from the command line, but Perforce also insists on pausing the client creation to show me the specification settings file, which I need to manually close before the client is created. To create the client I'm using ``` p4 -u myuser -P mypassword client -S //mydepo/mystream someclientname ``` and I'm using this awful hack to simultaneously kill notepad ``` p4 -u myuser -P mypassword client -S //mydepo/mystream someclientname | taskkill /IM notepad.exe /F ``` This sort of works, but it doesn't feel right. Is there an official/better way I can force p4 to silently force create a client?
2018/05/14
[ "https://Stackoverflow.com/questions/50327168", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1216792/" ]
You can position an absolute View over the RNCamera view, and put all of your content into that absolute view. For example: ```js import { RNCamera } from 'react-native-camera'; class TakePicture extends Component { takePicture = async () => { try { const data = await this.camera.takePictureAsync(); console.log('Path to image: ' + data.uri); } catch (err) { // console.log('err: ', err); } }; render() { return ( <View style={styles.container}> <RNCamera ref={cam => { this.camera = cam; }} style={styles.preview} > <View style={styles.captureContainer}> <TouchableOpacity style={styles.captureBtn} onPress={this.takePicture}> <Icon style={styles.iconCamera}>camera</Icon> <Text>Take Photo</Text> </TouchableOpacity> </View> </RNCamera> <View style={styles.space} /> </View> ); } } const styles = StyleSheet.create({ container: { position: 'relative' }, captueContainer: { position: 'absolute' bottom: 0, }, captureBtn: { backgroundColor: 'red' } }); ``` This is just an example. You will have to play with css properties to reach the desired layout.
3,959,078
I have a model called a `Statement` that belongs to a `Member`. Given an array of members, I want to create a query that will return the **most recent** statement for each of those members (preferably in one nice clean query). I thought I might be able to achieve this using `group` and `order` - something like: ``` # @members is already in an array @statements = Statement.all( :conditions => ["member_id IN(?)", @members.collect{|m| m.id}], :group => :member_id, :order => "created_at DESC" ) ``` But unfortunately the above always returns the *oldest* statement for each member. I've tried swapping the order option round, but alas it always returns the oldest statement of the group rather than the most recent. I'm guessing `group_by` isn't the way to achieve this - so how do I achieve it? PS - any non Ruby/Rails people reading this, if you know how to achieve this in raw MySQL, then fire away.
2010/10/18
[ "https://Stackoverflow.com/questions/3959078", "https://Stackoverflow.com", "https://Stackoverflow.com/users/151409/" ]
In MySQL directly, you need a sub-query that returns the maximum `created_at` value for each member, which can then be joined back to the `Statement` table to retrieve the rest of the row. ``` SELECT * FROM Statement s JOIN (SELECT member_id, MAX(created_at) max_created_at FROM Statement GROUP BY member_id ) latest ON s.member_id = latest.member_id AND s.created_at = latest.max_created_at ```
5,032,968
When an EXE raised an exception message like "access violation at address XXXXXXXX...", the address XXXXXXXX is a hex value, and we can get the source code line number that caused the exception, by looking at the map file. Details below ([by madshi at EE](http://www.experts-exchange.com/Programming/Languages/Pascal/Delphi/Q_21201209.html#a12542996)): > > you need to substract the image base, > which is most probably $400000. > Furthermore you need to substract the > "base of code" address, which is > stored in the image nt headers of each > module (exe/dll). It's usually $1000. > You can check which value it has by > using the freeware tool "PEProwse > Pro". It's the field "Base Of Code" in > the "Details" of the "Optional > Header". You'll also find the image > base address there. > > > **My question is**: How to get the source line number for a **DLL**? Does the same calculation apply? Thanks! Note 1: the map file is generated by Delphi and I'm not sure if this matters. Note 2: I've been using JCL DEBUG but it couldn't catch the exception which seems occurred at the startup of the DLL (an Office add-in, actually).
2011/02/17
[ "https://Stackoverflow.com/questions/5032968", "https://Stackoverflow.com", "https://Stackoverflow.com/users/133516/" ]
Same calculations apply, with the following note: instead of image base address of EXE you'll need to take actual address where DLL had been loaded. Base of code for a DLL should taken in the same manner as for EXE (stored in PE's `IMAGE_OPTIONAL_HEADER`). Btw, EXE and DLL are actually the same thing from the point of view of PE format.
52,332,409
I converted the png file to SVG and got it from <http://inloop.github.io/svg2android/> to find the vector path information. I have been trying to support from api level 21 to get the right resolution for all screen sizes by using vector drawables. (My app`s minSdk is 21) The problem is that the text is white and the background color is transparent, but I am trying to change it using the fillColor attribute or strokeColor, but somehow not working well. how do I achieve this? I want text`s color is white and other background is transparent. ``` <?xml version="1.0" encoding="utf-8"?> <vector xmlns:android="http://schemas.android.com/apk/res/android" android:width="386.000000dp" android:height="149.000000dp" android:viewportWidth="386.000000" android:viewportHeight="149.000000" > <group android:translateY="149.000000" android:scaleX="0.100000" android:scaleY="-0.100000" > <path android:strokeColor="#FFFFFF" android:strokeWidth="3" android:pathData="M0 745 l0 -745 1930 0 1930 0 0 432 0 432 -45 -72 c-85 -138 -151 -202 -209 -202 -65 0 -85 40 -87 175 -2 140 -18 161 -77 97 -46 -50 -153 -224 -155 -252 -1 -18 -7 -20 -37 -18 l-35 3 2 80 c2 44 5 91 9 105 5 24 5 23 -17 -5 -44 -60 -135 -147 -171 -166 -49 -25 -112 -25 -138 1 -29 29 -33 61 -17 138 l14 70 -60 -44 c-32 -24 -63 -44 -68 -44 -5 0 -6 -19 -3 -42 11 -86 -57 -158 -148 -158 -39 0 -54 5 -73 25 -14 13 -25 31 -25 39 0 24 48 74 100 103 l48 27 -31 57 -31 56 -54 -44 c-30 -25 -65 -50 -78 -55 -20 -10 -23 -16 -18 -52 10 -84 -58 -156 -148 -156 -39 0 -54 5 -73 25 -14 13 -25 31 -25 39 0 24 48 74 100 103 l49 27 -26 46 -26 46 -81 -81 c-99 -100 -170 -138 -266 -143 -55 -3 -70 0 -100 20 -96 65 -67 247 51 325 33 22 56 28 110 31 63 4 70 2 95 -23 22 -22 25 -32 21 -62 -11 -64 -79 -113 -184 -134 -70 -13 -79 -28 -44 -70 16 -20 28 -24 68 -23 67 1 142 43 229 129 59 59 72 78 78 114 7 48 52 101 84 101 27 0 55 -34 48 -58 -4 -10 -17 -29 -31 -42 l-24 -23 32 -58 c18 -32 34 -59 37 -59 3 0 36 23 73 51 55 40 73 61 92 104 35 79 83 106 119 66 21 -23 15 -49 -19 -81 l-25 -23 32 -56 c17 -31 33 -58 34 -60 2 -2 33 18 69 43 67 48 101 88 91 104 -7 11 60 26 74 17 15 -9 12 -70 -7 -163 -16 -75 -16 -83 -1 -98 21 -21 45 -13 106 35 64 51 160 179 158 211 -1 18 6 27 25 34 15 5 35 6 44 2 16 -6 17 -16 11 -99 l-7 -92 49 75 c65 101 114 142 166 138 62 -5 77 -33 83 -164 5 -106 14 -144 33 -144 20 0 78 62 130 139 47 69 58 80 78 76 l22 -5 0 310 0 310 -1930 0 -1930 0 0 -745z m499 358 c-30 -38 -44 -42 -145 -43 l-101 0 -12 -62 c-7 -35 -15 -74 -18 -87 l-6 -24 79 6 c44 3 88 9 97 13 23 8 21 -8 -4 -40 -19 -24 -26 -26 -99 -26 l-79 0 -12 -57 c-20 -98 -18 -115 16 -132 24 -12 42 -12 100 -3 38 6 80 14 93 18 13 4 22 2 22 -4 0 -6 -10 -22 -22 -36 -26 -29 -94 -46 -189 -46 -122 0 -138 23 -111 163 l19 98 -23 -5 c-12 -3 -30 -9 -40 -13 -17 -6 -16 -4 2 28 13 22 29 35 46 37 23 3 27 10 38 65 6 34 14 73 17 86 5 22 4 23 -28 16 -19 -4 -47 -14 -62 -22 -16 -8 -31 -12 -34 -10 -6 7 24 64 39 74 7 4 90 11 183 14 94 3 187 6 209 7 35 2 37 1 25 -15z m2587 -21 c-18 -34 -91 -92 -117 -92 -40 0 -31 56 10 65 15 3 47 19 71 35 24 16 46 28 48 26 2 -2 -3 -18 -12 -34z m-2037 -47 c25 3 57 9 70 12 23 6 24 5 17 -42 -4 -26 -10 -54 -13 -62 -4 -10 6 -8 36 8 51 26 129 23 162 -7 98 -87 40 -283 -101 -342 -22 -9 -57 -13 -101 -10 l-67 4 -17 -84 c-9 -46 -15 -98 -13 -115 3 -31 2 -32 -37 -32 -39 0 -40 1 -43 35 -2 20 11 100 28 179 16 79 30 147 30 150 0 3 -14 -11 -31 -32 -86 -104 -211 -116 -282 -26 l-24 31 -25 -44 c-14 -23 -31 -61 -39 -83 -7 -22 -17 -44 -21 -49 -11 -14 -48 24 -48 49 0 23 67 132 95 155 13 10 12 17 -4 48 -10 21 -27 63 -37 96 l-18 58 23 19 c34 27 61 25 61 -6 0 -31 39 -135 50 -135 15 0 61 67 75 107 10 30 19 39 40 41 63 8 50 -45 -35 -141 -28 -30 -50 -59 -50 -64 0 -5 10 -19 23 -30 60 -55 102 -53 172 9 60 53 100 113 109 163 4 22 9 48 12 58 4 14 -1 17 -35 17 -37 0 -71 19 -71 40 0 5 -3 15 -6 24 -5 13 0 13 32 5 20 -6 58 -8 83 -4z m769 -95 c2 -17 -6 -34 -22 -49 -25 -23 -27 -24 -45 -7 -18 16 -21 16 -50 1 -44 -22 -115 -116 -162 -212 -37 -76 -43 -83 -70 -83 -18 0 -32 6 -36 16 -3 8 4 65 17 126 12 61 22 132 23 157 1 25 6 49 12 53 17 13 65 9 71 -6 3 -8 -1 -50 -9 -93 -8 -43 -14 -79 -12 -81 1 -2 13 14 26 35 31 50 106 131 144 155 19 12 44 17 70 16 34 -3 40 -6 43 -28z" /> <path android:strokeColor="#FFFFFF" android:strokeWidth="1" android:pathData="M1163 894 c-48 -24 -59 -42 -77 -134 -21 -112 -22 -109 20 -126 88 -37 184 44 184 156 0 52 -24 98 -56 110 -32 13 -33 13 -71 -6z" /> <path android:strokeColor="#FFFFFF" android:strokeWidth="1" android:pathData="M1995 930 c-32 -13 -75 -65 -90 -106 -7 -22 -10 -40 -5 -42 22 -8 93 22 125 52 60 57 39 125 -30 96z" /> <path android:strokeColor="#FFFFFF" android:strokeWidth="1" android:pathData="M2329 656 c-41 -28 -53 -48 -36 -65 28 -28 86 5 90 53 3 38 -11 41 -54 12z" /> <path android:strokeColor="#FFFFFF" android:strokeWidth="1" android:pathData="M2639 656 c-41 -28 -53 -48 -36 -65 28 -28 86 5 90 53 3 38 -11 41 -54 12z" /> </group> </vector> ``` Thanks in advance for any help!
2018/09/14
[ "https://Stackoverflow.com/questions/52332409", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10363717/" ]
Use this class ``` private class VectorDrawableUtils { Drawable getDrawable(Context context, int drawableResId) { return VectorDrawableCompat.create(context.getResources(), drawableResId, context.getTheme()); } Drawable getDrawable(Context context, int drawableResId, int colorFilter) { Drawable drawable = getDrawable(context, drawableResId); drawable.setColorFilter(ContextCompat.getColor(context, colorFilter), PorterDuff.Mode.SRC_IN); return drawable; } } ``` And call it like this ``` new VectorDrawableUtils().getDrawable(mContext,R.drawable.x,R.color.black); ```
52,260,366
I am looking for a textbox control that suggests words as the user types, similar to SuggestAppend for textboxes in winforms, except for WPF. I have looked around on the WPFToolkit and haven't really found anything that fits my needs. Thanks.
2018/09/10
[ "https://Stackoverflow.com/questions/52260366", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6635930/" ]
Declare an enum AutoCompleteMode too with value(Append, None,SuggestAppend,Suggest) ``` public enum AutoCompleteMode ``` Create an custom UserControl with TextBox and ItemControls. Handle the **KeyDown** event of TextBox. Popup an custom List to show the suggestion list(ItemControls in here). Then Handle the selection of the ItemControls. Can custom the style of hte ItemControls's ItemTemplate. Apply the AutoCOmpleteMode in this UserControl and handle the Enum changed in the code behind.
5,788,258
Hey I have a .NET .aspx page that I would like to run every hour or so whats the best way to do this ? I assume it will have to open a browser window to do so and if possible that it closes the window after. EDIT : I have access over all features on the server
2011/04/26
[ "https://Stackoverflow.com/questions/5788258", "https://Stackoverflow.com", "https://Stackoverflow.com/users/215541/" ]
**Option 1**: The cleanest solution would be to write a Windows application that does the work (instead of an aspx page) and schedule this application on the server using the Windows Task Scheduler. This has a few advantages over the aspx approach: * You can use the features of the Windows Task Scheduler (event log entries if the task could not be started, see the time of the last run, run the task in the context of a specific user, etc.). * You don't need to "simulate" a web browser call. * Your page cannot be "accidentally" called by a web user or a search engine. * It's conceptually cleaner: The main purpose of a web page is to provide information to the client, not to trigger an action on the server. Of course, there are drawbacks as well: * You have two Visual Studio projects instead of one. * You might need to factor common code into a shared class library. (This can also be seen as an advantage.) * Your system becomes more complex and, thus, potentially harder to maintain. --- **Option 2**: If you need to stick to an aspx page, the easiest solution is probably to call the page via a command-line web client in a scheduled task. Since Windows does not provide any built-in command-line web clients, you'd have to download one such as `wget` or [`curl`](http://curl.haxx.se/). This related SO question contains the necessary command-line syntax: * [Scheduled Tasks for ASP.NET](https://stackoverflow.com/questions/2927330/scheduled-tasks-for-asp-net/2927375#2927375)
29,776,576
I can create a [Guava `ImmutableList`](https://google.github.io/guava/releases/23.0/api/docs/com/google/common/collect/ImmutableList.html) with the `of` method, and will get the correct generic type based on the passed objects: ``` Foo foo = new Foo(); ImmutableList.of(foo); ``` However, [the `of` method with no parameters](https://google.github.io/guava/releases/23.0/api/docs/com/google/common/collect/ImmutableList.html#of--) cannot infer the generic type and creates an `ImmutableList<Object>`. How can I create an empty `ImmutableList` to satisfy `List<Foo>`?
2015/04/21
[ "https://Stackoverflow.com/questions/29776576", "https://Stackoverflow.com", "https://Stackoverflow.com/users/722332/" ]
If you assign the created list to a variable, you don't have to do anything: ``` ImmutableList<Foo> list = ImmutableList.of(); ``` In other cases where the type can't be inferred, you have to write `ImmutableList.<Foo>of()` as @zigg says.
1,990,579
I am using "ExuberantCtags" also known as "ctags -e", also known as just "etags" and I am trying to understand the TAGS file format which is generated by the etags command, in particular I want to understand line #2 of the TAGS file. [Wikipedia says](http://en.wikipedia.org/wiki/Ctags#Etags_2) that line #2 is described like this: ``` {src_file},{size_of_tag_definition_data_in_bytes} ``` In practical terms though TAGS file line:2 for "foo.c" looks like this ``` foo.c,1683 ``` My quandary is how exactly does it find this number: 1683 I know it is the size of the "tag\_definition" so what I want to know is what is the "tag\_definition"? I have tried looking through the [ctags source code](http://ctags.sourceforge.net/), but perhaps someone better at C than me will have more success figuring this out. Thanks! EDIT #2: ``` ^L^J hello.c,79^J float foo (float x) {^?foo^A3,20^J float bar () {^?bar^A7,59^J int main() {^?main^A11,91^J ``` Alright, so if I understand correctly, "79" refers to the number of bytes in the TAGS file from after 79 down to and including "91^J". Makes perfect sense. Now the numbers 20, 59, 91 in this example wikipedia says refer to the {byte\_offset} What is the {byte\_offset} offset from? Thanks for all the help Ken!
2010/01/02
[ "https://Stackoverflow.com/questions/1990579", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2085667/" ]
You can probably use [mcrypt](http://de3.php.net/manual/en/ref.mcrypt.php). But may I ask why you're encrypting with ECB mode at all? Remember the [known problems](http://en.wikipedia.org/wiki/Block_cipher_modes_of_operation#Electronic_codebook_.28ECB.29) with that?
31,208,835
``` firstLetter = word.charAt(0); lastLetter = word.charAt((word.length()) - 1); noFirstLetter = word.substring(1); newWord = noFirstLetter + firstLetter; if(word.equalsIgnoreCase(newWord)) ``` So im trying to take the first letter of the word and if I take the first letter of the word away and move it to the end it should be equal to the same word. My code here isn't working. For example if the user entered "dresser" if you move the "d" to the end of the word you get the word "dresser" again. That is what im trying to check
2015/07/03
[ "https://Stackoverflow.com/questions/31208835", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5078138/" ]
I think what you are trying to do is to remove the first character, and then check if rest of the characters are symmetrical around the center of the word.(OK even it is complicated for me) EG: dresser => (drop d) => resser => (add d to the right) => resserd (read from right to left and it is dresser again). after you drop the first letter: resser (there are even number of letters in the word) ``` r e s s e r |_| |_____| |_________| ``` since they are symmetrical, you can say that that word would be Palindromic if you move D from left to right (or vice versa). The whole thing above could be horribly wrong if I misunderstood your question at the first place. But I assumed, your question was NOT a simple substring question. Cheers.
17,426,311
I have list of Active Directory Users's Guid, I need to load a set of properties of those users for a specific reporting. To do this, if we make a bind for each Guid, then it will be a costly one. Whether with DirectorySearcher, can we provide multiple Guid(say 1000) as filter and load the properties?.
2013/07/02
[ "https://Stackoverflow.com/questions/17426311", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2376887/" ]
``` In [9]: pd.Series(df.Letter.values,index=df.Position).to_dict() Out[9]: {1: 'a', 2: 'b', 3: 'c', 4: 'd', 5: 'e'} ``` Speed comparion (using Wouter's method) ``` In [6]: df = pd.DataFrame(randint(0,10,10000).reshape(5000,2),columns=list('AB')) In [7]: %timeit dict(zip(df.A,df.B)) 1000 loops, best of 3: 1.27 ms per loop In [8]: %timeit pd.Series(df.A.values,index=df.B).to_dict() 1000 loops, best of 3: 987 us per loop ```
19,966,453
I'm trying to select a node's value from XML in a table in MySQL/MariaDB Acoording to the MySQL docs, `following-sibling` is not supported as an XPath axis in MySQL. Is there an alternative? Docs: <http://dev.mysql.com/doc/refman/5.1/en/xml-functions.html#function_extractvalue> My XML structure looks something like: ``` <fields> <record> <id>10</id> <value>Foo</value> </record> <record> <id>20</id> <value>Bar</value> </record> </fields> ``` I need to find the record with ID 10, and get the text in `<value></value>`. Valid XPath would be `/fields/record/id[text()=10]/following-sibling::value/text()` which would return `Foo` What are my options? Thanks!
2013/11/13
[ "https://Stackoverflow.com/questions/19966453", "https://Stackoverflow.com", "https://Stackoverflow.com/users/565626/" ]
In this simple case you do not need the `following-sibling`. Try this instead: ``` /fields/record[id[text()=10]]/value/text() ``` Using the tag `id` inside the brackets leaves your context at `record` so that the following slash descends to the corresponding sibling of `id` (having the same parent as `id`).
2,621,549
Actually, I know that $\int\_0^n \lfloor t \rfloor dt$ is $\frac{n(n-1)}{2}$. But I can't solve this simple problem. Can anybody help me? P.S. I'm seventeen, I'm studying in last year of high school, and I'm preparing for the national exams.
2018/01/26
[ "https://math.stackexchange.com/questions/2621549", "https://math.stackexchange.com", "https://math.stackexchange.com/users/427758/" ]
\begin{eqnarray\*} \int\_0^n 2x \lfloor x \rfloor dx = \sum\_{i=0}^{n-1} i \underbrace{\int\_{i}^{i+1} 2x \,dx}\_{x^2 \mid\_i^{i+1}=2i+1} = \underbrace{\sum\_{i=0}^{n-1} i (2i+1)}\_{\text{using} \sum\_{i=0}^{n-1} i^2=\frac{n(n-1)(2n-1)}{6} } = \frac{(n-1)n(n+1)}{3}. \end{eqnarray\*}
273,520
If $\sum\_{n=1}^{\infty}a\_n$ converge, then $\sum\_{n=1}^{\infty}\sqrt[4]{a\_{n}^{5}}=\underset{n=1}{\overset{\infty}{\sum}}a\_{n}^{\frac{5}{4}}$ converge? Please verify answer below.
2013/01/09
[ "https://math.stackexchange.com/questions/273520", "https://math.stackexchange.com", "https://math.stackexchange.com/users/55682/" ]
Yes. Because $\sum a\_n$ converges, we know that the limit $\lim a\_n = 0$, by the Divergence Test. This means that $\exists N, \forall n > N, a\_n <1 $. It stands to reason then that $a\_n^{5/4} \le a\_n$ for all such $n>N$. By Direct Comparison, then, $\sum a\_n^{5/4}$ also converges. We cannot say $\sum a\_n^{5/4} < \sum a\_n$. Someone said that but it is untrue. It all depends on the front-end behavior. If for the first $N$ terms $a\_n^{5/4}$ is sufficiently larger than $a\_n$ then the inequality of the actual sum may be reversed. --- It doesnt matter if for any terms $a\_n<0$. If a term is odd then $a\_n^5$ is still odd. And the principle fourth root $a\_n^{5/4}$ is going to be a complex number where $a\_n^{5/4} = |a\_n|^{5/4} \frac{\sqrt{2}+i\sqrt{2}}{2}$ for all negative $a\_n$ The principle fourth root $a\_n^{5/4}$ for positive $a\_n$ is still positive and real. Simply break the series apart into two separate series of positive and negative $a\_n$ terms. We know that $\sum\_{a\_n>0} a\_n^{5/4}$ is going to converge as per the first part of this proof. It has fewer terms and therefore converges to a smaller sum. For the series $\sum\_{a\_n<0} a\_n^{5/4}$ we get the final sum $\frac{\sqrt{2}+i\sqrt{2}}{2} \sum\_{a\_n<0} |a\_n|^{5/4} $. Notice the sum is still going to be convergent as per the first part of this proof, but there is a complex scalar that was factored out. Thus, even for a series containing negative $a\_n$ terms, the sum $\sum a\_n^{5/4}$ is simply going to be the sum $\left(\sum\_{a\_n>0} a\_n^{5/4}\right) + \left(\frac{\sqrt{2}+i\sqrt{2}}{2} \sum\_{a\_n<0} |a\_n|^{5/4}\right) $ Each individual series is now a series of positive terms, each containing fewer terms than the original series and therefore each converges to a smaller sum. --- **Disclaimer** Im no expert in infinite series. They are not exactly intuitive. The problem is infinitely more complicated if you let $a\_n$ take any complex value.
39,193,733
It is my developed project with target API 23. Now I'm using Studio 2.1.3 When I am trying to open this project the error show me like `Error:failed to find Build Tools revision 24.0.0 rc2 Install Build Tools 24.0.0 rc2 and sync project` But when I try to install, then a error message shown. It was a big project, I have to run it. How can I sync it and run it properly? Please help me, Thanks in advance.. Screenshot 1: this is the error message [![enter image description here](https://i.stack.imgur.com/29uSF.png)](https://i.stack.imgur.com/29uSF.png) Screenshot 2: when i click to install and sync then this error message has appeared [![enter image description here](https://i.stack.imgur.com/OFx3n.png)](https://i.stack.imgur.com/OFx3n.png)
2016/08/28
[ "https://Stackoverflow.com/questions/39193733", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5032484/" ]
Update the `android-sdk` tools to the newest version: `24.0.2` Change your Android Support libraries version like `appcompat` from `23.x.x` version to `24.2.0` If you would any problem with updating dependencies, check: <https://developer.android.com/studio/intro/update.html#sdk-manager> **Tip:** Try to avoid use in your project `alpha`,`preview` or `beta` versions of project dependencies. Hope it will help
1,613,692
The way I understand the definition of a combination of a set is that, without repetition,for example, the combination of the set $\{1,2\}$ would be $(1,2)$, and not $(1,1)$, $(1,2)$ and $(2,2)$ because I thought I read that each element has to be unique. Is this the case? Also, What is the combination of a set that has only one element? like $\{2\}$ ? the empty set? or is it $(2,2)$ which would to violate the unique property, if uniqueness actually is a constraint. I'm not sure if it is or not because the web doesn't cover the topic well in a 'non mathematician can understand it' way.
2016/01/15
[ "https://math.stackexchange.com/questions/1613692", "https://math.stackexchange.com", "https://math.stackexchange.com/users/-1/" ]
$$\int\frac{u}{\left(a^2+u^2\right)^{\frac{3}{2}}}\space\text{d}u=$$ --- Substitute $s=a^2+u^2$ and $\text{d}s=2u\space\text{d}u$: --- $$\frac{1}{2}\int\frac{1}{s^{\frac{3}{2}}}\space\text{d}s=\frac{1}{2}\int s^{-\frac{3}{2}}\space\text{d}s=\frac{1}{2}\cdot-\frac{2}{\sqrt{s}}+\text{C}=-\frac{1}{\sqrt{a^2+u^2}}+\text{C}$$
21,266,901
Researching viewport behaviour, I've hit a bit of a snag in understanding the meta viewport declaration. I see `width=device-width` and `initial-scale=1` used together a lot but, as far as I can tell, the latter implies the former. MDN also mentions that defining both a `width` and `initial-scale=1` will result in the width acting as a minimum viewport width. If this is the case then is there any need to define the width as `device-width`? Surely the initial-scale can't be 1 with any layout viewport smaller than the device-width anyway. Am I missing something or is defining the width as device-width redundant here? Thanks
2014/01/21
[ "https://Stackoverflow.com/questions/21266901", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1778058/" ]
The usual problem when trying to use an audio signal as digital signal input is that it is [high-pass-filtered to avoid offsets](http://blog.faberacoustical.com/2010/ios/iphone/iphone-4-audio-and-frequency-response-limitations/) (long term pressure changes which could destroy the dynamic range of the soundcards Analog-to-Digital converters). This means you will get only the changes of the digital signal (like "clicks"). Actually you will be better of the higher frequency your signal has, but it will be non-trivial to process it well then (this was what ordinary modems did very well). If you can control the digital signals sent as sound (or to the microphone jack), make sure they are modulated the signal with one or more tones, like a morse transmitter or modem. Essentially you want to use your iPhone as an [Aucoustic Coupler](http://en.wikipedia.org/wiki/Modem#Acoustic_couplers). This is possible, but of course a bit computationally expensive considering the quite low bandwidth. Start by using some dirt simple modulation, like [1200-1800 Hz](http://en.wikipedia.org/wiki/MDC-1200) and make an FFT of it. There's probably [some reference implementation for any sound card out there](http://www.matthew.at/mdc/) to get started with. There have been some cool viruses recently that was said to be able to jump air-gaps, they used similar techniques as this one. If you still really want a DC (or slowly changing digital signal), check out a [solution using a separate oscillator](http://lea.hamradio.si/~s57uuu/scdsp/CheapChop/cheapchop.htm) that is [amplitude-modulated](http://en.wikipedia.org/wiki/Amplitude_modulation) by the incoming signal
42,048,152
I have the data given below with other lines of data in a huge file to be more specific this is a .json file, I have stripped the whole file except for this one catch. **Data:** * ,"value":["ABC-DE","XYZ-MN"] * ,"value":["MNO-RS"],"sub\_id":01 * "value":"[\"NEW-XYZ\"]"," * ,"value":["ABC-DE","XYZ-MN","MNO-BE","FRS-ND"] I want the data to look like this * ,"value":["ABC-DE,XYZ-MN"]-Changed * ,"value":["MNO-RS"],"sub\_id":01-Unchanged * "value":"[\"NEW-XYZ\"]","-Unchnaged * ,"value":["ABC-DE,XYZ-MN,MNO-BE,FRS-ND"]-Changed So far I have this piece of code however it seems to be replacing the whole files "," with , and not the ones just within [] ``` sed 's/\(\[\|\","\|\]\)/\,/g' testfile_1.txt >testfile_2.txt ``` Any help would be great \*\*Note: Edited fourth condition Cheers.
2017/02/05
[ "https://Stackoverflow.com/questions/42048152", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2102955/" ]
That's tougher without the non-greedy matching perl regex offers, but this seems to do it. ``` sed -e 's/\([^\[]*\"[A-Z\-]*\)\",\"\(.*\)/\1,\2/' ```
26,781,785
I'm trying to create a batch file which asks a user a question with multiple (four) options. The options that the user chooses should trigger the batch file to ignore one of the four options. Lets say that the commands that I would normally want to run is ECHO "A", ECHO "B", ECHO "C", ECHO "D". If the person puts A in, I would want them to still run all the other commands except ECHO "A". Currently the solution i have come up with is the following ``` @echo off set /p choice="Do you want not to do: A, B, C or D? [A/B/C/D] " [A/B/C/D] if %choice%==A ( ECHO "B" ECHO "C" ECHO "D" EXIT /b ) else if %choice%==B ( ECHO "A" ECHO "C" ECHO "D" EXIT /b ) else if %choice%==C ( ECHO "A" ECHO "B" ECHO "D" EXIT /b ) else if %choice%==D ( ECHO "A" ECHO "B" ECHO "C" EXIT /b ) ELSE ( ECHO Please select A, B, C or D! EXIT /b ) ``` However as you can imagine, i am using the echo commands as an example/abstraction. The actual commands are longer. It seems more efficient to define the commands under A, B, C and D once and then tell the batch file not to doA, B, C or D depending the users choice. Maybe it's because I started working early today but I cannot think of an easier way to do this right now. So I hope to hear your ideas on how to make this batch script less clogged up.
2014/11/06
[ "https://Stackoverflow.com/questions/26781785", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
The idea in this code is that it only skips the one that you choose. ``` @echo off set /p choice="Do you want not to do: A, B, C or D? [A/B/C/D] " [A/B/C/D] if "%choice%"=="" ( ECHO Please select A, B, C or D! EXIT /b ) if not %choice%==A ( ECHO "A" ) if not %choice%==B ( ECHO "B" ) if not %choice%==C ( ECHO "C" ) if not %choice%==D ( ECHO "D" ) exit /b ```
18,258,755
This feels like it should be simple but it's been driving me crazy. I've got a function `indent-or-expand` that I'd like to remap to `tab` but I simply can't get it to work (Emacs v24, OS X). The only help I've been able to get from Emacs itself is: > > error "To bind the key TAB, use \"\\t\", not [TAB]" > > > Doing `(global-set-key [\"\\t\"] 'indent-or-expand)` binds the function to `<"\t">` apparently (whatever that is), and every combination I've tried of `\`, `"`, `[``]`, and `(``)` has failed. I DID manage to bind the function to `t`, though...
2013/08/15
[ "https://Stackoverflow.com/questions/18258755", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2521092/" ]
In addition to what others have told you: 1. The Emacs error message you cite told you to use "\t", and if you use that you should be OK: (global-set-key "\t" 'indent-or-expand) 2. Be aware also that `TAB` is one thing and `<tab>` might be another thing. IOW, it depends what code your physical keyboard `Tab` key actually sends to Emacs. `TAB` is the tab character, and it i the same as ACSCII control character `C-i`, that is, `Control` + `i`, which has decimal integer value 9. `<tab>` is (in Emacs) a pseudo function key. (Most likely `TAB` is what you want. Use `C-h k` to see what your physical `Tab` key does.)
47,343,419
So I am having trouble implementing this scenario: From the backend server, I am receving an html string, something along like this: ``` <ul><li><strong>Title1</strong> <br/> <a class=\"title1" href="title1-link">Title 1</a></li><li><strong>Title2</strong> <a class="title2" href="/title2-link">Title 2</a> ``` Normally, that would be fine when just using `dangerouslySetInnerHTML`. However, around the `a href` tags in the html, I need to wrap those in component like so: ``` <ModalLink href={'title'}> {Title} </ModalLink> ``` This is because when wrapping the `a` tags, the component essentially adds functionality on creating a new child window. I figured this is something you would need to implement on Regex, but I dont have the slightest idea where to begin.
2017/11/17
[ "https://Stackoverflow.com/questions/47343419", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4927657/" ]
You can deconstruct and extract the necessary values from your html string with regex and then use JSX instead of dangerouslySetInnerHtml. This component shows how to render your sample html string. ``` import React, { Component } from 'react' export default class App extends Component { render() { const html = `<ul><li><strong>Title1</strong><br/><a class="title1" href="/title1-link">Title 1</a></li><li><strong>Title2</strong><br/><a class="title2" href="/title2-link">Title 2</a></li></ul>` return ( <div> <ul> {html.match(/(<li>.*?<\/li>)/g).map( li => { const title = li.match(/<strong>(.*?)<\/strong>/)[1] const aTag = li.match(/<a.*?\/a>/)[0] const aClass = aTag.match(/class="(.*?)"/)[1] const href = aTag.match(/href="(.*?)"/)[1] const aText = aTag.match(/>(.*?)</)[1] return ( <li> <strong>{title}</strong> <br/> <a className={aClass} href={href}>{aText}</a> </li> ) })} </ul> </div> ) } } ``` From there you can simply wrap the a tag in your ModalLink component. I'm not sure this is exactly how you want to do that, but here is an example. ``` return ( <li> <strong>{title}</strong> <br/> <ModalLink href={href}> <a className={aClass} href={href}>{aText}</a> </ModalLink> </li> ) ``` `html.match(/(<li>.*?<\/li>)/g)` matches each `<li>...</li>` within the html string in an array, which can then be mapped. Then I extract the title, href, etc. out of each `<li>...</li>` using captures (the part within parentheses), which can then be used in JSX. [This answer](https://stackoverflow.com/questions/7124778/how-to-match-anything-up-until-this-sequence-of-characters-in-a-regular-expres) provides more detail on the regular expressions used.
20
In French, some nouns are considered male and some female (le/la). Is there a way which can help me understand which grammatical gender to use with which noun?
2016/04/05
[ "https://languagelearning.stackexchange.com/questions/20", "https://languagelearning.stackexchange.com", "https://languagelearning.stackexchange.com/users/41/" ]
You can't, really ----------------- As I was learning French (English is my first language) the idea of gender of objects can be difficult to grasp. Genders are pretty much arbitrary and is something you just have to remember with each word (this means remembering it as *"une fenêtre"* rather than *"fenêtre"*). You can also always listen for a [*liaison*](https://en.wikipedia.org/wiki/Liaison_(French)). But usually when speaking with a fluent speaker this can be quite subtle, and difficult to listen to. General Rules ------------- That said, they are *some general* patterns which can be used to distinguish the gender of a noun but these **are not rules**, and are only generally followed: * Things originating in France *tend* to be feminine. e.g. `une crêpe`, or `une pizza` * Things originating in America *tend* to be masculine e.g. `Un burger` **BIG DISCLAIMER:** These **are not rules at all**, these are just observations I have made. --- ### Spelling Nouns ending in the following tend to be masculine: * `ge` * `le` (that aren't `-lle`, `-ole`, `-ale`, or `-ule`) * `me` * `re` (that isn't `-ure`) * `phe` * `age` source: @bleh Nouns ending in the following tend to be feminine: * `on` * `é` * `eur` [[source]](http://www.languageguide.org/french/grammar/gender/rule.html) Feminine nouns tend to have `e` at the end too but *many* masculine nouns also have `e` at the end --- While some genders *tend* to have certain endings, there isn't any definite cut and dry to determine the gender of a word without memorizing it. You *can* memorize some common endings though to make better guesses. [This question on French.SE](https://french.stackexchange.com/q/2616/7385) might provide more information on this.
1,370,899
I want to display different types of objects in the same ajax called controller function. I want to render out when I send back an ajax call. The problem is I want the "title" attribute of one object and the "name" attribute of another object. I can't render 2 partials and can seem to figure out how to check the type of object an object is. How do I solve this problem? Here is my current controller setup (NOT CORRECT) ``` @objects = Obj.find(:all,:conditions => ["name Like ?", "#{prefix}%"]) @moreObjects = ObjTwo.find(:all,:conditions => ["title Like ?","#{prefix}%"]) if @objects.empty? render :text => "No Matches" else render :partial => 'one', :collection => @objects end if @moreObjects.empty? render :text => "No Matches" else render :partial => 'two', :collection => @moreObjects end ```
2009/09/03
[ "https://Stackoverflow.com/questions/1370899", "https://Stackoverflow.com", "https://Stackoverflow.com/users/157894/" ]
try something like ``` <%= obj.title if obj.respond_to?(:title) %> ```
4,611,178
I am attempting to write a test case to ensure a Singleton class cannot be instantiated. The constructor for the Singleton is defined to be private so my test is as follows: ``` $this->expectError(); $test = new TestSingletonClassA(); ``` Instead of catching the error and passing the test, I get a 'PHP Fatal error: Call to private Singleton::\_\_construct()'. I've also tried passing a PatternExpectation as a parameter to expectError, but that didn't work either. Do you have any suggestions? Some background: php5.3, simpletest1.1a
2011/01/06
[ "https://Stackoverflow.com/questions/4611178", "https://Stackoverflow.com", "https://Stackoverflow.com/users/382462/" ]
If your php code throws a FATAL ERROR, it will never get to the phpunit, so you have to write "right" code in order to test it. If you call a private method, it will throw an excepcion, so it won't get to the phpunit. You have to change that. I think you have to mock the object. Try [these posts](http://sebastian-bergmann.de/archives/881-Testing-Your-Privates.html) about this subject (it's a series of 4 posts) and [these slides](http://www.slideshare.net/sebastian_bergmann/phpunit-best-practices) (from slide #43) .
73,910,771
I am writing a function that returns a list of car models. The input is a string of comma separated cars. Duplicate entries are not added to the result. The elements in the list should be in the same order as they appear in the input string. If the input string is empty, the result is an empty list. I modified it to support multiple model names, e.g. `print(car_models("Tesla Model S,Skoda Super Lux Sport))` gives `['Model S', 'Super Lux Sport']`. ``` def car_models(all_cars: str) -> list: if not all_cars: return [] all_models = [] cars = all_cars.split(",") for car in cars: unique_car = car.split(" ") if unique_car[1] not in all_models: all_models.append(" ".join(unique_car[1:])) return all_models ``` While testing the code, an error occurred: [![enter image description here](https://i.stack.imgur.com/QlYDw.png)](https://i.stack.imgur.com/QlYDw.png) And I can't figure out what's wrong, can anyone tell me how to fix it?
2022/09/30
[ "https://Stackoverflow.com/questions/73910771", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17261019/" ]
Since you're appending `" ".join(unique_car[1:])` to the list, you need to use the same thing when checking if already exists. Solve this easily by assigning that to a variable, so you can use the same thing in the `in` test and `append()` call. ``` def car_models(all_cars: str) -> list: if not all_cars: return [] all_models = [] cars = all_cars.split(",") for car in cars: car_words = car.split(" ") model = " ".join(car_words[1:]) if model not in all_models: all_models.append(model) return all_models ```
37,434,875
I'm getting a weird error when i try to set templateUrl in my component. This works: ``` @Component({ selector: 'buildingInfo', template: ` <html>stuff</html> ` }) ``` But when i do this (with the same content in the html-file): ``` @Component({ selector: 'buildingInfo', templateUrl: 'stuff.component.html' }) ``` the output is this: ``` <span>M</span> <span>M</span> <fakediscoveryelement></fakediscoveryelement> <span>M</span> <fakediscoveryelement></fakediscoveryelement> <span>M</span> <span>M</span> <span>M</span> <span>M</span> <span>M</span> <span>M</span> <span>M</span> <span>M</span> ``` I have no idea why this happens. I get the same output when i try to use a seperate file for html on almost all other components (but not all).
2016/05/25
[ "https://Stackoverflow.com/questions/37434875", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5119447/" ]
If you want Angular to find the templates relative to the Component e.g. you have a structure like app/ app/app.component.ts app/app.component.html make sure, you set the module id of the component. That'll cause the System loader to look relative to your current path. Otherwise, it will *always* expect the complete path as URL. Example for SystemJS: ``` declare var __moduleName: string; @Component({ moduleId: __moduleName, selector: 'foo-bar', templateUrl: 'app.component.html', }) ``` Example for others: ``` @Component({ moduleId: module.id, selector: 'foo-bar', templateUrl: 'app.component.html', }) ``` It took me some time to get this one :)
22,518,501
I am reading in another perl file and trying to find all strings surrounded by quotations within the file, single or multiline. I've matched all the single lines fine but I can't match the mulitlines without printing the entire line out, when I just want the string itself. For example, heres a snippet of what I'm reading in: ``` #!/usr/bin/env perl use warnings; use strict; # assign variable my $string = 'Hello World!'; my $string4 = "chmod"; my $string3 = "This is a fun multiple line string, please match"; ``` so the output I'd like is ``` 'Hello World!'; "chmod"; "This is a fun multiple line string, please match"; ``` but I am getting: ``` 'Hello World!'; my $string4 = "chmod"; my $string3 = "This is a fun multiple line string, please match"; ``` This is the code I am using to find the strings - all file content is stored in @contents: ``` my @strings_found = (); my $line; for(@contents) { $line .= $_; } if($line =~ /(['"](.?)*["'])/s) { push @strings_found,$1; } print @strings_found; ``` I am guessing I am only getting 'Hello World!'; correctly because I am using the $1 but I am not sure how else to find the others without looping line by line, which I would think would make it hard to find the multi line string as it doesn't know what the next line is. I know my regex is reasonably basic and doesn't account for some caveats but I just wanted to get the basic catch most regex working before moving on to more complex situations. Any pointers as to where I am going wrong?
2014/03/19
[ "https://Stackoverflow.com/questions/22518501", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1583932/" ]
Couple big things, you need to search in a `while` loop with the `g` modifier on your regex. And you also need to turn off greedy matching for what's inside the quotes by using `.*?`. ``` use strict; use warnings; my $contents = do {local $/; <DATA>}; my @strings_found = (); while ($contents =~ /(['"](.*?)["'])/sg) { push @strings_found, $1; } print "$_\n" for @strings_found; __DATA__ #!/usr/bin/env perl use warnings; use strict; # assign variable my $string = 'Hello World!'; my $string4 = "chmod"; my $string3 = "This is a fun multiple line string, please match"; ``` Outputs ``` 'Hello World!' "chmod" "This is a fun multiple line string, please match" ``` You aren't the first person to search for help with this homework problem. Here's a more detailed answer I gave to ... well ... you ;) [`finding words surround by quotations perl`](https://stackoverflow.com/questions/22418745/finding-words-surround-by-quotations-perl/22418809#22418809)
25,024,560
Assume I have a dataframe: ``` Col1 Col2 Col3 Val a 1 a 2 a 1 a 3 a 1 b 5 b 1 a 10 b 1 a 20 b 1 a 25 ``` I want to aggregate across all columns and then attach this to my dataframe so that I have this output: ``` Col1 Col2 Col3 Val Tot a 1 a 2 10 a 1 a 3 10 a 1 b 5 10 b 1 a 10 55 b 1 a 20 55 b 1 a 25 55 ``` Is there something I can do with `tapply` to accomplish this? I'm a little stuck on the most efficient way.
2014/07/29
[ "https://Stackoverflow.com/questions/25024560", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2565416/" ]
No guarantees in terms of performance, but for each directory you could check its files to see if it contains any with the matching extension: ``` List<string> imageDirectories = Directory.GetDirectories(sourceTextBox.Text, "*", SearchOption.AllDirectories) .Where(d => Directory.EnumerateFiles(d) .Select(Path.GetExtension) .Where(ext => ext == ".png" || ext == ".jpg") .Any()) .ToList(); ```
59,762,087
Hi I know that Flutter still doesn't support SVG files so I used flutter\_svg package, but for some reason, the svg file is not rendering the SVG file I want to use. What I want is use my custom SVG files as Icon in the bottomnavigation bar items. > > I want to use SVG icons so that I can easily change their colors when they are inactive or active (selected) > > > I call it like this: ``` BottomNavigationBarItem( icon: SvgPicture.asset("assets/svg_home.svg"), title: Text("Home"), activeIcon: Icon(Icons.category, color: Color(0xFFEF5123)), ), ```
2020/01/16
[ "https://Stackoverflow.com/questions/59762087", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12509659/" ]
Fixed it ``` height: 20.0, width: 20.0, allowDrawingOutsideViewBox: true, ``` I'm beginning to slowly fall in love with flutter
25,469,489
A long, long time ago, in a galaxy far away, I used to write programs in Delphi, and then if I needed something to happen really fast, I'd write those routines in hand-written assembler. It produced much faster code than the compiler did. But is this true **in practice** any more? Obviously hand-written assembler will always be at least as fast **in principle** as compiled high-level code. But CPUs have moved on a long way since those dark times. Now, if you were trying to optimize your assembler, you'd have to take into account ordering of instructions so they could be pipelined or run concurrently, the effect of branch prediction, and a million other things; and I suspect it's impossible to hold them all in human RAM simultaneously. So does this mean that a decent (but not superhuman) programmer will these days produce faster code by writing C than by writing hand-written assembler, at least when coding for a modern CPU? One other possibility that occurs to me. Does the optimization happen *before* the high-level language is turned into assembler, or afterwards? If it's afterwards... might it be faster to produce hand-written assembler, and then put it through the compiler's optimization process? The question arose recently when I was writing some code for a programming challenge, where the essence of it was to produce a routine that should run as fast as possible on a Raspberry Pi. I would have been allowed to write it in assembler; but my guess was that carefully written C would be faster, even though a Pi processor isn't that sophisticated in 2014 terms. To make the question more concrete and specific: * Suppose you're wanting to write blazingly fast (integer) number-crunching code to run on a Raspberry Pi. You've written some very nice C code that runs as a tight loop to solve the problem. Is it worth hand-crafting it in assembler to speed it up, or will that in practice give you something less efficient?
2014/08/24
[ "https://Stackoverflow.com/questions/25469489", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3933089/" ]
To me it looks both answers given so far are correct. The answer depends, among other things, on the particular CPU architecture we're talking about. The more complex architecture is, the harder it is to write efficient ASM code by hand. On one end of the spectrum are CISC cores such as x86. They have multiple execution units, long pipelines, variable instruction latencies per instruction, etc. In many cases ASM code that looks "clean" or "optimal" to a human isn't in fact optimal for a CPU and can be improved by using instructions or techniques from dark corners of processor manuals. Compilers "know" about this and can produce decently optimised code. True, in many cases emitted code can be improved by a skilful human, but with the right compiler and optimisations settings code is often already very good. Also, with C code at hand you won't need to re-optimise it manually for every new CPU generation (yes, optimisations often depend on particular CPU family, not only on instruction set), so writing in C is a way of "future-proofing" your code. On another end of the spectrum are simple RISC cores, such as 8051 (or others *simple* 8-bit controllers). They have much simpler scheduling semantics and smaller instruction sets. Compilers still do a decent job of optimisation here, but it's also much simpler to write a decent ASM code by hand (or fix performance issues in emitted code).
1,385,852
How do we do this? Does it involve the fact that we know $f$ is continuous, and therefore the limit approaching the endpoint $1$ should be the same coming from both sides?
2015/08/05
[ "https://math.stackexchange.com/questions/1385852", "https://math.stackexchange.com", "https://math.stackexchange.com/users/259137/" ]
If $f(1)<2$ then $\epsilon=2-f(1)$ is positive. Since $f$ is continuous and $f(0)\ge 2$, then there exists some $c\in[0,1)$ such that $f(c)=2-\frac\epsilon2$. Contradiction.
13,756,250
I am using Grails and I am currently faced with this problem. This is the result of my html table ![enter image description here](https://i.stack.imgur.com/QBAZY.png) And this is my code from the gsp page ``` <tr> <th>Device ID</th> <th>Device Type</th> <th>Status</th> <th>Customer</th> </tr> <tr> <g:each in = "${reqid}"> <td>${it.device_id}</td> </g:each> <g:each in ="${custname}"> <td>${it.type}</td> <td>${it.system_status}</td> <td>${it.username}</td> </g:each> </tr> ``` So the problem is, how do I format the table such that the "LHCT271 , 2 , Thomasyeo " will be shifted down accordingly? I've tried to add the `<tr>` tags here and there but it doesn't work.. any help please?
2012/12/07
[ "https://Stackoverflow.com/questions/13756250", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1790785/" ]
I think you problem is not in the view, but in the controller (or maybe even the domain). You must have some way of knowing that `reqid` and `custname` are related if they are in the same table. You must use that to construct an object that can be easily used in a g:each You are looking for a way to mix columns and rows, and still get a nice table. I'm afraid that is not possible. **Edit** (Sorry, I just saw the last comment.) You cannot mix two items in a g:each. Furthermore, if the two things are not related you probably must not put them in the same table. There will be no way for you or for Grails, to know how to properly organize the information
5,329,947
I have an input that I'd like to put a placeholder text in, but *only if* it's respective value is an empty string. The value that should go in the textbox is echoed from a PHP array, but if this value is empty, the placeholder should be echoed instead. At the moment, I've got this code: ``` <?php echo sponsorData('address0') == '' ? 'Address Line 1' : 'Other'; ?> ``` `sponsorData()` just gets stuff from an array; it's only argument is the key. The important bit here is it returns astring. This code gives odd behaviour; I get stuff like `Hello worldAddress Line 1`, where `Hello world` is the user typed text and `Address Line 1` is obviously the placeholder. Strangely, the placeholder gets stored into the array on submission. My question is this: can someone offer a correction of my ternary operator or, if that won't work, tell me to do an inline `if` statement (blegh)? Thanks
2011/03/16
[ "https://Stackoverflow.com/questions/5329947", "https://Stackoverflow.com", "https://Stackoverflow.com/users/383609/" ]
try the following code: ``` <?php echo ((sponsorData('address0') == '') ? 'Address Line 1' : 'Other'); ?> ``` felix
27,771,899
Our .net application supports AD authentication, so our application will read from the GC connection string and credentials. We now have a client who has ADFS in their on-premise and wants to create a trust with our server which hosts the application. Do I need to write a separate code to setup as a claims-aware (or) can I use the same GC after creating the trust between client and our server?
2015/01/03
[ "https://Stackoverflow.com/questions/27771899", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2024422/" ]
you've answered your own question : "Our .net application supports AD authentication..." This is not the same s being claims aware, so yes you will need to modify the app. Once your app is claims aware they will create a relying party (that's your app) trust with some data that you will provide after it's been made claims aware. This trust will allow their server to send your app the token with whatever authorization data you require (and was defined when you set up your app). You should reach out to the clients infrastructure team to coordinate what data you would like and what they will provide.
42,099,915
I don't mean collapse, I mean hide. For example for single line comments it'd completely hide it, the editor entirely skipping the comment's line number. I'm entirely self-taught when it comes to programming, so I'm sure I've picked up numerous bad habits, one of which is almost entirely forgoing commenting. I dislike the clutter, and have only coded alone so far. I'm wanting to comment my code more, but prefer to work with distraction-free code, so was wondering if there was a way to completely hide the comments when I don't need them? (Not hiding TODO comments would be a plus). I am using Android Studio 2.2.3 on Ubuntu 16.04
2017/02/07
[ "https://Stackoverflow.com/questions/42099915", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2868017/" ]
I am not sure, whether I would recommend working without comments. However, you could switch between two schemes. The first one would be the one you are currently working with. The other would be a copy of it, but with the -distracting- comments matching the background color. [For instance like this](https://i.stack.imgur.com/s5Jgv.jpg) It would still take the space, though.
13,624
[![](https://i.stack.imgur.com/9pJC6.jpg)](https://i.stack.imgur.com/9pJC6.jpg) This is a picture of a jet of particles exiting the supermassive black hole in the center of Pictor A galaxy at nearly the speed of light. [Source](http://www.astronomy.com/news/2016/02/blast-from-black-hole-in-a-galaxy-far-far-away?utm_source=SilverpopMailing&utm_medium=email&utm_campaign=ASY_News_Sub_160205_Final%20remainder&utm_content=&spMailingID=24659256&spUserID=MTE2MjkyOTM4OTcxS0&spJobID=741050037&spReportId=NzQxMDUwMDM3S0) This event is supposedly created from a black hole of 40 million solar masses. The [full quote](http://futurism.com/distant-supermassive-black-hole-emits-giant-death-rays-larger-galaxy/) here: > > The newly released picture shows the terrifying power of an actual > supermassive black hole located in the galaxy Pictor A, some 500 > million light years distant. **This black hole is about 40 million > times the mass of the Sun (that’s about 10 times larger than the black > hole at the center of our own galaxy)**, and if it were to replace the > Sun within our Solar System, its event horizon would swallow the > orbits of both Mercury and Venus. > > > Now a quick search to [Wikipedia](https://en.wikipedia.org/wiki/List_of_most_massive_black_holes) would show a abundance of supermassive black holes many, many times larger than that supermassive black hole as well as a few that are around the same mass as that. To my question: What set of special conditions that surround this particular supermassive black hole such that it is capable of creating this spectacular event? Edit for clarity: By this I meant the jet and the hotspot.
2016/02/09
[ "https://astronomy.stackexchange.com/questions/13624", "https://astronomy.stackexchange.com", "https://astronomy.stackexchange.com/users/7926/" ]
This is a clear example of an [astrophysical jet](https://en.wikipedia.org/wiki/Astrophysical_jet), in this case, most likely a relativistic jet. In short, an accretion disk forms around a black hole (supermassive or otherwise). Matter is pulled towards the black hole and further energized, before being accelerated into a jet emanating from the black hole's poles. Two different mechanisms have been proposed for the formation of jets: * The **[Blandford-Znajek process](https://en.wikipedia.org/wiki/Blandford%E2%80%93Znajek_process)** requires that a magnetic field forms (from the accretion disk) that is centered around the black hole. Charged particles then move along the field lines, into jets. I recently wrote an answer about the details (see [How does an accreting black hole acquire magnetic fields?](https://astronomy.stackexchange.com/questions/13570/how-does-an-accreting-black-hole-acquire-magnetic-fields/13580#13580)). For this process to work, you need an accretion disk. It is generally considered the most likely explanation for black hole jets. * The **[Penrose process](https://en.wikipedia.org/wiki/Penrose_process)** takes rotational kinetic energy from the ergosphere outside the event horizon and gives it to particles moving in jets. Note that this does not rely as heavily on the accretion disk as the Blandford-Znajek process does. For this process to work, you need a rotating black hole surrounded by some matter, likely in a disk. The hotspot is, to me, much more interesting. It reminds me of structures seen around young stars: [bipolar outflows](https://en.wikipedia.org/wiki/Bipolar_outflow) (streams of gas that can form shock waves) and [Herbig-Haro objects](https://en.wikipedia.org/wiki/Herbig%E2%80%93Haro_object) (the results of shock waves from relativistic jets. Obviously, the mechanisms are different, so no clear analogy can be drawn. But what is interesting about bipolar outflows and Herbig-Haro objects is that the shock waves produced therein result from collisions with the interstellar medium. If a similar mechanism were to cause the shock waves by the hotspot, then we could conclude that the jets have hit the intergalactic medium. But I don't think this is necessarily the case, in part because of just how long these jets are prior to the formation of the hotspot. One would think that if the hotspot and shock waves are because of collisions with the intergalactic medium, the jets would be much shorter, because they would likely have reached higher density regions of it sooner. So that's why I find it interesting, and why I can't give you a good reason as to why the hotspot formed where it did, or the precise reason for it being there at all.
253,869
I upgraded my service to 200 amp from 100 amp, but the new panel is 15 ft. away. In order to connect the existing wires to the new breakers in the new panel, will just a simple connection with higher guage wire and wire nut be fine or does it require a different approach? thanks
2022/07/31
[ "https://diy.stackexchange.com/questions/253869", "https://diy.stackexchange.com", "https://diy.stackexchange.com/users/100926/" ]
Extending the existing circuits from the old panel to the new one with the same gauge wire is acceptable. There is no need to upsize the wire. If you have an excess of larger gauge wire that you are trying to use up then you can use it, provided the breakers in the new panel are listed for use with that gauge. Your old breaker panel must not have open spaces when you are done. You can leave the old (disconnected) breakers, or you can buy blanks to fill in the openings. Note that some inspectors may not let you leave the old breakers. But using the old breaker panel as an oversized junction box is fine.
2,148,135
I've looked at the [documentation](http://www.trirand.com/jqgridwiki/doku.php?id=wiki:jqgriddocs) but I've been unable to find an answer. Is there a way to prevent a row from being highlighted when selected? That or even a way to stop the row being selected at all. I like the "hoverrows: true" option, but ideally I would like to stop a row from being selected on-click. Thanks, **Update:** I've been able to "hackily" implement something which seems to be an interim fix. I don't really like it at all and would idealy like a better solution, if there is one... I have found that if I pass the option ``` onSelectRow: function(rowid, status) { $('#'+rowid).removeClass('ui-state-highlight'); } ``` when I instantiate the jqGrid, I can strip the highlight when it is added. Is there another, more ideal, way to do this?
2010/01/27
[ "https://Stackoverflow.com/questions/2148135", "https://Stackoverflow.com", "https://Stackoverflow.com/users/178383/" ]
Use the following code: ``` beforeSelectRow: function(rowid, e) { return false; } ```
454,087
I have dual boot with Ubuntu 12.04 and Windows 7, and I would like to upgrade Ubuntu to 14.04 but still retain my windows 7, help! I have a DVD with the ubuntu 14.04 ISO
2014/04/24
[ "https://askubuntu.com/questions/454087", "https://askubuntu.com", "https://askubuntu.com/users/273372/" ]
If you copy a partition with `dd`, the output file will be as big as the partition. `dd` does a physical copy of the disc, it has no knowledge of blank or used space. If you compress the result file you will save a lot of space, though, given that blank space will compress away very well (beware, this is going to be computationally *very* heavy). You can even compress the output of `dd` on the fly, with something on the line of `dd if=/dev/sdaX | gzip -c > compressed_file.gz`. really important: ----------------- > > Moreover, you **cannot** (never) do a `dd` on a live (mounted) > partition, the data recorded will be totally inconsistent and > absolutely not useful for a backup. Think about it: blocks of data are > continually allocated, moved and deleted; is like shooting a photo > with long exposure time to a moving target. > > > To copy the partition with `dd` you must boot from a different one - > live USB or whatever. > > > What would I do to solve the problem at hand (notice, only generic instruction because you need to know what you are doing) *First option* buy Norton Ghost, or explore the opensource options: [partimage](http://www.partimage.org/Main_Page) and [clonezilla](http://clonezilla.org/) (never tested myself). *Second option* do it manually: 1. create an extra partition for backups, call it /dev/sdX (or use a common data partition, whatever). 2. to backup: * boot with live usb * mount the real root partition in /real * mount the extra partition in /extra * do a big tar, on the line of `(cd /real && tar cvf /extra/mybck.tar.gz)` 3. to restore * boot with live usb * mount the real root partition in /real * mount the extra partition in /extra * restore, on the line of `(cd /real && tar xvpf /extra/mybck.tar.gz)`, beware of the `p` option to preserve metadata * chroot in /real * update grub or the bootloader you are using You can substitute `tar` with your preferred archiver, just be sure it will respect ownership/mode of files. `rsync` is worth exploring.
3,705,480
How can I use RichTextBox Target in WPF application? I don't want to have a separate window with log, I want all log messages to be outputted in richTextBox located in WPF dialog. I've tried to use WindowsFormsHost with RichTextBox box inside but that does not worked for me: NLog opened separate Windows Form anyway.
2010/09/14
[ "https://Stackoverflow.com/questions/3705480", "https://Stackoverflow.com", "https://Stackoverflow.com/users/446876/" ]
A workaround in the mean time is to use the 3 classes available [here](http://nlog.codeplex.com/workitem/6272), then follow this procedure: 1. Import the 3 files into your project 2. If not already the case, use `Project > Add Reference` to add references to the WPF assemblies: `WindowsBase, PresentationCore, PresentationFramework`. 3. In `WpfRichTextBoxTarget.cs`, replace lines 188-203 with: ``` //this.TargetRichTextBox.Invoke(new DelSendTheMessageToRichTextBox(this.SendTheMessageToRichTextBox), new object[] { logMessage, matchingRule }); if (System.Windows.Application.Current.Dispatcher.CheckAccess() == false) { System.Windows.Application.Current.Dispatcher.Invoke(new Action(() => { SendTheMessageToRichTextBox(logMessage, matchingRule); })); } else { SendTheMessageToRichTextBox(logMessage, matchingRule); } } private static Color GetColorFromString(string color, Brush defaultColor) { if (defaultColor == null) return Color.FromRgb(255, 255, 255); // This will set default background colour to white. if (color == "Empty") { return (Color)colorConverter.ConvertFrom(defaultColor); } return (Color)colorConverter.ConvertFromString(color); } ``` 4. In your code, configure the new target like this below example: I hope it helps, but it definitely does not seem to be a comprehensive implementation... ``` public void loading() { var target = new WpfRichTextBoxTarget(); target.Name = "console"; target.Layout = "${longdate:useUTC=true}|${level:uppercase=true}|${logger}::${message}"; target.ControlName = "rtbConsole"; // Name of the richtextbox control already on your window target.FormName = "MonitorWindow"; // Name of your window where there is the richtextbox, but it seems it will not really be taken into account, the application mainwindow will be used instead. target.AutoScroll = true; target.MaxLines = 100000; target.UseDefaultRowColoringRules = true; AsyncTargetWrapper asyncWrapper = new AsyncTargetWrapper(); asyncWrapper.Name = "console"; asyncWrapper.WrappedTarget = target; SimpleConfigurator.ConfigureForTargetLogging(asyncWrapper, LogLevel.Trace); } ```
61,048,540
I'm trying to serve API with ***nodeJS***, and database use ***oracle***. I've an object like this that I got from `req.body.detail`: ``` { title: "How to Have", content: "<ol><li><b>Lorem ipsum dolor sit amet.</b></li></ol>" } ``` then I do ``` const data = JSON.stringify(req.body.detail); ``` but the inserted data in table become doesn't has *escape string*, it become likes: ``` {"title":"How to Have","content":"<ol><li><b>Lorem ipsum dolor sit amet.</b></li></ol>} ``` How do I can escape string to whole object and result become like this: ``` {"title":"How to Have","content":"<ol><li><b>Lorem ipsum dolor sit amet.<\/b><\/li><\/ol>} ``` My column in table has datatype `clob`.
2020/04/05
[ "https://Stackoverflow.com/questions/61048540", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4941250/" ]
If `public class ClassName1 extends/implements ClassName` than it is perfectly valid. This is how polimorphism works - you can treat given instance as it would be a solely instance of any of its superclasses or interfaces it implements.
151,594
I cannot for the life of me figure this out. I have two monitors. If I'm focused on the left monitor, I cannot use a shortcut to switch spaces on the right monitor. Or (as often happens) I click my right monitor to focus it instead of alt tabbing, and then I cannot switch the left monitor space with my keyboard without clicking on that screen. Is there not a way to control the space of another monitor with your keyboard?
2014/10/19
[ "https://apple.stackexchange.com/questions/151594", "https://apple.stackexchange.com", "https://apple.stackexchange.com/users/96457/" ]
Ctrl-Left Arrow/Right Arrow let you scroll through spaces from the keyboard in Mavericks. Spaces are only independent if you have "Displays Have Separate Spaces" enabled under `System Preferences > Mission Control` -- with this option enabled, you should be able to switch workspaces on each monitor independently. The monitor that switches when you use the keyboard shortcut should be the monitor where the pointer currently resides.
17,351,192
**dir1\dir2\dir3\file.aspx.cs**(343,49): error CS0839: Argument missing [**C:\dir\dir\dir\dir\namespace.namespace.namespace.namespace\**project.csproj] I've been trying for hours to create a regular expression to extract just 2 areas of this string. The bold areas are the parts I wish to capture. I need to split this string into two seperate strings: 1. I'd like everything before the first "(" 2. everything between the "[" and "]" but not including the "project.csproj" For #1 the closest i've gotten is `(^.*\()` which will basically capture everything up to the first "(" (*including the bracket though which I don't want*) For #2 the closest i've gotten is `(\[.*\])` which will basically capture everything inside the brackets (*including the brackets which i don't want*). **Any of the words in the above string could change apart from ".csproj" "C:\" and ".cs"** *Context: This is how MSBuild spits errors out when compiling. By capturing these two parts I can concatenate them to provide an exact link to the erroring file and open the file in Visual Studio automatically:* ``` System.Diagnostics.Process.Start("devenv.exe","/edit path"); ```
2013/06/27
[ "https://Stackoverflow.com/questions/17351192", "https://Stackoverflow.com", "https://Stackoverflow.com/users/882993/" ]
This pattern: ``` (^[^(]*).*\[(.*)project.csproj]$ ``` Captures these groups: 1. `dir1\dir2\dir3\file.aspx.cs` 2. `C:\dir\dir\dir\dir\namespace.namespace.namespace.namespace\` If the name `project.csproj` file could change, you can use this pattern instead: ``` (^[^(]*).*\[(.*\\)[^\\]*]$ ``` This will match everything up to the last path fragment within the brackets.
36,734,566
I am working on performance storage. When I am selecting Storage Size 250/500 then no data In IOPS. When I was select storage size `100/20/80/1000/2000gb` then I am getting IOPS. I am facing problem only `250/500gb`. this is the API i am using ``` https://[username]:[apikey]@api.softlayer.com/rest/v3.1/SoftLayer_Product_Package/222/getItemPrices?objectFilter={"itemPrices": { "attributes": { "value": { "operation": 20 } }, "categories": { "categoryCode": { "operation": "performance_storage_iops" } }, "locationGroupId": { "operation": "is null" } } } ``` I am sending screenshot when i was select storage size `50/500gb` what I am getting response. So could you kindly provide the information to me. ![enter image description here](https://i.stack.imgur.com/OI7Tw.png)
2016/04/20
[ "https://Stackoverflow.com/questions/36734566", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6171678/" ]
if you have just use three array means just use if condition ``` String arraname=""; if (Arrays.asList(lac1).contains("102")) { arraname="lac1"; } if (Arrays.asList(lac2).contains("102")) { arraname="lac2"; } if (Arrays.asList(lac3).contains("102")) { arraname="lac3"; } ```
178
Suppose we want to translate the whole of Wikipedia from English into [Lojban](https://jbo.wikipedia.org/), what are the main known big limitations or concerns we should be aware of? In other words, does Lojban as a language have sufficient expressive power for being translated from English?
2018/02/08
[ "https://conlang.stackexchange.com/questions/178", "https://conlang.stackexchange.com", "https://conlang.stackexchange.com/users/30/" ]
Length ====== A few things. First, Lojban often needs longer sentences to express something than it does in, for example, English. Vocabulary ========== Secondly, Lojban's vocabulary isn't that big, especially in the domain of sciences. Words would have to be calqued, adapted from English, French, etc. or completely re-invented. Loaning and naming ================== Thirdly, the English language (and many natural languages) loans words directly (for example, *champagne* could be \*shampain and *buoy* could be \*boy or \*boi) without changing spelling (a slight counterexample would be German, which often changes the letter c pronounced [k] to the letter k, like *Kanada* and *Vokabular*). Lojban doesn't. *.romas.* is Rome (Italy), *.xavanas.* is Havanas (Cuba) and *.lidz.* is Leeds (UK). This makes it confusing in some cases. How would Lojban adapt [Turra Coo](https://en.wikipedia.org/wiki/Turra_Coo) or people like [Nelson Rolihlahla Mandela](https://en.wikipedia.org/wiki/Nelson_Mandela)? The name should stay recognisable but pronounceable.
6,935,450
``` $(window).bind("beforeunload",function(){ return "cant be seen in ff"; }); ``` The problem is that i can't see the "cant be seen in ff" on the confirm box in my FireFox browser, but works well in other browsers(IE Chrome) Any solutions??
2011/08/04
[ "https://Stackoverflow.com/questions/6935450", "https://Stackoverflow.com", "https://Stackoverflow.com/users/342366/" ]
See this: <https://bugzilla.mozilla.org/show_bug.cgi?id=588292> It looks like forefox decided to remove the support for the beforeunload as we know it.
251,927
What is the proper way to fuse and switch a power supply consisting of a bunch of SMPS like the following: [![smps power supply](https://i.stack.imgur.com/qd2vI.jpg)](https://i.stack.imgur.com/qd2vI.jpg) There would be up to 5 separate output voltages. The outputs shown are about 35W each. Other outputs would be less. So currently I have a mockup that has a single fuse and a single switch on the AC load line. Is this safe? Would it be better to use a 2 pole switch to switch in both load an neutral? Why? Should I fuse each SMPS separately? If yes, why and where? Points labelled A, B, C and D are potential locations for reference.
2016/08/12
[ "https://electronics.stackexchange.com/questions/251927", "https://electronics.stackexchange.com", "https://electronics.stackexchange.com/users/18385/" ]
> > So currently I have a mock-up that has a single fuse and a single switch on the AC load line. Is this safe? > > > The majority of devices found in the home or office are wired this way and there are few issues. The problem is that if you live in a land of non-polarised mains plugs which when reversed, can make the non-switched wire live, then the internal circuitry remains live even when the switch is off. A table lamp, for example, has a single-pole swtich and the terminals are exposed when the lamp is removed. Your setup should be much safer if boxed up properly. > > Would it be better to use a 2 pole switch to switch in both load an neutral? Why? > > > When the switch is off both lines are cut and the circuit is completely dead. > > Should I fuse each SMPS separately? If yes, why and where? > > > Check your SMPS and you should find that there is a fuse on the mains side of each. The main fuse protects the wiring inside your unit in the event of a fault. Your SMPS units will supply a total of about 100 W so will draw a max of 130 to 150 W fully loaded. In 110 V land this will be about 1.5 A and in 230 V land it will be less than 1 A. Use a 2 A or 1 A fuse as appropriate in the common live line, point 'A' as you have correctly shown. This will limit any fault current to a much lower and safer value than your mains wiring can provide.
45,200,443
the idea is within class Card I have dict ``` pack_of_cards = {'2': 2,'3': 3,'4': 4,'5': 5,'6': 6, \ '7': 7,'8': 7,'9': 9,'10': 10,'J': 10, \ 'D': 10,'K': 10,'T': 10} ``` I need this class to return a random set of key and value as a dict. For example: ``` Card() == {'T': 10} ``` Thanks to everyone.
2017/07/19
[ "https://Stackoverflow.com/questions/45200443", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8291387/" ]
You can do this using a method in the `random` module, but it wouldn't make sense unless your `Card` class implements an `__eq__` method. Example: ``` In [450]: class Card: ...: def __init__(self, suite, num): ...: self.suite = suite ...: self.num = num ...: ...: def __eq__(self, item): ...: k, v = list(item.items())[0] ...: return True if (self.suite == k and self.num == v) else False ...: In [452]: c = Card('T', 10) In [454]: c == {'T' : 10} Out[454]: True ``` Now that you have a working class, you can use `random.choice` to extract a card: ``` In [470]: x = random.choice(list(pack_of_cards.items())) In [471]: dict([x]) Out[471]: {'D': 10} ```
37,261,889
I have handle that I got via `stdinHandle = GetStdHandle(STD_INPUT_HANDLE)` and I have separate thread which execute such code: ``` while (!timeToExit) { char ch; DWORD readBytes = 0; if (!::ReadFile(stdinHandle, &ch, sizeof(ch), &readBytes, nullptr)) { //report error return; } if (readBytes == 0) break; //handle new byte } ``` where `timeToExit` is `std::atomic<bool>`. I wan to stop this thread from another thread. I tried this: ``` timeToExit = true; CloseHandle(stdinHandle); ``` and code hangs in `CloseHandle`. The code hangs while program is running by other program that uses `CreatePipe` and `DuplicateHandle` to redirect input of my program to pipe. So how should I stop `while (!timeToExit)..` thread in win32 way? Or may be I should some how change `while (!timeToExit)..` thread to make it possible to stop it? **Update** I thought about usage of `WaitForMultipleObjects` before call of `ReadFile` with stdin and event as arguments, and trigger event in other thread, but there is no mention of anonymous pipe as possible input for `WaitForMultipleObjects`, plus I tried when stdin connected to console, and it become useless (always return control without delay) after the first character typed into console, looks like I have to use `ReadConsoleInput` in this case, instead of `ReadFile`?
2016/05/16
[ "https://Stackoverflow.com/questions/37261889", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1034749/" ]
When reading from a console's actual STDIN, you can use [`PeekConsoleInput()`](https://msdn.microsoft.com/en-us/library/windows/desktop/ms684344.aspx) and [`ReadConsoleInfo()`](https://msdn.microsoft.com/en-us/library/windows/desktop/ms684961.aspx) instead of `ReadFile()`. When reading from an (un)named pipe, use [`PeekNamedPipe()`](https://msdn.microsoft.com/en-us/library/windows/desktop/aa365779.aspx) before calling `ReadFile()`. This will allow you to poll STDIN for new input before actually reading it, and then you can check your thread termination status in between polls. You can use [`GetFileType()`](https://msdn.microsoft.com/en-us/library/windows/desktop/aa364960.aspx) to detect what kind of device is attached to your `STD_INPUT_HANDLE` handle.
65,171,888
I tried to shuffle two matrices. And before shuffling I tried to concatenate them since it looked easier. (Since you wanted examples)For ex first matrix is: ``` A = [[ 1. 2. 3. 4] [ 1. 5. 6. 7] [ 1. 8. 9. 9] [ 1. 2. 1. 7] [ 1. 5. 5. 6] [ 1. 2. 3. 2] [ 1. 1. 4. 6]] ``` And the second is: ``` B = [ 1. 2. 3. 4. 5. 6. 7.] ``` Then how can I shuffle them?By shuffling I want to do something like this: first element of A will change places with first element of B. And the output will be: ``` A = [[ 1.] [ 1. 5. 6. 7] [ 1. 8. 9. 9] [ 1. 2. 1. 7] [ 1. 5. 5. 6] [ 1. 2. 3. 2] [ 1. 1. 4. 6]] B = [ 1. 2. 3. 4]. 2. 3. 4. 5. 6. 7.] ``` Is it possible? I hope the question is more understandable now, thanks for helping.
2020/12/06
[ "https://Stackoverflow.com/questions/65171888", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9314444/" ]
It's not possible to concatenate two matrixes with different dimensions since the result matrix would be ambiguous. You can either pad the smaller matrix with the same datatype (usually floats or integers) to fit the size of the larger matrix ```py >>> result = np.full(fill_value=0, shape=b.shape) >>> offset = (0, 0) # you can even set an offset >>> result[offset[0]:a.shape[0]+offset[0],offset[1]:a.shape[1]+offset[1]] = a ``` or slice the larger one to fit the size of the smaller one. ```py >>> b[:a.shape[0],:a.shape[1]] ``` Since you ask such a general question it's hard to know what exactly the solution could be.
16,315,042
Below is my code ``` DirectoryInfo directoryInfo = new DirectoryInfo(@"C:\Users\Shahul\Documents\Visual Studio 2010\Projects\TreeView\TreeView\bin\FileExplorer"); private void Form1_Load(object sender, EventArgs e) { if (Directory.Exists("FileExplorer")) { try { DirectoryInfo[] directories = directoryInfo.GetDirectories(); foreach (FileInfo file in directoryInfo.GetFiles()) { if (file.Exists) { TreeNode nodes = treeView.Nodes[0].Nodes.Add(file.Name); } } if (directories.Length > 0) { foreach (DirectoryInfo directory in directories) { TreeNode node = treeView.Nodes[0].Nodes.Add(directory.Name); node.ImageIndex = node.SelectedImageIndex = 0; foreach (FileInfo file in directory.GetFiles()) { if (file.Exists) { TreeNode nodes = treeView.Nodes[0].Nodes[node.Index].Nodes.Add(file.Name); } } } } } catch (Exception ex) { MessageBox.Show(ex.Message); } } } ``` When I run I just get a blank treeview form? Unable to figure out what is the error? Btw this my first post in Stack Overflow.
2013/05/01
[ "https://Stackoverflow.com/questions/16315042", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2338764/" ]
This should solve your problem, I tried on WinForm though: ``` public Form1() { InitializeComponent(); DirectoryInfo directoryInfo = new DirectoryInfo(@"C:\Users\hikuma\Documents\IR"); if (directoryInfo.Exists) { treeView1.AfterSelect += treeView1_AfterSelect; BuildTree(directoryInfo, treeView1.Nodes); } } private void BuildTree(DirectoryInfo directoryInfo, TreeNodeCollection addInMe) { TreeNode curNode = addInMe.Add(directoryInfo.Name); foreach (FileInfo file in directoryInfo.GetFiles()) { curNode.Nodes.Add(file.FullName, file.Name); } foreach (DirectoryInfo subdir in directoryInfo.GetDirectories()) { BuildTree(subdir, curNode.Nodes); } } private void treeView1_AfterSelect(object sender, TreeViewEventArgs e) { if(e.Node.Name.EndsWith("txt")) { this.richTextBox1.Clear(); StreamReader reader = new StreamReader(e.Node.Name); this.richTextBox1.Text = reader.ReadToEnd(); reader.Close(); } } ``` It is a simple example of how you can open file in rich text box, it can be improved a lot :). You might want to mark as answer or vote up if it helped :) !!
15,509,300
I'm creating an Oracle Report and I would like to display certain results based on when I print the report. There is a field called apply\_date. For example, if I print the report <= sysdate of 3/15 then I only want to display the records that have an apply\_date of 3/1 - 3/15. This also goes for printing on the 30th of each month. If I print the report after 3/15 then it would only show me the results that have an apply\_date of >= 3/16.
2013/03/19
[ "https://Stackoverflow.com/questions/15509300", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2188170/" ]
If you don't care much about the fiddly bits of column alignment, this isn't too bad: ``` datapoints = [{'a': 1, 'b': 2, 'c': 6}, {'a': 2, 'd': 8, 'p': 10}, {'c': 9, 'd': 1, 'z': 12}] # get all the keys ever seen keys = sorted(set.union(*(set(dp) for dp in datapoints))) with open("outfile.txt", "wb") as fp: # write the header fp.write("{}\n".format(' '.join([" "] + keys))) # loop over each point, getting the values in order (or 0 if they're absent) for i, datapoint in enumerate(datapoints): out = '{} {}\n'.format(i, ' '.join(str(datapoint.get(k, 0)) for k in keys)) fp.write(out) ``` produces ``` a b c d p z 0 1 2 6 0 0 0 1 2 0 0 8 10 0 2 0 0 9 1 0 12 ``` As mentioned in the comments, the [pandas](http://pandas.pydata.org) solution is pretty nice too: ``` >>> import pandas as pd >>> df = pd.DataFrame(datapoints).fillna(0).astype(int) >>> df a b c d p z 0 1 2 6 0 0 0 1 2 0 0 8 10 0 2 0 0 9 1 0 12 >>> df.to_csv("outfile_pd.csv", sep=" ") >>> !cat outfile_pd.csv a b c d p z 0 1 2 6 0 0 0 1 2 0 0 8 10 0 2 0 0 9 1 0 12 ``` If you really need the columns nicely aligned, then there are ways to do that too, but I never need them so I don't know much about them.
41,921,530
I have a little dilemma with the decision part of my form. I'm attempting to create a form with radio buttons and a checkbox in an html page but I would like to retrieve data from my .php page. I think there's an issue with the .php portion of the code. I'm getting a response from each 'if' statement regardless of the selections I make. for Example - If I select radio1 & checkbox I get "Radio One AND checkbox.Radio Two AND checkbox.Radio Three AND checkbox." This is the type of result with any query. Suggestions ? HTML FORM ```html // start the query string var QueryString = "form_test.php?"; if (document.getElementById("radio1").checked == true && document.getElementById("box").checked) { QueryString = QueryString + "radio1=" + document.getElementById("radio1").value + "box=" + document.getElementById("box").value; } else if (document.getElementById("radio2").checked == true && document.getElementById("box").checked) { QueryString = QueryString + "radio2=" + document.getElementById("radio2").value + "box=" + document.getElementById("box").value; } else if (document.getElementById("radio3").checked == true && document.getElementById("box").checked) { QueryString = QueryString + "radio3=" + document.getElementById("radio3").value + "box=" + document.getElementById("box").value; } //alert(QueryString); xmlHttp.open("GET", QueryString, true); xmlHttp.send(null); } </script></head> <body> <p>Test Form</p> <form id="myform" name="myform" method="POST"> <p> <input type="radio" name="radbutton" id="radio1"> <label>Radio One</label> </p> <p> <input type="radio" name="radbutton" id="radio2"> <label>Radio Two</label> </p> <p> <input type="radio" name="radbutton" id="radio3"> <label>Radio Three</label> </p> <p> <input type="checkbox" name="check" id="box"> <label>CheckBox</label> </p> <input type="button" name="button" id="button" value="Test Form" onclick="ajaxFunction();"/> </p> </form> <p> <div id="OutputPane"> </div> </p> </body> </html> ``` PHP CODE ```html <?php if ((isset($_GET['radio1']) || isset($_GET['box']))) { echo "Radio One AND checkbox."; } else { echo "Radio One"; } if ((isset($_GET['radio2']) || isset($_GET['box']))) { echo "Radio Two AND checkbox."; } else { echo "Radio Two."; } if (isset($_GET['radio3']) || (isset($_GET['box']))) { echo "Radio Three AND checkbox."; } else { echo "Radio Three."; } ?> ```
2017/01/29
[ "https://Stackoverflow.com/questions/41921530", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7422381/" ]
There are few issues with your code, such as: * There's no `value` attribute in your radio buttons, so you won't get anything with `document.getElementById("radioX").value`. Add a `value` attribute in your radio buttons, ``` <input type="radio" name="radbutton" id="radioX" value="radioX" /> ``` * Missing `&` between `radioX=...box=...`. It should be like this, ``` ... document.getElementById("radioX").value + "&box=" + ... ``` * Change your `QueryString` in the following way, ``` QueryString = QueryString + "radio=" + ... ``` Because in the way it'd be easier for you to access `$_GET['radio']` values in the backend PHP page. * Change `<div id="OutputPane">` to `<div id="DisplayBox"></div>`. So your code should be like this: **HTML** ``` <p>Test Form</p> <form id="myform" name="myform" method="POST"> <p> <input type="radio" name="radbutton" id="radio1" value="radio1" /> <label>Radio One</label> </p> <p> <input type="radio" name="radbutton" id="radio2" value="radio2" /> <label>Radio Two</label> </p> <p> <input type="radio" name="radbutton" id="radio3" value="radio3"> <label>Radio Three</label> </p> <p> <input type="checkbox" name="check" id="box"> <label>CheckBox</label> </p> <input type="button" name="button" id="button" value="Test Form" onclick="ajaxFunction();"/> </p> </form> <p> <div id="DisplayBox"></div> </p> ``` **Javascript** ``` // start the query string var QueryString = "form_test.php?"; if (document.getElementById("radio1").checked == true){ QueryString += "radio=" + document.getElementById("radio1").value; } else if (document.getElementById("radio2").checked == true){ QueryString += "radio=" + document.getElementById("radio2").value; } else if (document.getElementById("radio3").checked == true){ QueryString += "radio=" + document.getElementById("radio3").value; } if(document.getElementById("box").checked){ QueryString += "&box=" + document.getElementById("box").value; } ``` **PHP** ``` $str = ''; if(isset($_GET['radio'])){ switch($_GET['radio']){ case 'radio1': $str .= 'Radio One'; break; case 'radio2': $str .= 'Radio Two'; break; case 'radio3': $str .= 'Radio Three'; break; } } if(isset($_GET['box'])){ $str .= !empty($str) ? ' AND ' : ''; $str .= 'Checkbox'; } echo $str; ```
17,691,691
If you close a GUI using the the little X in the top right of the form, does that kill all your threads as well? If not, how to you catch that event so I can put in some close down code?
2013/07/17
[ "https://Stackoverflow.com/questions/17691691", "https://Stackoverflow.com", "https://Stackoverflow.com/users/758323/" ]
``` setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); ``` To execute some code on closing have a look at this. [close window event in java](https://stackoverflow.com/questions/1984195/close-window-event-in-java)
54,547,061
How can I get the following effect with FFMPEG? [![enter image description here](https://i.imgur.com/8KeRNk5.gif)](https://i.imgur.com/8KeRNk5.gif) I know I have to do it with Zoompan, but the truth is, I've been trying for a while and I can not!
2019/02/06
[ "https://Stackoverflow.com/questions/54547061", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6726976/" ]
The below pom.xml would suffices your requirement and this [tutorial](https://www.journaldev.com/21816/mockito-tutorial) will help you for better understanding how to work with mockito using maven ``` <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>BlackJack</groupId> <artifactId>BlackJack</artifactId> <version>0.0.1-SNAPSHOT</version> <dependencies> <dependency> <groupId>org.mockito</groupId> <artifactId>mockito-core</artifactId> <version>2.24.0</version> <scope>test</scope> </dependency> </dependencies> <build> <sourceDirectory>src</sourceDirectory> <testSourceDirectory>test</testSourceDirectory> <resources> <resource> <directory>src</directory> <excludes> <exclude>**/*.java</exclude> </excludes> </resource> </resources> <plugins> <plugin> <artifactId>maven-compiler-plugin</artifactId> <version>3.8.0</version> <configuration> <source>1.8</source> <target>1.8</target> </configuration> </plugin> </plugins> </build> </project> ```
44,266,435
When clicking on "a" anchor tag I want to redirect from one controller(HomeController.cs) to another controller(CartController.cs) index [GET] and and execute code and return data to view(cart/index.cshtml). Here is the js code ``` $(document).on('click', '.btn-margin', function () { if (parseInt($('#UserID').val()) > 0) { var pmID = $(this).attr("id"), bid = $(this).attr("brand-id"); $.ajax({ url: '@Url.Action("index", "cart")', data: { "id": pmID, "bid" : bid }, type: 'GET', dataType: 'json', success: function (response) { }, error: function (xhr, status, error) { } }); } }); ``` and in CartController ``` [HttpGet] public ActionResult Index(long id = 0, long bid = 0) { GetStates(); return View(productBL.GetProductById(id, bid)); } ``` As expected it has to redirect to index.cshtml of cart.. but my result is still in homeController of index.cshtml page. Please help me out how to get the expected result..
2017/05/30
[ "https://Stackoverflow.com/questions/44266435", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5663668/" ]
I may be a little bit late, but: You do not need anything special, it's simply formating. Put label on top of form, wrap both label and select in a div, then adjust background colors and borders. See the example: ```css .select-wrap { border: 1px solid #777; border-radius: 4px; margin-bottom: 10px; padding: 0 5px 5px; width:200px; background-color:#ebebeb; } .select-wrap label { font-size:10px; text-transform: uppercase; color: #777; padding: 2px 8px 0; } select { background-color: #ebebeb; border:0px; } ``` ```html <div class="select-wrap"> <label>Color</label> <select name="color" style="width: 100%;"> <option value="">---</option> <option value="yellow">Yellow</option> <option value="red">Red</option> <option value="green">Green</option> </select> </div> ``` --- **UPDATE** I somehow remembered that I have this post. As I have improved it for personal usage, and this is version is better (you can click anywhere inside select - it will trigger dropdown, while on previous version you couln't) I thought I should share an update I have made to my code and used since. ```css .select-wrap { border: 1px solid #777; border-radius: 4px; padding: 0 5px; width:200px; background-color:#fff; position:relative; } .select-wrap label{ font-size:8px; text-transform: uppercase; color: #777; padding: 0 8px; position: absolute; top:6px; } select{ background-color: #fff; border:0px; height:50px; font-size: 16px; } ``` ```html <div class="select-wrap"> <label>Color</label> <select name="color" style="width: 100%;"> <option value="">---</option> <option value="yellow">Yellow</option> <option value="red">Red</option> <option value="green">Green</option> </select> </div> ```
27,952
Mit „was“ meine ich hier das **neutrale** [Interrogativadverb – auch: Frageadverb](https://de.wikipedia.org/wiki/Interrogativadverb), mit dem man sich z.B. nach einem Gegenstand erkundigt: „Was hältst du in der Hand?“, im Gegensatz zu dem *persönlichen* Frageadverb „wer“, dessen Genitiv definitiv „wessen“ lautet. Aber wie bildet man den Genitiv von „was“? Auf [cafe-lingua.de](http://www.cafe-lingua.de/deutsche-grammatik/genitiv-wessen-fall.php) steht, er laute auch „wessen“. Ist es also korrekt, wenn ich frage „Wessen Dach stürzte ein?“ – „Das des Hauses.“ Für mich hört sich diese Kombination falsch an, da ich „wessen“ immer mit der Frage nach einem Menschen assoziiere. M.E. müsste die Antwort hier lauten: „Peters Dach stürzte ein.“ Laut [Wiktionary](https://en.wiktionary.org/wiki/wessen) gilt „wessen“ hingegen nur als der Genitiv von „wer“. Der [Duden](http://www.duden.de/rechtschreibung/wessen) sagt: > > **wes­sen**: Genitiv von wer und was > > > Gehen wir also davon aus, dass „wessen“ auch für Neutra gilt. Nehmen wir folgenden Satz als Beispiel: „Das Feuer ließ das Dach einstürzen.“ Wie bilde ich den Fragesatz nach der *Ursache* des Einsturzes mit „aufgrund ...“? * „Aufgrund *wessen* stürzte das Dach ein?“ Mit dieser Frage wird suggeriert, dass die Ursache menschlicher Herkunft ist. Ich möchte aber lediglich unvoreingenommen nach dem Grund fragen! Dieser Satz sollte nur ein Beispiel dafür sein, dass ich „wessen“ für menschlich halte. Ein getrenntes Betrachten von „wessen“ und „aufgrund wessen“ ergibt vermutlich keinen Sinn. Deswegen verbleibt die Grundfrage: Wie bildet man den (neutralen) Genitiv von „was“?
2016/02/01
[ "https://german.stackexchange.com/questions/27952", "https://german.stackexchange.com", "https://german.stackexchange.com/users/19609/" ]
*Wessen* ist der korrekte Genitiv zu *was* (und *wer*). *Aufgrundwessen* existiert nicht (zumindest nicht im Duden; gehört habe ich es auch noch nie). Nach der Ursache kann man z.B. mit *weshalb*, *warum*, *wieso* fragen.
51,848,564
I have run into the problem of sending data, a simple int type, from a dialogue fragment to all the fragments within a viewpager. I have an activity that hosts both the dialogue fragment and the viewpager. I know how to send data from the dialogue fragment to the activity using an interface defined in the dialogue fragment and implementing it within the activity itself. I was thinking maybe it had something to do with the onAttach method but i am not sure. i feel i am overlooking a simple solution here. please help! thanks!
2018/08/14
[ "https://Stackoverflow.com/questions/51848564", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7180267/" ]
Your call to `ToListAsync()` is returning a `Task`, which may not have completed executing by the time you return from the method. The best solution would be to make the method async, like so: ``` public async Task<IActionResult> GetApplications() { var result = await context.Applications.Include(a=> a.AplicantCompany) .Include(c=>c.CreditorCompany) .ToListAsync(); return Ok(result); } ``` These changes will cause the method to wait for all the results before continuing to the `return` statement, while allowing other requests to run while this one is waiting for its data. The second case probably won't work, as EF wants to load the entire entity with `Include`. If you want to load another entity that's referenced by `AplicantCompany`, you can use ``` .Include(a => a.AplicantCompany).ThenInclude(c => c.Entity) ``` Actually, according to [this answer](https://stackoverflow.com/a/46477084/1210520), you might be able to do (I haven't tried it): ``` var result = await context.Applications.Select(a => new { Application = a, CreditorCompany = a.CreditorCompany.Name, ApplicantCompany = a.AplicantCompany.Name}).ToListAsync(); ```
66,996,455
I am fairly new to R and I would like to paste the string "exampletext" in front of each file name within the path. ``` csvList <- list.files(path = "./csv_by_subject") %>% paste0("*exampletext") ``` Currently this code renders things like "csv\*exampletext" and I want it to be \*exampletextcsv". I would like to continue to using dplyr and piping - help appreciated!
2021/04/08
[ "https://Stackoverflow.com/questions/66996455", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10524382/" ]
As others pointed out, the pipe is not necessary here. But if you do want to use it, you just have to specify that the second argument to `paste0` is "the thing you are piping", which you do using a period (.) ``` list.files(path = "./csv_by_subject") %>% paste0("*exampletext", .) ```