INSTRUCTION
stringlengths
25
999
RESPONSE
stringlengths
0
999
SOURCE
stringlengths
16
38
METADATA
dict
Emacs installer for Windows 8 As of the 1st of April 2013 (and no, this is not an April Fool prank) the Emacs Windows FAQ states that Emacs 23.3 is known to run on all versions of Windows from Windows 95 and Windows NT 4.0 through to Vista. Are there any approved Emacs installers (i.e. not self-build) tried and tested on Windows 8?
There are native Windows builds of FSF Emacs at <ftp://ftp.gnu.org/gnu/emacs/windows/> (e.g., `emacs-24.3-bin-i386.zip`). Just extract the ZIP file wherever you prefer, and create a shortcut to `bin\runemacs.exe`.
stackexchange-superuser
{ "answer_score": 4, "question_score": 7, "tags": "windows 8, emacs" }
Intel HD 3000 - Will system memory increase performance? I have a Dell Latitude 5420 Laptop. It has a 2nd-gen Intel i5 with Intel HD 3000 graphics. I have 4GB of ram. I realize that this will never be close to discrete graphics, but would adding more system ram help gaming performance at all since the system ram is shared with the video chip? Also, how can I tell if my BIOS will support 1600 mhz ram? The memory I have now is 1333, and if it will make a difference, I'll buy 8GB of 1600.
No, not at all. In fact, because accessing RAM is the bottleneck on shared memory setups, extreme cleverness and engineering brilliance is used to permit the graphics subsystem to use as _little_ system memory as possible. The more memory it accesses, the more time it spends accessing that memory, and thus the slower the graphics system goes. Worse, that also makes the rest of the system slower because other CPU memory accesses compete with graphics subsystem accesses. The exception would be if all of your memory channels weren't populated. If you have one 4GB stick, adding a second will help a bit because it will give you two memory channels. if you have two 2GB sticks, then you already have all channels populated, so there's no performance benefit there.
stackexchange-superuser
{ "answer_score": 4, "question_score": 2, "tags": "memory, integrated graphics, intel core i5" }
On session timeout capture info Trying to implement data to be saved on the session timeout.how can i capture the `session timeout event`.
You have to implement `Session_End` event in `Global.asax`, The Session_End event is raised at the end of a request when the Abandon method has been called or when the session has expired. A session expires when the number of minutes specified by the Timeout property passes without a request being made for the session. **MSDN reference** publicvoid Session_OnEnd() { //Saving of data goes here. }
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": -2, "tags": "asp.net" }
When not "all" neither "some" is stated, what is implied? For example, in sentence "Multinational companies are unethically exploiting the plant genetic resources of developing countries." is it implied that ALL multinational companies do that, or that SOME multinational companies do that? My math teacher once told me, that in math "all" is always implied, and "some" is never implied, but I guess English rules may be different from math rules.
The context usually indicates whether you should interpret it as some or all. I think that it is reasonable to assume **some** in your sentence, as it would be difficult to collect sufficient evidence that all were doing it. > Visitors to Indonesia must apply in advance for a visa and provide evidence of a recent health check. In this sentence, we should assume **all**. It describes a law and, unless otherwise stated, laws apply equally to all people. > Triangles have three sides Like law, mathematics is logical, so it is generally reasonable to assume **all**.
stackexchange-ell
{ "answer_score": 2, "question_score": 1, "tags": "ambiguity" }
What is the idea of this rook move in this puzzle? < (Also if anyone knows how to start the PGN player with a black move, please let me know) [Event "Juan Martinez Sola Open A"] [Site "Almeria ESP"] [Date "2015.12.18"] [Round "2.1"] [White "Arboledas Fernandez,A"] [Black "Del Rio de Angelis,S"] [FEN "q3r3/5k2/p4n2/2p1p3/1p3n1Q/1P2N2P/2B3P1/3R3K b - - 1 1"] 1. ... Rh8 My thought process is that the white knight is the only thing preventing Qg2#, so maybe putting a knight on d5 can deflect it away. The solution of the puzzle for black is Rh8. This puts a threat on the white queen but it can just move away. The engine recommends either 2. Be4 Qxe4 and trade off pieces or 2. Bh7 to sacrifice the bishop, but I don't understand why Black has to trade. So why is Rh8 the correct move?
> so maybe putting a knight on d5 can deflect it away Putting a knight on d5 will close the h1-a8 diagonal after a capture on d5 and therefore gives the chance to counterattack for white. Haven't analyzed but from intuitive POV black might even lose the knight after something like `1. ... N6d5 2. Nxd5 Nxd5 3. Be4` > So why is Rh8 the correct move? Notice the **a8** Queen pins the **g2** pawn and therefore **Rxh3** is a threat. Also White queen doesn't have any good squares apart from **e1** and **f2** to defend the **e3** Knight to the threat of **Rxh3** -> **Rxe3** > My thought process is that the white knight is the only thing preventing Qg2#, This is exactly the idea behind Rh8 as well. say after Qf2 comes Rxh3, then in the next move comes Rxe3 removing the g2 defending Knight. White queen can't recapture rook since g2 will be unprotected then. This sequence will leave black with an extra piece and with then threats of Re2.
stackexchange-chess
{ "answer_score": 0, "question_score": 1, "tags": "puzzles" }
Adding App Recommendation Support Library for TV I am trying to add the app recommendation surrport library for TV to my Android TV project, but when I add the following Gradle dependency, it fails to find it: compile 'com.android.support:app.recommendation-app:23.0.0' I have the Android Support Repository downloaded via the SDK Manager, but it cannot seem to resolve the dependency. Here is the link to the Android documentation: <
It appears that the library is now included in the release of the `23.0.1` revision of the Android Support Library. It can be added as a dependency to a project like this: compile 'com.android.support:recommendation:23.0.1'
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 2, "tags": "android, android support library, android tv" }
Query works in mysql but not in PHP Following is my prepared statement which I am using to make insertion in a table. When I run the same query in mysql by only changing `?` in actual values then the query runs successfully but it doesnot in PHP and gives following error: `Call to a member function execute() on a non-object` Kindly let me know what I did wrong: $stmt = $con->prepare(" INSERT INTO test_given ( test_id, test_giver, test_completed, dt_created ) SELECT * FROM ( SELECT ?, ?, '0',NOW() ) AS tmp WHERE NOT EXISTS ( SELECT test_id FROM test_given WHERE test_id = ? AND test_giver = ? ) limit 1 "); // s means only string input is allowed $stmt->bind_param("ssss", $qid, $username,$qid, $username); _Note: I echoed $qid, $username and they are getting right values._
You can't use `?` for table names. In SQL, values look like `"value"`, while table/column names look like ``colname`` (backtick, not single quote); they're not interchangeable. You can use `sprintf` and manually escape the table name with `mysqli_escape_string`, ie.: $stmt = $con->prepare(sprintf(" INSERT INTO test_given ( test_id, test_giver, test_completed, dt_created ) SELECT * FROM ( SELECT `%s`, `%s`, '0',NOW() ) AS tmp WHERE NOT EXISTS ( SELECT test_id FROM test_given WHERE test_id = ? AND test_giver = ? ) limit 1 "), $qid, $username); // s means only string input is allowed $stmt->bind_param("ss", $qid, $username);
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "php" }
Nuget as a package manager I'm looking to work on an application, an internal toolbelt if you will. Rather than having users messing around with DLL's for the differing tools (they plug in via MEF) I was wondering if it's possible to jump on the back of Nuget? I'd build the tools, package them as nuget packages and host them internally and the toolbelt application would then query the catalog, retrieve and extract etc etc. Does anybody know of a way this is possible?
Chocolatey uses nuget as an underlying package manager to install applications on your pc. < So I'm sure it's possible, but I've not done it myself. The nuget documentation discusses a command line and power shell reference: < Also linqpad, does something similar (in the paid for version), where you can include dll's from nuget. There is a screen shot on this page: <
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 1, "tags": "c#, nuget, nuget package" }
Why is $\frac{\sqrt{32}}{\sqrt{14D}}=\frac{4\sqrt{7D}}{7D}$ and not $2\sqrt{8}$? I am asked to simplify $\frac{\sqrt{32}}{\sqrt{14D}}$ and am provided with the solution $\frac{4\sqrt{7D}}{7D}$. (Side question, in the solution why can't $\sqrt{7D}$ and $7D$ cancel out since one is in he denominator so if multiplying out would it not be $\sqrt{7D} * 7D = 0$?) I gave this question a try but arrived at $2\sqrt{8}$. Here's my working: (multiply out the radicals in the denominator) $\frac{\sqrt{32}}{\sqrt{14D}}$ = $\frac{\sqrt{32}}{\sqrt{14D}} * \frac{\sqrt{14D}}{\sqrt{14D}}$ = $\frac{\sqrt{32}\sqrt{14D}}{14D}$ = (Use product rule to split out 32 in numerator) $\frac{\sqrt{4}\sqrt{8}\sqrt{14D}}{14D}$ = $\frac{2\sqrt{8}\sqrt{14D}}{14D}$ = Then, using my presumably flawed logic in my side question above I cancelled out $14D$ to arrive at $2\sqrt{8}$ Where did I go wrong and how can I arrive at $\frac{4\sqrt{7D}}{7D}$?
Hint: Multiplying numerator and denomninator by $$\sqrt{14D}$$ we get $$\frac{\sqrt{32}\sqrt{14D}}{14D}$$ and this is equal b$$\frac{4\sqrt{2}{\sqrt{2}}\sqrt{7D}}{14D}$$ and this is equal to $$\frac{4\sqrt{7D}}{7D}$$ for $$D\neq 0$$ $$\sqrt{32}=\sqrt{2\cdot 16}=4\sqrt{2}$$ and $$\sqrt{14}=\sqrt{2}\sqrt{7}$$
stackexchange-math
{ "answer_score": 2, "question_score": 0, "tags": "algebra precalculus" }
Implementing Wireless Sensor Network using Raspberri Pi3 I am supposed to write the Energy sensed routing algorithm for Wireless Sensor Network using Python. The node hardware are Raspberry Pi 3 boards. Is there any way to manipulate the wifi hardware using python (OS will be raspbian or noobs)?
Module for scanning and connecting to wifi networks on linux wifi. Module for accessing to a wireless network card's capabilities using the Linux Wireless Extensions python-wifi Module for packet manipulation scapy.
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 1, "tags": "python, linux, wifi, raspberry pi3" }
QT "Could not find the Qt platform plugin "xcb" " I installed QT-everywhere 5.15 open-source for academic reasons, but I have failed to run a program. Firstly, I compiled the necessary source files with `make` and installed the QT Creator, then I selected qmake for running programs inside it. When I tried to run an example program, I encounter this error: qt.qpa.plugin: Could not find the Qt platform plugin "xcb" in "/usr/lib/x86-64-linux-gnu" This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem. Available platform plugins are: eglfs, linuxfb, minimal, minimalegl, offscreen, vnc. The program has unexpectedly finished. The process was ended forcefully. Then I looked into `/usr/lib/x86-64-linux-gnu` for finding the xcb plugin and set `LD_LIBRARY_PATH=/usr/lib/x86-64-linux-gnu`, but again the same error appeared. What should I do to solve this problem?
**1\. Install requirements:** sudo apt install make g++ pkg-config libgl1-mesa-dev libxcb*-dev libfontconfig1-dev libxkbcommon-x11-dev python libgtk-3-dev * `python` is optional for `QtQuick`. * `libgtk-3-dev` optional if you want the GTK native theme for `QtWidgets`. **2\. Configure:** ./configure -opensource -confirm-license -nomake tests -nomake examples -prefix /path/to/install/dir **3\. Compile:** make -j $(nproc) make install
stackexchange-stackoverflow
{ "answer_score": 7, "question_score": 6, "tags": "qt, ubuntu 18.04" }
Custom logo button doesn't appear after adding theme support in functions.php Word Press I'm following tutorial to create custom theme for Word Press. I'm trying to add custom logo theme support but button doesn't appear in Word Press panel. function fja_theme_support() { add_theme_support('custom-logo'); } add_action('after_theme_setup', 'fja_theme_support); here is my word press admin panel
This is an example from Theme Developer Handbook Hook should be named `after_setup_theme`, provide an array of additional settings - you can find them here function themename_custom_logo_setup() { $defaults = array( 'height' => 100, 'width' => 400, 'flex-height' => true, 'flex-width' => true, 'header-text' => array( 'site-title', 'site-description' ), 'unlink-homepage-logo' => true, ); add_theme_support( 'custom-logo', $defaults ); } add_action( 'after_setup_theme', 'themename_custom_logo_setup' );
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "wordpress, wordpress theming" }
System bar not showing when using the macbuntu theme i think i really need your assistance in this.I've installed ubuntu 10.10 and this mac theme and so far it works fine. This morning i upgraded to `11.04` and it also went well. i just realise some of the effects were gone. so i open compizconfig settings manager, i've tried to enable the destop cube and the expo and it prompted me of desabling somethings here and there. honestly i went fast couldn't undo what i've done and i realize the new application launcher and the system bar weren't showing properly, so i decided to restart my machine.After that 'bummer', nothing were like before.no system bar, no application launcher, not menu bar for any of my applications not even for the console. How i'm going to solve this one this time. thanks for reading this and specially for helping out.
**Macbuntu** , according to its own site, is not compatible with **Unity**. After you downloaded it, you extracted it into a directory. If you've deleted that directory, re-download and re-extract. * Open a terminal, run `cd /path/to/the/macbuntu/folder/` * In that same terminal, run `./uninstall.sh` This should remove **Macbuntu**. If it does not, please read its README and/or contact the developer for support. Now we need to fix Unity. * Go to the terminal and type `gksu synaptic`. You will be prompted for your password. * Type **Unity** in the quick filter bar. !enter image description here * Right click on the **Unity** package (in the list in the middle of the window), and choose **Mark for Reinstallation**. !enter image description here * Click the apply button, and wait for the changes to finish. !enter image description here * Close Synaptic, and the terminal. You may need to log out and back in to see the changes.
stackexchange-askubuntu
{ "answer_score": 6, "question_score": 1, "tags": "11.04, compiz" }
Top color of a Scene2d.ui window? I want to create a UI window in libgdx where the top part (the part containing the title and which allows you to drag the window) has a different background color from the rest of the window. I can only set the background color for the entire window, is it possible to change it for just this top part? Code so far: WindowStyle windowStyle = new WindowStyle(new BitmapFont(), Color.WHITE, skin.newDrawable("white", Color.BLACK)); Window window = new Window("test", windowStyle); window.setMovable(true); window.padTop(20); stage.addActor(window); window.setPosition(100, 100); window.setSize(500, 300);
The top bar for UI Windows in libgdx uses the same texture as the whole window. In order to change the color for the top bar the underlying texture file will need to be modified. libgdx treats it as a whole and there is no built-in way to specify separate colors for each component of a window. There are other ways, but they are non-trivial and requires writing your own widget class to replicate most of the behavior of the built-in Window class.
stackexchange-stackoverflow
{ "answer_score": 6, "question_score": 5, "tags": "libgdx" }
How to check if a date is after today java Im trying to check whether a date entered by the user is after todays date. Here is my code: SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd"); Date enteredDate = sdf.parse(date); Date currentDate = new Date(); if(enteredDate.after(currentDate)){ Date is a variable with the user date in the format "2016/04/26". After doing some debugging i found that enteredDate and currentDate are null. Any ideas why this is? Thanks
As mentioned in comments, it's not possible that Date object will have null reference. However if sdf.parse(date) throws an exception which is suppressed then enteredDate could be null. String date="2016/04/26"; Date enteredDate=null; try { SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd"); enteredDate = sdf.parse(date); }catch (Exception ex) { // enteredDate will be null if date="287686"; } Date currentDate = new Date(); if(enteredDate.after(currentDate)){ System.out.println("after "); }else System.out.println("before");
stackexchange-stackoverflow
{ "answer_score": 5, "question_score": 0, "tags": "java, date, parsing, simpledateformat" }
"welcoming of someone" vs "welcoming to someone" Tell me please if can use the preposition _to_ after the preposition _welcoming_ in the following sentence. > The Abbasids kept the idea of a hereditary monarchy, but they moved the capital of the empire to Baghdad, and they were much more **welcoming** ( **to** ) of other non-Arab muslims in positions of power. This is from Crash Course World History. It is at 5 minute and 12 second. The use of the preposition _of_ sounds strange to me. I have looked it up the adjective in a few dictionaries, and I have not find the examples of it used with _of_. Would it not be better to use the preposition _to_.
They are both correct and both commonly used. Remember that dictionaries give you definitions, but not complete descriptions of how words are used. This US English speaker actually thinks "welcoming **of** " sounds better - it was certainly more common for most of the last hundred years. The idea in the sentence is not that the Abbasids gave a specific welcome _to_ non-Arab Muslims in positions of power, but that they had a welcoming attitude _about_ non-Arab Muslims in positions of power.
stackexchange-ell
{ "answer_score": 1, "question_score": 1, "tags": "prepositions, difference" }
TortoiseSVN - "revert changes from this revision" vs "revert to this revision" The link: < describes two ways of rolling back an SVN directory after a wrongful commit. What is the difference between the two options Revert changes from this revision Revert to this revision As a test, I added a file, rolling back using "Revert changes from this revision" and did the same process for the "Revert to this revision", and there is no difference with the state of the SVN log. Am I missing something?
Let's say you have these N sucessive commits: 1, 2, 3 and 4. If you select the commit 2 and choose "Revert to this revision", your working copy will contain the changes brought by commits 1 and 2. Commits 3 and 4 will be "canceled". If you select the commit 2 and choose "Revert changes from this revision", your working copy will contain the changes brought by commits 1, 3 and 4. Commit 2 will be "canceled", or rather, played in reverse on the top of commit 4: if a line was added, it will be removed. If a line was removed, it will be readded.
stackexchange-stackoverflow
{ "answer_score": 92, "question_score": 52, "tags": "svn, version control, tortoisesvn, revert" }
Unable to test nested Rails controller How do I manage to test **Task::HoursController**? The requests from my rspec test hits **HoursController** , not **Task::HoursController** **The route** `# POST /tasks/:task_id/hours(.:format) tasks/hours#create` **The test** describe Tasks::HoursController, :type => :controller do it "assigns all hours as @hours" do hour = Hour.create! valid_attributes get :index, { task_id: @task.id }, valid_session assigns(:hours).should eq([hour]) end end **The log output** Processing by HoursController#index as HTML Parameters: {"task_id"=>"207"} Completed 500 Internal Server Error in 3ms
It was hard for you guys to see, as I didn't post the code to my controller. The fix was this: -class Tasks::HoursSpentController < ApplicationController +module Tasks + class HoursSpentsController < ApplicationController And the suggestion @vince-v posted. Thanks Vince. :-)
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "ruby on rails, rspec, controller" }
Facebook requests example project Has anyone found an example project for this tutorial on facebook requests: < Since I have already integrated a list of facebook friends a user has, can I send each a message?
You can find the actual project on GitHub, < If you already have a list of Facebook friends you can just send them a message. Just get a comma-separated, string representation of those friends, and pass the info to the "suggested" parameter: NSString *friendList = @"12345, 4567"; NSMutableDictionary* params = [NSMutableDictionary dictionaryWithObjectsAndKeys: @"Check this out.", @"message", friendList, @"suggestions", nil]; [self.facebook dialog:@"apprequests" andParams:params andDelegate:self];
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "ios, xcode, facebook" }
Moving cvs repository to a new machine We have a CVS repository on machine 'A'. Want to copy a specific directory to machine 'B's CVS with all the history from 'A'. The problem is I can only access CVS on machine 'A' using Eclipse only (dont have access using Unix). Is it possible to do that using Eclipse?
Not really. You could probably script an automatic checkout from A and commit to B based on `cvs log` output but you'd still lose date and author information and reinstating tags and branches will probably get tricky, too. You should better find someone with file-level access to the two repositories as in that case it's a simple copy operation. No additional work required.
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 0, "tags": "cvs" }
Функция декоратор или кастинг Как мне сделать функцию обёртку, которая принимает строку, и возвращает новую строку с начальными заглавными символами? **Ввод:** _"How can mirrors be real if our eyes aren't real"_ **Вывод:** _"How Can Mirrors Be Real If Our Eyes Aren't Real"_ \-- Уточненее Да вы, правы хотелось бы увидеть как можно написать функцию декоратор, которая оборачивает другую функцию, и в итоге получается строка в которой каждое слово с заглавной буквы. Это мне позволит изменять исходную функцию по своему усмотрению, а когда нужно вызвать декоратор на этой функции и получить каждое слово с заглавной буквы. Если я правильно понимаю. Поясните? var str = "How can mirrors be real if our eyes aren't real"; var arr = str.split(' '); for (var i = 0; i < arr.length; i++) { console.log(arr[i][0].toUpperCase() + str.slice(1)); }
Полагаю, подобная функция также должна "нормализовать" хвост. function repl() { return this .replace(/[^\s-]+/g, function(txt){ return txt[0].toUpperCase() + txt.substr(1).toLowerCase(); }); } function split_map() { // сложно обработать случай "строка-пример" return this .split(/\s+/) .map((word) => word[0].toUpperCase() + word.substr(1).toLowerCase() ).join(' '); } // String.prototype.capitalize = selected_fn; var sample = 'просто сТРОКА-ПРИМЕР with RUSSIAN wORDS'; console.log(repl.apply(sample)); console.log(split_map.apply(sample)); <span style="text-transform:capitalize"> кстати, CSS решение этоГо не дЕлает </span>
stackexchange-ru_stackoverflow
{ "answer_score": 1, "question_score": -1, "tags": "javascript" }
Fast list-product sign for PackedArray? As a continuation of my previous question, Simon's method to find the list product of a PackedArray is fast, but it does not work with negative values. This can be "fixed" by `Abs` with minimal time penalty, but the sign is lost, so I will need to find the product sign separately. The fastest method that I tried is `EvenQ @ Total @ UnitStep[-lst]` lst = RandomReal[{-2, 2}, 5000000]; Do[ EvenQ@Total@UnitStep[-lst], {30} ] // Timing Out[]= {3.062, Null} Is there a faster way?
This is a little over two times faster than your solution and apart from the nonsense of using `Rule@@@` to extract the relevant term, I find it more clear - it simply counts the number elements with each sign. EvenQ[-1 /. Rule@@@Tally@Sign[lst]] To compare timings (and outputs) In[1]:= lst=RandomReal[{-2,2},5000000]; s=t={}; Do[AppendTo[s,EvenQ@Total@UnitStep[-lst]],{10}];//Timing Do[AppendTo[t,EvenQ[-1/.Rule@@@Tally@Sign[lst]]],{10}];//Timing s==t Out[3]= {2.11,Null} Out[4]= {0.96,Null} Out[5]= True
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": 2, "tags": "list, wolfram mathematica, numeric, packed" }
How can I collect a vector of Traits from an iterator of structs implementing that trait I'm trying to get a vector of traits from an iterator of structs implementing that trait. So far I was able to do this : fn foo() -> Vec<Box<dyn SomeTrait>> { let v: Vec<_> = vec![1] .iter() .map(|i| { let b: Box<dyn SomeTrait> = Box::new(TraitImpl { id: *i }); b }) .collect(); v } But I would like to make it more concise.
This works for me. Playground Though I'm not a Rust guru, so I'm not sure about `'static` limitation in `foo<S: SomeTrait + 'static>` trait SomeTrait { fn echo(&self); } impl SomeTrait for u32 { fn echo(&self) { println!("{}", self); } } fn foo<S: SomeTrait + 'static>(iter: impl Iterator<Item=S>) -> Vec<Box<dyn SomeTrait>> { iter.map(|e| Box::new(e) as Box<dyn SomeTrait>).collect() } fn main() { let v = vec!(1_u32, 2, 3); let sv = foo(v.into_iter()); sv.iter().for_each(|e| e.echo()); }
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "rust, iterator, traits" }
Familiar function of PATINDEX in mysql for Postgresql Is there any familiar function for PATINDEX of mysql for postgresql. I'm trying to make a sql like this in postgres. SELECT PATINDEX('%schools%', 'W3Schools.com'); which throw an error: > no function matches the given name and argument types. you might need to add explicit type casts To be more detailed, I'm trying to get seperate number part and string part of a string in Postgresql. I found example like this: SELECT Section FROM dbo.Section ORDER BY LEFT(Section, PATINDEX('%[0-9]%', Section)-1), -- alphabetical sort CONVERT(INT, SUBSTRING(Section, PATINDEX('%[0-9]%', Section), LEN(Section))) -- numerical
There are two ways to implement this, the example as below: postgres=# select strpos('W3Schools.com','Schools'); strpos -------- 3 (1 row) postgres=# select position('Schools' in 'W3Schools.com'); position ---------- 3 (1 row) postgres=# select regexp_matches('hahahabc123zzz', '(abc)(123)'); regexp_matches ---------------- {abc,123} postgres=# select array_to_string(regexp_matches('hahahabc123zzz', '(abc)(123)'),' '); array_to_string ----------------- abc 123 postgres=# select (regexp_matches('hahahabc123zzz', '(abc)(123)'))[1] as a, (regexp_matches('hahahabc123zzz', '(abc)(123)'))[2] as b; a | b -----+----- abc | 123 (1 row) Do you want this? And you can get all functions of string process here: <
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 1, "tags": "mysql, sql, postgresql" }
How do commit allowances work on Area 51? I have a couple of questions related to the 3 (actual) commitment allowance: * Is committing to your own proposal assumed, or does it use up one of the committments you're allowed? * Is there ever a time you are "refunded" a commitment that you can then use to commit to another proposal? Say, for example, you commit to a site and it goes live (or even to beta). Things are going great. Can you then go back and commit to another proposal to help it get launched? * Is the commitment allowance hard set at 3?
> Is committing to your own proposal assumed, or does it use up one of the committments you're allowed? No, it is not _assumed_ the author of a Proposal is committed to using the site on day one. > Is there ever a time you are "refunded" a commitment that you can then use to commit to another proposal? Say, for example, you commit to a site and it goes live (or even to beta). Things are going great. Can you then go back and commit to another proposal to help it get launched? Once a site exits beta, you are free to commit to another site. Even before the site goes to beta, you can un-commit to apply your commitment to other sites. The idea is that you only have three outstanding commitment "tokens" at any one time. > Is the commitment allowance hard set at 3? Yes. **EDIT** : We changed the way this works. Once a proposal enters the beta phase, your commitment "token" is only freed after the site exits beta.
stackexchange-meta
{ "answer_score": 12, "question_score": 10, "tags": "discussion, area 51, commitment phase, commitment, commitment fulfillment" }
how to find the original directed graph? I was thinking on a homework question given to me, it is as follows: If you are given with a BFS and DFS traversal of a directed( or un-directed graph), how would you find the original graph ? Is it possible in either case? thankyou
If I understand it correctly, it is not possible, since BFS and DFS produce a tree, and tree has |V|-1 edges. So, in these two trees you have at most 2|V|-2 different edges, and original graph can have up to |V|(|V|-1) edges for directed, and |V|(|V|-1)/2 for undirected graph.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "graph, depth first search, breadth first search" }
Direction vector of a line **Information given:** The line $x = 0 , z = \frac{1}{\sqrt{2}}$. **What I need to find:** The direction vector. **Where I'm at:** I just don't really understand how to get a direction vector from two equation. **The answer to this problem:** Vector $\vec{j}$
The line is defined by two planes * $x=0$ * $z = \frac{1}{\sqrt{2}}$ and a generic point P on the line is in the form $(0,t,\frac{1}{\sqrt{2}})=(0,0,\frac{1}{\sqrt{2}})+t(0,1,0)$ which is known as parametric form of the line equation $P(t)=P_0+t\vec v$ thus by definition the **direction vector** is $$\vec v=(0,1,0)$$
stackexchange-math
{ "answer_score": 2, "question_score": 2, "tags": "linear algebra, vectors" }
Static Block for specific products in magento Is there any way to do this : I have two kinds of products, Handmade and ready women accessories. for handmade products I want a block under the price that tell the customer "This Product is 100% Handmade" and for the ready product nothing. So it will be only for the Handmade. I already have a block but it is visible to all products, so I want it to be visible only for Handmade products. Any Ideas ?
Can you not create an attribute specifically for the Handmade products? e.g the attribute could be called 'IsHandmade'. Then on your product page (view.phtml) under the price have something like this?: <?php if ($product->getIsHandMade == 'Yes'): echo 'This Product is 100% Handmade'; endif; ?>
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "magento, magento 1.7" }
Why can't 'use' statement be in include file? Why can't my `use` statement be placed inside an `include` file? This works fine: require_once("PHPMailer_Loader.php"); use PHPMailer\PHPMailer\PHPMailer; use PHPMailer\PHPMailer\Exception; SendEmailWindows("[email protected]", "smtp test", "test body"); function SendEmailWindows($emailTo, $subject, $body){ $mail = new PHPMailer; [... all the rest of the function code] } Yet when I try to move those 2 `use` statements into my **PHPMailer_Loader.php** script (placed at the very bottom of the file), it breaks with this error: Fatal error: Class 'PHPMailer' not found in [...]\EmailTester.php on line 12 Just for tidyness and compactness I'd like to move everything into the `include` except for the function and the calling line.
The PHP manual is saying this: > The use keyword must be declared in the outermost scope of a file (the global scope) or inside namespace declarations. [...] **Importing rules are per file basis** , meaning included files will NOT inherit the parent file's importing rules. The `"Importing rules are per file basis"` part being the important one here. You _can_ `use PHPMailer\PHPMailer\PHPMailer` in your `include` file, but that only means that `PHPMailer` _(without having to specify the full class name)_ will be available inside your `include` file and **_not in the parent file_** _(the one which includes your`include` file)_. ### tl;dr You need to specify your `use ...;` statements in **every** file you want that specific `use` to apply.
stackexchange-stackoverflow
{ "answer_score": 8, "question_score": 3, "tags": "php" }
illegal to crawl open source forum and post the threads in my forum? is it illegal to crawl open source forum and then post the threads i crawled in my own forum? if yes, what is not illegal to crawl? cause there are a lot of crawling tutorials and classes you can download to crawl. i want to know what they are good for?
Whether or not it is illegal shouldn't really matter. It is (In My Opinion) unethical, it's a form of plagiarism. Crawling can be used legitimately, for instance, to provide a near-to-you "backup" of a forum if for example, you are going to be somewhere with little or no internet connectivity and you want/need to read through the forum offline, or if you want to extract certain posts containing keywords that interest you and disregard the rest. My basic point is, don't do it unless you have the permission of the site owner, you provide it as a mirror (with the owner's permission) and don't pass it off as your own, or if you are going to be the only person using it (as per my example above)
stackexchange-serverfault
{ "answer_score": 3, "question_score": 0, "tags": "php, internet" }
Can not run vstest.console.exe for Windows Store app on Azure Windows 8.1 When i trying to launch it it breaks with error: C:\Users\xakpc\.jenkins\workspace\App>"C:\Program Files (x86)\Mi crosoft Visual Studio 12.0\Common7\IDE\CommonExtensions\Microsoft\TestWindow\vst est.console.exe" "src\App\App.Tests\AppPackages\App.Tests_1.0. 0.0_x86_Debug_Test\App.Tests_1.0.0.0_x86_Debug.appx" /UseVsixExtensions:false /Platform:x86 /Logger:trx /InIsolation Microsoft (R) Test Execution Command Line Tool Version 12.0.30723.0 Copyright (c) Microsoft Corporation. All rights reserved. Starting test execution, please wait... Error: Unit tests for Windows Store apps cannot be run from BUILTIN\administrato r or TR\xakpc user accounts. Please run tests using a user account fro m which process with medium and low privileges can be launched. Does anyone has any ideas what can cause this error?
That was quite a funny. Error message > Error: Unit tests for Windows Store apps cannot be run from BUILTIN\administrato r or TR\xakpc user accounts. Please run tests using a user account fro m which process with medium and low privileges can be launched. means that i need simple local user (not administrator) account to run tests. I created new user without admin rights and tests works fine.
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "visual studio, azure, windows runtime, windows 8.1, vstest" }
Sub pages result in 404 I'm running Drupal 7, and I've cleared the cache through drush many times (drush cc all). I'm trying to access any subsequent pages beyond the front page and it results in a "Object not found error" error. Does anyone have any idea? I feel like it's most likely an Apache or site configuration issue but I can't figure out what it is.
Sounds like the problem is that clean URL's are enabled in Drupal but not supported by your Apache configuration (make sure that mod_rewrite is enabled and the folder/vhost has AllowOverrides enabled) or the .htaccess file is missing. You can verify that this is the problem by accessing the non-clean version of the URL. For example, instead of example.org/something, try example.org/?q=something. See < for more information.
stackexchange-drupal
{ "answer_score": 5, "question_score": 2, "tags": "7" }
Make persistent a DAO recordset in a class module I am filtering a DAO recordset for sub-results as part of a set of recursive tasks. I'm trying to speed the routine, and I can see the recordset is being opened fresh every time the class object is instantiated. This step happens many hundreds of times. Isn't there a way to re-use it? The keyword here is persistence, isn't it? I've tried setting the recordset in the Instantiate event, alternatively from within the functions. I've tried using static (instead of dim or private) to declare the recordset. I've also fiddled also with how the class object is declared and set. I know a common solution is to change to a specific SQL source for each call, but the query that produces the recordset is itself slow so I don't see that as helpful. And yes, the base tables are optimally indexed. I'm happy to post code, but is this enough for you to offer any tips?
Is the recordset itself only needing to be created once and then filtered many times? If so, can you pass the recordset as a parameter into the classes method/function that does the filtering on it? That way the recordset can be created once.
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 0, "tags": "ms access, vba, class" }
Typescript + requirejs: How to handle circular dependencies? I am in the process of porting my JS+requirejs code to typescript+requirejs. One scenario I haven't found how to handle is circular dependencies. Require.js returns undefined on modules that are also dependent on the current and to solve this problem you can do: _MyClass.js_ define(["Modules/dataModel"], function(dataModel){ return function(){ dataModel = require("Modules/dataModel"); ... } }); Now in typescript, I have: _MyClass.ts_ import dataModel = require("Modules/dataModel"); class MyClass { dataModel: any; constructor(){ this.dataModel = require("Modules/dataModel"); // <- this kind of works but I lose typechecking ... } } How to call require a second time and yet keep the type checking benefits of typescript? dataModel is a module { ... }
Specify the type using what you get from `import` i.e import dataModelType = require("Modules/dataModel"); class MyClass { dataModel: typeof dataModelType;
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 0, "tags": "requirejs, typescript" }
Powershell: How to copy source document and rename it from a list in a text file? I have this document that needs to be copied every month to every college with their name as its new name so i would like to take my source document and copy it and renamed it from a list i have in a text file. This is what i tried: $source = "C:\Users\BackZ\Documents\environment\Source\Booking og lønafregning Blank.xls" $Namelist = get-content "C:\Users\BackZ\Documents\environment\Source\List.txt" Get-ChildItem $source | Rename-Item -NewName { $_.name -Replace 'Booking og lønafregning Blank.xls',set-content $Namelist} Im pretty new at this so please bare that in mind when you answer. i have already looked at several other post her and on other site but non seems to have the same needs as this in a why that i can understand what they're doing so i'm looking for some guidens.
Based on your code, I am making the following assumptions: 1. You want the copied/renamed documents to be in the same folder as the source document and the list of names 2. The list of names contains one college name per line. On that basis, the following should work: Push-Location "C:\Users\BackZ\Documents\Environment\Source" $NameList = Get-Content "List.txt" ForEach ($Name in $NameList) { Copy-Item -Path "Booking og lønafregning Blank.xls" -Destination ("$Name"+".xls") -Force } Pop-Location
stackexchange-stackoverflow
{ "answer_score": 4, "question_score": 0, "tags": "powershell" }
C# : how do you obtain a class' base class? In C#, how does one obtain a reference to the base class of a given class? For example, suppose you have a certain class, `MyClass`, and you want to obtain a reference to `MyClass`' superclass. I have in mind something like this: Type superClass = MyClass.GetBase() ; // then, do something with superClass However, it appears there is no suitable `GetBase` method.
Use Reflection from the Type of the current class. Type superClass = myClass.GetType().BaseType;
stackexchange-stackoverflow
{ "answer_score": 61, "question_score": 44, "tags": "c#, superclass" }
<動詞の辞書形> + がよい ― How is this allowed? I've come across this form many times in my Japanese Bible. The meaning is quite obvious based on context, and seems to be one of the following: ``, ``, ``, or `` (let it be ). Here are a few verses with this form: > * []{} ****... ― Come and hear, all who fear God... - Psalm 66:16 > * **** ― And Jesus said to him, “Friend, do what you have come for.” Then they came and laid hands on Jesus and seized Him. - Matthew 26:50 > * **** ... And He said to them, “Come away by yourselves to a secluded place and rest a while.” - Mark 6:31 > * **** But even if we, or an angel from heaven, should preach to you a gospel contrary to what we have preached to you, he is to be cursed! - Galatians 1:8 > How is this form "allowed" to exist without a `` following the verb? Is this only a literary written form or something? Because I've never seen this form anywhere except my Bible.
That structure came from classical Japanese (), which had been used in formal writing until just after WWII. Technically those are not (), but . In classical Japanese, the of a verb can work as a noun, like + / in modern Japanese ().
stackexchange-japanese
{ "answer_score": 9, "question_score": 8, "tags": "grammar, usage, syntax" }
problem in connecting studio management to sql server I had installed SQL Server 2008, but faced some complications with that. I then installed SQL Server 2005, and now installed SQL Server Management Studio for SQL Server 2005 successfully. I am not able to connnect to the server name it suggests. > TITLE: Connect to Server > > Cannot connect to POONAM-C586A95C\SQLEXPRESS. > > * * * > > ADDITIONAL INFORMATION: > > This version of Microsoft SQL Server Management Studio Express can only be used to connect to SQL Server 2000 and SQL Server 2005 servers. (Microsoft.SqlServer.Express.ConnectionDlg) It doesn't show any other option of SQL Server name, though I changed the name as I remembered but for no good. How can this be solved?
It sounds as if you're trying to connect to the 2008 instance with the 2005 SSMS. It's not clear whether you un-installed the 2008 instance. Suggest installing the SQL Server 2008 SSMS. Confirm/modify as needed that you're running the SQL Server instance that you require. This will show you which instances are available. !enter image description here
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "sql server 2005, ssms" }
NSData means what? how to implements its characterstics in java? NSData means what? how to implements its characterstics in java?
NSData is an array of bytes with flexible size (for the mutable version). (I guess the corresponding Java type is `byte[]`.)
stackexchange-stackoverflow
{ "answer_score": 4, "question_score": 0, "tags": "java, iphone, android" }
Prove that $g(x,y) = \frac{x^3y}{x^2+y^2}$ with $g(0,0)=0$ is continuous Consider the function $g:\mathbb{R^2} \rightarrow \mathbb{R}$ defined by $g(x,y) = \left\\{\begin{matrix} \dfrac{x^3y}{x^2+y^2}& \textrm{if } (x,y) \neq (0,0) \\\ 0 & \textrm{if }(x,y) = (0,0) \end{matrix}\right.$ How do I prove this is continuous? I know that I have to: Consider $x_0 \in \mathbb{R^2}$, and let $\epsilon > 0$ be given. I am confused on how to pick a $\delta$ that will work such that $d(x,x_o) < \delta$.
Since $f(x,y)$ for $(x,y)\neq (0,0)$ is a composition of continous functions, it is continuous on $\mathbb{R}^2 \setminus \\{(0,0)\\}$. For continuity on $\mathbb{R}^2$ we only have to show that the limit $$\lim_{(x,y)\to (0,0)} f(x,y) = 0$$ exists, e.g. by changing the limit using polar coordinates: $$ x = r \cdot \cos(\theta)$$ $$y = r \cdot \sin(\theta)$$ $$\lim_{(x,y)\to (0,0)} {x^3y\over x^2+y^2} = \lim_{r \to 0} {r^4 \cos^3 \theta \sin \theta \over r^2(\cos^2 \theta + \sin^2 \theta)}= \lim_{r \to 0} {r^2 \cos^3 \theta \sin \theta } = 0$$ Thus, $f(x,y)$ is continuous on $\mathbb{R}^2$.
stackexchange-math
{ "answer_score": 0, "question_score": 1, "tags": "real analysis, limits, multivariable calculus, continuity" }
Expression<Func<string>> method and unit test which calls it Can someone help break down and explain the following method, and how it relates to the unit test which calls it? static class Class1 { public static Expression<Func<string>> Method1(Interface1 param1, string param2) { return () => param1.Method2( param2 ); } } In unit test. The 'A' class is FakeItEasy: A.CallTo( Class1.Method1( instanceOfInterface1, "someText" ) ).MustHaveHappened();
Contents of the method are actually unrelated to the unit test. The test checks if an object (of a different type) called the `Method1` with these specific parameters `(instanceOfInterface1, "someText")`. The unit test probably executes some code prior to the `MustHaveHappened` check? The result of this method is an expression which wraps the call to the `Method2` on the `param1` instance, passing the `param2` as the parameter. The `Method2` is not actually invoked. The resulting `Expression<Func<string>>` object contains an expression tree, which can allow you to inspect the method's body programmatically.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 1, "tags": "c#, lambda" }
Most optimal way to search through a Map I have a Map (lets say of people, per example) like this: public Map<String, Person> personMap = new HashMap<>(); And I want to search through this map filtering by name. I have this code, but I am curious if there is a more optimal or elegant way to do it. public ArrayList<Person> searchByName(String query) { ArrayList<Person> listOfPeople = new ArrayList<>(); for (Map.Entry<String, Person> entry : this.personMap.entrySet()) { Person person = entry.getValue(); String name = entry.getValue().getName(); if (name.toLowerCase().contains(query.toLowerCase())) { listOfPeople.add(person); } } if (listOfPeople.isEmpty()) { throw new IllegalStateException("This data doesn't appear on the Map"); } return listOfPeople; } thanks in advance
I think your solution is close to optimal (except for the use of Streams). I would simplify the `for` clause as: for (Person person : this.personMap.values()) { String name = person.getName(); if (name.toLowerCase().contains(query.toLowerCase())) { listOfPeople.add(person); } } Since you are not using the key of the map at all.
stackexchange-stackoverflow
{ "answer_score": 4, "question_score": 2, "tags": "java, list, search, optimization, hashmap" }
Why is my tooltip flashing on and off? I am creating a tooltip after this example. For some reason, my tooltip flashes on and off as I move the mouse. As I understand it, the `mousemove()` function finds the closest datapoint; so as long as the mouse is over the `.overlay` rectangle, the tooltip should always be showing. Any ideas? Here's my fiddle: <
I think it's to do the the `mouseover`/`mouseout` continuosly firing when they needn't: updated fiddle (again): < g.on("mouseover", function() { tooltip.style("display", null); }); g.on("mouseout", function() { tooltip.style("display", "none"); }); g.select(".overlay").on("mousemove", mousemove);
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 7, "tags": "d3.js, tooltip" }
Use a Like expression in Lambda I have a Lambda expression that search the column after submitting a form. It does work when I submit it but its doesn't search the right way I would like to search. I would like to make it work the same way it search in SQL like statement. select * FROM tableSearch where subject like '%f5%' This way even if 'F' is capital it still finds it. Can this be possible using Lambda expression. With the below code it only finds it if 'F' is not capital unless i enter 'F5' in subject. if (!string.IsNullOrEmpty(searchControl.subject)) { searchList = searchList.Where(x => x.subject.Contains(searchControl.subject)).ToList(); }
why not make them both `ToLower`: searchList.Where(x => x.subject.ToLower().Contains(searchControl.subject.ToLower())) or: searchList.Where(x => x.subject.IndexOf(searchControl.subject, StringComparison.OrdinalIgnoreCase) >= 0)
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 1, "tags": "c#, lambda" }
Why does my C++ program silently exit when a use a NULL object? string n = NULL; cout << "blah: " << n << " foo!" << endl; // never printed cout << "BLAH" << endl; // never printed cerr << "FOO" << endl; // never printed I understand assigning or appending something to NULL is not right. But silently dying is not good either. How should I handle / debug those situations? And why is the program dying?
Your program is free to do whatever the implementation of `std::string` you have choses to. `std::string` has a constructor taking a `const char* s`. However, this involves: > Constructs the string with the contents initialized with a copy of the null-terminated character string pointed to by `s`. The length of the string is determined by the first null character. The behavior is undefined if `s` does not point at an array of at least `Traits::length(s)+1` elements of `CharT`, **including the case when s is a null pointer.** > > (emphasis mine) Via cppreference
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": -4, "tags": "c++" }
Extracting last n elements from array without disturbing original array I want to extract last n elements from array without splice I have array like below , I want to get last 2 or n elements from any array in new array [33, 44] [22, 55, 77, 88, 99, 22, 33, 44] I have tried to copy old array to new array and then do splice.But i believe there must be some other better way. var arr = [22, 55, 77, 88, 99, 22, 33, 44] ; var temp = []; temp = arr; temp.splice(-2); Above code is also removing last 2 elements from original array `arr`; So how can i just extract last n elements from original array without disturning it into new variable
Use `slice()` instead of `splice()`: As from Docs: > The `slice()` method returns a shallow copy of a portion of an array into a new array object selected from begin to end (end not included). The original array will not be modified. var arr = [22, 55, 77, 88, 99, 22, 33, 44] ; var newArr = arr.slice(-2); console.log(newArr); console.log(arr); .as-console-wrapper { max-height: 100% !important; top: 0; }
stackexchange-stackoverflow
{ "answer_score": 6, "question_score": 3, "tags": "javascript, arrays" }
Number from sample to be drawn from a Poisson distribution with upper/lower bounds Working in `R`, I need to create a vector of length `n` with the values randomly drawn from a Poisson distribution with lambda=1, but with a lower bound of 2 and upper bound of 6 (i.e. all numbers will be either 2,3,4,5, or 6). I am unsure how to do this. I tried creating a `for` loop that would replace any values outside that range with values inside the range: seed(123) n<-25 #example length example<-rpois(n,1) test<-example #redundant - only duplicating to compare with original *example* values for (i in 1:length(n)){ if (test[i]<2||test[i]>6){ test[i]<-rpois(1,1) } } But this didn't seem to work (still getting 0's and 1, etc, in `test`). Any ideas would be greatly appreciated!
Here is one way to generate `n` numbers with Poisson distribution and replace all the numbers which are outside range to random number inside the range. n<-25 #example length example<-rpois(n,1) inds <- example < 2 | example > 6 example[inds] <- sample(2:6, sum(inds), replace = TRUE)
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "r, poisson" }
Simple dup2 function not working on ubuntu Can someone please tell me why this basic implementation of dup2 is not working. When i run it the output is not redirected but is simply printed on the standard output. #include<unistd.h> #include<stdio.h> #include<sys/types.h> #include<fcntl.h> void main(int argc,char *argv[] ) { int fd,nread; char buf[4096]; if(fd=open(argv[1],O_WRONLY|O_CREAT|O_TRUNC,S_IRUSR|S_IWUSR|S_IROTH|S_IRGRP)<0) printf("error opening"); printf("fd=%d",fd); if(dup2(fd,STDOUT_FILENO)==-1) printf("error in duplicating"); while(nread=read(STDIN_FILENO,buf,4096)) write(STDOUT_FILENO,buf,nread); }
if(fd=open(argv[1],O_WRONLY|O_CREAT|O_TRUNC,S_IRUSR|S_IWUSR|S_IROTH|S_IRGRP)<0) Please mind operator precedence (`<` trumps `=`), use parentheses. You are setting `fd` to 0 (stdin) on success. write(STDOUT_FILENO,buf,nread); This line fails because stdin is not open for writing.
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": 0, "tags": "c, unix, dup2" }
Cleanup redirected output file from failed command When doing: CMD > file.out if CMD fails (non-zero exit code), 'file.out' with be empty or incomplete. I looking for a way to cleanup in case the CMD fails. When CMD is run in a CRON job I would prefer for the directed output file to be deleted instead of leaving an empty/incomplete file behind. My initial idea was: if ! CMD > file.out; then rm file.out; fi However it hides the CMD exit status, making it unsuitable. (especially for CRON) * Can anyone think a better solution ? * Is there some functionality in bash or sh that would allow this ? * I was hoping maybe there is some 'tee' like utility that could: * It would redirect STDOUT output to a file * If the command fails it would remove output file * In all case it would return the CMD exit code
Your initial idea is good and could be expanded into if ! CMD >file.out; then rm file.out; exit 1; fi If you need to capture the specific exit status from `CMD`, then do that and `exit` with it later: if ! CMD >file.out; then err="$?"; rm file.out; exit "$err"; fi Note that you can't use `exit "$?"` since at that point, `rm` has modified `$?`. * * * `tee` will always create its output file, no matter if data is available to put into it, so you would have the same issue as you had from the start.
stackexchange-unix
{ "answer_score": 0, "question_score": 0, "tags": "scripting, cron, pipe, io redirection" }
Given Range of a Function, Find the Function Let $a$ and $b$ be positive integers so that as $x$ varies over all real numbers, the range of the function $$y=\frac{x^2+ax+b}{x^2+2x+3}$$ is the interval $−5≤y≤4$. Find $a+b$.
We have $$y(x^2+2x+3)=x^2+ax+b,$$ i.e. $$(y-1)x^2+(2y-a)x+3y-b=0.$$ Since the discriminant has to be non-negative, we have $$(2y-a)^2-4(y-1)(3y-b)\ge 0,$$ i.e. $$y^2+\frac{a-b-3}{2}y+\frac{4b-a^2}{8}\le 0.$$ We want this to be $(y+5)(y-4)\le 0$, so solving$$\frac{a-b-3}{2}=5-4,\qquad \frac{4b-a^2}{8}=5\times (-4)$$ gives $a=14,b=9$.
stackexchange-math
{ "answer_score": 2, "question_score": 0, "tags": "algebra precalculus, functions" }
making a div visible but able to click through I have two full screen divs stacked. css #border-overlay { position:absolute; z-index: 100; top:0; left:0; width: 100vw; height: 100vh; box-sizing: border-box; border: solid 8px white; } #button position: absolute; display: block; top: 0; left: 0; height: 100%; width: 100%; background-color: rgba(0,0,0,0); z-index: 15; } html <div id="border-overlay"></div> <a id="button" href=""> ... </a> I need the border div on top the button div, however this removes the link function of the button which I want to keep. Essentially the button takes up the full screen so you can click anywhere.
No JavaScript needed. Use the CSS `pointer-events: none` on the div: #border-overlay { position: absolute; z-index: 100; top: 0; left: 0; width: 100vw; height: 100vh; box-sizing: border-box; border: solid 8px white; pointer-events: none; } **jsFiddle example**
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "html, css" }
pytest-cov - Don't count coverage for the directory of integration tests I have the following directory structure: ./ src/ tests/ unit/ integration/ I would like to use pytest to run all of the tests in both `unit/` and `integration/`, but I would only like coverage.py to calculate coverage for the `src/` directory when running the `unit/` tests (not when running `integration/` tests). The command I'm using now (calculates coverage for all tests under `tests/`): pytest --cov-config=setup.cfg --cov=src with a setup.cfg file: [tool:pytest] testpaths = tests [coverage:run] branch = True I understand that I could add the `@pytest.mark.no_cover` decorator to each test function in the integration tests, but I would prefer to mark the whole directory rather than to decorate a large number of functions.
You can attach markers dynamically. The below example does that in the custom impl of the `pytest_collection_modifyitems` hook. Put the code in a `conftest.py` in the project root dir: from pathlib import Path import pytest def pytest_collection_modifyitems(items): no_cov = pytest.mark.no_cover for item in items: if "integration" in Path(item.fspath).parts: item.add_marker(no_cov)
stackexchange-stackoverflow
{ "answer_score": 4, "question_score": 3, "tags": "python, unit testing, pytest, coverage.py" }
Double spending on a given Blind Signature over ECC protocol Here's a blind signature protocol based on ECC. The question is if it has the double spending problem? ![A blind signature protocol]( As I investigated, if we can change the `c` without changing the `r` and subsequently no change on `m^`, then there would be two different `(F, s)` for a single `m`. And this can be achieved if considering `F` as (x, y), one can find another point on the curve with (x, **-y** ) coordinates.
There's no such problem because, even if you find other $(F,s)$ pair, you still have signature for **the same message $m$**. So if your message contains anything like transaction id or serial number, it doesn't matter if you have more than one signature for it. Second thing is that, even there are two pairs for single $m$, given one of them it's hard to find the other. Proof: Given point $F$ with coordinates $(x,y)$, coordinates $(x,-y)$ correspond to point $-F$. So to have valid $s$ you have to calculate $c'$ that satisfies: > $-F=b^{-1}R+ab^{-1}G+c'G$ After transformation: > $c'G=-F-b^{-1}R-ab^{-1}G$ Let's set > $C=-F-b^{-1}R-ab^{-1}G$. Then we get: > $c'G=C$ and this is exactly discrete logarithm problem.
stackexchange-crypto
{ "answer_score": 3, "question_score": 3, "tags": "elliptic curves, blind signature" }
What does this number and line mean under these violin notes? ![enter image description here]( What do these numbers and the short line under the notes mean?
It means to place the third finger (ring finger) and keep it on the string for as long as the line continues. This clearly is written for or by a beginner since the first such phrase runs a lot more naturally in third position (once you are used to playing it). However, the printed 0s are _also_ clearly a choice for a beginner, so we are talking about a violin method. The prolonged line notation is sort-of a bit of an advanced tool, so it is most likely a method annotated by a teacher, particularly so since keeping the third finger down does not serve a harmonic purpose (by providing a "resonance string") and interferes with vibrato. The main purpose is practicing keeping a placed finger without interfering with the next string. This isn't useful here, but there are situations with double stops or drones or resonance where that skill comes in handy.
stackexchange-music
{ "answer_score": 3, "question_score": 3, "tags": "notation, violin" }
Warning on using strtotime in php? Warning: mysql_result() expects at least 2 parameters, 1 given on this line $time = mysql_result( date('d F Y', strtotime($i["time_stamp"])));
If you look at the documentation for mysql_result you'll see that it expects the query resource as the first parameter, the row number as the second parameter, and (optionally) the field name or offset as the third parameter. You're not using the function in anyway that even resembles its purpose. **Edit:** Based on your comment above ("my timestamp showing 1357294428 i want to show in proper format H:mm:ss DD-MM-YY"), you're looking for this: date('H:i:s d-m-y', strtotime($i["time_stamp"])); Although if `$i["time_stamp"]` is already a timestamp then you just need this: date('H:i:s d-m-y', $i["time_stamp"]);
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": -10, "tags": "php, strtotime" }
SQL not accepting my string as a condition in a CASE statement I am using SQL Server and SSMS. I am writing a CASE expression in SQL. Here is one of the lines WHEN [Group] = 'Representation Accepted' AND [Reason] = 'Reduced to Warning Notice' Area Authorised' THEN 31 The issue I am having here is that for the string: Reduced to Warning Notice' Area Authorised SQL is getting confused with the quotation mark here and believes it to be the end of the condition and completely omits " Area Authorised". I'm not sure how to solve this issue without removing the single quotation mark. Does anyone know how I cam make SQL accept the entire string with the quotation mark as a condition?.
use two times single quotation as below WHEN [Group] = 'Representation Accepted' AND [Reason] = 'Reduced to Warning Notice'' Area Authorised' THEN 31
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "sql, sql server, tsql" }
Cron job terminates early In my crontab file I execute a script like so (I edit the crontab using `sudo crontab -e`): 01 * * * * bash /etc/m/start.sh The script runs some other scripts like so: sudo bash -c "/etc/m/abc.sh --option=1" & sleep 2 sudo bash -c "/etc/m/abc.sh --option=2" & When cron runs the script `start.sh`, I do `ps aux | grep abc.sh` and I see the `abc.sh` script running. After a couple of seconds, the script is no longer running, even though `abc.sh` should take hours to finish. If I do `sudo bash /etc/m/start.sh &` from the command line, everything works fine (the `abc.sh` scripts run for hours in the background until they complete). How do I debug this? Is there something I'm doing that is preventing these scripts from running in the background until they are done?
The program(s) you're starting might be expecting a terminal to send their output to, or receive input from. If you set the `MAILTO=` variable, and you have a sendmail(-like) daemon installed, you will get an email with the error message(s) it prints, if there are any: [email protected] 01 * * * * bash /path/to/something.sh Another way to debug would be to run the script from the command line, while redirecting all inputs and outputs: $ sudo bash -c "foo.sh" > output_file 2>&1 < /dev/null Also, the system log files (usually found in `/var/log`) might contain useful hints.
stackexchange-stackoverflow
{ "answer_score": 5, "question_score": 1, "tags": "bash, cron" }
Plugin to customize home page i would like to know of there's a plugin to let an authentified user customize his home page by moving and adding predifined widgets like (agenda, events ..), using drag and drop like iGoogle. i'm still drupal newbie, any advices are welcomed.
The homebox module makes that reasonably easy to do, worth a look: < Details from its project page: > Homebox allows site administrators to create dashboards for their users, using blocks as widgets. Blocks in a Homebox page are resizeable, and reorderable by dragging. > > Homebox is currently used on Drupal.org for the 'Your Dashboard' feature.
stackexchange-drupal
{ "answer_score": 2, "question_score": 1, "tags": "7" }
Is this question about Git appropriate for Stack Overflow? Would the following question about troubleshooting Git on openSUSE be appropriate for Stack Overflow? > I've just installed openSUSE, which came with Git version 1.8.1.4. > > However, the credential helper does not work. It spits out this message: > > > error: cannot run git-credential-cache--daemon: No such file or directory > fatal: unable to start cache daemon: No such file or directory >
Yes this is suitable. Git is a tool used by programmers, and tool support is on-topic for Stack Overflow. Do, however include as many details as you can - what you tried to make it work and how you set it up, for example.
stackexchange-meta
{ "answer_score": 6, "question_score": 3, "tags": "support, stack overflow, scope" }
Missing Listing number in caption My problem is that I don't have automatic listing numbers in the caption. (I thought they would be included by default and can't seem to find a way to include them) \begin{lstlisting}[caption={test}, label={test}, title={test test test}, language=JavaScript, style=JavaScript] import axios from 'axios'; console.log("hello world!"); \end{lstlisting} This is an example listing code. This is how it looks right now: ![enter image description here](
You should use either the `caption` key or the `title` key, not both at the same time. From `listings` manual: > title = _title text_ > is used for a title without any numbering or label. > > caption = {[ _short_ ] _caption text_ } > The caption is made of `\lstlistingname` followed by a running number, a separator, and _caption text_. Either the caption text or, if present, _short_ will be used for the list of listings. Simply drop the `title` key and you get a numbered caption.
stackexchange-tex
{ "answer_score": 0, "question_score": 1, "tags": "captions, numbering, listings" }
Extracting consecutive occurences in R (like unix uniq) I'm beginning to analyse datas for my thesis. I first need to count consecutive occurences of strings as one. Here's a sample vector : test <- c("vv","vv","vv","bb","bb","bb","","cc","cc","vv","vv") I would like to simply extract unique values, as in the unix command uniq. So expected output would be a vector as : "vv","bb","cc","vv" I looked at rle function, wich seems to be fine, but how would I get the output of rle as a vector ? I don't seem to understand the rle class... > rle(test) Run Length Encoding lengths: int [1:5] 3 3 1 2 2 values : chr [1:5] "vv" "bb" "" "cc" "vv" How to get one vector of the values output by rle and another one for the lengths ? Hope I'm making myself clear... Thanks again for any help !
`rle()` returns a two-element list of class `"rle"`; as @gsk points out, you can use ordinary list-indexing constructs to access the component vectors. Also, try this, to put the results of `rle` into a more familiar format: as.data.frame(rev(unclass(rle(test)))) # values lengths # 1 vv 3 # 2 bb 3 # 3 1 # 4 cc 2 # 5 vv 2
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 2, "tags": "r" }
base cleaned after rebuild project I have c# project and locale database inside. I run application everything ok. I can add new rows to database and data is saved. but when I do a changes or rebuild project and run it again database is cleaned. can someone tell me why this happend please ?
My educated guess: Probably you have build action "copy" on your database file. so it gets copied every time you build. the full one is in /bin, the empty one in your project, you overwrite it every time, end of story:)
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 2, "tags": "c#" }
Correct way to apply brakes Just to illustrate that there are better and worse ways to apply brakes, here's an example of a less-than-ideal way: I was biking on a borrowed bike and getting used to the brakes. The front brake lever was squishier than the rear. After skidding out and landing my hip on a stump, which lowered morale significantly for the next half-hour or so, I learned to give the front brake a harder squeeze to compensate for the squish. This was on a mountain trail and at the urging of my biking companion on that day. So my question is this: How does one brake under certain circumstances? Are there times when all-front or all-rear braking makes sense, or is it always best to apply pressure somewhat evenly to both brakes, and are there different braking techniques on roads vs trails and such?
To reduce your speed significantly while on dry roads, I recommend front brake first and hardest, because the front wheel will have most grip. If you only want to lose a little speed (but more than soft-pedalling), and gently at that, e.g. in a group riding situation to prevent others running into the back of you, then rear-brake only. On wet roads or loose surfaces you must avoid locking the front-wheel, so brake evenly and simultaneously front and rear. You have a chance of controlling a rear-wheel that is locked and skidding; that control is unlikely to extend to a locked and skidding front wheel. If it is icy and extremely slippery, consider rear-brake only and don't go too fast to begin with!
stackexchange-bicycles
{ "answer_score": 3, "question_score": 0, "tags": "brakes, braking" }
Mysql COUNT, GROUP BY and ORDER BY This sounds quite simple but I just can't figure it out. I have a table `orders` (`id`, `username`, `telephone_number`). I want to get **number of orders from one user by comparing the last 8 numbers** in `telephone_number`. I tried using `SUBSTR(telephone_number, -8)`, I've searched and experimented a lot, but still I can't get it to work. Any suggestions?
Untested: SELECT COUNT(*) AS cnt, * FROM Orders GROUP BY SUBSTR(telephone_number, -8) ORDER BY cnt DESC The idea: 1. Select `COUNT(*)` (i.e., number of rows in each `GROUP`ing) and all fields from `Orders` (`*`) 2. `GROUP` by the last eight digits of `telephone_number`1 3. Optionally, `ORDER` by number of rows in `GROUP`ing descending. * * * 1) _If_ you plan to do this type of query often, some kind of index on the last part of the phone number could be desirable. How this could be best implemented depends on the concrete values stored in the field.
stackexchange-stackoverflow
{ "answer_score": 5, "question_score": 1, "tags": "mysql, count, group by, sql order by, substr" }
IBM MQ and Kafka connector issue (host name supplied is not not valid) I have been trying to connect IBM MQ to Kafka on my Ubuntu. I want to get the messages from MQ to Kafka. I am trying to use a connector Link. I followed all the steps, but I keep on getting the following errors: > host name supplied is not valid. and > JMSCMQ0001: IBM MQ call failed with compcode '2' ('MQCC_FAILED') reason '2538' ('MQRC_HOST_NOT_AVAILABLE'). I tried everything, but nothing seems to work. If anyone has faced the same issue, please let me know. My configuration includes the following line:- # A list of one or more host(port) entries for connecting to the queue manager. Entries are separated with a comma - required mq.connection.name.list=localhost:1414
Turning Andrew Schofield's comment into an answer in case it gets lost in mist. Your configuration file has the following:- mq.connection.name.list=localhost:1414 IBM MQ does not use the industry-standard `host:port` syntax. It uses `host(port)`. Unfortunately, there was a (now fixed) mistake in the instructions. Please use the following syntax instead:- mq.connection.name.list=localhost(1414)
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 1, "tags": "ubuntu, apache kafka, jms, ibm mq" }
Azure data disk for Parse Server I already have deployed an Ubuntu VM from Azure and I want to install Parse Server on it. Yesterday, I saw this: screenshot from azure docs This is what I have on "Disks" of my server now: screenshot from azure portal My question is whether I need to add a new data disk to install Parse Server, or can I do it having the OS disk only?
> My question is whether I need to add a new data disk to install Parse Server, or can I do it having the OS disk only? We'd better add a new data disk to host application or data. By default, Linux VM OS disk size is 30 GB, maximum capacity of 2048 GB. If you just want to create a test lab, I think you can host your application or data on OS disk. If not a test lab, I think we should create a new disk to host Application or data. Each data disk has a maximum capacity of 4095 GB, add new data disk, we can have more **IO**. You add extra disks as needed per your space and IOps requirements. Each disk has a performance target of 500 IOps for Standard Storage and up to 5000 IOps per disk for Premium Storage. More information about Azure VM IOps, please refer to this blog. Also if you want to add a new data disk, please refer to this link.
stackexchange-serverfault
{ "answer_score": 1, "question_score": 1, "tags": "virtual machines, azure, parse server" }
Git, deleting repository I somewhat screwd up the file system of my remote node. I am doing a project and the remote repo was initialized by my instructor. I cloned it and then pushed the updates from my home directory. I now want to delete the repo which I cloned in the remote server. I want to start it over. How do I delete the repository which was cloned before?
A repository is just a directory with working copy (though it is optional) and `.git`, so deleting the directory deletes the repository. To delete a remote repository you need to have access to the remote filesystem.
stackexchange-stackoverflow
{ "answer_score": 16, "question_score": 10, "tags": "git" }
Make a hidden field required This is my code: <label for="uploadFile" class="custom-uploadFile"> <i class="fa fa-cloud-upload"></i> UPLOAD ID </label> <input class="form-control input-lg" name="picture" id="uploadFile" type="file" style="display:none;" required> I _want_ to let this upload field be required, but the input is hidden. I must use some JavaScript. Or what can I use to solve this problem? I watched a lot of tutorials, but they did not work!
If you want to see the form validation message you can hide the input using opacity. #uploadFile { opacity: 0; width: 0; float: left; /* Reposition so the validation message shows over the label */ } div { text-align: center; } <form> <input name="picture" id="uploadFile" type="file" required> <label for="uploadFile">Upload label</label> <div><input name="submit" type="submit"></div> </form>
stackexchange-stackoverflow
{ "answer_score": 22, "question_score": 11, "tags": "html" }
changing specific letters in a string from random import randint tal = ['0','1','2','3','4','5','6','7','8','9'] sign = ['@','£','$','€','&', '!', '?', '!'] bogstaver = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'x', 'y', 'z'] numbers = [tal[randint(0,9)] + sign[randint(0,7)] + bogstaver[randint(0,24)] + tal[randint(0,9)] for x in range(4)] password = "".join(numbers) print(password[2::8]) print(password) I want every 4., starting from the second first letter in a password to uppercase the letter in the string. Which is the [2::8] of the code. But I just cant figure out how to only replace these two letters with the same letter in uppercase. Any help?
password = ''.join([c.upper() if i in range(2, len(password), 8) else c for i, c in enumerate(password)])
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 0, "tags": "python" }
Access citrix mapped local drive from scheduled task in Windows My setup is Linux Mint as host OS, which logs in to a Windows 7 machine using through Citrix. My local (linux) home directory is visible on the Windows system as \\Client\S$ What I want to do is make a (robo)copy of this folder to another Windows folder. My copy .bat script works when run by hand, but when run as a scheduled task I get (added a `dir` command for debugging) dir \\Client\S$ The network path was not found. Tried executing as myself as well as using `SYSTEM`. When I execute `net use` by hand I see: \\Client\S$ PICAClientNetwork `net use` from the bat script lists nothing. So my question is: how do I access this drive from my script?
The path `\\client\s$` is mapped only in the user session context. Running your script as any other user, or otherwise outside the user's session, means the path won't be reachable, and your script will fail. Try and configure the task to run as the same user that is logged on to the Windows machine and select **Run only when user is logged on**. As far as I remember, that should cause the task to run in the user's session. I'm not sure if **Run with highest privileges** will cause the script to run in a different session, but you can try it out if you need script to run elevated.
stackexchange-superuser
{ "answer_score": 2, "question_score": 0, "tags": "windows, citrix, robocopy" }
jquery putting json in a dialog I have this piece of code inside a `jQuery` focusout : $.ajax({ type : 'GET', data : 'auteur='+auteurExiste, url : 'existeAuteur.php', success: function(data) { jQuery.each(data, function(index,item) { alert ("bla bla bla "+item) }); } }); The `json` response from `existeAuteur.php` is : > 0:"Le droit privé" > > 1:"Le droit foncier" This of cours opens an alert per item. (logical since the alert is within the jQuery.each). But how can I put the list of items in one single alert box, or in a single `jQuery.dialog`. I tried to put the `jQuery.each` in a function dialog but without success. Thanks !
**DO YOU WANT TO** put the all the item names in one message alert ? If I understand your question right, then this should work. $.ajax({ type : 'GET', data : 'auteur='+auteurExiste, url : 'existeAuteur.php', success: function(data) { var items = ""; jQuery.each(data, function(index,item) { // Let's say the item[0] = "gum01" and item[1] = "gum02" and so on... // Then 'items' will contain "gum01gum02gum03gum04gum05..." in a single row. // so you may want to give it line feeds with "\n" items += item + "\n" }); alert(items); } }); Try this code.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "jquery, json, parsing, dialog, alert" }
javascript replace array’s elements with their respective innerHTML In javascript, how can I do, with elegant code, that: [div#id1, div#id2, ...] replace the array’s elements with their respective `innerHTML` like so [div#id1.innerHTML, div#id2.innerHTML, ...] without using loops but with something built into js like for example the `.filter()` fuction for being clean and concise. The arrays can also be `HTMLCollections`; it’s no problem. And I surely prefer a solution that covers all the field variables of the elements, and not only their `innerHTML`.
Use `map()` newArray = array.map(div => div.innerHTML)
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "javascript" }
Getting difference of dates based on minutes and seconds I have two date columns, the first one is for beginning, the second one is for ending. ![Two of our columns]( We want to get difference of these dates based on minutes and seconds. My Goal is get result as below: _**1:05:06(1 min 5 seconds)**_ I have tried functions such as `date_trunc(), datediff()` and `EXTRACT(EPOCH))` but we couldn't do that. Can you please help? Thanks in advance.
The simplest method is `-`: select (end_ts - start_ts) as diff_time If you want this in seconds, you can convert to epoch time and subtract: select extract(epoch from end_ts) - extract(epoch from start_ts) as diff_seconds
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "sql, postgresql" }
python function with numpy I'm using anaconda with python 2.7. How can I do a function with parameters recognized by the IDE as for example np.array? In order to use the method of the type? import numpy as np def calculate_variance(weight,sigma): return weight.transpose * sigma * weight How can I do when I write the "dot" after the word "weight" it complete me with the methods of the np.array type?
What you need to do is this assuming your `weight` is a `numpy` array: import numpy as np def calculate_variance(weight,sigma): return np.transpose(weight) * sigma * weight Also, notice how I took out the space between `calculate` and `variance` within your function definition and added an underscore.
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "python 2.7, numpy, anaconda" }
DomCrawler 2nd and etc child I'm reworking my parsers from SimpleHTMLDom on DomCrawler and on some points dcumentation(as for me) not covering all the questions which might be from newbie devs. In SHD i'm wrote just like this for access to second child: $value = $dom->find('.t18',0); $result = $value->find('b',1); but in DomCrawler i can't find any similar way of selecting exactly second child of element with t18 class. How can i do that? code example from which i'm trying get data: <div class="t18"> <b>20(PLN)</b> <b>4.66 (EUR)</b> <br> <b>20(EUR)</b> <b>85.87(PLN)</b> <br> </div>
You can use "eq" function to select the n'th child of a node. for your example, to select second b element inside first .t18 element: ` echo $domCrawler->filter(".t18")->eq(0)->filter("b")->eq(1)->text(); // will echo 4.66 (EUR) `
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 1, "tags": "css selectors, domcrawler" }
Neo4j Webadmin Overview Dashboard: From where is the created_on information retrieved? Afaik there is no meta-information per default stored when creating a node, relationship or property. Therefore I use custom created_on, modified_on timestamp properties. I was just wondering, the OVerview dashboard (< depicts date information on the horizontal axis. Where is this information stored? I am using Neo4j 2.1.5 Thanks
That information is stored in `data/graph.db/rrd`. Please note that these numbers a just a indicator and should not be treated as precise counters. Instead of real counts they use the largest id in use. If you want to use `created_on` and `modified_on` timestamps you can use e.g. Cypher's `MERGE` in combination with the `timestamp()` function: MATCH (a:Person {name:...}), (b:Product {name:...}) MERGE (a)-[r:BUYS]->(b) ON CREATE SET r.created=timestamp() ON MATCH SET r.updated=timestamp()
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "neo4j" }
Show that a positive integer $n \in \mathbb{N}$ is prime if and only if $\gcd(n,m)=1$ for all $0<n<m$. Show that a positive integer $n \in \mathbb{N}$ is prime if and only if $\gcd(n,m)=1$ for all $0<m<n$. I know that I can write $n=km+r$ for some $k,r \in \mathbb{Z}$ since $n>m$ and also that $1=an+bm$. for some $a,b \in \mathbb{Z}$ Further, I know that $n>1$ if I'm to show $n$ is prime. I'm not sure how I would go about showing this in both directions though.
**Hint:** If $d$ divides $n$, then $gcd(d,n)=d$.
stackexchange-math
{ "answer_score": 1, "question_score": 0, "tags": "prime numbers, gcd and lcm" }
Selecting country and city Are there php file with array with countries and cities, something like that: $country[] = "Albania"; $country[] = "Algeria"; And the same with cities? Or are there any other, maybe better, solutions for showing countries for users and give them to select? Thanks.
Yes, GeoNames: $countries = json_decode(file_get_contents(' true); For cities you need to use the bounding box coordinates (available from the previous request result) and the Cities method, localization is also supported for most languages using the `lang` query string. **EDIT** : You probably want to cache (or download) these results to avoid overloading GeoNames server.
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": 3, "tags": "php, html, select" }
How to end a foreground service only when app has been closed In my application I have a foreground service running. I am able to stop the foreground service without issues when the user logs out. However, if the user swipes to close the app or the app crashes, I'm not able to handle stopping the foreground. OnSleep() is called when the application closes/crashes, however it's also called when the app is backgrounded. The foreground service I am using MUST continue to run if the app has been backgrounded but I need to stop the foreground service when it has been closed as opposed to backgrounded, for this reason I cannot stop the foreground service in the OnSleep() method. Is there any way I can know when the application is closing (Not being backgrounded) so I can handle stopping the foreground service?
I've found a solution, that at least seems to work for my situation. It's also a simple fix. In the same class that I override OnStartCommand, I've also done an override of OnTaskRemoved which is fired when a task from the service has been removed by the user. So when a user swipes to close the app, OnTaskRemoved will be called, where you can handle closing the service. public override void OnTaskRemoved(Intent rootIntent) { if (Build.VERSION.SdkInt >= BuildVersionCodes.N) { StopForeground(StopForegroundFlags.Remove); } else { StopForeground(true); } StopSelf(); base.OnDestroy(); System.Diagnostics.Process.GetCurrentProcess().Kill(); }
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "c#, android, xamarin" }
Find its taylor expansion > Find the taylor expansion of $$\operatorname{arcsin}2x$$ with center $0$ I can find taylor expansion of small polynomials but I am not able to find the same for an inverse trigonometric function. Any help is greatly appreciated.
**Just to remove it from the list of unanswered questions.** $\mathrm{Taylor\:series\:of\:function\:f\left(x\right)\:at\:a\:is\:defined\:as:}$ $$f(x)=f(a)+\frac{f^{'}(a)}{1!}(x-a)+\frac{f^{''}(a)}{2!}(x-a)^2+\frac{f^{'''}(a)}{3!}(x-a^3)+\cdots $$ Now applying it $$0+\frac{\frac{d}{dx}\left(\arcsin \left(2x\right)\right)\left(0\right)}{1!}x+\frac{\frac{d^2}{dx^2}\left(\arcsin \left(2x\right)\right)\left(0\right)}{2!}x^2+\frac{\frac{d^3}{dx^3}\left(\arcsin \left(2x\right)\right)\left(0\right)}{3!}x^3+\ldots \:$$ $$=0+\frac{2}{1!}x+\frac{0}{2!}x^2+\frac{8}{3!}x^3+\frac{0}{4!}x^4+\frac{288}{5!}x^5+\frac{0}{6!}x^6+\frac{28800}{7!}x^7+\frac{0}{8!}x^8+\frac{5644800}{9!}x^9+\ldots \:$$ $$=2x+\frac{4}{3}x^3+\frac{12}{5}x^5+\frac{40}{7}x^7+\frac{140}{9}x^9+\ldots \:$$
stackexchange-math
{ "answer_score": 0, "question_score": 0, "tags": "taylor expansion" }
svn update mechanism, dealing with potentially corrupt data I am using an svn repo to keep my work files in sync between my local machine and server administered by someone else. Recently, I received notice that the server's storage was corrupt, and that not all corrupted files could be detected. When I svn update, will svn be able to determine if files have been changed by means of corruption? What is the mechanism that svn uses to determine changes in files? I have a feeling that it uses the timestamp, although I can't confirm this. My safest move right now is to re-checkout out the repo on the server, which is very time consuming and desirable to avoid. Thank you very much for your time. Adam.
SVN detects file modifications by diffing files. Afaik the file timestamps are not considered at all. > My safest move right now is to re-checkout out the repo on the server, which is very time consuming and desirable to avoid. I do not understand right what you tried to explain, is there really a corruption of the repo on svn server or is your working copy corrupted? If the latter one is true then you can indeed try to a) "clean" and then "update" your working copy or b) first reverting your working copy then updating it or c) check-out a new working copy. If the svn repo is corrupted then you should at least backup your working copy asap just for the case that you cannot recover the svn repo on the server (in this case you would at least have a recent copy in your working directory and could try to setup a new svn repo and check-in the content of this working directory).
stackexchange-stackoverflow
{ "answer_score": 3, "question_score": 0, "tags": "svn, remote access, corruption" }
HTML full page zoom depending on screen resolution I have a problem with displaying my `html` site on different monitors/resolutions. I was trying to to solve this problem with the following script, but it isn't working. How could I improve this? if (width <= 1280 && height <= 720) { document.getElementById('html').style.zoom = '50%'; html { zoom: 100%; }
You could scale the content without javascript, just using a mediaquery and a `CSS3` transformation applied to the `html` element @media screen and (max-width: 1280px) and (max-height: 720px) { html { transform: scale(.5); // or simply zoom: 50% } } as a side note your code can't work because you're looking for an element with `id="html"`, while you're trying to target the `html` element (that is `document.documentElement` or `document.querySelector('html')`)
stackexchange-stackoverflow
{ "answer_score": 8, "question_score": 2, "tags": "javascript, html, css, zooming" }
Host bukkit server with regular server My question is simple. I have a Bukkit Minecraft server. Right now there is no Bukkit version compatible with Minecraft 1.3.1. Is there a way to take my server and host it with the regular Minecraft server until a new version of Bukkit comes out? If there is, how can I accomplish this?
I found out that by using windows 7's restoring previous versions system, I could downgrade my Bin folder to be able to go back on my server. Hope this helps someone
stackexchange-gaming
{ "answer_score": 0, "question_score": 0, "tags": "minecraft java edition, minecraft java edition server, minecraft bukkit" }
Should I free memory before exit? Should I free all my mallocated memory when I am exiting program in the due of error? something = (char**) malloc (x * sizeof(char*)); for (i = 0; i < x; i++) something[i] = (char*) malloc (y + 1); ... if (anything == NULL) { printf("Your input is wrong!"); // should I free memory of every mallocated entity now? exit(1); } else { // work with mallocated entities ... free(something); // it must be here system("pause); }
It depends on the OS. Best practice I'd say you should explicitly free it. It also makes using tools like valgrind a PITA if you have memory not freed all over the place and I cannot tell what's good and bad etc. If on an OS that explicitly frees memory you still have the problem of other resources. As your app starts to grow and pull in third party libraries you can get resource leaks. Imagine I've written a library that asks that you call close on a handler. This handler happens to be backed by temporary files that doesn't get deleted unless you call close. Or I've detached processes that are running in the background that I'm managing using signals or some other resource that you're unaware of.
stackexchange-stackoverflow
{ "answer_score": 12, "question_score": 40, "tags": "c, malloc, free, dynamic allocation" }
Alternative SSH Application to Plink I have recently started having problems with TortoiseCVS, or more specifically with plink, the SSH application that comes with it. The IP address it tries to connect to can not be changed and is stuck with the old CVS repository's IP. Downloading plink from it's home site and calling from the command line still has this problem. TortoiseCVS has the option to choose the SSH application it uses and I was wondering which other alternatives there are that I can use instead?
For what it's worth, plink is just a command-line version of putty written by the same guy. I think jsight probably has the right idea.
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 1, "tags": "ssh, cvs, tortoisecvs, plink" }
Die Bedeutung des Ausdruckes " Bananen voll wie auf Oliver Kahn schmeissen" > Und sollte ich erfahren, ich rap prollig und arm `schmeiß ich voll die Bananen wie auf Olliver Kahn`. Was bedeutet dieser Ausdruck? Ich habe diese Redewendung nicht in meinem Wörterbuch gefunden. Könnte mir jemand sagen, was dieser Ausdruck ist?
Es ist keine feststehende Redewendung, und Rapper sind auch nicht gerade für ihr stilsicheres und makelloses Deutsch bekannt. Offenbar wird hier aber auf Oliver Kahn angespielt, _der während seiner Vereinskarriere des Öfteren von gegnerischen Fans mit Bananen beworfen [wurde], um ihn wegen seiner angeblichen Ähnlichkeit mit einem Gorilla zu verspotten._ (Wikipedia)
stackexchange-german
{ "answer_score": 4, "question_score": 0, "tags": "idiom" }
Why does PHP Include not work with child Includes? I may have phrased the question slightly wrong so feel free to edit the title. I was working on a site and I made this whole PHP Include system that was easy so that people with less knowledge could edit the content. Anyway it was like this. Say you have index.php and the code is. <?PHP include 'tabs.php'; ?> and then tabs.php is: include 'tab-1.php' 2, 3 etc. and then tab-1 is: <?PHP include 'tab-1-content.php' ?> I hope you kind of get the idea, of course the formatting was way neater and there was html around it and stuff but the point is it didnt work at all. It seems like you can only include one file and then if there is an include in that file it wont work. I was wondering if anyone could explain this!? Thanks!
I think multiple includes doesn't cause problems ... but if it doesn't work for you, it's most probably you have a conflict in the files' paths. My advice is to test the includes statements one by one for example:- include 'tabs.php'; if the above line works fine, add into "tabs.php" the following line include 'tab-1.php' and keep going until you find the file where the problem happens.
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": -2, "tags": "php, html" }
significance test for yes/no data in R I have the following data format: id drug_type result -- --------- ------ 1 A Yes 2 B No 3 A No 4 Placebo Yes . . How do I test the result column for significance of each `drug_type` that is not `Placebo`, against the `Placebo`. Usually I would take subsets of the table based on `drug_type` and do: t.test(drugA,placebo) however I know I should not be using a t-test for categorical data. The `prop.test` handles categorical variables, but to me does not seem to be able to compare each non-Placebo drug group to the placebo, but merely run significance test on the proportion of successful tests within each `drug_type`. any suggestions?
How about logistic regression -- especially if you have other factors that you need to control? You can simply set up a contrast to test differences in drug types. For example: id<-seq(1, 100) drug_type<-as.factor(sample(c(LETTERS[1:2], "Placebo"), size=100, replace=TRUE)) result<-as.factor(sample(c("Yes","No"), size=100, replace=TRUE)) mydf<-data.frame(id, drug_type, result) mydf2<-cbind(mydf, result2=as.numeric(mydf$result)-1) head(mydf2) mymodel<-glm(result2~drug_type, data=mydf2, family="binomial") summary(mymodel) install.packages("aod") library(aod) L<-cbind(0, 1, -1) #For example to test Test Drug B against Placebo wald.test(b = coef(mymodel), Sigma = vcov(mymodel), L = L)
stackexchange-stats
{ "answer_score": 5, "question_score": 1, "tags": "r, statistical significance" }
UserNotFound: Could not find user admin@automation I am trying to launch a Mongodb instance as follows and running into error as below, how do I debug this?please provide guidance on how to fix this error mongo automation --host machine40.scv.company.com -u admin -p passd 2018-05-15T21:11:30.346-0700 I ACCESS [conn3] SCRAM-SHA-1 authentication failed for admin on automation from client 17.xxx.xxx.x:54756 ; UserNotFound: Could not find user admin@automation
Please refer below step. 1) log into mongo console as super admin user. mongo admin --host machine40.scv.company.com -u admin -p passd 2) Then check, is there any user call admin who can authenticate to access "automation" DB. Sample output given below { "_id" : "XXXXXX", "user" : "admin", "db" : "automation", "roles" : [ { "role" : "root", "db" : "automation" } ] }
stackexchange-stackoverflow
{ "answer_score": 4, "question_score": 2, "tags": "mongodb" }
Detect which release channel (stable,unstable,dev) from JavaScript I'd like to be able to detect which release channel of ChromeOS or Chrome a user is in from inside my chrome platform app. Is there any way to do this? The information is in chrome://version navigator.appVersion of course gives which major chrome version I'm running. I would be fine with having to make an XHR to some webpage that lists the current ChromeOS versions. But I cannot find such a table anywhere. It would be nice if it were on <
What exactly are you trying to do? Tying app behavior to a channel is an anti-pattern, as the channels are constantly evolving. If you are interested in restricting functionality to a specific new feature, then use minimum_chrome_version in your manifest, or if you don't want to restrict availability of your product during the (generally) brief window between dev and stable, simply parse navigator.userAgent (or navigator.appVersion, as you say) for the Chrome version, then switch your app's behavior based on whether you're before or at the version you need for the functionality in question. Again, don't require a specific channel. It frustrates users and is a maintenance headache for you.
stackexchange-stackoverflow
{ "answer_score": 2, "question_score": 1, "tags": "google chrome app, google chrome os" }
Regarding BU MID creation Quick Question. I'm assuming if I would like to have multiple BU. SFMC account Rep can do that. Not me through Admin.
If you would like to add another business unit to marketing cloud, yes you need to go through your account executive to MC support to create that BU. As per my conversation with support team, we need to purchase to get other BU in MC
stackexchange-salesforce
{ "answer_score": 1, "question_score": 1, "tags": "marketing cloud" }
When assigning in C++, does the object we assigned over get destructed? Does the following code fragment leak? If not, where do the two objects which are constructed in foobar() get destructed? class B { int* mpI; public: B() { mpI = new int; } ~B() { delete mpI; } }; void foobar() { B b; b = B(); // causes construction b = B(); // causes construction }
The default copy assignment operator does a member-wise copy. So in your case: { B b; // default construction. b = B(); // temporary is default-contructed, allocating again // copy-assignment copies b.mpI = temp.mpI // b's original pointer is lost, memory is leaked. // temporary is destroyed, calling dtor on temp, which also frees // b's pointer, since they both pointed to the same place. // b now has an invalid pointer. b = B(); // same process as above // at end of scope, b's dtor is called on a deleted pointer, chaos ensues. } See Item 11 in Effective C++, 2nd Edition for more details.
stackexchange-stackoverflow
{ "answer_score": 7, "question_score": 4, "tags": "c++, rule of three" }
Get number of widgets in sidebar How can I get the number of widgets that are active on a specific sidebar? Is there a core function for this? I want to add a class to each widget on a sidebar based on how many of them are displayed. Thanks.
After some research and based on the answer from Eugene Manuilov I made a function that adds custom classes to widgets in a specific sidebar ('sidebar-bottom' in my case) based on the number of widgets set in that sidebar. This will suit perfectly in horizontal sidebars and themes based on twitter bootstrap that need spanX class to adjust the element's width. function cosmos_bottom_sidebar_params($params) { $sidebar_id = $params[0]['id']; if ( $sidebar_id == 'sidebar-bottom' ) { $total_widgets = wp_get_sidebars_widgets(); $sidebar_widgets = count($total_widgets[$sidebar_id]); $params[0]['before_widget'] = str_replace('class="', 'class="span' . floor(12 / $sidebar_widgets) . ' ', $params[0]['before_widget']); } return $params; } add_filter('dynamic_sidebar_params','cosmos_bottom_sidebar_params');
stackexchange-wordpress
{ "answer_score": 13, "question_score": 8, "tags": "widgets, sidebar" }
Conditional columns in select statement based on parameters I have the below conditions: - If ouk_shipment.shipper_parent_id = Parameter1 OR ouk_shipment.shipper_id = Parameter2 =====> ouk_shipment.first_mwb_ref_id - If ouk_shipment.cnee_parent_id = Parameter1 OR ouk_shipment.cnee_id = Parameter2 =====> ouk_shipment.last_mwb_ref_id **Parameter1 and Parameter2: we enter at run time of SQL. I'm trying to achieve the following here: Select case when condition 1=True then ouk_shipment.first_mwb_ref_id when condition 2=True then ouk_shipment.last_mwb_ref_id End AS Col1 From ouk_shipment How to add conditions in my SQL? Please check
You are 99% there select case when ouk_shipment.shipper_parent_id = Parameter1 OR ouk_shipment.shipper_id = Parameter2 then ouk_shipment.first_mwb_ref_id when ouk_shipment.cnee_parent_id = Parameter1 OR ouk_shipment.cnee_id = Parameter2 then ouk_shipment.last_mwb_ref_id end col from ouk_shipment ...
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "sql, oracle, select, parameters, conditional statements" }
Cube root in $ C^{*}$-algebra. Let $A$ be a $C^*\text{-algbera}$ and $x\in A$. I'm trying to show that a)for $0<\alpha<\frac{1}{2}$, there exists $u\in A$ with $x=u(x^*x)^{\alpha}$ and $u^*u=(x^*x)^{1-2\alpha}$. b) there exists $y\in A$ such that $x=yy^*y$ ($\text{"cube root"}$ of x) and such $y$ is unique. Thank you for your help.
For the proof of first part see $C^*$-algebras and their automorphisms group by G. K. Pedersen pages 11-12, lemmas 1.4.4-1.4.5. For the proof of the second part use previous result with $\alpha=1/3$. Then you get $u\in A$ such that $x=u(x^*x)^{1/3}$ and $u^*u=(x^*x)^{1/3}$. Hence $x=uu^*u$. Proof of uniqueness I leave to you since this is a homework.
stackexchange-math
{ "answer_score": 8, "question_score": 7, "tags": "functional analysis, operator algebras, c star algebras" }
Can't Change xp Default mailto handler I installed Thunderbird to try it out then uninstalled it from a windows xp machine and now when I try to change the default mailto handler from internet options programs tab, It allows me to change it to "`GMail`" but the handler doesn't actually change. I tried using the chrome browser to change the mailto handler to a gmail client but when I click on the mail client in the drop-down list it won't change it defaults back to "`(None)`" I have tried the `javascript:navigate()` "fix" to no avail. How can I permanently change xp's Default mailto application?
Seeing as how nobody left an answer I chose to go with @Ramhound's suggestion of a restore point. While this worked for me I am still very curious as to what Thunderbird(if it was truly the culprit) did to irreversibly set it self as the default mailto handler.
stackexchange-superuser
{ "answer_score": 0, "question_score": 2, "tags": "windows xp, email, thunderbird, gmail, mailto" }
How to add a new taxonomy link to the admin menu I am looking to add a new admin menu item from my plugin call "Tickers" under "Post", with the link similar to "Tags", but point to /wp-admin/edit-tags.php?taxonomy=tickers What I have so far is add_action('admin_menu', array($this,'admin_menu')); function admin_menu () { add_options_page(); } I am not sure what are the right parameters to pass to add_options_page. Any help would be much appreciated. **Edit** Answer provided below lead me to < which can generate the custom taxonomy functions for you.
The taxonomy admin page will be handled by WordPress once you register your custom taxonomy. add_action( 'init', 'create_ticker_taxonomies', 0 ); //create two taxonomies, genres and writers for the post type "book" function create_ticker_taxonomies() { // Add new taxonomy, make it non-hierarchical (like 'tags') $labels = array( 'name' => _x( 'Tickers', 'taxonomy general name' ), ... ); register_taxonomy('ticker',array('post'), array( 'hierarchical' => false, 'labels' => $labels, 'show_ui' => true, 'query_var' => true, )); } The full options available to you regardin the taxonomy and its labels can be found on the Codex Page.
stackexchange-wordpress
{ "answer_score": 1, "question_score": 0, "tags": "plugin development" }
Does 映す also mean "to copy" in some sense? I was just sitting in a coffee shop, sheltering myself from the cloudburst over Tokyo a few minutes ago, and I couldn't help but overhear the conversation between to girls beside me. They were talking about mobile phones, apps, and were showing each other pictures on their phones. One of the girls said: > SD{} `{}` means to reflect, or project, and I'm only familiar with it in the sense of a film projector projecting an image on a screen. However, it seemed they were talking about copying pictures to their SD card. Is `{}` extended in use to mean copying data to a disk? As in, the bits are reflected on the disk? What are the nuances of `{}` that make it applicable here? Is this a recent usage of `{}`?
As far as I know, `{}` is generally used for "copy (homework/data etc)"/"take a photo", and `{}` is generally used for "reflect/project", but that `` can mean "copy" with the right Kanji. Also note a third way of writing with `{}`, which means "move/remove/transfer" etc.
stackexchange-japanese
{ "answer_score": 10, "question_score": 4, "tags": "word choice" }
Core Motion: Value of optional type 'NSOperationQueue?' not unwrapped I am following a tutorial from RayWenderLich's website, however, I am stuck on the part about Core Motion. // CoreMotion // 1 motionManager.accelerometerUpdateInterval = 0.2 // 2 motionManager.startAccelerometerUpdatesToQueue(NSOperationQueue.currentQueue(), withHandler: { (accelerometerData: CMAccelerometerData!, error: NSError!) in // 3 let acceleration = accelerometerData.acceleration // 4 self.xAcceleration = (CGFloat(acceleration.x) * 0.75) + (self.xAcceleration * 0.25) }) I try fixing the error, but I end up with more errors. Any help is appreciated. Thank you.
The `NSOperationQueue`'s `currentQueue` returns an optional so you need to unwrap the optional, `NSOperationQueue.currentQueue()!`. // CoreMotion // 1 motionManager.accelerometerUpdateInterval = 0.2 // 2 motionManager.startAccelerometerUpdatesToQueue(NSOperationQueue.currentQueue()!, withHandler: { (accelerometerData: CMAccelerometerData?, error: NSError?) in // 3 let acceleration = accelerometerData.acceleration // 4 self.xAcceleration = (CGFloat(acceleration.x) * 0.75) + (self.xAcceleration * 0.25) }) Also, the closure that you use as handler has wrong parameter types. It's `typealias CMAccelerometerHandler = (CMAccelerometerData?, NSError?) -> Void`
stackexchange-stackoverflow
{ "answer_score": 0, "question_score": 0, "tags": "swift, sprite kit, core motion" }
Need help in one issue while Cake php migration from 1.3 to 2.x Hi We are trying to migrate our website which is currently running with Cakephp 1.3 so we are first trying to migrate it Cakephp 2.X than after will try for cake3.x So I am facing problem we have some values which we are using as a global variable & in cakephp 1.3 we have defined these in app/config/config.php like $config['Site.title'] = 'XXXXXX'; $siteFolder = dirname(dirname(dirname($_SERVER['SCRIPT_NAME']))); define('SITE_URL', ' . $_SERVER['HTTP_HOST'] . $siteFolder); define('MENTORS_IMAGE_PATH','members'.DS.'profile_images'); But now when we are migrating so in new version no config file under Config folder according to new structure & if I am copy pasting same file under Config folder that also not solving my problem giving error message:- > Use of undefined constant SITE_URL - assumed 'SITE_URL'
In CakePHP 2 you should define constants in app/Config/bootstrap.php. The error message you are getting is probably because CakePHP doesn't know about your config.php file. If you want to keep these in that file just `require` it from within bootstrap.php:- require 'config.php'; In CakePHP you should be defining constants/configuration settings using `Configure::write()` and reading them using `Configure::read()`. For example:- Configure::write('Site.title', 'XXXXX');
stackexchange-stackoverflow
{ "answer_score": 1, "question_score": 0, "tags": "cakephp" }