INSTRUCTION
stringlengths
25
999
RESPONSE
stringlengths
0
999
SOURCE
stringlengths
16
38
METADATA
dict
KDE: shortcut to screenshot directly to clipboard I'm looking for a way to put a rectangular screenshot directly (IE, without GUI interaction) into the clipboard -- it's a feature I used several times a day back in my bad old days with Gnome, but Spectacle has nothing like it. I'm not above scripting it, and I've seen a couple of references to using xclip. Unfortunately, I've probably got an hour into trying this, and it simply doesn't work for me. * Does the xclip method work for you in a modern KDE? * gnome-screenshot doesn't work for me in KDE. Spectacle lacks the functionality I need. Is there another KDE-compatible clipboard app that you can recommend that will do this?
Had lots of discussion and comments on the KDE sub on reddit. The final choice involved maim, xclip, and klipper config. After unsetting Klipper's option to "ignore images," the standard xclip instructions appear to work. Of the many screenshot options suggested, `maim` has the best options and requires only two clicks (and no keyboard) to make a rectangular selection. My final command looks like: `maim -s /tmp/ss.png && xclip -sel clip -t image/png -i /tmp/ss.png` A big part of my problem was that I was testing with thunderbird, which doesn't (seem to) comprehend image/png clipboards. If you want thunderbird to work, you need to clip it as `-t text/html`, thus: echo "<img src='data:image/png;base64,"$(base64 -w0 "/tmp/ss.png")"' />" \ | xclip -selection clipboard -t text/html -i
stackexchange-askubuntu
{ "answer_score": 1, "question_score": 4, "tags": "kde, clipboard" }
Check whether user is logged in or not and require different pages depending on that I have a webpage that has sensitive information, that I do not want logged out users to access, and that's why I need to include different menus depending on whether the user is logged in or not. This is the code I have right now. if(!isset($_SESSION['user']) || isset($_SESSION['user'])=="") { require('menu.php'); } if else(isset($_SESSION['user']) || isset($_SESSION['user'])!="") { require('homemenu.php'); } But it doesn't show any of the menus no matter how I proceed with it. Any ideas on how to do this? Thanks.
Ensure that you have initiated the session by adding `session_start()` at top of your page on both login page (during registering session and on current page) and then use this shortened version of your conditions: if(isset($_SESSION['user']) AND $_SESSION['user'] != '') { require ('homemenu.php'); } else { require ('menu.php'); }
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "php, sql" }
Forgot 4wd on on jeep patriot I have a Jeep Patriot 2.0 crd 2007 with 4wd. I went fishing and used the 4wd when leaving. Once i hit the tarmac i forgot to switch it off and drive 10 miles to home doing a speed of 50MPH. Is this dangerous for the transmission in any way? Thank you! * * * No unusual sounds. Thank you for your reply. I only pushed the 4wd button and did not deactivate the ESP.
I'm assuming that model has a simple 4WD transfer case and not one with a front-to-rear differential. That means that there is no "slip" in the driveline. Generally you feel this when you try to turn at low speeds as a "binding" often accompanied by creaking or popping. For a vehicle in normal condition, this causes no damage other than slipping the tires. If the vehicle is damaged, however, the added stress of this may cause something to break but that's unusual in my experience. 4WD vehicles are designed to handle this, it's not a good practice because it causes difficulty in steering under some circumstances and hurts fuel-economy but should not cause any long-term damage to your driveline. If the vehicle has a fancier transfer case, then there is slip allowed there and there is no issue at all. Often these vehicles say "Full Time 4WD" or similar.
stackexchange-mechanics
{ "answer_score": 4, "question_score": 3, "tags": "jeep, 4wd" }
Changing the value of an element of an list within a list Kotlin error I have `var layout = mutableListOf<MutableList<Int>>()` and I am trying to replace the element `layout[pr][pc] = 0` For: `pr = 1 and pc = 2` I got `[[-1, -1, 0, -1, -1], [-1, -1, 0, -1, -1], [-1, -1, 0, -1, -1], [-1, -1, 0, -1, -1]]` Instead of `[[-1, -1, -1, -1, -1], [-1, -1, 0, -1, -1], [-1, -1, -1, -1, -1], [-1, -1, -1, -1, -1]]`
Like @kabanus mentioned, the inner list is not mutable. If you really want it mutable you can define it like, var layout = mutableListOf<MutableList<Int>>()
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": -1, "tags": "kotlin" }
Erro ao converter data php Estou recebendo a seguinte data de um formulário: `26/09/2016` preciso converte-la para: `2016-09-01` estou usando o seguinte comando: `$v_data= date('Y-m-d', strtotime($data));` só que esta dando o seguinte retorno: `1970-01-01`, o que estaria errado ?
Se você está recebendo a data do mysql e quer converter para o formato brasileiro use o seguinte comando: $data = implode("/", array_reverse(explode("-", $data))); Isto vai criar a data do mysql em formato brasileiro. Se você quer preparar a data em formato brasileiro para inserir no mysql use: $data = implode("-", array_reverse(explode("/", $data)));
stackexchange-pt_stackoverflow
{ "answer_score": 4, "question_score": 1, "tags": "php, data" }
Why is the word 'appetite' appropriate in this context? In his book about Bill Clinton, Christopher Hitchens describes how, in a 1992 speech on an event hosted by Jesse Jackson, Clinton "ambushed" Jackson by picking a fight with certain anti-White rap lyrics. Hitchens relates how, in reaction to this, Jackson "exasperatedly described the hungry young candidate as 'just an appetite'" Why does Jackson use 'appetite' here? Is this an idiom I'm not familiar with? I do see the potential wordplay on 'hungry' but I wonder if that's really supposed to be the punchline here. Since if it was, it seemed a bit off-target for Jackson quite clearly intended to rebuke the presidential candidate's _behaviour_ , which is something else entirely than scoffing his _hunger_ for office.
It's poorly expressed. Hitchens sometimes had editing that was slighlty sloppy. Here it is expressed more clearly: > Jesse Jackson said in 1992: ''I can maybe work with him but I know now who he is, what he is. There is nothing this man won't do. He is immune to shame. Move past all the nice posturing and get really down in there in him, you find absolutely nothing . . . nothing but an appetite." > > Senator Bob Kerrey, the Nebraska Democrat, was a bit gentler: ''Clinton's an unusually good liar, unusually good.'' > > Both quotes come from William J. Bennett's solidly valuable new book, ''The Death of Outrage -- Bill Clinton and the Assault on American Ideals'' (The Free Press). Read it, particularly if you are sure you won't agree. In other words, it's an image: "He's nothing but an appetite." In other words, he wants to gobble everything up for himself, is my reading. New York Times
stackexchange-english
{ "answer_score": 1, "question_score": 0, "tags": "meaning, expressions, idioms" }
How can I get which part of an if expression is true? Assume I have code like: if(condition1 || condition2 || condition 3 || condition4) { // this inner part will be executed if one of the conditions is true. // Now I want to know by which condition this part is executed. }
I'm sure there are better ways to do this, here's one: int i = 0; auto check = &i->bool { if (!b) ++i; return b; }; if (check(false) || // 0 check(false) || // 1 check(true) || // 2 check(false)) // 3 { std::cout << i; // prints 2 }
stackexchange-stackoverflow
{ "answer_score": 5, "question_score": 1, "tags": "c++, objective c, c, if statement" }
How can I get all network requests and full response data when loading a page by Puppeteer-sharp? I`m trying to get all network requests (as in the chrome dev tools network tab) by Puppeteer-sharp, like it works with JS Puppeteer: const page = await browser.newPage(); page.on('response', async (response) => {} I cant find the solution in documentation of Puppeteer-sharp.
You can use the Response event: var page = await browser.NewPageAsync(); page.Response += (sender, e) => { Console.WriteLine(e.Response.Url); }
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "c#, web scraping, puppeteer, puppeteer sharp" }
Drupal 7: active main menu when click menu block's menu I have 3 content type HTML HTML4 HTML5 2 menu block HTML4 HTML5 In my main menu have 2 menu links (HOME | HTML) HTML4 (menu block) show the contents of HTML4 (content type). I configured the HTML4 and HTML5 (2 menu block) should be appear when user click the HTML (main menu). It is fine. My question is : how to active(highlighting) HTML(main menu) when the user click a link from the HTML4 or HTML5 (2 menu block) ? Solution : I found the module name is "menu position" < This module make relationship between the main menu and content type.
Well to do that: 1> make sure you are using your own theme. 2> Write the css for the menu to highlight when one clicks inside. ## To Know when the child of the menu is clicked Use `jQuery` to check for the children being clicked and add the highlight class to the menu name using $('#MenuDiv').addClass('highlightClass'); If you post code of your menu, maybe I can help from jQuery point of view.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "drupal, drupal 7" }
Scikit-learn: ARI score for cluster evaluation I am calculating the Adjusted Rand index score for evaluating the cluster performance. Suppose, the true cluster and predicted cluster looks like the following. The format `{i, "x"}` tells that the element `"x"` is in `ith` cluster. >>> labels_true = [{0,"a"}, {0,"b"}, {0,"c"}, {1,"d"}, {1,"e"}, {1,"f"}] >>> labels_pred = [{0,"a"}, {0,"b"}, {1,"c"}, {1,"d"}, {2,"e"}, {2,"f"}] >>> metrics.adjusted_rand_score(labels_true, labels_pred) The ARI score is coming 1.0, but it seems it should not be 1.0 as the predicted cluster is different from the true one. I am wondering if it is a valid way to calculate ARI score.
you just have to put the labels in the ARI score fonction : `labels_true = [0, 0, 0, 1, 1, 1]` `labels_pred = [0, 0, 1, 1, 2, 2]` `metrics.adjusted_rand_score(labels_true, labels_pred)`
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 2, "tags": "python, scikit learn, cluster analysis" }
Export all subsites I am looking for a quick way to export all sub-sites from a web application and exclude the root url, is there a quick way to accomplish this?
maybe this can help : Get-SPSite | Get-SPWeb | Where-Object { $_.ParentWeb -Ne $null } | ForEach-Object { Export-SPWeb -Identity $_ -Path $_.ID } you will need to adjust the export params according your needs
stackexchange-sharepoint
{ "answer_score": 0, "question_score": 0, "tags": "powershell, stsadm, export" }
Are the strong and the weak operator topology well defined in abstract C* and Von Neumann algebras? If $A$ is an abstract $C^*$ algebra, then a $A$ is isometrically isomorphic to a subalgebra of bounded operators $B(H)$ for some Hilbert space $H$. We can restrict the weak operator toplogy and the strong operator topology of $B(H)$ to $A$. Are these definitions independent of $H$? And what about the case of $A$ being an abstract Von Neummann Algebra (a $C^*$ algebra who has a predual)?
No, the weak and strong operator topologies depend strongly on the chosen representation. For example, if you represent $C([0,1])$ on $L^2([0,1])$ by multiplication operators, then the functions $$f_n(x) = x^n$$ converge strongly to zero. However, if you take the direct sume of that representation with the one dimensional representation corresponding to the character $$f\mapsto f(1),$$ then the $f_n$ do not converge strongly to any $f$ in $C([0,1])$.
stackexchange-math
{ "answer_score": 2, "question_score": 1, "tags": "operator theory, operator algebras" }
Vue filter by two properties in same filter I have created a simple Vue app that I would like to filter by both the name of a city as well as the code (value). Is this possible? I know the right way to go is using Vue computed but for some reason I just can't link this one up. < new Vue({ el: '#app', data() { return { findName: '', options: [ {"text":"Aberdeen","value":"ABZ"}, {"text":"Belfast","value":"BHD"}, {"text":"Bradford","value":"BRF"} ] } }, computed: { filteredNames() { let filter = new RegExp(this.findName, 'i') return this.options.filter(el => el.match(filter)) } } })
You just need to filter on the properties of your list of options. Check this fiddle: < The changed code: return this.options.filter(el => el.text.match(filter) || el.value.match(filter))
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "vue.js" }
"off topic" en castellano `"Off topic"` es un término que se usa regularmente hoy en día, preferentemente en temas informáticos pero cada vez más en temas más generales. Sin embargo, no deja de ser un anglicismo al que creo que debería corresponderle algún término equivalente en castellano. ¿Cuál sugieren? Leyendo el artículo de Wikipedia no encuentro ninguna, pero en Wordreference veo `"que no viene al caso"` o `"sin relación al tema"`.
Yo propongo la expresión: > Fuera de ámbito Funcionaría bien en un contexto como este foro, donde puedes cerrar una pregunta porque está `fuera de(l) ámbito` del sitio. Es una expresión un poco más corta ya sencilla que "No viene al caso" o "Sin relación con el tema" o incluso "está fuera de lugar" (una de las propuestas en el enlace a _Wordreference_ que aporta la pregunta, y que puede tener otras connotaciones distintas a _off topic_ ).
stackexchange-spanish
{ "answer_score": 6, "question_score": 13, "tags": "traducción" }
Template method with one of the types being itself a template class class Foo { public: template<typename SignalType, typename ...Arguments> void invokeQueued(SignalType<Arguments...>& signal, const detail::identity<Arguments>&... args) { m_threadSyncQueue.invokeQueued(signal, tag, std::forward<Arguments>(args)...); } } This code generates enormous number of errors in all the .cpp files it's included into, starting with > unrecognizable template declaration/definition in the first `invoke` parameter. How to make it work?
You should use template template parameter. template<template<typename...> class SignalType, typename... Arguments>
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": 0, "tags": "c++, templates" }
Why Mule http inbound endpoint is always GET request Why Mule http inbound endpoint is always GET request. I'm logging type of http method and it always logs type is GET even I specified method type PUT in http inbound end point. <http:inbound-endpoint exchange-pattern="request-response" path="testPath" doc:name="HTTP" host="localhost" port="8083" mimeType="application/json" method="PUT"/> <logger level="INFO" message="method type #[message.inboundProperties['http.method']]" doc:name="Logger"/> <--- It always logs method is GET It never go into following expression block: <choice doc:name="Choice"> <when expression="#[message.inboundProperties['http.method']=='PUT']"> I would like to set http method as a "PUT" in http inbound endpoint
The `method` attribute on `http:inbound-endpoint` is ineffective: you can put any value there, it won't change anything. As Ale suggested, it's up to the HTTP client to use whatever method you want to receive on Mule's side.
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": -3, "tags": "mule, inbound" }
How to retrieve the absolute path of a file stored inside the jar I have a file, ("hwc.bat") stored inside of my projects resources folder: "project/res/HWC/hwc.bat". I am writing code from within a class "/src/test/java/.../aTest.java" I want to be able to retrieve the absolute path of the file hwc.bat, but using getResource isn't working for me. Here's what I've been trying: final URL resource = this.getClass().getClassLoader().getResource("hwc.bat"); absolutePath = Paths.get(resource.toURI()).toString(); I've tried plenty of variations of "hwc.bat", including things like "/hwc.bat", or "/res/HWC/hwc.bat", but I can't seem to get the URL to be anything but null. Here is a picture of my project set-up, just to give a better idea of where the file is and what I'm trying to do/the context of everything. ![Image of Class Layout](
`ClassLoader().getResource` only can find resource which are contained in the classpath. This not the case for the current location of your `hwc.bat`. Since you are using a Maven project, the correct location to place the file is in `src/main/resources` in order to find it via `ClassLoader.getResource("hwc.bat")`.
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": 1, "tags": "java" }
How to prove easily that geodesic is auto parallel? I only have the elementary concept of geodesic and differential equn of geodesic. Intrinsic derivative =0 implies parallel displacement along a curve. What does it mean by auto parallel? How to prove easily that geodesic is auto parallel ?
$\frac{d^2x^a}{ds^2} + \Gamma^{a}_{bc}\frac{dx^b}{ds}\frac{dx^c}{ds} = 0$ This is the required differential equations of geodesic. Which reduces to \frac{dx^a}_{;b} \frac{dx^b} =0 This shows that the unit tangent vector \frac{dx^a} suffers a parallel displacement along the geodesic curve. Hence proved.
stackexchange-math
{ "answer_score": -3, "question_score": -1, "tags": "differential geometry" }
Личный кабинет пользователя Как сделать так, чтобы при входе на сайт (логин, пароль) пользователь входил в СВОЙ личный кабинет, т.е. видел только свои сообщения и т.д. Как вывести запрос к базе, я понимаю, а вот как сделать так, чтобы не вводить логин пароль на каждой странице.
Почитайте по **session_start()** и **$_SESSION** Страница авторизации: <?php session_start(); $_SESSION['user'] = "Irina"; echo 'Вы вошли как: '.$_SESSION['user']; ?> Личный кабинет: <? session_start(); echo $_SESSION['user'].', добро пожаловать в Личный Кабинет'; ?>
stackexchange-ru_stackoverflow
{ "answer_score": 2, "question_score": 0, "tags": "php" }
How big a problem is 'Cannot find map file.' boot message? This is a follow-on to another question that I have asked here. To summarise: I am trying to boot a linux kernel that I have configured and built myself, as part of a Linux From Scratch (LFS) installation. However, I am seeing the following line in `/var/log/kern.log`: Oct 9 17:24:17 <lee_lfs> kernel: Cannot find map file. I've been reading through the source code for klogd (this is using SysVinit) and the problem seems to be that the map file doesn't contain the 'version' line that klogd is looking for. Anyway, my question is: how big of a problem is this? What sorts of problems might this potentially cause? Is it something I can just ignore and the system should still boot up and run ok, or is this a problem that needs to be solved?
To provide an answer to my own question: I can confirm that the custom kernel that I've built does boot and and seem to run fine, even if the map file is completely removed. So, it doesn't appear to be a critical requirement, from the point-of-view of booting up the system. However, as Matt O. said in his answer, it seems that it may make debugging harder, if the memory locations can't be matched-up to the symbols that the System.map file contains.
stackexchange-unix
{ "answer_score": 0, "question_score": 2, "tags": "boot, linux kernel, logs, sysvinit" }
Write out relation from a function I have this problem: "Let $R$ be a binary relation $(x,y)\in R$ if and only if $f(x) = f(y)$ where $f: \\{a, b, c, d\\} \rightarrow \\{0, 1\\}$ given by $f(a) = 0$, $f(b) = 1$, $f(c) = 0$, $f(d) = 0$ Write out $R$ and show that it's an equivalence relation." I can't seem to grasp this particular question. Particularly the part about $f(x) = f(y)$ I know that it has $R$ has to be reflexive, symmetric and transitive for it to be an equivalence relation, but I guess I'm having trouble seeing exactly what's in $R$. I know it's supposed to be a subset of $\\{a, b, c, d\\}\times\\{0, 1\\}$, but the restriction $f(x) = f(y)$ is confusing me. Wondered if someone could explain?
R = {(a,c), (c,a), (a,d), (d,a), (d,c), (c,d), (a,a), (c,c), (d,d), (b,b)} Hope that helps. Note: The claim that R should be a subset of {a,b,c,d}x{0,1} is incorrect.
stackexchange-math
{ "answer_score": 1, "question_score": 1, "tags": "discrete mathematics, relations" }
Django - saving two records at the same time with a foreign key relation I want to be able to save two records in two database tables at the same time with one of the tables having foreign key relation to the other table. models.py class Model1(models.Model): Modlel1Filed1 = models.CharField() class Model2 (models.Model): Model2Filed1 = models.ForeignKey(Model1) Modle2Field2 = models.CharField() Below is how I save the data using Model1: p = Model1.objects.create(Model1Filed1=some_data_here) p.save() For Model2 I tried: p = Model1.objects.get(pk=p.pk) f = Model2.objects.create(Model2Filed1=p.id, Modle2Field2=some_data) f = save() but I'm getting an error like this: Cannot assign "78": "Model2.Model2Filed1" must be a "Model1" instance. Any ides?
The error message is pretty clear: `"Model2.Model2Filed1" must be a "Model1" instance`: f = Model2.objects.create(Model2Filed1=p, Modle2Field2=some_data) changed `Model2Filed1=p.id` to `Model2Filed1=p`
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": 2, "tags": "django, django models, django views" }
Efficient (non-crypto-grade?) pseudorandom permutations with arbitrary domain size I'm looking for an efficient/simple (even if not necessarily cryptographically strong) algorithm for implementing pseudorandom permutations with domain cardinality other than a power of 2. (FWIW, the domain cardinality I'm interested in at the moment is $900,000$.) All the algorithms I've found for doing this aim for cryptographic strength, and tend to be relatively slow and intricate. One exception to the last point, arguably, is the standard Feistel network algorithm, which is at least fairly simple. Unfortunately, AFAICT, this algorithm works only for permutations with domain size $2^{2m}$, with $m\in\mathbb{Z}^+$. (I've found some generalizations of Feistel networks to arbitrary domain sizes, but they all aim for cryptographic strength, at the expense of performance (and simplicity).)
unbalanced numeric Feistel (page 10) swap-or-not FastPRP Those are all cryptographically strong; I'm not aware of any way to get better performance by sacrificing that.
stackexchange-cstheory
{ "answer_score": 3, "question_score": 2, "tags": "ds.algorithms, permutations, pseudorandom generators" }
How do I merge multiple objects so I can sculpt it? ![so **strong text**]( As the title implies, how do I do this? Is there maybe an add-on to make it easier? I did ctrl-J to join all the bodies together, but they really weren't connected as one.
1. Search in the add-ons window "bool tool". 2. Select the two mesh that your want to join. 3. Go to the object menu in the view-port,bool tool operation, and select "union". 4. And wuala! you have a unified object. You can do this without the add-on using only modifiers but its a little bit wonky Hope it helps! ![two meshes joined](
stackexchange-blender
{ "answer_score": 0, "question_score": 0, "tags": "sculpting" }
Convert seconds to ISO8601 duration in Freemarker How to convert seconds to ISO 8601 Duration in Freemarker? For eg. **140 seconds -> PT2M20S** Is there any freemarker builtins that can come in handy here? Or String manipulation?
I ended up adding this function: <#function convertDurationSeconds seconds> <#local mins = (seconds/60)?int /> <#local seconds = (seconds%60) /> <#return 'PT' + (mins > 0)?then(mins + 'M','') + (seconds > 0)?then(seconds + 'S','') /> </#function> Note: I needed it for min and seconds only since it was for short video durations, this function can be extended to represent other time intervals (Y, M(month), W, D, M, and S)
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "freemarker, iso8601" }
Excluding path in url using AngularJS My angular application has multiple pages which users can visit and I would like to hide all other urls and only show users the base url. So imagine my base url is: www.example.com and I have other pages like About, Contact Us etc. Currently, when the user clicks on About, the url changes to www.example.com/about. Is it possible for angular not to add the "/about"? Is this possible using angular js? Also, I have been searching for solutions and have experimented with ui-router.js, is it also possible with this module?
If you are using ui-router, then you can define states without specifying urls like myApp.config(function($stateProvider, $urlRouterProvider) { // // For any unmatched url, redirect to /state1 $urlRouterProvider.otherwise("/state1"); // // Now set up the states $stateProvider .state('state1', { url: "/state1", templateUrl: "state1.html", controller: 'Controller3' }) .state('state2', { templateUrl: "state2.html", controller: 'Controller2' }) .state('state3', { templateUrl: "state3.html", controller: 'Controller3' }) }); So by default the url will be /state1. And you can implement navigation by using ui-sref directive in your template like `ui-sref="state2"` or using $state service in your controller like `$state.go('state2')`.
stackexchange-stackoverflow
{ "answer_score": 11, "question_score": 3, "tags": "angularjs, angular ui router" }
Are all metric tensors diagonal? If I understand correctly, one way to get the components of a metric tensor (treating it like a matrix here) is to look at the $ds$ interval. Isn't that interval always in terms of sums of $dr^2+d\theta^2$ etc, meaning that the metric tensor will only have nonzero values for $x^ix^j$ when $i=j$? If this is not the case, can anyone give an example?
Being diagonal is a coordinate-dependent concept: the components of the matrix associated to the metric tensor depend on the coordinate system you use. Thus a very simple example of a non-diagonal metric is the standard Euclidean metric $\delta = dx^2 + dy^2$ on $\mathbb R^2$ in the coordinate system $(x,z) = (x, x+y)$, where it has the coordinate expression $$\delta = dx^2 + d(z-x)^2 = 2dx^2 + dz^2 - 2 dx dz.$$
stackexchange-math
{ "answer_score": 10, "question_score": 9, "tags": "differential geometry" }
Run xcode in mode debug I am wondering if is possible run xcode in mode debug as you can run Java. I am mean not only for debug your app is more, debug and write code in the same time without re-run the compiler again. Now each time that I write something new I have to restart the compiler and I lost a lot of time.
as far as i know xcode does not provide a clean native way to do this kind of stuff. you can try using this project : < I haven't used it intensively yet but it seemed to work pretty well and it is quite easy to set up.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "xcode, debugging, xdebug" }
How to update static HTML files with PHP We've 700 static HTML files in folder "music". We want to put analytic code in the end of the HTML files.. like before </body> </html> tags. Please anybody let me know, how its possible with PHP code?
Too easy. Find all files, read content, modify content, save content. <?php // open directory if($handle = opendir(__DIR__)) { // search for $search = '</body>'; // replace with (</body> gets appended later in the script) $replace = <<< EOF <!-- your analytics code here --> EOF; // loop through entries while(false !== ($entry = readdir($handle))) { if(is_dir($entry)) continue; // ignore entry if it's an directory $content = file_get_contents($entry); // open file $content = str_replace($search, $replace . '</body>', $content); // modify contents file_put_contents($entry, $content); // save file } } echo 'done'; ?>
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 1, "tags": "php, html" }
Dual monitors, second monitor not working I have recently bought a new PC with two monitors. The first time I connected both monitors, it worked fine but since then after a restart, the second (non primary) monitor does not turn on even though I see the on light flashing but it does not say "No signal" If I make the scond monitor my primary monitor, it starts working fine but the first monitor turns off. I have a GTX1060 with one monitor connecting via HDMI (secondary monitor) and one via DVI (primary monitor). If I use Nvidia control panel to span the screen across both monitors, that works after which if I change it back to dual monitors, both start working. But after a restart, secondary monitor if off again. I will be trying to update drivers this weekend but apart from that I don't know what to try. Any help appreciated. **Edit** Using Windows 10
It seems the the Nvidia control panel was considering the monitor connect via HDMI as being my primary monitor but I had set the monitor connected via DVI as primary. Swapping the cable on the monitors, the HDMI to my primary and DVI to my secondary monitor, fixed the problem for me. Both monitors now turn on as expected when restarting my machine.
stackexchange-superuser
{ "answer_score": 0, "question_score": 0, "tags": "windows 10, multiple monitors" }
What is considered an enemy unit? I was reading about Trundle's rework, and I noticed his passive is "Whenever an enemy unit near Trundle dies, he heals for 2% of their maximum Health." But what exactly is 'enemy unit' in this case? I think it includes enemy champions as well as enemy minions, but does it include jungle mobs as well? If it does, does that mean dragon and Baron are included? Seems a bit overpowered if all of those count as well... I tried searching for the definition, but I can't find a clear explanation of what 'enemy unit' means.
Yes, it's minions, champs and jungle mobs, this is what gives Trundle his sustain while jungling (it's very useful). See this link for info, as a bonus you'll even get the regen if the enemy kills the unit (didn't think of that one myself!) so will trigger for neutral mobs as long as you're in range.
stackexchange-gaming
{ "answer_score": 5, "question_score": 2, "tags": "league of legends" }
I want to ranking result with city based in mysql I want to ranking result with city based in mysql **table1:-users** | user_id | marks | -------------------- | 1 | 10 | | 5 | 10 | | 5 | 50 | | 3 | 15 | | 4 | 10 | | 2 | 10 | | 6 | 10 | | 6 | 50 | | 4 | 15 | | 4 | 10 | table:-2 users details | user_id | city | -------------------- | 1 | newdelhi | | 2 | kolkata | | 3 | mumbai | | 4 | newdelhi | | 5 | 6 | newdelhi | I want to result like this: | user_id | points | -------------------- | 6 | 60 | | 4 | 35 | | 1 | 10 |
Try this : SELECT users.user_id ,SUM(users.marks) AS points FROM users INNER JOIN users_details ON users.user_id = users_details.user_id WHERE users_details.city = 'newdelhi' GROUP BY user_id
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": -2, "tags": "mysql, sum, rows, ranking" }
How to prevent Kendo UI Grid from rebinding many times when updating ViewModels When you bind to a Kendo UI Grid with MVVM, databound will fire once and all is well. If you need to update that data after the fact, every time you change one piece of data on any viewmodel (or child viewmodel), the entire grid re-databinds. Thus, if you had some cell in the grid that is bound to a template and you have to change 2 or 3 properties on the viewmodel from some external ajax source, Databound will fire 2 or 3 times for each model that is changed, causing the entire viewable area to rebind. How can we update lots of data at once and only have databound fire once?
How exactly you rebind the Grid? Basically if you change some of the models like this: dataItem.set('SomeField','new value'); dataItem.set('someOtherField','other value'); This way the Grid will be indeed bound two times because of the MVVM. The change event is triggered each time you call set. However if you update the values like this: dataItem.SomeField='new value'; dataItem.someOtherField= 'other value'; The Grid wont react to the change and wont rebind re-read the values from the models you can force the Grid to do it through the **refresh** method. $('#gridName').data().kendoGrid.refresh()
stackexchange-stackoverflow
{ "answer_score": 9, "question_score": 8, "tags": "mvvm, kendo ui, kendo grid" }
Extract a string between double quotes I'm reading a response from a source which is an journal or an essay and I have the html response as a string like: > According to some, dreams express "profound aspects of personality" (Foulkes 184), though others disagree. My goal is just to extract all of the quotes out of the given string and save each of them into a list. My approach was: [match.start() for m in re.Matches(inputString, "\"([^\"]*)\""))] Somehow it didn't work for me. Any helps on my regex here? Thanks a lot.
Provided there are no nested quotes: re.findall(r'"([^"]*)"', inputString) Demo: >>> import re >>> inputString = 'According to some, dreams express "profound aspects of personality" (Foulkes 184), though others disagree.' >>> re.findall(r'"([^"]*)"', inputString) ['profound aspects of personality']
stackexchange-stackoverflow
{ "answer_score": 34, "question_score": 15, "tags": "python, regex, string" }
Reading pdf books on my phone When I want to get/download books from Google Play Store, I usually get this notification: !enter image description here But then I am not sure what to do afterwards to be able to read those pdf books on my phone. I've installed to ebook reader apps (kindle and another one), I also downloaded Google Play books app but I can't find those books exploring in those ebook reader apps and I can't find Google Play Books app on my phone to check whether it is possible to read them there.
You can download the Google Play Books app from the market (link) If there is a problem with your installed app, open the app using Play Store app and uninstall and reinstall it. Now you should have the app shortcut in your app drawer. In this app, you will be able to view your purchased books.
stackexchange-android
{ "answer_score": 2, "question_score": 2, "tags": "google play store, samsung galaxy nexus, pdf, ebooks" }
Converting 3-pin brushless fan to 2-pin I need to replace a 2-pin fan on my PSU unit. The fan is 40x40x20, DC12V, 0.15A. I am replacing the fan because the noise is unbearable, >75dB right next to it. ![fan]( Can I simply buy a 3-pin fan and cut off the 3rd cable? I was unable to find any 2-pin cable in stores around me and I expect there will be even less choice if I want a silent fan. What happens if the new 3-pin fan is not rated as 12V fan, but 5V? Do I just add a resistor to the positive cable? Another issue is that the connector won't fit and I’ll need to use the existing connector or buy an 3-to-2-pin adapter, if I can find one. ![fan connector]( Thanks for the help.
Usually the 3rd pin is the "tachometer" output so that the fan's speed can be read by whatever is controlling it. So in the case of a 2 pin 12V fan, you need only to connect the power leads properly and leave off the tach output since nothing in your PSU is expecting it. As far as the connector, it's often simplest to cut the wires off the old fan and simply splice the wires onto the new fans leads. Finding such connectors by themselves can be tricky. Do not substitute a 5V fan for a 12V fan. While it may run for a while, the fan will likely overspeed, overheat, and likely fail in a relatively short period of time.
stackexchange-electronics
{ "answer_score": 4, "question_score": 1, "tags": "power supply, fan, cooling" }
Verify the string " 2 Sep 2018 09:00 " is a valid date format I know there are multiple questions asking to verify a valid date. But I was unable to find out the exact format. So please do not mark this as a duplicate. I have a date returned as a string E.g., 2 Sep 2018 09:00 in my web page. I need to verify this is a date as a part of my selenium tests. Appreciate if someone could help me to verify this as a valid date format in Java. Thanks
I found a way. Posting since it will be useful. String dateformat = "A valid date time format"; String notValidDateFormat = "Not a valid date time format" ; final DateFormat fmt = new SimpleDateFormat("dd MMM yyyy hh:mm"); Date input = null; try { input = fmt.parse(offerDate); } catch (ParseException e) { e.printStackTrace(); } if (input.before(new Date())) { return dateformat; } return notValidDateFormat; }
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "java, validation, datetime, datetime parsing" }
no record selected with the following query query.prepare("SELECT invoice FROM " + m_invoiceInfoTable + " WHERE invalid='' AND invoice IN (SELECT invoice FROM " + m_invoiceUserTable + " WHERE user=:user)"); Is there any problem with this query ? I had not set the invalid field and still its not giving any record corresponding to ths
What are you trying to say with invalid='' Are you saying that invalid is defined as an empty string or that invalid is null (undefined) which would be done as invalid IS NULL
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 0, "tags": "sql, qt" }
Alterar a cor de um slot de tempo específico no Fullcalendar Eu estou trabalhando com a view agendaDay no FullCalendar. Eu tenho uma função que bloqueia quando o usuário clica em slots de tempo específicos, em dias específicos (esses valores são gravados no banco). Gostaria de saber como posso definir uma cor diferente apenas para determinados slots de tempo em um dia, especificamente, para as linhas bloqueadas. Como posso identificar uma linha de tempo específica para mudar a sua cor?
A solução que melhor atendeu meu problema foi a sugerida neste link do Stackoverflow em inglês: < Utilizei uma função javascript mais ou menos como a que segue abaixo. Para dar certo é preciso configurar o intervalo dos slots de tempo de modo a aparecer o rótulo da hora para as linhas. Visto que se colocamos a duração dos slots como 00:15:00 ou 00:00:30:00, 00:45:00 os rótulos das linhas não aparecem, deve-se acrescentar 1 segundo ao final da duração do slot: 00:15:01. Segue o código sugerido: $('tr').find('span').each( function(){ var timeSlot = $(this).text(); if(timeSlot> 13 && timeSlot < 18) //Change 13 and 18 according to what you need $(this).closest('tr').css('background-color', '#000'); });
stackexchange-pt_stackoverflow
{ "answer_score": 0, "question_score": 2, "tags": "javascript, css, fullcalendar" }
Excluding nested transitive dependency in maven My project depends on `jparsec`, which depends on `cglib`, which depends on `asm`. My project also directly depends on `asm`, but a newer version than the one `cglib` depends on: !enter image description here It seems I cannot exclude `asm` from my `jparsec` dependency. When I attempt to exclude it with Eclipse, it makes no change to my pom. If I manually exlude it, it has no effect. Is my only option here to exclude `cglib` from `jparsec` and then to manually add a dependency on `cglib` with `asm` excluded? This seems a bit convoluted to me, but it does work.
As per my comment, you have 2 options to solve this issue: 1. The one that you suggested, e.g. exclude `cglib` from `jparsec` and add `cglib` with `asm` excluded. 2. Locate your `asm` dependency above the `jparsec` dependency.
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": 6, "tags": "java, maven, dependencies" }
How JAVA format date 4/06/2011 instead of 04/06/2011 use GregorianCalendar? String.format("%1$tm/%1$td/%1$tY", today); How JAVA format date > 4/06/2011 instead of 0 > 4/06/2011 ? I need to use GregorianCalendar GregorianCalendar today=new GregorianCalendar(); String todayStr = String.format("%1$tm/%1$td/%1$tY", today); gives > 04/06/2011 I want > 4/06/2011 thanks in advance
DateFormat dateFormat1=new SimpleDateFormat("M/dd/yyyy"); System.out.println(dateFormat1.format(new Date())); **Output:** > 4/06/2011 **Note:** It might fail for month greater than Oct.
stackexchange-stackoverflow
{ "answer_score": 6, "question_score": 4, "tags": "java" }
Link between uniform continuity of two differentiable functions I'm working on a question that states: Let $f,g:\mathbb{R}\rightarrow\mathbb{R}$ be two differentiable functions with $g'(x)\neq0$ for all $x\in\mathbb{R}$. Consider the function $h=\frac{f'}{g'}$. Given that $h$ is bounded, what is the link between the following statements: (a) $f$ is uniformly continuous (b) $g$ is uniformly continuous My first thought was that (b) implies (a), but not necessarily the other way around. To prove that (b) implies (a), I noticed that since $h$ is bounded we have $|f'(x)|\leq M|g'(x)|$ for an $M\in\mathbb{R}^+$. Now using the fact that $g$ is uniformly continuous and the mean value theorem I showed that $f$ was also uniformly continuous. Is this correct? The other way around I struggled to find a counterexample, but I was trying to do something with $\sin$ and $\cos$. Can anyone help with this?
Your proof for $b\Rightarrow a$ looks valid. For a counterexample to the other direction, you could let $g(x) = x^3+x$ and $f(x)=1$.
stackexchange-math
{ "answer_score": 2, "question_score": 0, "tags": "real analysis, continuity, uniform continuity" }
Error while running any ruby related commands Gives me this error twice: rbenv: version `2.1.1' is not installed rbenv: version `2.1.1' is not installed When I do `rvenv versions` it gives me this output system 1.9.3-p547 * 2.1.1 Not sure what wrong I'm doing here.
adding these two lines inside my bashrc file solved my problem. export PATH="$HOME/.rbenv/bin:$PATH" eval "$(rbenv init -)"
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "ruby on rails, ruby, rbenv" }
Escaping question mark in mySQL regex I have this simple query that uses regex. I don't know why it returns an error every time I try to run it. select * from mytable where thumbnail_url regexp '^\?.+' Basically, I want to see if any string in this list starts with a question mark or not. I am connected to Amazon RDS through MySQLWorkbench 6.3.
When you use a backslash to escape a regexp character in MySQL, you must also escape the backslash itself as `\\`. MySQL would see a single `\` character and attempt to use it as an escaping character within the SQL statement itself rather than treating it as a literal. But you need it to act as a literal in order to modify the `?` within the regex. The first `\` escapes the second `\`, resulting in a literal regex sequence `\?` to represent a single literal `?` in the matching string. MySQL documentation on string literals... Format your expression with an escaped backslash as: select * from mytable where thumbnail_url regexp '^\\?.+'
stackexchange-stackoverflow
{ "answer_score": 8, "question_score": 4, "tags": "mysql, sql, regex" }
form to normal text using CSS and minimal jquery or javascript I have a form having all kind of tags (check box, dropdown etc) in my HTML page, on click of a button I want to show the same form as a normal text on the popup. For popup, I am using jQuery dialog. using following code, I am able to show the same form on the popup. but it is coming as a form with editable fields. var dialogHtml = jQuery('#requestForm').html(); jQuery(dialogHtml).dialog(); is it possible to change the same form in non-editable text format on the popup. I don't want to write the same code for the popup. Actually, requirement is like that, I have a form which needs to be filled and on submitting of that form, I need to display order number along with that form's data. OrderNumber + some other HTML data I am getting dynamically.
You might try something like this, which loops through all the form elements, and put their names and values into a table for display. var dialogHtml = $("<table></table>"); jQuery('#requestForm').find("input,select,textarea").each( function(){ results.append( "<tr><td>" + $(this).attr("name") + ":</td><td>" + $(this).val() + "</td></tr>"); }); jQuery(dialogHtml).dialog();
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "javascript, jquery, html, css, forms" }
Is it possible to destructure function arguments with ternary assignment? I would like to be able to destructure function arguments with ternary assignment. const fn = (size ? 'large' : 'small') => [ `lots${size}`, `of${size}`, `values${size}`, ]; fn(true); // imageLarge fn(); // imageSmall
You can do that using default parameters: const fn = (isLarge, size = isLarge ? 'large' : 'small') => [ `lots${size}`, `of${size}`, `values${size}`, ]; console.log(fn(true)); console.log(fn(false));
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 3, "tags": "javascript, ecmascript 6" }
SQLite3 with multiple WHERE I'm new to SQLite3 with iOS I'm trying to create an SQL Query that will execute the following statement SELECT student_name FROM class_roster WHERE student_id='1' AND student_first_name='Jon' ORDER BY student_first_name; In my iOS code, i'm getting the data from textfields. Any help would be appreciated. (I just need to know how to create the `string` or `char*`) I saw this in a book but not sure how to use it char *cQuery = "SELECT DISTINCT country FROM countryTable WHERE nationName LIKE ? ORDER BY nationName"; if (sqlite3_prepare_v2(database,cQuery, -1, &statement, NULL) != SQLITE_OK) { NSLog(@"query error: %s", statement); } How do I put more than 1 value? How does the application know what the `?` does? Thanks
The posted code prepares a statement. You have a bit of extra work e.g. by binding values to the wilcards "?". This is documented here: < if (sqlite3_bind_double( statement, 1, // Index of wildcard 4.2 // Value ) != SQLITE_OK) { // Error handling... } Execute the statement and do sth. with the result. <
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "database, ios4, sqlite, char" }
Change contour colours using directlabels I'm fairly new to ggplot2, and I'm trying to create a contour plot of data that has missing values. Because there's missing values I can't have the contours by themselves, so I'm combining a tiles background with a contour. The problem is the labels are the same colour as the background. Suppose I have data like so: DF1 <- data.frame(x=rep(1:3,3),y=rep(1:3,each=3),z=c(1,2,3,2,3,4,3,NA,NA)) I can make a plot like this: require(ggplot2); require(directlabels) plotDF <- ggplot(DF1,aes(x,y,z=z)) + geom_tile(aes(fill=z)) + stat_contour(aes(x,y,z=z,colour= ..level..),colour="white") direct.label(plotDF) This gives me a plot similar to what I want but I'd like to be able to change the colours of the labels to be black. Any ideas?
I spotted a similar post and thought this would be easy, something along the lines of `direct.label(p, list("last.points", colour = "black")`. I could not make it work, unfortunately; I believe, this is not directly supproted. I then decided to use black magic and managed to do the trick by manually overriding the colour scale: direct.label(plotDF + scale_colour_gradient(low="black", high="black")) !enter image description here
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 1, "tags": "r, ggplot2" }
ruflin elastica how to use _source to get certain fields how to use _source to get certain fields in ruflin elastica. please suggest how to use it. For Ex: { "_source": {"user", "message"}, "query" : { "term" : { "user" : "kimchy" } } } How can i convert this to ruflin elastica. Please help. Thanks
Query class provides a `setSource` method to add the list of fields, as an array, you want to retrieve. Some code I use to make a query by using `ruflin/elastica v3.2` and ElasticSearch 2.4 can be: $search = new Search(new Elastica\Client()); $query = new Elastica\Query(); $query->setSource(['user', 'message'] $boolQuery = new Elastica\Query\BoolQuery(); $boolQuery->addMust(new Term(['user' => 'kimchy'])); $query->setQuery((new BoolQuery())->addMust(new MatchAll())->addFilter($boolQuery)); $search->setQuery($query); try { $resultSet = $search->search(); } catch (ResponseException $exception) { // code } $results = $resultSet->getResults();
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "php, elasticsearch, elastica" }
Chrome causing 404's ending with "/cache/[hex-string]/"? Since the last weeks we see many 404's on our sites caused by Chrome adding `/cache/[hex-string]/` to the current page URL. The hex strings we have seen are: * e9c5ecc3f9d7fa1291240700c8da0728 * 1d292296547f895c613a210468b705b7 * 408cfdf76534ee8f14657ac884946ef2 * 9b0771373b319ba4f132b9447c7060a4 * b8cd4270356f296f1c5627aa88d43349 If you search for these strings you get matches from different sites, but they are most likely auto-generated (`/search/cache/e9c5ecc3f9d7fa1291240700c8da0728/` for example). Is this a known issue with Chrome (or an extension)?
I looks like a bug in a chrome extension: < It is marked as "won't fix" by chrome developers, as it depends on the extension owners.
stackexchange-webmasters
{ "answer_score": 1, "question_score": 7, "tags": "url, cache, 404, google chrome" }
replacing wpf image source on the fly I am using an Image in xaml like below, <Image x:Name="JustMyImage" Width="635" Height="120" Canvas.Left="-19" Canvas.Top="-19" Source="../images/UnCategorized/Anywhere.png"/> If i want to dynamically change the image source i need to do the following code BitmapImage bi = new BitmapImage(); bi.BeginInit(); bi.UriSource = new Uri(".\images\panel.PNG", UriKind.Relative); bi.EndInit(); this.JustMyImage.Source = bi; Is there a straight forward 'one line' method to replace the image.
You can do like this: JustMyImage.Source = new BitmapImage(new Uri(".\images\panel.PNG"))
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "c#, wpf" }
How to handle slow network connection speed in Android/Glass app? If my Glass app has a slow network connection it starts freezing up and reacting horribly (even though network calls are done on Async tasks in background.) What do you have to do to make your app responsive even if there are asynch tasks in the background struggling with a slow network connection? How do you simulate slow network connections on a Glass handset in a dev environment to test error handling cases?
To deal with slow network connections you can try and have as much data as possible stored locally to the app meaning the app won't have to download as much. In order to simulate slow network connections you can use one of these tools < This will only work however if the stuff the stuff the app is downloading is stored across the network, it can't be stored in your computers file system. A working example would be a raspberry-pi fileselver on your local network.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "android, google glass" }
test:62 Uncaught ReferenceError: is not defined at HTMLButtonElement.onclick (test:62) I would like to be able to transmit in my function values that are not integers but strings. I do not have any problem with the integers but for the chains, I have a problem of declaration but I do not understand where it comes from ... <div id="test"></div> <script> var b = "hello"; var test = document.getElementById('test'); test.innerHTML += "<button onclick='myFunction("+b+")'>Click me</button> "; function myFunction(MyVar) { console.log(MyVar); } </script>
Fix variants: test.innerHTML += "<button onclick=myFunction('"+b+"')>Click me</button> "; test.innerHTML += "<button onclick='myFunction(\""+b+"\")'>Click me</button> "; test.innerHTML += "<button onclick=\"myFunction('"+b+"')\">Click me</button> "; etc.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 1, "tags": "javascript" }
Definition of infinite tree in set theory Really basic question concerning trees in set theory. _What is the definition of an **infinite** tree?_ I ask the following because, rather peculiarly, neither in Kechris classical book on descriptive set theory, nor in Srivastava book on the same topic, there is an explicit definition, even if they both use the concept (e.g. Srivastava use the infinity of a tree for the Koenig's infinity lemma, p.28). Thanks in advance. * * * **Edit after the answers:** Thanks all for the number of answers, and the quality behind them.
Recall that a tree is a partial order that for each point $x$, the cone below $x$ is well-ordered. An infinite tree is a tree with infinitely many nodes. Sometimes, however it is easier to work with "reversed" trees. With reversed ordering, being well-founded is equivalent to not having an infinite branch. And that is something which comes up often in descriptive set theory.
stackexchange-math
{ "answer_score": 7, "question_score": 6, "tags": "set theory, descriptive set theory" }
How to echo php variable from array? I need echo something like this: echo "<a href="#">$some['variable']</a> How can I escape `[]` brackets to echo variable in link?
echo "<a href='#'>" . $some['variable'] . "</a>"; or echo "<a href=\"#\">" . $some['variable'] . "</a>"; or echo "<a href='#'>{$some['variable']}</a>";
stackexchange-stackoverflow
{ "answer_score": 6, "question_score": -1, "tags": "php, syntax, escaping" }
How can I add a new property to Component in _app.tsx in Next.js with Typescript? I'm developing some protected pages using Next.js, NextAuth.js and Typescript. The following code from my `_app.tsx` was taken from the NextAuth.js official website but that includes a property `auth` that does not exist for `Component` which has the type `var Component: NextComponentType<NextPageContext, any, {}>`, so TS is displaying an error for that: function MyApp({ Component, pageProps: { session, ...pageProps } }: AppProps) { return ( <> <SessionProvider session={session}> {Component.auth ? ( <Auth> <Component {...pageProps} /> </Auth> ) : ( <Component {...pageProps} /> )} </SessionProvider> </> ); } I'm not a Typescript expert, so my question is how can I add/extend that `auth` property to the Component with TS?
You need to extend `AppProp` and add your custom attributes import type { NextComponentType } from 'next' //Import Component type //Add custom appProp type then use union to add it type CustomAppProps = AppProps & { Component: NextComponentType & {auth?: boolean} // add auth type } function MyApp({ Component, pageProps: { session, ...pageProps } }: CustomAppProps) { ... }
stackexchange-stackoverflow
{ "answer_score": 24, "question_score": 11, "tags": "reactjs, typescript, next.js, next auth" }
iphone/objective c (simple) question I'm trying to avoid the redeclaration of self, in the following picker2.peoplePickerDelegate = self; // showing the picker [self presentModalViewController:picker2 animated:YES]; Why am i not able to just go like: [picker2.peoplePickerDelegate presentModalViewController:picker2 animated:YES]; Regards
Because `picker2.peoplePickerDelegate` may not be `self` before your assignment. (Also, `picker2.peoplePickerDelegate` is not a `UIViewController` so sending the `-presentModalViewController:animated:` message to it is wrong.)
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "iphone, c, objective c, uiviewcontroller" }
What is Oracle Session? I am using Oracle 11g. I am looking for a good explanation of Oracle Sessions. I googled for this, but strangely, none of the web sites contain any explanation of what oracles sessions are. My specific questions are 1) What are oracle sessions? 2) Does one connection object always relate to one oracle session.? 3) can one oracle session be shared by another connection started by the same user.?
1. A logical entity in the database instance memory that represents the state of a current user login to a database. 2. A single connection can have 0, 1, or more sessions established on it. 3. I can't imagine that it can <
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": 11, "tags": "oracle" }
how to use get function to pass an argument/parameter to a lambda function which is a value in the dictionary in python? To implement switch cases, people have suggested to use dictionary like: ` result = { 'a': lambda x: x * 5, 'b': lambda x: x + 7, 'c': lambda x: x - 2 }` and call it using- `result'a'` But to set a default value, people have suggested to use get function. How do I pass 'a' and 2 as well as default value using get ? This dosen't works: `result.get('a',default)` Here 'a' is the key to be searched and if found 2 is the parameter for the lambda function. Default represents any value in case if key 'a' is not found.
From _docs_ of `dict.get()`: > Return the value for _key_ if _key_ is in the dictionary, else _default_. Values in you dictionary is callable which expect 1 argument, so we can pass _lambda_ which will return `0`: result.get('blah', lambda x: 0)(0)
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": -1, "tags": "python, python 3.x" }
How to prevent "abc" (text-based) hints from being on the top of suggestions list ![enter image description here]( You could see hints on the picture above when I type `def`. The problem is that the hint on the top doesn't do anything (if I click `Tab` or `Enter` it just returns `def`) but the hint below creates a method like: def (method_name) () end How could I remove (or down in priority) hint on the top?
> // Controls whether snippets are shown with other suggestions and how they are sorted. > // - top: Show snippet suggestions on top of other suggestions. > // - bottom: Show snippet suggestions below other suggestions. > // - inline: Show snippets suggestions with other suggestions. > // - none: Do not show snippet suggestions. "editor.snippetSuggestions": "top", will move your snippets to the top of the suggestions list and > // Controls whether completions should be computed based on words in the document. "editor.wordBasedSuggestions": false, will remove suggestions that are derived solely from other text in the file (hence the little "abc" in the box preceding your first "def" - that means it is text-based and not snippet-based for example).
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "ruby, visual studio code" }
Enumeration of the possible number of ways of the classical Airplane probability problem If there are $100$ people about to aboard an airplane and the first person has lost his ticket (which means he sits randomly), find the number of possible ways in which the people can sit if the rule is to sit in your own place if it's empty, otherwise sit randomly. If the first person sits in the $j$ place, then all people from $2$ to $j-1$ will be in their original position. The problem now boils down to a '$101-j$'-person problem. So if for $n$ people, the answer is $f(n)$, we get the following recursion : $f(n) = \sum \left(f(n+1-j) + 1\right)$ because $j$ will either go to the $1$st position or the problem boils down to the $101-j$ case as mentioned before. Finally this can be solved using generating functions. Is this correct? Or am I missing something?
Let $n$ be the total number of people. $n=1$: $$1\Rightarrow f(1)=1$$ $n=2$: $$12, \color{red}{21}\Rightarrow f(2)=2=1+\color{red}{f(1)}$$ $n=3$: $$123,\color{red}{213,312},\color{blue}{321} \Rightarrow f(3)=4=1+\color{blue}{f(1)}+\color{red}{f(2)}$$ $n=4$: $$1234, \color{red}{2134,3124,4123,4132},\color{blue}{3214,4213},\color{green}{4231} \Rightarrow f(4)=8=1+\color{green}{f(1)}+\color{blue}{f(2)}+\color{red}{f(3)}$$ $n=5$: $$12345,\color{red}{21345,31245,41235,51234,51243,41325,51324,51342},\\\ \color{blue}{32145,42135,52134,52143},\color{green}{42315,52314},\color{brown}{52341} \Rightarrow \\\ f(5)=16=1+\color{brown}{f(1)}+\color{green}{f(2)}+\color{blue}{f(3)}+\color{red}{f(4)}$$ Do you see the pattern? Answer: > $f(n)=2^{n-1}.$
stackexchange-math
{ "answer_score": 1, "question_score": 2, "tags": "algorithms, recursion" }
Power supply from laptop ozone smell I have a laptop which gave a small "plof" sound, after that the laptop was totally dead. The smell is like ozone, the same when a power-supply from a desktop computer stops working. This is new to me when it's on a laptop. When I open the laptop, there is a strong a ozone smell from the fan. My question.. There is a cooling block on the processor with a copper cooling element, which has an exhaust on left right of the laptop. Can it be that the cooling fan just broken which produces that smell or can it be something else? I'm 90% sure it's not the harddisk, because the smell is not on that side of the laptop.
First you can 100% the laptop hard drive by putting it in an enclosure made to check out laptop hard drives and see if it will come on in another PC. As for the smell it could be a number of different components that are causing the smell (which should probably not be inhaled too much out of common safety practice). If it was just the fan there should be a chance the laptop will come back on if just for a few seconds to either give a cpu fan error of some kind.
stackexchange-superuser
{ "answer_score": 4, "question_score": 2, "tags": "laptop, power supply" }
WPF checkbox Tag is null eventhough it is set in XAML I am trying to make use of the Tag property of the WPF checkbox. This is my XAML: <CheckBox Content="BTC/USD" HorizontalAlignment="Left" Margin="14,0,0,41" VerticalAlignment="Bottom" IsChecked="True" Checked="CheckBox_Checked" Tag="btcusd" Unchecked="CheckBox_Checked"/> When I open my app, `CheckBox_Checked` is called immediately, but the sender's Tag property is null. Why can this happen?
The Checked property is set right on the XAML loading, when you set IsChecked="True". The tag may be loaded only later when the XAML loading code decides to set this property. That's why you can see uninitialized properties.
stackexchange-stackoverflow
{ "answer_score": 5, "question_score": 4, "tags": "c#, wpf, xaml" }
Probability density of a product of two random variables (discrete and continuous) If $X$ is a gaussian random variable with $\mu=0$ and $\sigma^2=1$, and $Y$ is a discrete random variable taking the values $\\{ {1,-1} \\}$ with probability $\frac{1}{2}$ each. Let $Z=XY$, how do I find the CDF and PDF of Z? Edit: $X$ and $Y$ are independent. I started by evaluting: $F_Z(z)=P(Z\leqslant z)=P(XY\leqslant z)=P(X\leqslant\frac{z}{Y})=$ $=P(X\leqslant -z|Y=-1).P(Y=-1) + P(X\leqslant z|Y=1).P(Y=1)$ But I'm not sure about this last expression, it seems incorrect and I can't see where is the problem.
\begin{align} F_Z(z)&=P(Z\leqslant z)\\\&=P(XY\leqslant z) \\\&=P(XY \le z|Y=-1)P(Y=-1)+ P(XY \le z|Y=1)P(Y=1)\\\ &=P(X \ge -z|Y=-1)P(Y=-1)+P(X \le z|Y=1)P(Y=1) \end{align} If you assume independence, we can further simplify things. Be careful when you work with negative number and inequalities.
stackexchange-math
{ "answer_score": 3, "question_score": 0, "tags": "probability, random variables" }
Post is marked as spam and hidden My answer to this question was deleted by a moderator. The answer was once upvoted, is specific to the question and even contains a link to a fiddle that demonstrates a working solution. Even more than that, the fiddle is eventually the same example that supports the #2 answer, just using a different technology for the solution. I assumed that the answer was deleted by mistake and gave it again. But it was marked as spam as well. So I'm wondering what I am doing wrong.
Your first answer wasn't deleted as spam. It was just deleted. Probably because it consists of nothing more than a link to a off-site resource. A fiddle link may only be used as supplementary material for an answer but not as the main part of it. Your second answer has been spam-deleted. Probably for reposting the exact same content again.
stackexchange-meta_stackoverflow
{ "answer_score": 9, "question_score": -11, "tags": "discussion, deleted answers, spam, not an answer, specific answer" }
Checking command execution status using if condition I am using Powershell version 5.1 on Windows 10. I have the below code where I am trying to check the execution status, if it works then output as success else failed. When I run the code, the code works, but it gives an output as failed. Below is the code if(Enable-LocalUser -Name TEST) { Write-Host "Success" } else { Write-Host "Failed" } How can I get a proper confirmation of the command execution? Please help
You can use $? to check whether the last powershell command executed successfully or not : Enable-LocalUser -Name TEST if($?) { Write-Host "Success" } else { Write-Host "Failed" } If you wanted exception details , then i would suggest try catch : try{ Enable-LocalUser -Name TEST2 -ErrorAction Stop #The below line will only run if enable-localuser did not generate any exception Write-Host "Success" } catch { Write-Host "Failed,Due to :" $_.exception } $? Contains the execution status of the last operation. It contains TRUE if the last operation succeeded and FALSE if it failed.(Excerpt from: Powershell Automatic Variables Documentation)
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "powershell, powershell 4.0, powershell 5.0" }
How to retrieve PID of cmd.exe on windows? How to retrieve PID of cmd.exe on windows? I am trying to figure out PID for cmd.exe , like in Unix i can get with "ps" command what should be windows equivalent for same?
tasklist |find "cmd.exe" will always return you list of cmd.exe with PID if you wish to know PID of specific terminal then execute from the terminal:- wmic process get parentprocessid,name|find "WMIC" WMIC.exe 11348 it should return the parent PID which will always be the PID of your cmd.exe
stackexchange-stackoverflow
{ "answer_score": 17, "question_score": 3, "tags": "windows, cmd, pid" }
How does the movie Spirited Away justify its title? The movie **Spirited Away** has the title in Japanese as , which means **Sen and Chihiro Spiriting Away**. This movie is about the Chihiro), a ten-year-old girl who enters the spirit world while moving to new house and try to find a way to free herself and her parents from this spirit world. **How does this movie justify its title, Sen and Chihiro Spiriting Away?**
From Merriam-Webster, _spirit_ means > the immaterial intelligent or sentient part of a person and > to carry off usually secretly or mysteriously **Spirited Away** is a clever play on words, referencing how Chihiro _enters the spirit world_. She gets carried off her own world, and she becomes a spirit. For reference, _Spirited Away_ is not a literal translation. _Sen to Chihiro no Kamikakushi_ literally means _hiding in the spirit world_ or _hidden by the gods_ , and in other languages, the movie was distributed with other titles, such as _Chihiro's Journey_. Oh, and also, if you're wondering about the Sen and Chihiro references, check out my other question!
stackexchange-movies
{ "answer_score": 45, "question_score": 28, "tags": "title, spirited away" }
Getting time difference per unique row items using pandas Can someone please show me how to use pandas to get time difference per unique rows in the following data (df): Round Order Date 1 1 2011.02.04 00:20:21 1 2 2011.02.04 00:25:11 1 3 2011.02.04 00:35:10 1 4 2011.02.04 00:47:10 2 1 2011.02.04 00:21:21 2 2 2011.02.04 00:31:11 2 3 2011.02.04 00:41:10 Because of the sequential order i column 'Order', the time difference will be the date value in row 4 minus the date value in row 1. So I want to arrive at this table (time_df): Round TimeDiff 1 26.39 2 19.39
You can use `groupby` with difference `min` and `max`: df['Date'] = pd.to_datetime(df['Date'], format='%Y.%m.%d %H:%M:%S') print df Round Order Date 0 1 1 2011-02-04 00:20:21 1 1 2 2011-02-04 00:25:11 2 1 3 2011-02-04 00:35:10 3 1 4 2011-02-04 00:47:10 4 2 1 2011-02-04 00:21:21 5 2 2 2011-02-04 00:31:11 6 2 3 2011-02-04 00:41:10 print df.groupby('Round')['Date'].apply(lambda x: x.max() - x.min()) Round 1 00:26:49 2 00:19:49 Name: Date, dtype: timedelta64[ns]
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 1, "tags": "python, pandas" }
C# ListBox Selected Item Null Exception The user can click an item in a ListBox as follows: private void listBox1_SelectedIndexChanged(object sender, EventArgs e) { textBox2.Clear(); listBox2.Items.Clear(); string[] p = Directory.GetFiles( textBoxDir.Text, listBox1.SelectedItem.ToString(), SearchOption.AllDirectories); foreach (string open in p) ...... } All is fine. However if the user clicks on an empty space in the ListBox, it displays the following error: System.NullReferenceException This is because of this line of code: string[] p = Directory.GetFiles( textBoxDir.Text, listBox1.SelectedItem.ToString(), SearchOption.AllDirectories); Does anyone have a clever work around? Or suggest an aalternative to my code?
The workaround is to check for a null value, and exit early. if (listBox1.SelectedItem == null) { return; } This avoids the nesting introduced by the other answers, which makes the code less readable.
stackexchange-stackoverflow
{ "answer_score": 11, "question_score": 4, "tags": "c#, listbox, nullreferenceexception" }
Should I connect two 4-pin EATX12V power plugs? I have an Asus P8Z68-V Pro motherboard and a Cooler Master Silent Pro 700W PSU. The PSU has two 4-pin connectors and the motherboard has one 8-pin EATX12V connector. It boots fine with only one 4-pin connector plugged into the 8-pin EATX12V connector. I wonder whether I should also plug the other 4-pin connector from the PSU into the 8-pin connector on the motherboard, that is, plug the 4-pin connectors side by side into the 8-pin connector? I have not tried because I am afraid to damage something. Also, if I should connect it, how would I benefit? The manual (you have to select OS, select any, and then choose the English manual to reach it) says the following: !ATX power connectors of Asus P8Z68-V Pro !Installation of ATX power connectors on Asus P8Z68-V Pro
Speaking as an owner of the 1kW version, I can say that the two connectors you're talking about do sit side-by-side in the EATX12V port. They're split up (on most PSUs, not just the CM-SP) to allow people to use them on old motherboards where they only have 4-pin auxilliary power ports. The pins on the connectors are "keyed" in such a way that the connectors will only go in the right holes. On some PSUs both connectors have some sort of marking to indicate which way they fit together. I can't remember if the Silent Pro's does or not but it's fairly obvious from the way they're bound and if they fit in ;) I'd heartily suggest you plug it in. It'll give you better stability if you ever play around with the voltages... And does no harm if you don't.
stackexchange-superuser
{ "answer_score": 5, "question_score": 10, "tags": "power supply" }
Segmentation fault when writing to struct I have a `struct` defined in my program as: struct memregion { void *from; void *to; int mode; } I declare in my program, an array of this struct as `struct memregion regions[10]`. Then I pass it to a function as `get_mem_layout(regions, 10)` whose declaration is: void get_mem_layout(struct memregion *regions, int size) However, when I try to write data to any member variable of the struct as regions[j].mode = 1; OR void *addr; addr = (void *)0; regions[j].from = addr; I receive a segmentation fault. I cannot determine why this is happening. Please help. UPDATE: Full code removed because it was part of an assignment. Problem was resolved through @paddy's answer.
Why has nobody picked this up? Or am I missing something? In `get_mem_layout` one of the first things you did is this: regions = 0; Then you go on to access `regions` as an array... Did you mean: num_regions = 0;
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": 2, "tags": "c, pointers, struct, segmentation fault" }
How to capture scroll start event on iPhone/Android I'm using JQuery with a mobile site to reposition the header nav on scroll in the absence of position:fixed support. That works fine, when the user stops scrolling the header is placed back at the top of the page. To enhance the experience for the user I want to hide() the header when the user _starts_ to scroll and then have it slide in when they stop. The problem is that the scroll event only fires when the user stops scrolling. I've read that there are iOS specific touch events but is there any way I can capture a scroll start event on iOS and Android using mutually common code? Thanks
I believe jQuery Mobile, can do this. Take a look at the following code: $(document).bind("scrollstop", function() { //What occurs when the scrolling stops alert("You have stopped scrolling"); }); $(document).bind("scrollstart", function() { //What occurs when the scrolling starts alert("You have started scrolling"); });
stackexchange-stackoverflow
{ "answer_score": 5, "question_score": 2, "tags": "jquery, android, iphone, events, scroll" }
Проблема с преобразованием string в int php Есть скрипт: $passport = '28 48 399999'; $passport = str_replace(' ','', $passport); $passport = intval($passport); var_dump($passport); Его dump: `int(2147483647)` Вопрос: почему? пробелы убрал, а в число преобразует кое-как...
2 147 483 647 — это 231–1, максимальное целое число, помещающееся в 32 бита. Ваше число 2 848 399 999 больше, поэтому PHP решил преобразовать его к самому близкому значению, которое может быть представлено. Похапэ искаропки не умеет в длинные целые. Должны быть математические пакеты, если вам это действительно нужно.
stackexchange-ru_stackoverflow
{ "answer_score": 2, "question_score": 3, "tags": "php, числа" }
Django find_each (like RoR) Is there way to use `find_each` in django? According to the rails documentation: > This method is only intended to use for batch processing of large amounts of records that wouldn’t fit in memory all at once. If you just need to loop over less than 1000 records, it’s probably better just to use the regular find methods. < Thanks.
One possible solution could be to use the built-in `Paginator` class (could save a lot of hassle). < Try something like: from django.core.paginator import Paginator from yourapp.models import YourModel result_query = YourModel.objects.filter(<your find conditions>) paginator = Paginator(result_query, 1000) # the desired batch size for page in range(1, paginator.num_pages + 1): for row in paginator.page(page).object_list: # here you can add your required code Or, you could use the limiting options as per needs to iterate over the results.
stackexchange-stackoverflow
{ "answer_score": 5, "question_score": 3, "tags": "python, ruby on rails, django" }
Break line an inline list I have an inline list and I need to line break the list in two lines... <ul> <li><h1><a href="#">One</a></h1></li> <li><h1><a href="#">Two</a></h1></li> <li><h1><a href="#">Three</a></h1></li> <li><h1><a href="#">Four</a></h1></li> <li><h1><a href="#">Five</a></h1></li> <li><h1><a href="#">Six</a></h1></li> <li><h1><a href="#">Seven</a></h1></li> </ul> Desire result: **One Two Three Four < /br> Five Six Seven**
What about `float` and `clear`? ul {overflow: hidden;} li {float: left;} li:nth-child(4) {clear: left;} < Or if you don't want to float items and use, as you wrote, `display: inline`, you can use this code with `:before`: ul {overflow: hidden;} li, h1 {display: inline;} li:nth-child(4):before {display: block; content: '';} <
stackexchange-stackoverflow
{ "answer_score": 10, "question_score": 6, "tags": "html, css" }
how to make tor functions on Heroku How can I make Tor functions on Heroku? I'm using tor as a proxy rotator along with my python project for web crawling. Everything works fine on localhost but I don't find how to make tor functions on Heroku? do I just install it on the Heroku server? or are there any other solutions?
@lmen is probably talking about Tor Proxy Buildpack for Heroku, it can setup Tor on a heroku node with socks5 and control port available (They can be configured in the environment values). All you need to do is run $ heroku buildpacks:add And it will automatically setup a proxy that you can use at port 9050.
stackexchange-tor
{ "answer_score": 1, "question_score": 2, "tags": "tor install, server, python" }
how to convert integer to bool in html? I have below code where hold.Property__r.Holds__c is a numeric value due to which I am getting error. Can someone suggest how we convert this field to bool <div if:true={hold.Property__r.Holds__c} class="slds-col slds-size_1-of-2"> <lightning-badge class="slds-text-heading_medium" label="On Hold"></lightning-badge> </div> <div if:false={hold.Property__r.Holds__c} class="slds-col slds-size_1-of-2"> <lightning-badge class="slds-text-heading_medium" label="Error - Incorrect Hold Status"></lightning-badge> </div>
As @OlehBerehovskyi said, use a getter that coerces the number into a boolean. The assumption here is that you care if the "holds" value is non-zero. First, add the following getter to your LWC: get holds() { return !!this.hold?.Property__r?.Holds__c; } And update your template to use: <div if:true={holds} class="slds-col slds-size_1-of-2"> ... This works by: 1. Using "!!" to get the "truthiness" of a number; it first does a "not" of a number, which is a boolean indicating whether it is zero (the "falsiness"), then notting that again to indicate whether the number is non-zero (the "truthiness"). 2. Using safe navigation, which stops the traversal of the path if there's a null/undefined; note that the "!!" still works here because it gets the truthiness of null/undefined in the same way it would for a number (or string etc.). 3. Using the getter in the template.
stackexchange-salesforce
{ "answer_score": 3, "question_score": 0, "tags": "apex, lightning web components, salesforcedx" }
How to get multiple random numbers in sqlite3 I'm trying to sample multiple records from big table randomly. Currently, a way I can go is to make random numbers in python and use them in sqlite3. Though I know random() of sqlite gives a random number, I don't know how to get (DISTINCT) multiple random numbers in sqlite. If I can make a table filled with random numbers, it would be OK.
If you know how many rows you want, you can use something like: SELECT DISTINCT col1, col2, etc FROM yourtable ORDER BY random() LIMIT 10;
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "sqlite" }
Creating a page footer div? I need to create a page footer, basically a div that stretch 100% width of the page. With a height of 300px. I need it to stick to the absolute bottom of the page. Could somebody please show me how to do this using CSS? I have not included code as the code would simply be div tags. Thanks
If you set the footer to position: fixed, it will appear above your content, even if the page is longer than the window. If what you want is only to keep the footer at the bottom, even when the content is really short, there's that answer : Sticky footer on Stack overflow That way, your footer will stay at the bottom of the page OR at the end of the content.
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": -3, "tags": "jquery, css, css position, footer, sticky footer" }
How to define database variable for logging in Kettle? I would like to know if there is a proper way to pass the database connections variable so they can be used in the logging sections of both jobs and transformations. Regards, Nicolas.
Edit the kettle.properties from the top menu. If you want to do it for _ALL_ the log use the variables like KETTLE_JOB_LOG_* and KETTLE_JOB_TRANS_*. There is no way to do it for job and transformation at the same time, but it is defining 8 variables (instead of 4) which can be copy/pasted. If you want to do it for specific job and/or transformation, define your own variables like log_bd, log_table,... and use them as ${log_db}, ${log_table},... You have to define the parameters for each job and transformation. Or else, you could write a small program to change the xml of the .ktr and .kjb.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "kettle, pentaho data integration, spoon" }
Combining CSS Classes in CSS Modules in React I am using Fontawesome icons in my react and I am using CSS modules in react. Now I want to use this Icon so I am using the following syntax : `<i className={styles['fa-user-circle']} ></i>` I cant use normal syntax `styles.someClassName` because of hyphens in the name of fontawesome icons and also I need to combine fas and fa-user-circle classNames . How do I do that? Thanks.
You can use the FontAwesome React version here Implementation of it looks like import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; import { faPlus } from '@fortawesome/free-solid-svg-icons' and your render component looks like export default (props) => { return ( <div> <FontAwesomeIcon icon={faPlus} className="pointer" onClick={props.onAdd} id={props.id} /> </div> ) } As you can see className we can give so whatever the extra CSS you want to give you can.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "css, reactjs, react css modules" }
What is this insect? Found in Peru I took the pictures today in Cusco Peru. It is the third insect of its class in a month. I never see it before. I thought that it is a wasp, but I think it's really thin to be a wasp. It's about 4 or 5cm. I want to know what kind of insect is and if it's dangerous. Thanks! !enter image description here !enter image description here !enter image description here !enter image description here
So that looks to me like the _Ophioninae_ family of wasps, genus _Ophion_. I'll query the list of known species to try to find a more direct match. !enter image description here Some evidence exists which notes _Ophion_ may sting when threatened, but at the same time (and I don't have the reference ready) it's believed that the sting contains no toxin. As for a positive identification, it's difficult without examining the the features of the wasp extremely close up. Identification keys exist here.
stackexchange-biology
{ "answer_score": 12, "question_score": 15, "tags": "entomology, species identification" }
text to phonemes converter I'm searching for a tool that converts text to phonemes, (like text to speech software) I can program one but it will not be without errors and takes a lot of time! so my question is: is there a simple tool for converting e.g. "hello" to "HH AH0 L OW1" maybe some command-line tool so i can capture the stdout? i'm searching for the phonemes in 'Arpabet' style (see the 'hello' example). espeak does something like that but the output is not in Arpabet style and the phonemes are not split by some determiner.
If you had searched for Arpabet on wiki you would have found your answer. The CMU guys have prepared scripts which convert most english words to their respective Arpabet phonetic break up. If you want the phone sequence of a couple of words you can use their interface here. But, if you want it for a big file then you might have to run their scripts on your own. They used to have a working page here, but it seems to be not working now.
stackexchange-stackoverflow
{ "answer_score": 7, "question_score": 10, "tags": "text, text to speech, speech" }
Regex to replace a string In VI I need to replace a pattern that looks like this: seq- followed by exactly 24 chars (can be 0-9, a-z, A-Z only) followed by / followed by some number of (0-9, a-z, A-Z). So an example string would be: seq-BzFk78qrJBkbnv1KkxppsfG4/92191_A_B I want to replace the above string with a fixed string: seq-ID/NUM_ID How do I do this in Vi or Vim? I tried a few things like :%s/seq-[a-zA-Z0-9]{24}/[a-zA-Z0-9]{+}/seq-ID/NUM_ID But it doesnt' work..
You have to be careful with how you use quantifier and you must escape the `/`. Try this :%s/^seq-[a-zA-Z0-9]\{24\}\/.*$/seq-ID\/NUM_ID/
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "regex, search, vim, replace, vi" }
How to create a regex which accepts 12 numbers with plus, minus, space I want to create regex which should have following things: * The regex is for validating phone numbers so it should have minimum length 10 digits and maximum length of 12 digits except special symbols like `+`, `-` and space. * Plus sign only allowed at start. I tried below regex but not working for me. ^\+[-0-9 ]\d{10,12}$ Please advice me how I can achieve this. Below are few examples for which I need to write regex: +12 1234567890 +12 12 345 567 89 +12 123-455-6789 +9712345567 In the question which was said to be a duplicate, do not have any information regarding restricting the length upto 12 numbers.
This regex allows `+` at start and `-` or space between digits. ^\+?0-9{9,11}$ Last character needs to be a digit.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "javascript, regex" }
Windows 8 / 8.1 / 8.1 Update 1 Bluetooth File Transfer My laptop came with Windows 8 pre-installed. I've since updated it to Windows 8.1, and recently, 8.1 update 1. For an OS which focused on more mobile tech, I have to say, it sure made BlueTooth File transfers a PITA, especially compared to Windows 7. Here's my BlueTooth Icon on the systray. Notice the lack of Send / Receive File Options. !enter image description here And here's my BlueTooth Settings: !enter image description here I don't see anything out of the ordinary. I'm aware that I can type `fsquirt` in command prompt to bring up the original File Transfer Dialog, but really, Windows 8? Is there an easier way to do this? Did I miss something?
Due to the ambiguity of your question, I can only guess what the problem is. More research and editing would be required to achieve a definite answer. The lack of Send/Receive File options is, as Ramhound said, probably due to you not having any devices connected. I recommend checking the connectivity of the device you're trying to transfer files to. If your bluetooth devices are connected, your drivers may be out of date. As (I'm guessing) you know, those options exist, and they look like this: !enter image description here Source I provided that image because I'm unsure if you have ever been able to successfully transfer files via Bluetooth, and if anything has changed in your setup since then. Good luck!
stackexchange-superuser
{ "answer_score": 1, "question_score": 0, "tags": "windows 8, bluetooth" }
Meaning of in the margins What is the meaning of **in the margins** in the following sentence > The Left has joined the Congress **in the margins** , and it will be a contest between the aggressive Hindutva agenda of the BJP, and the incoherence of the AITMC which is often seen as indulgence of Muslim communal politics, in West Bengal. Does it mean **in very small amounts**?
Yes, it basically means that. More specifically, it could mean that they will not be in the middle of things---'where the action is'---either physically or metaphorically (with regard to power). The reason for this is presumably that not enough of them were voted into power. In British politics, the physical aspect is actually relevant, because the leading two parties in Parliament do get to sit in the best seats, in the middle of the benches, and people from marginal / fringe parties sometimes have to crowd in at the edges.
stackexchange-ell
{ "answer_score": 1, "question_score": 0, "tags": "meaning" }
Normal app with ARKit as a "bonus"? I am doing some experiments with ARKit and tried to run in an iPhone 5S just to see what happens: I got this error in Xcode 9.0 beta 6: > “ARDemo” requires the “ARKit” capability which is not supported by iPhone So far so good. My question is (and is kinda related with this one): is it possible to install in an iPhone lower that iPhone 6S even though the ARKit will not work? I want to be able to offer ARKit as a complement to an app, but only offer it if the device supports it.
You can ship a product that uses ARKit to any device, provided you check for it runtime. If the package won't install to devices then the project has the arkit capability marked as required and this will block installation. Just remove this from the `UIRequiredDeviceCapabilities` section in the info.plist and the installation will succeed. See the documentation
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": 1, "tags": "ios, iphone, arkit" }
Measurability of set of points where a measurable function sequence is strictly increasing pointwise Let $\\{f_n\\}$ be a sequence of measurable functions from $\mathbb{R}$ to itself. How do we show that the set $S=\\{x\in\mathbb{R} \,\, |\,\, \\{f_n(x)\\} \,\text{is strictly increasing}\\}$ is a measurable set? I think we need to write the set as a union and intersection of inverse images of $f_n$'s but I have no idea how to proceed. Please drop some hints!
Yes, $S$ is measurable. Define $A_n=\\{x| f_{n+1}(x) -f_n(x)>0)\\}$. Then $S=\bigcap_{n\geq 1} A_{n}$.
stackexchange-math
{ "answer_score": 2, "question_score": 4, "tags": "measure theory, lebesgue measure" }
Ref parameters and reflection I'm not sure if I'm totally missing something here but I can't find any way to determine if a parameter is passed by reference or not by using reflection. ArgumentInfo has a property "IsOut", but no "IsRef". How would I go about to get all reference parameters in a given MethodInfo?
ParameterInfo[] parameters = myMethodInfo.GetParameters(); foreach(ParameterInfo parameter in parameters) { bool isRef = parameterInfo.ParameterType.IsByRef; }
stackexchange-stackoverflow
{ "answer_score": 42, "question_score": 35, "tags": "c#, reflection" }
SharpDX v4.0.1 sharpdx_direct3d11_effects_x64.dll DLLNotFoundException Last year, I asked the question how to solve a DllNotFoundException for sharpdx_direct3d11_effects_x64.dll with SharpDX.Direct3D11.Effects.dll **version 3** Now I'm trying the same thing with **version 4**. I was expecting the two DLLs sharpdx_direct3d11_effects_x64.dll and sharpdx_direct3d11_effects_x32.dll to be added to the Visual Studio project but they are not. ![enter image description here]( Has the deployment mechanism for these two DLLs changed?
OK I got this to work thanks to @Leo-MSFT's answer above. 1. I had to download the NuGet package from here. 2. Rename to *.zip and unzip 3. Copy the folders runtime/win-x64/sharpdx_direct3d11_1_effects.dll and runtime/win-x86/sharpdx_direct3d11_1_effects.dll to my project and set to Copy Always This didnt' work so I now copied win-x64/sharpdx_direct3d11_1_effects.dll to the project root and renamed as win-x64/sharpdx_direct3d11_1_effects_x64.dll and set to Copy Always and it worked. ![enter image description here]( I'm sure this isn't intentional so I've reported a bug to SharpDX on Github.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 1, "tags": "c#, visual studio, nuget, sharpdx" }
Send UIImageView (label background) to back to display UILabel I am trying to add an image as a background to a UILabel, but my UILabel's title cannot be seen, even though I tried to send the background image to the back. My code is below and any advice on how to help with this would be great, thanks! UIImageView *labelBackground = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"image.png"]]; [myLabel addSubview:labelBackground]; [myLabel sendSubviewToBack:labelBackground]; myLabel.backgroundColor = [UIColor clearColor]; [myLabel setText:title];
When you add a view (your image view) as a subview to another view (your label), the subview will always be in front of its superview. They would either need to be siblings: [myContainer addSubview:labelBackground]; [myContainer addSubview:myLabel]; or better yet, the label should be a subview of the image view: [labelBackground addSubview:myLabel]; [myContainer addSubView:labelBackground]; Another solution might be to use your image as a background color for your label: [myLabel setBackgroundColor:[UIColor colorWithPatternImage:myUIImage]]; But note that the image will be repeated instead of centered or stretched.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "uiimageview, uilabel" }
Best way to work easily with a database in remote programs? In Database 101 you learned never to distribute the sensitive database password along with your program, since all a person has to do is reverse engineer the program, find where you actually need the original password for authentication, then echo/print that line. However when you have multiple remote programs that need to talk to a central database, what do you do? My hackish solutions used to involve PHP, tons of `GET` variables, and JSON. I would make a request to the server with a set mode and parameters, then parse the JSON output. It was buggy, not entirely secure (only slowed an attacker down) since I didn't have any registration mechanism, hard to scale, and made all existing ORM's useless. Besides, it was attempting to reinvent SSH or SSL, not something that's too terribly smart. What's the alternative though? What other options are out there that can provide security for the database while making it easy on me?
The biggest thing I can comment on with databases and applications is to have multiple accounts. Separate accounts for read and write access also and give these accounts the least required access to complete the given task. You do have alternatives such as VPN's/SSH tunnels too have a more secure channel for distributed remote access to your central database. Also, you should never really in your applications directly deal with the database, rather your applications should have a database abstraction layer or some sort which interacts with database. This is one: good design, and two: a better approach as you place all the DB interaction in one place and provide your application with an API to use the database interaction layer.
stackexchange-softwareengineering
{ "answer_score": 5, "question_score": 4, "tags": "database, distributed development" }
regex to convert plain image url to img tags I know there are other topics but most of them have different issues. I am trying to match image urls inside plain text and convert them to tags but the regex is not working right `/(http|https):\/\/(\S*)\.(jpg|gif|png)(\?(\S*))?/i` the above should match an image with url string: ` and without query string: ` but it should NOT match this one, **notice the X at the end** : ` that is not an url of an image and my current regex matches that, how can I adjust the regext NOT to match that last URL format ?
You can add a lookahead at the end that checks the next character after the url _(here, a whitespace character, the end of the string or a punctuation character)_ : ~https?://\S+\.(?:jpe?g|gif|png)(?:\?\S*)?(?=\s|$|\pP)~i
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "php, regex, image, preg replace, preg match" }
Convertir miles y decimales con Expresion regular Necesito de su ayuda debido a que tengo una expresion regular para convertir un numero a milles y decimales, pero cuando le pongo mas de tres decimales tambien le da formato a los decimales, com se lo podria quitar...? function milesNumeros(numero) { return numero.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","); }; console.log("Esta Ok: " + milesNumeros(36598365.36)); console.log("Error: " + milesNumeros(3.659836536));
Intenta hacerlo así: (\d) # Encuentra un dígito (sera reinsertado) (?: (?=\d+(?=[^\d.])) # En el caso que no haya decimales (?=(?:\d{3})+ # Chequea que haya digitos multiplos de 3 al principio \b) # Hasta el ultimo digito | # O (?=\d+(?=\.)) # En el caso que tenga decimales (?=(?:\d{3})+ # Chequea que haya digitos multiplos de 3 al principio (?=\.)) # Hasta el punto ) function milesNumeros(numero) { return numero.toString().replace(/(\d)(?:(?=\d+(?=[^\d.]))(?=(?:[0-9]{3})+\b)|(?=\d+(?=\.))(?=(?:[0-9]{3})+(?=\.)))/g, "$1,"); }; console.log("Esta Ok: " + milesNumeros(36598365.36)); console.log("Esta Ok: " + milesNumeros(3.659836536)); Respuesta original aquí
stackexchange-es_stackoverflow
{ "answer_score": 2, "question_score": 2, "tags": "javascript, regex" }
How to add a section header in UITableView How can I add a section header in UITableView?
if you just want section header title, you can use UITableViewDataSource method: - (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section Or you can set you custom view as header using UITableViewDelegate method: - (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section The controller implementing these, needs to be the delegate/datasource of your table view.
stackexchange-stackoverflow
{ "answer_score": 24, "question_score": 10, "tags": "iphone, uitableview" }
Array to String conversion Can I convert an array to a string in apex? Is string valueOf() method an efficient way to convert it?
I think `String.join()` method is what you are looking for, since it > Joins the elements of the specified iterable object, such as a List, into a single String separated by the specified separator. For instance List<String> elements = new List<String>{ 'one', 'two', 'three' }; String.join(elements, ''); // 'onetwothree'
stackexchange-salesforce
{ "answer_score": 6, "question_score": 0, "tags": "lightning web components, json, js" }
Cleaning out laptop hinges and buttons after a soda spill I had a soda spill on my laptop. I only had technical issues with the keyboard but I fixed that by purchasing a new keyboard part. However, I still have issues with stickyness on the hinges between the monitor and the laptop, and a couple of buttons. Any suggestions on how to clean this up? **Note:** I'm assuming this will require some sort of distilled water or something. Just mentioning that because I'm willing to let it dry out for as long as it takes. Just want to get rid of the stickiness.
I would go with rubbing alcohol
stackexchange-superuser
{ "answer_score": 2, "question_score": 1, "tags": "laptop, cleaning" }
Rails -- routing: using a sub-directory before controller/action Say I have an application called employeesmanager, and it has an `employees` resource, so `/employees/new` is a new employee etc. I want to have the name of the company preceding this action, so for example, `ford/employees/new` should create a new employee at ford, while `exxon/employees/new` should create a new employee at exxon. What is the best way to do this? Ideally I don't want to have to use nested controllers with `/company/exxon/employees/new` because that seems like extra wasted words in the URL that can be annoying to type in.
scope ":company_name" do resources :employees end For more details check out Rails Guides on routing.
stackexchange-stackoverflow
{ "answer_score": 4, "question_score": 3, "tags": "ruby on rails 3, routes" }