qid
int64
1
74.7M
question
stringlengths
15
58.3k
date
stringlengths
10
10
metadata
list
response_j
stringlengths
4
30.2k
response_k
stringlengths
11
36.5k
27,060,296
Good afternoon, I'm working on a section of the installer where I want to insert an image with a link in wpInstalling section but I don't manage to do it, I know how to insert text but I don't know how to do what I said before. I hope you can help me. ![enter image description here](https://i.stack.imgur.com/BwnYJ.png) Thanks in advance.
2014/11/21
[ "https://Stackoverflow.com/questions/27060296", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3113105/" ]
Thank you v20100v for your reply, but I found a simple way to do it. Here I leave the code just in case someone needs it. ``` [Setup] AppName=My Program AppVersion=1.5 DefaultDirName={pf}\My Program [Files] Source: "Logo.bmp"; Flags: dontcopy [Code] procedure MyImageClick(Sender: TObject); var ErrorCode: Integer; begin ShellExec('open', 'http://www.google.es', '', '', SW_SHOWNORMAL, ewNoWait, ErrorCode); end; procedure CreateMyImage(); begin ExtractTemporaryFile('Logo.bmp'); with TBitmapImage.Create(WizardForm) do begin Parent := WizardForm.InstallingPage; Bitmap.LoadFromFile(ExpandConstant('{tmp}\Logo.bmp')); AutoSize := True; Left := 0; Top := WizardForm.InstallingPage.Top + WizardForm.InstallingPage.Height - Height - 8; Cursor := crHand; OnClick := @MyImageClick; end; end; procedure InitializeWizard; begin CreateMyImage(); end; ```
You can find more information in this project (made by a japanese dvp). He creates a web control in InnoSetup. * Blog here : [Innosetup webctrl v2.1](http://restools.hanzify.org/article.asp?id=90) * Download here : [inno\_webctrl\_v2.1.zip](http://restools.hanzify.org/inno/webctrl/inno_webctrl_v2.1.zip)
60,697
Since upgrading from **Magento CE 1.7.0.2** to **1.9.1** its not showing any visitors. Google is activated and I use the **Fooman extension**. Any ideas why its not tracking visitors? Thanks.
2015/03/13
[ "https://magento.stackexchange.com/questions/60697", "https://magento.stackexchange.com", "https://magento.stackexchange.com/users/6124/" ]
Magento 1.9.1 uses universal analytics. You need to enable universal analytics on google if you haven't already. Probably the fooman extension is outdated. Old version didnt support UA. Now it does. Update extension and make sure UA is enabled on google. <http://www.magentocommerce.com/magento-connect/google-analytics-by-fooman.html>
+1 on Ladle3000, a good idea also is to checkout Blue Acorn's Univeral analytics extension which enables your site voor enhanced e-commerce. This will give your much more insight in the performance and potential problems in your store. More info on Enhanced e-commerce: <http://analytics.blogspot.nl/2014/05/better-data-better-decisions-enhanced.html> and the Blue Acron <http://www.blueacorn.com/magento-blog/google-universal-analytics-enhanced-ecommerce-magento/>
60,697
Since upgrading from **Magento CE 1.7.0.2** to **1.9.1** its not showing any visitors. Google is activated and I use the **Fooman extension**. Any ideas why its not tracking visitors? Thanks.
2015/03/13
[ "https://magento.stackexchange.com/questions/60697", "https://magento.stackexchange.com", "https://magento.stackexchange.com/users/6124/" ]
In version **1.9.1**, Magento added an admin configuration setting for setting different Google Analytics code types. You can see this setting by going to: > > **Admin > Configuration > Sales > Google API > Google Analytics > Type** > > > There should be two options here "Universal Analytics" and "Google Analytics". Older versions of Magento did not have this setting and would always default to Universal Analytics code. After upgrading to 1.9.1, I believe Magento now automatically defaults to Google Analytics code instead. This caused issues for me with `Uncaught ReferenceError: ga is not defined` errors showing up in the console on pages. I resolved it by switching the config setting, **Type**, back to **Universal Analtyics** and my errors went away and my tracking came back. You can see the conditional for the two different GA code types and what the code looks like in: > > app\design\frontend\base\default\template\googleanalytics\ga.phtml > > >
Magento 1.9.1 uses universal analytics. You need to enable universal analytics on google if you haven't already. Probably the fooman extension is outdated. Old version didnt support UA. Now it does. Update extension and make sure UA is enabled on google. <http://www.magentocommerce.com/magento-connect/google-analytics-by-fooman.html>
60,697
Since upgrading from **Magento CE 1.7.0.2** to **1.9.1** its not showing any visitors. Google is activated and I use the **Fooman extension**. Any ideas why its not tracking visitors? Thanks.
2015/03/13
[ "https://magento.stackexchange.com/questions/60697", "https://magento.stackexchange.com", "https://magento.stackexchange.com/users/6124/" ]
In version **1.9.1**, Magento added an admin configuration setting for setting different Google Analytics code types. You can see this setting by going to: > > **Admin > Configuration > Sales > Google API > Google Analytics > Type** > > > There should be two options here "Universal Analytics" and "Google Analytics". Older versions of Magento did not have this setting and would always default to Universal Analytics code. After upgrading to 1.9.1, I believe Magento now automatically defaults to Google Analytics code instead. This caused issues for me with `Uncaught ReferenceError: ga is not defined` errors showing up in the console on pages. I resolved it by switching the config setting, **Type**, back to **Universal Analtyics** and my errors went away and my tracking came back. You can see the conditional for the two different GA code types and what the code looks like in: > > app\design\frontend\base\default\template\googleanalytics\ga.phtml > > >
+1 on Ladle3000, a good idea also is to checkout Blue Acorn's Univeral analytics extension which enables your site voor enhanced e-commerce. This will give your much more insight in the performance and potential problems in your store. More info on Enhanced e-commerce: <http://analytics.blogspot.nl/2014/05/better-data-better-decisions-enhanced.html> and the Blue Acron <http://www.blueacorn.com/magento-blog/google-universal-analytics-enhanced-ecommerce-magento/>
18,258,731
Take the following struct and class: ``` struct TestStruct { }; class TestClass { public: TestStruct* testStruct; }; ``` Do the following in `main`: ``` TestClass testClass; if (testClass.testStruct == NULL) cout << "It is NULL." << endl; else cout << "It is NOT NULL."; ``` The output will be: `It is NOT NULL.`. However, if I instead do this: ``` TestClass testClass; if (testClass.testStruct == NULL) cout << "It is NULL." << endl; else cout << "It is NOT NULL." << endl << testClass.testStruct; ``` The output will be: `It is NULL.`. Interestingly enough, if I do this (fundamentally the same as above): ``` TestClass testClass; if (testClass.testStruct == NULL) { cout << "It is NULL." << endl; } else { cout << "It is NOT NULL." << endl; cout << testClass.testStruct; } ``` The output will be: ``` It is NOT NULL. 0x7fffee043580. ``` What is going on?
2013/08/15
[ "https://Stackoverflow.com/questions/18258731", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1819815/" ]
Your pointer is not initialized when you declare `testClass`. You experience here an undefined behaviour. The value of the pointer will be the last value that was contain in the memory section where it is stored. If you wanted it to **always** be `NULL`, you would need to initialize it in the constructor of your class. ``` class TestClass { public: TestClass(): testStruct(NULL) {} TestStruct* testStruct; }; ```
The `testStruct` will sometimes be NULL and sometimes not be NULL. Make sure your constructor clears the pointer. Variables in C++ are not default to NULL/0.
18,258,731
Take the following struct and class: ``` struct TestStruct { }; class TestClass { public: TestStruct* testStruct; }; ``` Do the following in `main`: ``` TestClass testClass; if (testClass.testStruct == NULL) cout << "It is NULL." << endl; else cout << "It is NOT NULL."; ``` The output will be: `It is NOT NULL.`. However, if I instead do this: ``` TestClass testClass; if (testClass.testStruct == NULL) cout << "It is NULL." << endl; else cout << "It is NOT NULL." << endl << testClass.testStruct; ``` The output will be: `It is NULL.`. Interestingly enough, if I do this (fundamentally the same as above): ``` TestClass testClass; if (testClass.testStruct == NULL) { cout << "It is NULL." << endl; } else { cout << "It is NOT NULL." << endl; cout << testClass.testStruct; } ``` The output will be: ``` It is NOT NULL. 0x7fffee043580. ``` What is going on?
2013/08/15
[ "https://Stackoverflow.com/questions/18258731", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1819815/" ]
Your pointer is not initialized when you declare `testClass`. You experience here an undefined behaviour. The value of the pointer will be the last value that was contain in the memory section where it is stored. If you wanted it to **always** be `NULL`, you would need to initialize it in the constructor of your class. ``` class TestClass { public: TestClass(): testStruct(NULL) {} TestStruct* testStruct; }; ```
Well, the Pointer doesn't get initialized by default. You'll have to do that in the constructor. It just contains what's in your RAM. On usual 32 bit systems the propability of it being NULL is around 0,2e-9. on 64 bit systems ( in 64 bit assemblies) it will be even lower.
18,258,731
Take the following struct and class: ``` struct TestStruct { }; class TestClass { public: TestStruct* testStruct; }; ``` Do the following in `main`: ``` TestClass testClass; if (testClass.testStruct == NULL) cout << "It is NULL." << endl; else cout << "It is NOT NULL."; ``` The output will be: `It is NOT NULL.`. However, if I instead do this: ``` TestClass testClass; if (testClass.testStruct == NULL) cout << "It is NULL." << endl; else cout << "It is NOT NULL." << endl << testClass.testStruct; ``` The output will be: `It is NULL.`. Interestingly enough, if I do this (fundamentally the same as above): ``` TestClass testClass; if (testClass.testStruct == NULL) { cout << "It is NULL." << endl; } else { cout << "It is NOT NULL." << endl; cout << testClass.testStruct; } ``` The output will be: ``` It is NOT NULL. 0x7fffee043580. ``` What is going on?
2013/08/15
[ "https://Stackoverflow.com/questions/18258731", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1819815/" ]
Your pointer is not initialized when you declare `testClass`. You experience here an undefined behaviour. The value of the pointer will be the last value that was contain in the memory section where it is stored. If you wanted it to **always** be `NULL`, you would need to initialize it in the constructor of your class. ``` class TestClass { public: TestClass(): testStruct(NULL) {} TestStruct* testStruct; }; ```
It is because you didn't initialized the `testStruct` member. You have an *Undefined behaviour* here. It contains garbage value. If you want it to be always initialized to `NULL`, you can do : ``` class TestClass { public: TestClass(): testStruct(NULL) {} TestStruct* testStruct; }; ``` Or with the **c++11** way : ``` class TestClass { public: TestStruct* testStruct{NULL}; // or TestStruct* testStruct = NULL; }; ``` All the three examples in live : <http://ideone.com/ge25Zr> --- As it is said in the comment, to complete with the C++11 way, you could use `nullptr` : ``` class TestClass { public: TestStruct* testStruct = nullptr; // or TestStruct* testStruct{nullptr}; }; ``` --- By the way, it is a better practice to keep member attributes private or at least protected. You should create accessors to retreive them.
18,258,731
Take the following struct and class: ``` struct TestStruct { }; class TestClass { public: TestStruct* testStruct; }; ``` Do the following in `main`: ``` TestClass testClass; if (testClass.testStruct == NULL) cout << "It is NULL." << endl; else cout << "It is NOT NULL."; ``` The output will be: `It is NOT NULL.`. However, if I instead do this: ``` TestClass testClass; if (testClass.testStruct == NULL) cout << "It is NULL." << endl; else cout << "It is NOT NULL." << endl << testClass.testStruct; ``` The output will be: `It is NULL.`. Interestingly enough, if I do this (fundamentally the same as above): ``` TestClass testClass; if (testClass.testStruct == NULL) { cout << "It is NULL." << endl; } else { cout << "It is NOT NULL." << endl; cout << testClass.testStruct; } ``` The output will be: ``` It is NOT NULL. 0x7fffee043580. ``` What is going on?
2013/08/15
[ "https://Stackoverflow.com/questions/18258731", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1819815/" ]
Your pointer is not initialized when you declare `testClass`. You experience here an undefined behaviour. The value of the pointer will be the last value that was contain in the memory section where it is stored. If you wanted it to **always** be `NULL`, you would need to initialize it in the constructor of your class. ``` class TestClass { public: TestClass(): testStruct(NULL) {} TestStruct* testStruct; }; ```
***Answer*** ------------ For me it displays **"It is NOT NULL"** in both questions and **sometimes you may get it as NULL** The reason for above scenario to occur is that C++ doesn't automatically assign anything to a variable, Therefore it contains an unknown value so that unknown value may be NULL sometimes but sometimes it may be not the best way to test this theory is to try it in visual C++ and g++ and any other c++ compiler Yet another reason for you to get either null or not null is that **when you compile the application in different ways the compiler outputs different executables** so in one undefined variable scenario the **compiler may output an executable which when executed may point the undefined variable to a NULL or NOT NULL** ***A Test using GNU C++ compiler and Microsoft Command line compiler*** ----------------------------------------------------------------------- **warning don't use this code IT'S BAD (this is a test for undefined variable scenario in two compilers)** code (based on OP) : ``` #include <iostream> using namespace std; struct TestStruct { }; class TestClass { public: TestStruct* testStruct; }; int main(){ TestClass testClass; if (testClass.testStruct == NULL) cout << "It is NULL." << endl; else cout << "It is NOT NULL." << endl << testClass.testStruct; } ``` GNU G++ ![GNU G++ test](https://i.stack.imgur.com/15xQt.png) Visual Studio CL ![CL](https://i.stack.imgur.com/WGvoT.png)
3,964,478
> > Find all the functions $f :\mathbb R \to \mathbb R$ that satisfy the > conditions: > > > 1. $$f(x+y)=f(x)+f(y), \enspace \forall x,y \in \mathbb R;$$ > 2. $$\exists \lim\_{x\to \infty}f(x).$$ > > > This problem is important for the community because on the forum I only saw the case where $f$ is continuous, but not the case when we only know that $\displaystyle\exists \lim\_{x\to \infty}f(x).$ I found a solution to this problem in a book of analysis I own, which hints the following: It is easy to see that $f(q)=q\cdot f(1), \enspace \forall q\in \mathbb Q$. Let $f(1)=a$. If $a>0$, then consider the sequence $a\_n=n.$ It follows that $$\lim\_{x\to \infty}f(x)=\lim\_{n\to \infty}f(a\_n)=\lim\_{n\to \infty}an=\infty.$$ The next step in the book is that this implies $f$ is increasing. I couldn't understand this line properly. Why is $f$ increasing? Of course, it is easy to check that $f(q)\le f(r), \forall q<r \in \mathbb Q$, but why is this also true for reals? Please help me understand this! Thank you so much! It is also clear that if $f$ is increasing then $f(x)=ax$ for all $x\in \mathbb R$ (suppose there exists an $x\in \mathbb R\setminus \mathbb Q$ such that $f(x)<x$. Then by density there is a $q\in \mathbb Q$ such that $f(x)<aq=f(q)<ax$, and this clearly gives the contradiction that $x< q <x$).
2020/12/28
[ "https://math.stackexchange.com/questions/3964478", "https://math.stackexchange.com", "https://math.stackexchange.com/users/463062/" ]
So we have that lim $f = +\infty $. Let's $x<y$ be real numbers. Then $f(y)-f(x) = f(y-x)$, so $n(f(y)-f(x)) = f(n(y-x))$. Since $f(n(y-x)) \rightarrow +\infty$ when $n\rightarrow +\infty$, it is positive for $n$ big enough. So $n(f(y)-f(x))$ is positive for $n$ big enough. But the sign of $n(f(y)-f(x))$ does not depend on $n$. So $n(f(y)-f(x))$ is always positive, and especially $f(y) > f(x)$.
I do not think you need the increasing property and can argue more directly: As before, $f(qx)=qf(x)$ for $q\in \Bbb Q$ and $x \in\Bbb R$, and let $a=f(1)$ Let $y\notin\Bbb Q$. Assume $f(y)\ne ay$, say $\epsilon:=\left|\frac{f(y)}y-a\right|>0$. By density of $\Bbb Q$ in $\Bbb R$, we find $u,v\in \Bbb Q$ with $y-\epsilon<u<y<v<y+\epsilon$. Then $|f(y)-ay|>|a|\epsilon$ whereas $|f(u)-ay|$ and $|f(v)-ay|$ are both $<|a|\epsilon$. So $f(u)$, $f(v)$ are either both $>f(y)$ or both $<f(y)$. At any rate, we find two positive numbers $x\_1=y-u$ and $x\_2=v-y$ such that exactly one of $f(x\_1)$, $f(x\_2)$ is positive and the other negative. Then one of $\lim\_{n\to\infty}f(nx\_1)$, $\lim\_{n\to\infty}f(nx\_2)$ is $+\infty$ and the other is $-\infty$. This contradicts the existence of $\lim\_{x\to\infty}f(x)$.
165,349
I want to add a class to a menu - doing it in hook\_menu won't work because I'm adding an icon with the icon API, and this seems to override any classes put on the menu items. I have this preprocess function: ``` /** * hook_preprocess_page(). */ function MYMODULE_preprocess_page(&$vars) { $vars['main_menu']['menu-1914']['attributes']['class'] = array('message'); } ``` But it doesn't seem to add the css class "message" onto my element. How do I reliably add a css class to a menu item before display, but before icon API would display it. Theming has to be my weakest Drupal skill.
2015/07/14
[ "https://drupal.stackexchange.com/questions/165349", "https://drupal.stackexchange.com", "https://drupal.stackexchange.com/users/6491/" ]
To add class in navigation's `<ul>` element, include below code in template.php ``` function THEMENAME_menu_tree__menu_MENUNAME($variables) { return '<ul class="CLASSNAME YOU WANT TO ADD">' . $variables['tree'] . '</ul>'; } ```
I was able to apply a class to the menu item this way: ``` function MYMODULE_preprocess_menu_link(&$variables) { if($variables['element']['#original_link']['link_title'] == "Messages") { $variables['element']['#attributes']['class'][] = "no-message"; } } ```
31,975,529
I have some images in a feature image slider. I need to make these programmable by date so that i don't have to go online to change these during the weekend or so on. I want to put a start date and an end date in the object. How do you use a date in an object (not as a string)? ``` var bannerOne = {dateStart:"08/12/2015", dateEnd:"08/13/2015", banner:"<li><a href=\"https://unsplash.it/200/300\"><img src=\"https://unsplash.it/500/300\" /></a></li>"}; var bannerTwo = {dateStart:"08/14/2015", dateEnd:"08/15/2015", banner:"<li><a href=\"https://unsplash.it/200/300\"><img src=\"https://unsplash.it/600/300\" /></a></li>"}; var bannerThree = {dateStart:"08/12/2015", dateEnd:"08/13/2015", banner:"<li><a href=\"https://unsplash.it/200/300\"><img src=\"https://unsplash.it/550/300\" /></a></li>"}; ``` I want to compare the current date and see if the dates in the object include the current date and if so display that image. I am still new to javascript. Currently I use this code: ``` <ul> <script type="text/javascript"> var banner = new Array(); banner[0] = "<li>First Statement</li>"; banner[1] = "<li>Second Statement</li>"; banner[2] = "<li>Third Statement</li>"; banner[3] = "<li>Fourth Statement</li>"; banner[4] = "<li>Fifth Statement</li>"; var d = new Date(); if (d.getDate() == 12) {document.write(banner [0], banner [1], banner[2])} /*Use this to program to be live during two dates !!!!LEAVE(-1)!!!!*/ else if (d.getMonth() == 8-1 && d.getDate() >= 10 && d.getDate() < 12) {document.write(banner [4], banner [1])} else { document.write(banner [1], banner[2], banner [3], banner[4], banner [0]) } </script> </ul> ```
2015/08/12
[ "https://Stackoverflow.com/questions/31975529", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1985504/" ]
You case comparison should be something like below, if you are testing `P.TEST` value based on `S.SWITCH` case. ``` AND ( P.TEST = CASE WHEN S.SWITCH = 'A' THEN T.OPTION_1 WHEN S.SWITCH = 'C' THEN T.OPTION_1 + T.OPTION_2 WHEN S.SWITCH = 'G' THEN T.OPTION_3 WHEN S.SWITCH = 'N' THEN TRUE ELSE FALSE END ) ``` If you are comparing based on P.TEST and S.SWITCH, you can do either of following 1. Blorgbeard already provided this answer ``` AND ( (S.SWITCH = 'A' AND P.TEST = T.OPTION_1) OR (S.SWITCH = 'C' AND T.OPTION_1 + T.OPTION_2) OR (S.SWITCH = 'G' AND P.TEST = T.OPTION_3) OR (S.SWITCH = 'N') ) ``` 2. If you want to make case statement work for this, following could be a possible solution. ``` AND ( CASE 1 = WHEN S.SWITCH = 'A' AND P.TEST = T.OPTION_1 THEN 1 WHEN S.SWITCH = 'C' AND P.TEST = T.OPTION_1 + T.OPTION_2 THEN 1 WHEN S.SWITCH = 'G' AND P.TEST = T.OPTION_3 THEN 1 WHEN S.SWITCH = 'N' THEN 1 ELSE 0 END ) ```
Boolean expressions don't work like that in SQL. You can reformulate your switch like this: ``` AND ( (S.SWITCH = 'A' AND P.TEST = T.OPTION_1) OR (S.SWITCH = 'C' AND T.OPTION_1 + T.OPTION_2) OR (S.SWITCH = 'G' AND P.TEST = T.OPTION_3) OR (S.SWITCH = 'N') ) ```
31,975,529
I have some images in a feature image slider. I need to make these programmable by date so that i don't have to go online to change these during the weekend or so on. I want to put a start date and an end date in the object. How do you use a date in an object (not as a string)? ``` var bannerOne = {dateStart:"08/12/2015", dateEnd:"08/13/2015", banner:"<li><a href=\"https://unsplash.it/200/300\"><img src=\"https://unsplash.it/500/300\" /></a></li>"}; var bannerTwo = {dateStart:"08/14/2015", dateEnd:"08/15/2015", banner:"<li><a href=\"https://unsplash.it/200/300\"><img src=\"https://unsplash.it/600/300\" /></a></li>"}; var bannerThree = {dateStart:"08/12/2015", dateEnd:"08/13/2015", banner:"<li><a href=\"https://unsplash.it/200/300\"><img src=\"https://unsplash.it/550/300\" /></a></li>"}; ``` I want to compare the current date and see if the dates in the object include the current date and if so display that image. I am still new to javascript. Currently I use this code: ``` <ul> <script type="text/javascript"> var banner = new Array(); banner[0] = "<li>First Statement</li>"; banner[1] = "<li>Second Statement</li>"; banner[2] = "<li>Third Statement</li>"; banner[3] = "<li>Fourth Statement</li>"; banner[4] = "<li>Fifth Statement</li>"; var d = new Date(); if (d.getDate() == 12) {document.write(banner [0], banner [1], banner[2])} /*Use this to program to be live during two dates !!!!LEAVE(-1)!!!!*/ else if (d.getMonth() == 8-1 && d.getDate() >= 10 && d.getDate() < 12) {document.write(banner [4], banner [1])} else { document.write(banner [1], banner[2], banner [3], banner[4], banner [0]) } </script> </ul> ```
2015/08/12
[ "https://Stackoverflow.com/questions/31975529", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1985504/" ]
You case comparison should be something like below, if you are testing `P.TEST` value based on `S.SWITCH` case. ``` AND ( P.TEST = CASE WHEN S.SWITCH = 'A' THEN T.OPTION_1 WHEN S.SWITCH = 'C' THEN T.OPTION_1 + T.OPTION_2 WHEN S.SWITCH = 'G' THEN T.OPTION_3 WHEN S.SWITCH = 'N' THEN TRUE ELSE FALSE END ) ``` If you are comparing based on P.TEST and S.SWITCH, you can do either of following 1. Blorgbeard already provided this answer ``` AND ( (S.SWITCH = 'A' AND P.TEST = T.OPTION_1) OR (S.SWITCH = 'C' AND T.OPTION_1 + T.OPTION_2) OR (S.SWITCH = 'G' AND P.TEST = T.OPTION_3) OR (S.SWITCH = 'N') ) ``` 2. If you want to make case statement work for this, following could be a possible solution. ``` AND ( CASE 1 = WHEN S.SWITCH = 'A' AND P.TEST = T.OPTION_1 THEN 1 WHEN S.SWITCH = 'C' AND P.TEST = T.OPTION_1 + T.OPTION_2 THEN 1 WHEN S.SWITCH = 'G' AND P.TEST = T.OPTION_3 THEN 1 WHEN S.SWITCH = 'N' THEN 1 ELSE 0 END ) ```
I know this is more of a comment than an answer, but hopefully this will lead to an answer, and I need to do formatted code for this so... I tried this in Mysql and it worked. Could you try something like this in Sybase and see what it returns? The point being, extract the part that failed and test it out and see if you can figure out exactly what is wrong. It may be that Sybase is pointing to that equal sign but something else is really what is confusing it. ``` set @miller:='C'; set @mtime:=2; select CASE @miller WHEN 'A' THEN @mtime = 1 WHEN 'C' THEN @mtime = 2 WHEN 'G' THEN @mtime = 3 WHEN 'N' THEN TRUE ELSE FALSE END ``` This returns a 1 since miller = 'C' takes it to check if mtime = 2, which is true, and that means a 1 or true in Mysql. Could you try and isolate this bit of code like this in Sybase?
31,975,529
I have some images in a feature image slider. I need to make these programmable by date so that i don't have to go online to change these during the weekend or so on. I want to put a start date and an end date in the object. How do you use a date in an object (not as a string)? ``` var bannerOne = {dateStart:"08/12/2015", dateEnd:"08/13/2015", banner:"<li><a href=\"https://unsplash.it/200/300\"><img src=\"https://unsplash.it/500/300\" /></a></li>"}; var bannerTwo = {dateStart:"08/14/2015", dateEnd:"08/15/2015", banner:"<li><a href=\"https://unsplash.it/200/300\"><img src=\"https://unsplash.it/600/300\" /></a></li>"}; var bannerThree = {dateStart:"08/12/2015", dateEnd:"08/13/2015", banner:"<li><a href=\"https://unsplash.it/200/300\"><img src=\"https://unsplash.it/550/300\" /></a></li>"}; ``` I want to compare the current date and see if the dates in the object include the current date and if so display that image. I am still new to javascript. Currently I use this code: ``` <ul> <script type="text/javascript"> var banner = new Array(); banner[0] = "<li>First Statement</li>"; banner[1] = "<li>Second Statement</li>"; banner[2] = "<li>Third Statement</li>"; banner[3] = "<li>Fourth Statement</li>"; banner[4] = "<li>Fifth Statement</li>"; var d = new Date(); if (d.getDate() == 12) {document.write(banner [0], banner [1], banner[2])} /*Use this to program to be live during two dates !!!!LEAVE(-1)!!!!*/ else if (d.getMonth() == 8-1 && d.getDate() >= 10 && d.getDate() < 12) {document.write(banner [4], banner [1])} else { document.write(banner [1], banner[2], banner [3], banner[4], banner [0]) } </script> </ul> ```
2015/08/12
[ "https://Stackoverflow.com/questions/31975529", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1985504/" ]
Boolean expressions don't work like that in SQL. You can reformulate your switch like this: ``` AND ( (S.SWITCH = 'A' AND P.TEST = T.OPTION_1) OR (S.SWITCH = 'C' AND T.OPTION_1 + T.OPTION_2) OR (S.SWITCH = 'G' AND P.TEST = T.OPTION_3) OR (S.SWITCH = 'N') ) ```
I know this is more of a comment than an answer, but hopefully this will lead to an answer, and I need to do formatted code for this so... I tried this in Mysql and it worked. Could you try something like this in Sybase and see what it returns? The point being, extract the part that failed and test it out and see if you can figure out exactly what is wrong. It may be that Sybase is pointing to that equal sign but something else is really what is confusing it. ``` set @miller:='C'; set @mtime:=2; select CASE @miller WHEN 'A' THEN @mtime = 1 WHEN 'C' THEN @mtime = 2 WHEN 'G' THEN @mtime = 3 WHEN 'N' THEN TRUE ELSE FALSE END ``` This returns a 1 since miller = 'C' takes it to check if mtime = 2, which is true, and that means a 1 or true in Mysql. Could you try and isolate this bit of code like this in Sybase?
46,811,163
How Can I convert dates into string format? I am getting dates between two dates ( From to end date). and I was using this below method ``` class Dates { static func printDatesBetweenInterval(_ startDate: Date, _ endDate: Date) { var startDate = startDate let calendar = Calendar.current let fmt = DateFormatter() fmt.dateFormat = "yyyy-MM-dd" while startDate <= endDate { print(fmt.string(from: startDate)) startDate = calendar.date(byAdding: .day, value: 1, to: startDate)! } } static func dateFromString(_ dateString: String) -> Date { let dateFormatter = DateFormatter() dateFormatter.dateFormat = "yyyy-MM-dd" return dateFormatter.date(from: dateString)! }} ``` and printing dates here ``` Dates.printDatesBetweenInterval(Dates.dateFromString("2017-10-02"), Dates.dateFromString("2017-10-9")) ``` result: ``` 2017-10-02 2017-10-03 2017-10-04 2017-10-05 2017-10-06 2017-10-07 2017-10-08 2017-10-09 ``` Now, I want pass this dates to String format to calendar (I am using FSCalendar lib into app). I want this format example: ``` ["2017-10-02", "2017-10-03", "2017-10-04", "2017-10-05", "2017-10-06", "2017-10-07", "2017-10-08", "2017-10-09"] ``` Can anyone guide me . Thanks
2017/10/18
[ "https://Stackoverflow.com/questions/46811163", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6638003/" ]
Try this: ``` function displayHTMLpage() { $asubHTML = file_get_contents(plugins_url('/myfile/test.php',__FILE__ )); echo $asubHTML; } add_action('wp_enqueue_scripts', 'adsense_unblock_divs'); ```
It worked when I removed the folder "template" and kept the html file in plugin main folder. But i dont understand why wordpress not reading html file when it was inside another folder. :( :(
46,811,163
How Can I convert dates into string format? I am getting dates between two dates ( From to end date). and I was using this below method ``` class Dates { static func printDatesBetweenInterval(_ startDate: Date, _ endDate: Date) { var startDate = startDate let calendar = Calendar.current let fmt = DateFormatter() fmt.dateFormat = "yyyy-MM-dd" while startDate <= endDate { print(fmt.string(from: startDate)) startDate = calendar.date(byAdding: .day, value: 1, to: startDate)! } } static func dateFromString(_ dateString: String) -> Date { let dateFormatter = DateFormatter() dateFormatter.dateFormat = "yyyy-MM-dd" return dateFormatter.date(from: dateString)! }} ``` and printing dates here ``` Dates.printDatesBetweenInterval(Dates.dateFromString("2017-10-02"), Dates.dateFromString("2017-10-9")) ``` result: ``` 2017-10-02 2017-10-03 2017-10-04 2017-10-05 2017-10-06 2017-10-07 2017-10-08 2017-10-09 ``` Now, I want pass this dates to String format to calendar (I am using FSCalendar lib into app). I want this format example: ``` ["2017-10-02", "2017-10-03", "2017-10-04", "2017-10-05", "2017-10-06", "2017-10-07", "2017-10-08", "2017-10-09"] ``` Can anyone guide me . Thanks
2017/10/18
[ "https://Stackoverflow.com/questions/46811163", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6638003/" ]
Try this: ``` function displayHTMLpage() { $asubHTML = file_get_contents(plugins_url('/myfile/test.php',__FILE__ )); echo $asubHTML; } add_action('wp_enqueue_scripts', 'adsense_unblock_divs'); ```
I know this question is old, but for anyone who may come across this, I'm pretty sure the error was the path starting with a backslash, which in Linux would have him pathing from the root directory (/) I assume.
46,811,163
How Can I convert dates into string format? I am getting dates between two dates ( From to end date). and I was using this below method ``` class Dates { static func printDatesBetweenInterval(_ startDate: Date, _ endDate: Date) { var startDate = startDate let calendar = Calendar.current let fmt = DateFormatter() fmt.dateFormat = "yyyy-MM-dd" while startDate <= endDate { print(fmt.string(from: startDate)) startDate = calendar.date(byAdding: .day, value: 1, to: startDate)! } } static func dateFromString(_ dateString: String) -> Date { let dateFormatter = DateFormatter() dateFormatter.dateFormat = "yyyy-MM-dd" return dateFormatter.date(from: dateString)! }} ``` and printing dates here ``` Dates.printDatesBetweenInterval(Dates.dateFromString("2017-10-02"), Dates.dateFromString("2017-10-9")) ``` result: ``` 2017-10-02 2017-10-03 2017-10-04 2017-10-05 2017-10-06 2017-10-07 2017-10-08 2017-10-09 ``` Now, I want pass this dates to String format to calendar (I am using FSCalendar lib into app). I want this format example: ``` ["2017-10-02", "2017-10-03", "2017-10-04", "2017-10-05", "2017-10-06", "2017-10-07", "2017-10-08", "2017-10-09"] ``` Can anyone guide me . Thanks
2017/10/18
[ "https://Stackoverflow.com/questions/46811163", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6638003/" ]
Try this: ``` function displayHTMLpage() { $asubHTML = file_get_contents(plugins_url('/myfile/test.php',__FILE__ )); echo $asubHTML; } add_action('wp_enqueue_scripts', 'adsense_unblock_divs'); ```
This worked for me. The problem it that the plugin folder need to be added to the url of the file. ``` function my_function($content) { // all Plugins directory url // Need to add the directory of your plugin $pluginUrl = plugin_dir_url('/index.html', __FILE__); $content .= ' <p> <hr> <iframe src="' . $pluginUrl . 'your-plugin-name/index.html" width="100%" height="700px"></iframe> <hr> </p> '; // Return the content return $content; } // Hook our function to WordPress the_content filter add_filter('the_content', 'my_function'); ```
53,243,855
How can I connect to SQL database hosted on Microsoft Azure without having credentials in plain text in my .asp files or config files in VBScript? I want to have the database connection string stored in Azure Key Vault, and have the web app access the key vault to get the connection string and then connect to the database. I have looked at a lot of Microsoft documentations but they are all in C#. My web app is all in VBScript and .asp files and I don't want to spend the time rebuilding the whole web app to ASP.NET/.aspx Thank you
2018/11/10
[ "https://Stackoverflow.com/questions/53243855", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10634403/" ]
A small expansion of @OZ17's answer. Armadillo seems to store data with sizes< 16 locally `mem_local`and larger ones in an area pointed out by `mem` ``` From GDB: > p x { <arma::Mat<double>> = { <arma::Base<double, arma::Mat<double> >> = { <arma::Base_inv_yes<arma::Mat<double> >> = {<No data fields>}, <arma::Base_eval_Mat<double, arma::Mat<double> >> = {<No data fields>}, <arma::Base_trans_default<arma::Mat<double> >> = {<No data fields>}, <No data fields>}, members of arma::Mat<double>: n_rows = 1, n_cols = 10, n_elem = 10, vec_state = 2, mem_state = 0, mem = 0x7fffffffb830, mem_local = {0 <repeats 16 times>}, static is_col = false, static is_row = false }, members of arma::Row<double>: static is_col = false, static is_row = false } ``` and a small example to visualize it: ``` arma::rowvec x(10,arma::fill::ones); arma::rowvec y(10,arma::fill::zeros); std::cout << "Size=10" << std::endl; std::cout << "&x=" << x.memptr() << ", x[0..4]=" << x.subvec(1,5); std::cout << "&y=" << y.memptr() << ", y[0..4]=" << y.subvec(1,5); x.swap(y); std::cout << "x.swap(y)" << std::endl; std::cout << "&x=" << x.memptr() << ", x[0..4]=" << x.subvec(1,5); std::cout << "&y=" << y.memptr() << ", y[0..4]=" << y.subvec(1,5); arma::rowvec x2(17,arma::fill::ones); arma::rowvec y2(17,arma::fill::zeros); std::cout << "\nSize=17" << std::endl; std::cout << "&x=" << x2.memptr() << ", x[0..4]=" << x2.subvec(1,5); std::cout << "&y=" << y2.memptr() << ", y[0..4]=" << y2.subvec(1,5); x2.swap(y2); std::cout << "x.swap(y)" << std::endl; std::cout << "&x=" << x2.memptr() << ", x[0..4]=" << x2.subvec(1,5); std::cout << "&y=" << y2.memptr() << ", y[0..4]=" << y2.subvec(1,5); ``` The output from the example shows that the content is swapped in both cases but for small arrays it has swapped the local mem area and for the larger case it has swapped the mem pointer. ``` Size=10 &x=0x7fffffffb830, x[0..4]= 1.0000 1.0000 1.0000 1.0000 1.0000 &y=0x7fffffffb8e0, y[0..4]= 0 0 0 0 0 x.swap(y) &x=0x7fffffffb830, x[0..4]= 0 0 0 0 0 &y=0x7fffffffb8e0, y[0..4]= 1.0000 1.0000 1.0000 1.0000 1.0000 Size=17 &x=0x5555557d7fd0, x[0..4]= 1.0000 1.0000 1.0000 1.0000 1.0000 &y=0x5555557d8060, y[0..4]= 0 0 0 0 0 x.swap(y) &x=0x5555557d8060, x[0..4]= 0 0 0 0 0 &y=0x5555557d7fd0, y[0..4]= 1.0000 1.0000 1.0000 1.0000 1.0000 ```
Looks like armadillo's swap is internally a memcpy below a certain array size (according to op <=16).
15,813,321
I have reviewed possible answers here (for PHP, I think): <http://www.lateralcode.com/store-array-database/> but I am unable to find a C#.net version of serialize/deserialize. Would this be done the same as the way shown in my link, above, or is there a completely different approach I should be using, given the environment? I just don't want to have a bunch of different columns for each of the 12 values in each of my 9 different arrays, so if there is another approach to achieve this (converting to byte[], etc.) I am more than willing to hear it. If it helps any, the arrays will be simple string[] arrays.
2013/04/04
[ "https://Stackoverflow.com/questions/15813321", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1590549/" ]
Convert your string array into single String like given below: ``` var a = String.Join(",",arrays); //or aim is to provide a unique separator, //i.e which won't be the part of string values itself. var a= String.Join("~~",arrays); ``` and fetch it back like this: ``` var arr = a.Split(','); //or split via multiple character var arr = a.Split(new string[] { "~~" }, StringSplitOptions.None); ```
Try this to seralize the array and create a column in the database of type Blob to store the byte array. Serialization: ``` if(array == null) return null; BinaryFormatter bf = new BinaryFormatter(); MemoryStream ms = new MemoryStream(); bf.Serialize(ms, array); ``` Deserialization: ``` String[] array = new String[10]; BinaryFormatter bf = new BinaryFormatter(); ms.Position = 0; array = (String[])bf.Deserialize(ms); ```
15,813,321
I have reviewed possible answers here (for PHP, I think): <http://www.lateralcode.com/store-array-database/> but I am unable to find a C#.net version of serialize/deserialize. Would this be done the same as the way shown in my link, above, or is there a completely different approach I should be using, given the environment? I just don't want to have a bunch of different columns for each of the 12 values in each of my 9 different arrays, so if there is another approach to achieve this (converting to byte[], etc.) I am more than willing to hear it. If it helps any, the arrays will be simple string[] arrays.
2013/04/04
[ "https://Stackoverflow.com/questions/15813321", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1590549/" ]
Try this to seralize the array and create a column in the database of type Blob to store the byte array. Serialization: ``` if(array == null) return null; BinaryFormatter bf = new BinaryFormatter(); MemoryStream ms = new MemoryStream(); bf.Serialize(ms, array); ``` Deserialization: ``` String[] array = new String[10]; BinaryFormatter bf = new BinaryFormatter(); ms.Position = 0; array = (String[])bf.Deserialize(ms); ```
> > I just don't want to have a bunch of different columns for each of the > 12 values in each of my 9 different arrays, so if there is another > approach to achieve this (converting to byte[], etc.) I am more than > willing to hear it. > > > From the above description, it looks like you are using an RDBMS. The fact that you want to store multiple values in a single column screams of an issue with the design. I concur that having separate columns may not be the way to go, especially if the number of items in each array could potentially change in the future. Consider separating this data into a separate table and having a 1 to many mapping with your original table with a foreign key relationship
15,813,321
I have reviewed possible answers here (for PHP, I think): <http://www.lateralcode.com/store-array-database/> but I am unable to find a C#.net version of serialize/deserialize. Would this be done the same as the way shown in my link, above, or is there a completely different approach I should be using, given the environment? I just don't want to have a bunch of different columns for each of the 12 values in each of my 9 different arrays, so if there is another approach to achieve this (converting to byte[], etc.) I am more than willing to hear it. If it helps any, the arrays will be simple string[] arrays.
2013/04/04
[ "https://Stackoverflow.com/questions/15813321", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1590549/" ]
Convert your string array into single String like given below: ``` var a = String.Join(",",arrays); //or aim is to provide a unique separator, //i.e which won't be the part of string values itself. var a= String.Join("~~",arrays); ``` and fetch it back like this: ``` var arr = a.Split(','); //or split via multiple character var arr = a.Split(new string[] { "~~" }, StringSplitOptions.None); ```
> > I just don't want to have a bunch of different columns for each of the > 12 values in each of my 9 different arrays, so if there is another > approach to achieve this (converting to byte[], etc.) I am more than > willing to hear it. > > > From the above description, it looks like you are using an RDBMS. The fact that you want to store multiple values in a single column screams of an issue with the design. I concur that having separate columns may not be the way to go, especially if the number of items in each array could potentially change in the future. Consider separating this data into a separate table and having a 1 to many mapping with your original table with a foreign key relationship
50,107,982
I have a quandary on my hands. I created an AES service to encrypt/decrypt sensitive information. The AES key is randomly generated using java's `SecureRandom`. I have a protected file that stores the seed and upon calling the service the seed is populated into the Secure Random class. To make sure it works I have the following logic: ``` private boolean secureRandom(final String seed) { SecureRandom sr1 = new SecureRandom(seed.getBytes(UTF8_CHARSET)); SecureRandom sr2 = new SecureRandom(seed.getBytes(UTF8_CHARSET)); //Two secure random with the same seed should generate the same results boolean secureRandomWorks = sr1.nextLong() == sr2.nextLong(); if (!secureRandomWorks) { System.err.println("Secure random not supported. Defaulting to old key"); } return secureRandomWorks; } ``` The idea here is I should be able to create two secure random objects with the same seed and they should both return the same value upon the call to `nextLong()` When I deploy my application on a windows machine this works fine, but when I deploy it on a RHEL 7 machine I get my error. I was under the impression that as long as the seed is the same, both instances will always produce the same output. This seems to be the case on windows, but not when I tested it on RHEL 7 this doesn't seem to be the case. I created this simple test to see verify: ``` SecureRandom sr1 = new SecureRandom("encryptionKey".getBytes("UTF-8")); SecureRandom sr2 = new SecureRandom("encryptionKey".getBytes("UTF-8")); for (int i = 0; i < 1000; i++) { System.out.println(sr1.nextLong() == sr2.nextLong()); } ``` And on windows every output was true while on RHEL 7 this was false. Any idea's suggestions on what might be causing RHEL 7 to ignore the seed?
2018/04/30
[ "https://Stackoverflow.com/questions/50107982", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1830916/" ]
I don't find any documentation that prohibits the behavior that you observe on RHEL 7. The JavaDoc for [`java.util.Random`](https://docs.oracle.com/javase/8/docs/api/java/util/Random.html) explicitly states > > If two instances of Random are created with the same seed, and the same sequence of method calls is made for each, they will generate and return identical sequences of numbers > > > The JavaDoc for [`java.security.SecureRandom`](https://docs.oracle.com/javase/8/docs/api/java/security/SecureRandom.html) contains no similar statement. On the contrary, it mentions (in the documentation for the `setSeed()` method) > > Reseeds this random object. The given seed supplements, rather than replaces, the existing seed. Thus, repeated calls are guaranteed never to reduce randomness. > > >
Turns out that RHEL 7 (and Linux machines in general) uses a different algorithm by default than windows. Linux uses `NativePRNG` while Windows uses `SHA1PRNG`. Linux utilizes the built in `/dev/random` or `/dev/urandom` with the use of `NativePRNG`. With this in mind I was able to change how I initialize the SecureRandom object ``` private static final String ALGORITHM = "SHA1PRNG"; private static final String PROVIDER = "SUN"; private SecureRandom getSecureRandom(String seed) throws NoSuchAlgorithmException, NoSuchProviderException { SecureRandom sr = SecureRandom.getInstance(ALGORITHM, PROVIDER); sr.setSeed(seed.getBytes(UTF8_CHARSET)); return sr; } ``` From the documentation `getInstance` does not seed the object thus it does as I need. > > The returned SecureRandom object has not been seeded. To seed the > returned object, call the setSeed method. If setSeed is not called, > the first call to nextBytes will force the SecureRandom object to seed > itself. This self-seeding will not occur if setSeed was previously > called. > > > Now it is forced to use what I need and I shouldn't have an issue with RHEL 7.
37,560,688
what i want to happen is to have a pagination to have a clean look at the data. here is my html code for gridview: ``` <asp:gridview ID = "grid" runat="server" AllowPaging="true" OnPageIndexChanging="gdview_PageIndexChanging"> ``` and code behind: ``` public static string cs = "Server=PAULO;Database=ShoppingCartDB;Integrated Security=true"; protected void Page_Load(object sender, EventArgs e) { if (Session["New"] != null) { if (!IsPostBack) { SqlConnection con = new SqlConnection(cs); con.Open(); string sql = "SELECT * FROM CustomerDetails Where CustomerName = '" + Session["New"] +"'"; SqlDataAdapter da = new SqlDataAdapter(sql, con); DataTable dt = new DataTable(); da.Fill(dt); Label2.Text += Session["New"].ToString(); linkLogout.Visible = true; //linkOrderHistory.Visible = true; Label2.Visible = true; linkViewProfile.Visible = true; grid.DataSource = dt; grid.DataBind(); } } } private void CustomBindData() { SqlConnection con = new SqlConnection(cs); con.Open(); string sql = "SELECT * FROM CustomerDetails Where CustomerName = '" + Session["New"] + "'"; SqlDataAdapter da = new SqlDataAdapter(sql, con); DataTable dt = new DataTable(); da.Fill(dt); } protected void gdview_PageIndexChanging(object sender, GridViewPageEventArgs e) { CustomBindData(); grid.PageIndex = e.NewPageIndex; grid.DataBind(); } ``` somehow my code is not working. it has the pages but when i click on page 2, no data is shown. i think it has something to do on how i get the data from the sql. any tricks on this?
2016/06/01
[ "https://Stackoverflow.com/questions/37560688", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4980525/" ]
`[:]` just creates a copy of the list, so `[1]` indexes that copy. And no, outside of NumPy arrays, there is technically no way to avoid a loop. The loop may be done in C code in a function like `map()`, but there's going to be a loop anyway. Using `map()` for example applies a callable for each element in your input list: ``` map(lambda nested: nested[1], my_list) ``` or ``` from operator import itemgetter map(itemgetter(1), my_list) ``` Both work in Python 2, in Python 3 you need to wrap the `map()` call in a `list()` call to drive the iteration. Either way, I find a list comprehension to be clearer here anyway.
As mentioned in [python get list of tuples first index](https://stackoverflow.com/questions/10735282/python-get-list-of-tuples-first-index) try with `zip` ``` my_list = [(1,4),(3,6),(10,7)] print zip(*my_list)[1] (4, 6, 7) ```
35,570,512
I am new in java. I just wants to read each string in java and print it on console. Code: ``` public static void main(String[] args) throws Exception { File file = new File("/Users/OntologyFile.txt"); try { FileInputStream fstream = new FileInputStream(file); BufferedReader infile = new BufferedReader(new InputStreamReader( fstream)); String data = new String(); while ((data = infile.readLine()) != null) { // use if for reading just 1 line System.out.println(""+data); } } catch (IOException e) { // Error } } ``` If file contains: ``` Add label abc to xyz Add instance cdd to pqr ``` I want to read each word from file and print it to a new line, e.g. ``` Add label abc ... ``` And afterwards, I want to extract the index of a specific string, for instance get the index of `abc`. Can anyone please help me?
2016/02/23
[ "https://Stackoverflow.com/questions/35570512", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5649003/" ]
Just add a for-each loop before printing the output :- ``` while ((data = infile.readLine()) != null) { // use if for reading just 1 line for(String temp : data.split(" ")) System.out.println(temp); // no need to concatenate the empty string. } ``` This will automatically print the individual strings, obtained from each String line read from the file, in a new line. > > And afterwards, I want to extract the index of a specific string, for > instance get the index of abc. > > > I don't know what index are you actually talking about. But, if you want to take the index from the individual lines being read, then add a temporary variable with count initialised to 0. Increment it till d equals `abc` here. Like, ``` int count = 0; for(String temp : data.split(" ")){ count++; if("abc".equals(temp)) System.out.println("Index of abc is : "+count); System.out.println(temp); } ```
Use `Split()` Function available in `Class String`.. You may manipulate according to your need. or use `length` keyword to iterate throughout the complete **line** and if any non- alphabet character get the `substring()`and write it to the new line.
35,570,512
I am new in java. I just wants to read each string in java and print it on console. Code: ``` public static void main(String[] args) throws Exception { File file = new File("/Users/OntologyFile.txt"); try { FileInputStream fstream = new FileInputStream(file); BufferedReader infile = new BufferedReader(new InputStreamReader( fstream)); String data = new String(); while ((data = infile.readLine()) != null) { // use if for reading just 1 line System.out.println(""+data); } } catch (IOException e) { // Error } } ``` If file contains: ``` Add label abc to xyz Add instance cdd to pqr ``` I want to read each word from file and print it to a new line, e.g. ``` Add label abc ... ``` And afterwards, I want to extract the index of a specific string, for instance get the index of `abc`. Can anyone please help me?
2016/02/23
[ "https://Stackoverflow.com/questions/35570512", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5649003/" ]
Just add a for-each loop before printing the output :- ``` while ((data = infile.readLine()) != null) { // use if for reading just 1 line for(String temp : data.split(" ")) System.out.println(temp); // no need to concatenate the empty string. } ``` This will automatically print the individual strings, obtained from each String line read from the file, in a new line. > > And afterwards, I want to extract the index of a specific string, for > instance get the index of abc. > > > I don't know what index are you actually talking about. But, if you want to take the index from the individual lines being read, then add a temporary variable with count initialised to 0. Increment it till d equals `abc` here. Like, ``` int count = 0; for(String temp : data.split(" ")){ count++; if("abc".equals(temp)) System.out.println("Index of abc is : "+count); System.out.println(temp); } ```
``` List<String> words = new ArrayList<String>(); while ((data = infile.readLine()) != null) { for(String d : data.split(" ")) { System.out.println(""+d); } words.addAll(Arrays.asList(data)); } //words List will hold all the words. Do words.indexOf("abc") to get index if(words.indexOf("abc") < 0) { System.out.println("word not present"); } else { System.out.println("word present at index " + words.indexOf("abc")) } ```
35,570,512
I am new in java. I just wants to read each string in java and print it on console. Code: ``` public static void main(String[] args) throws Exception { File file = new File("/Users/OntologyFile.txt"); try { FileInputStream fstream = new FileInputStream(file); BufferedReader infile = new BufferedReader(new InputStreamReader( fstream)); String data = new String(); while ((data = infile.readLine()) != null) { // use if for reading just 1 line System.out.println(""+data); } } catch (IOException e) { // Error } } ``` If file contains: ``` Add label abc to xyz Add instance cdd to pqr ``` I want to read each word from file and print it to a new line, e.g. ``` Add label abc ... ``` And afterwards, I want to extract the index of a specific string, for instance get the index of `abc`. Can anyone please help me?
2016/02/23
[ "https://Stackoverflow.com/questions/35570512", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5649003/" ]
It sounds like you want to be able to do two things: 1. Print all words inside the file 2. Search the index of a specific word In that case, I would suggest scanning all lines, splitting by any whitespace character (space, tab, etc.) and storing in a collection so you can later on search for it. Not the question is - can you have repeats and in that case which index would you like to print? The first? The last? All of them? Assuming words are unique, you can simply do: ``` public static void main(String[] args) throws Exception { File file = new File("/Users/OntologyFile.txt"); ArrayList<String> words = new ArrayList<String>(); try { FileInputStream fstream = new FileInputStream(file); BufferedReader infile = new BufferedReader(new InputStreamReader( fstream)); String data = null; while ((data = infile.readLine()) != null) { for (String word : data.split("\\s+") { words.add(word); System.out.println(word); } } } catch (IOException e) { // Error } // search for the index of abc: for (int i = 0; i < words.size(); i++) { if (words.get(i).equals("abc")) { System.out.println("abc index is " + i); break; } } } ``` If you don't break, it'll print every index of `abc` (if words are not unique). You could of course optimize it more if the set of words is very large, but for a small amount of data, this should suffice. Of course, if you know in advance which words' indices you'd like to print, you could forego the extra data structure (the `ArrayList`) and simply print that as you scan the file, unless you want the printings (of words and specific indices) to be separate in output.
Use `Split()` Function available in `Class String`.. You may manipulate according to your need. or use `length` keyword to iterate throughout the complete **line** and if any non- alphabet character get the `substring()`and write it to the new line.
35,570,512
I am new in java. I just wants to read each string in java and print it on console. Code: ``` public static void main(String[] args) throws Exception { File file = new File("/Users/OntologyFile.txt"); try { FileInputStream fstream = new FileInputStream(file); BufferedReader infile = new BufferedReader(new InputStreamReader( fstream)); String data = new String(); while ((data = infile.readLine()) != null) { // use if for reading just 1 line System.out.println(""+data); } } catch (IOException e) { // Error } } ``` If file contains: ``` Add label abc to xyz Add instance cdd to pqr ``` I want to read each word from file and print it to a new line, e.g. ``` Add label abc ... ``` And afterwards, I want to extract the index of a specific string, for instance get the index of `abc`. Can anyone please help me?
2016/02/23
[ "https://Stackoverflow.com/questions/35570512", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5649003/" ]
It sounds like you want to be able to do two things: 1. Print all words inside the file 2. Search the index of a specific word In that case, I would suggest scanning all lines, splitting by any whitespace character (space, tab, etc.) and storing in a collection so you can later on search for it. Not the question is - can you have repeats and in that case which index would you like to print? The first? The last? All of them? Assuming words are unique, you can simply do: ``` public static void main(String[] args) throws Exception { File file = new File("/Users/OntologyFile.txt"); ArrayList<String> words = new ArrayList<String>(); try { FileInputStream fstream = new FileInputStream(file); BufferedReader infile = new BufferedReader(new InputStreamReader( fstream)); String data = null; while ((data = infile.readLine()) != null) { for (String word : data.split("\\s+") { words.add(word); System.out.println(word); } } } catch (IOException e) { // Error } // search for the index of abc: for (int i = 0; i < words.size(); i++) { if (words.get(i).equals("abc")) { System.out.println("abc index is " + i); break; } } } ``` If you don't break, it'll print every index of `abc` (if words are not unique). You could of course optimize it more if the set of words is very large, but for a small amount of data, this should suffice. Of course, if you know in advance which words' indices you'd like to print, you could forego the extra data structure (the `ArrayList`) and simply print that as you scan the file, unless you want the printings (of words and specific indices) to be separate in output.
``` List<String> words = new ArrayList<String>(); while ((data = infile.readLine()) != null) { for(String d : data.split(" ")) { System.out.println(""+d); } words.addAll(Arrays.asList(data)); } //words List will hold all the words. Do words.indexOf("abc") to get index if(words.indexOf("abc") < 0) { System.out.println("word not present"); } else { System.out.println("word present at index " + words.indexOf("abc")) } ```
35,570,512
I am new in java. I just wants to read each string in java and print it on console. Code: ``` public static void main(String[] args) throws Exception { File file = new File("/Users/OntologyFile.txt"); try { FileInputStream fstream = new FileInputStream(file); BufferedReader infile = new BufferedReader(new InputStreamReader( fstream)); String data = new String(); while ((data = infile.readLine()) != null) { // use if for reading just 1 line System.out.println(""+data); } } catch (IOException e) { // Error } } ``` If file contains: ``` Add label abc to xyz Add instance cdd to pqr ``` I want to read each word from file and print it to a new line, e.g. ``` Add label abc ... ``` And afterwards, I want to extract the index of a specific string, for instance get the index of `abc`. Can anyone please help me?
2016/02/23
[ "https://Stackoverflow.com/questions/35570512", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5649003/" ]
Split the `String` received for any whitespace with the regex `\\s+` and print out the resultant data with a `for` loop. ``` public static void main(String[] args) { // Don't make main throw an exception File file = new File("/Users/OntologyFile.txt"); try { FileInputStream fstream = new FileInputStream(file); BufferedReader infile = new BufferedReader(new InputStreamReader(fstream)); String data; while ((data = infile.readLine()) != null) { String[] words = data.split("\\s+"); // Split on whitespace for (String word : words) { // Iterate through info System.out.println(word); // Print it } } } catch (IOException e) { // Probably best to actually have this on there System.err.println("Error found."); e.printStackTrace(); } } ```
Use `Split()` Function available in `Class String`.. You may manipulate according to your need. or use `length` keyword to iterate throughout the complete **line** and if any non- alphabet character get the `substring()`and write it to the new line.
35,570,512
I am new in java. I just wants to read each string in java and print it on console. Code: ``` public static void main(String[] args) throws Exception { File file = new File("/Users/OntologyFile.txt"); try { FileInputStream fstream = new FileInputStream(file); BufferedReader infile = new BufferedReader(new InputStreamReader( fstream)); String data = new String(); while ((data = infile.readLine()) != null) { // use if for reading just 1 line System.out.println(""+data); } } catch (IOException e) { // Error } } ``` If file contains: ``` Add label abc to xyz Add instance cdd to pqr ``` I want to read each word from file and print it to a new line, e.g. ``` Add label abc ... ``` And afterwards, I want to extract the index of a specific string, for instance get the index of `abc`. Can anyone please help me?
2016/02/23
[ "https://Stackoverflow.com/questions/35570512", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5649003/" ]
Split the `String` received for any whitespace with the regex `\\s+` and print out the resultant data with a `for` loop. ``` public static void main(String[] args) { // Don't make main throw an exception File file = new File("/Users/OntologyFile.txt"); try { FileInputStream fstream = new FileInputStream(file); BufferedReader infile = new BufferedReader(new InputStreamReader(fstream)); String data; while ((data = infile.readLine()) != null) { String[] words = data.split("\\s+"); // Split on whitespace for (String word : words) { // Iterate through info System.out.println(word); // Print it } } } catch (IOException e) { // Probably best to actually have this on there System.err.println("Error found."); e.printStackTrace(); } } ```
``` List<String> words = new ArrayList<String>(); while ((data = infile.readLine()) != null) { for(String d : data.split(" ")) { System.out.println(""+d); } words.addAll(Arrays.asList(data)); } //words List will hold all the words. Do words.indexOf("abc") to get index if(words.indexOf("abc") < 0) { System.out.println("word not present"); } else { System.out.println("word present at index " + words.indexOf("abc")) } ```
42,721,708
I'm trying to run multiple commands in a single shell execution build step. If one of those commands exits on a code other than 0, the build will fail immediately. This is how it is by default. I want for the build to continue executing all the commands in this build step even if one or more exit code 0 are given. After all these commands are executed, I want my build to fail if the exit code is anything other than 0. Is there any way to do this by just using console commands and not using a (shell) script? These commands are the ones I'm trying to execute: ``` git diff origin/develop --name-only --diff-filter=AM | grep .php | xargs -n1 -P8 php -l git diff origin/develop --name-only --diff-filter=AM | grep .php | xargs -n1 phpcs --standard=PSR2 git diff origin/develop --name-only --diff-filter=AM | grep .php | xargs -n1 -I file phpmd file text cleancode,codesize,controversial,design,naming,unusedcode ``` As you might know these are for php code analysis and I want to know *everything* that's wrong before failing. Thanks in advance for your help.
2017/03/10
[ "https://Stackoverflow.com/questions/42721708", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1793874/" ]
Use a variable to record if one of them fails and then check if that variable is set at the end of the script: ``` FAILURE=0 command1 || FAILURE=1 command2 || FAILURE=1 command3 || FAILURE=1 if [ $FAILURE -eq 1 ] then echo "One or more failures! exit 1 fi ``` So in your case: ``` FAILURE=0 git diff origin/develop --name-only --diff-filter=AM | grep .php | xargs -n1 -P8 php -l || FAILURE=1 git diff origin/develop --name-only --diff-filter=AM | grep .php | xargs -n1 phpcs --standard=PSR2 || FAILURE=1 git diff origin/develop --name-only --diff-filter=AM | grep .php | xargs -n1 -I file phpmd file text cleancode,codesize,controversial,design,naming,unusedcode || FAILURE=1 if [ $FAILURE -eq 1 ] then echo "One or more failures! exit 1 fi ```
With shell, you can do: ``` command || true; ``` In order to allow the command to fail.
37,522,569
I have fetched a current month from my DB which is basically a join date of the user. Lets say the use joined this month and it is May. The code I do to fetch the month name is like this: ``` $months = array(); array_push($months,date("F",strtotime($me['joinTime']))); ``` In this case I add the start month to the array, which in this case is May... Now what I'd like to do is as the months go by, I'd like to add each new month to the array.. So for instance in a few days its June, and when June kicks in, I'll add that Month as well to the array.. So my question here is, how can I get the rest of the month names from the start date (May). I need June, July, August, September, October, November, December... If the start month was April I'd add May into the array as well... Can someone help me out with this ?
2016/05/30
[ "https://Stackoverflow.com/questions/37522569", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4008951/" ]
First you need to get he month number and than you need to use a loop through to end of the year that is 12. For each month number you also need the month name so use `DateTime createFromFormat`. [Online Check](https://3v4l.org/eONQm) ``` $months = array(); $num = date("n",strtotime($me['joinTime'])); array_push($months, date("F", strtotime('2016-05-17 16:41:51'))); for($i = ($num + 1); $i <= 12; $i++){ $dateObj = DateTime::createFromFormat('!m', $i); array_push($months, $dateObj->format('F')); } print_r($months); // Array ( [0] => May [1] => June [2] => July [3] => August [4] => September [5] => October [6] => November [7] => December ) ```
Yo can also put it like ``` $array = array(); array_push($array, date('F')) ; for ($i=1; $i<= 12 - date('m'); $i++ ){ array_push($array, date('F', strtotime("+$i months"))) ; } print "<pre>";print_r($array); ```
37,522,569
I have fetched a current month from my DB which is basically a join date of the user. Lets say the use joined this month and it is May. The code I do to fetch the month name is like this: ``` $months = array(); array_push($months,date("F",strtotime($me['joinTime']))); ``` In this case I add the start month to the array, which in this case is May... Now what I'd like to do is as the months go by, I'd like to add each new month to the array.. So for instance in a few days its June, and when June kicks in, I'll add that Month as well to the array.. So my question here is, how can I get the rest of the month names from the start date (May). I need June, July, August, September, October, November, December... If the start month was April I'd add May into the array as well... Can someone help me out with this ?
2016/05/30
[ "https://Stackoverflow.com/questions/37522569", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4008951/" ]
First you need to get he month number and than you need to use a loop through to end of the year that is 12. For each month number you also need the month name so use `DateTime createFromFormat`. [Online Check](https://3v4l.org/eONQm) ``` $months = array(); $num = date("n",strtotime($me['joinTime'])); array_push($months, date("F", strtotime('2016-05-17 16:41:51'))); for($i = ($num + 1); $i <= 12; $i++){ $dateObj = DateTime::createFromFormat('!m', $i); array_push($months, $dateObj->format('F')); } print_r($months); // Array ( [0] => May [1] => June [2] => July [3] => August [4] => September [5] => October [6] => November [7] => December ) ```
Here we will be using DatePeriod which allows iteration over a set of dates and times, recurring at regular intervals, over a given period. So we got the end date and we have the start date and then calculated the interval. And then looping over the period we got the array of months. ``` // current date : 20 Feb 2019 $startDate = new \DateTime('first day of next month'); $endDate = new \DateTime('1st january next year'); $interval = new \DateInterval('P1M'); $period = new \DatePeriod($startDate, $interval, $endDate); // Start array with current date $dates = []; // Add all remaining dates to array foreach ($period as $date) { array_push($dates, $date->Format('F')); } // output print_r($dates); die; Array ( [0] => March [1] => April [2] => May [3] => June [4] => July [5] => August [6] => September [7] => October [8] => November [9] => December ) ```
16,068,968
Is it possible to **skip the staging area** and (also) commit **untracked, new files** to git in a single built-in, command-line command ? If not, what are the alternatives ? <http://git-scm.com/book/en/Git-Basics-Recording-Changes-to-the-Repository> > > Providing the -a option to the git commit command makes Git > automatically stage every file that is already tracked before doing > the commit, letting you skip the git add part: > > > `$ git commit -a -m 'added new benchmarks'` > > > Thanks.
2013/04/17
[ "https://Stackoverflow.com/questions/16068968", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2153622/" ]
Using a single, built-in, command-line command? No. **Using two commands:** ``` git add -A git commit ``` **Using a custom alias:** Add this to *.gitconfig*: ``` [alias] commituntracked = "!git add -A; git commit" ``` Then you can do ``` git commituntracked ```
This might seem quite trivial for the gurus, but is a minor revelation to me (I admit) - at least I just used it for the first time now and it works (*without* custom aliases): Just use a semicolon `;` and it'll work as a one-liner: `git add --all; git commit -m "some informative commit message"`
16,068,968
Is it possible to **skip the staging area** and (also) commit **untracked, new files** to git in a single built-in, command-line command ? If not, what are the alternatives ? <http://git-scm.com/book/en/Git-Basics-Recording-Changes-to-the-Repository> > > Providing the -a option to the git commit command makes Git > automatically stage every file that is already tracked before doing > the commit, letting you skip the git add part: > > > `$ git commit -a -m 'added new benchmarks'` > > > Thanks.
2013/04/17
[ "https://Stackoverflow.com/questions/16068968", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2153622/" ]
Using a single, built-in, command-line command? No. **Using two commands:** ``` git add -A git commit ``` **Using a custom alias:** Add this to *.gitconfig*: ``` [alias] commituntracked = "!git add -A; git commit" ``` Then you can do ``` git commituntracked ```
Yes. There are at least two major ways of doing that. First, you don't have to use "the" staging area, you can have as many staging areas as you like -- set `GIT_INDEX_FILE=/path/to/private/index` and do as you please; second you can construct commits yourself, directly. It isn't even hard. Git's repository core deals with blob, tree, and commit objects (also, not so relevant here, notes and annotated tags). The git command to dump objects is `git cat-file -p`. A blob is just a bag-o-bits. Add one to the repository with `git hash-object -w`*`filename`*, it'll print the ~true name~ of the blob in that file and add the blob to the repo. A tree ties an object to a filesystem name. Add one to the repository with `git mktree`; to see what to feed it, print a tree with e.g. `git cat-file -p HEAD^{tree}`. Add a commit to the repository with `git commit-tree`, basically, you say `git commit-tree -p`*`mom`*`-p`*`dad sometree`*, set some environment variables, and feed it a commit message on stdin. That's really all that's necessary; if you want to get further into slicing and dicing with trees and staging `read-tree` and `write-tree` can be very useful, if this is at all attractive to you the [git core tutorial](https://www.kernel.org/pub/software/scm/git/docs/gitcore-tutorial.html) is a good overview.
16,068,968
Is it possible to **skip the staging area** and (also) commit **untracked, new files** to git in a single built-in, command-line command ? If not, what are the alternatives ? <http://git-scm.com/book/en/Git-Basics-Recording-Changes-to-the-Repository> > > Providing the -a option to the git commit command makes Git > automatically stage every file that is already tracked before doing > the commit, letting you skip the git add part: > > > `$ git commit -a -m 'added new benchmarks'` > > > Thanks.
2013/04/17
[ "https://Stackoverflow.com/questions/16068968", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2153622/" ]
Using a single, built-in, command-line command? No. **Using two commands:** ``` git add -A git commit ``` **Using a custom alias:** Add this to *.gitconfig*: ``` [alias] commituntracked = "!git add -A; git commit" ``` Then you can do ``` git commituntracked ```
Using the command below skips the staging area and commits directly from the working directory. ``` git commit -a ``` Note that you still need to add new untracked files.
16,068,968
Is it possible to **skip the staging area** and (also) commit **untracked, new files** to git in a single built-in, command-line command ? If not, what are the alternatives ? <http://git-scm.com/book/en/Git-Basics-Recording-Changes-to-the-Repository> > > Providing the -a option to the git commit command makes Git > automatically stage every file that is already tracked before doing > the commit, letting you skip the git add part: > > > `$ git commit -a -m 'added new benchmarks'` > > > Thanks.
2013/04/17
[ "https://Stackoverflow.com/questions/16068968", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2153622/" ]
This might seem quite trivial for the gurus, but is a minor revelation to me (I admit) - at least I just used it for the first time now and it works (*without* custom aliases): Just use a semicolon `;` and it'll work as a one-liner: `git add --all; git commit -m "some informative commit message"`
Yes. There are at least two major ways of doing that. First, you don't have to use "the" staging area, you can have as many staging areas as you like -- set `GIT_INDEX_FILE=/path/to/private/index` and do as you please; second you can construct commits yourself, directly. It isn't even hard. Git's repository core deals with blob, tree, and commit objects (also, not so relevant here, notes and annotated tags). The git command to dump objects is `git cat-file -p`. A blob is just a bag-o-bits. Add one to the repository with `git hash-object -w`*`filename`*, it'll print the ~true name~ of the blob in that file and add the blob to the repo. A tree ties an object to a filesystem name. Add one to the repository with `git mktree`; to see what to feed it, print a tree with e.g. `git cat-file -p HEAD^{tree}`. Add a commit to the repository with `git commit-tree`, basically, you say `git commit-tree -p`*`mom`*`-p`*`dad sometree`*, set some environment variables, and feed it a commit message on stdin. That's really all that's necessary; if you want to get further into slicing and dicing with trees and staging `read-tree` and `write-tree` can be very useful, if this is at all attractive to you the [git core tutorial](https://www.kernel.org/pub/software/scm/git/docs/gitcore-tutorial.html) is a good overview.
16,068,968
Is it possible to **skip the staging area** and (also) commit **untracked, new files** to git in a single built-in, command-line command ? If not, what are the alternatives ? <http://git-scm.com/book/en/Git-Basics-Recording-Changes-to-the-Repository> > > Providing the -a option to the git commit command makes Git > automatically stage every file that is already tracked before doing > the commit, letting you skip the git add part: > > > `$ git commit -a -m 'added new benchmarks'` > > > Thanks.
2013/04/17
[ "https://Stackoverflow.com/questions/16068968", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2153622/" ]
This might seem quite trivial for the gurus, but is a minor revelation to me (I admit) - at least I just used it for the first time now and it works (*without* custom aliases): Just use a semicolon `;` and it'll work as a one-liner: `git add --all; git commit -m "some informative commit message"`
Using the command below skips the staging area and commits directly from the working directory. ``` git commit -a ``` Note that you still need to add new untracked files.
16,068,968
Is it possible to **skip the staging area** and (also) commit **untracked, new files** to git in a single built-in, command-line command ? If not, what are the alternatives ? <http://git-scm.com/book/en/Git-Basics-Recording-Changes-to-the-Repository> > > Providing the -a option to the git commit command makes Git > automatically stage every file that is already tracked before doing > the commit, letting you skip the git add part: > > > `$ git commit -a -m 'added new benchmarks'` > > > Thanks.
2013/04/17
[ "https://Stackoverflow.com/questions/16068968", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2153622/" ]
Yes. There are at least two major ways of doing that. First, you don't have to use "the" staging area, you can have as many staging areas as you like -- set `GIT_INDEX_FILE=/path/to/private/index` and do as you please; second you can construct commits yourself, directly. It isn't even hard. Git's repository core deals with blob, tree, and commit objects (also, not so relevant here, notes and annotated tags). The git command to dump objects is `git cat-file -p`. A blob is just a bag-o-bits. Add one to the repository with `git hash-object -w`*`filename`*, it'll print the ~true name~ of the blob in that file and add the blob to the repo. A tree ties an object to a filesystem name. Add one to the repository with `git mktree`; to see what to feed it, print a tree with e.g. `git cat-file -p HEAD^{tree}`. Add a commit to the repository with `git commit-tree`, basically, you say `git commit-tree -p`*`mom`*`-p`*`dad sometree`*, set some environment variables, and feed it a commit message on stdin. That's really all that's necessary; if you want to get further into slicing and dicing with trees and staging `read-tree` and `write-tree` can be very useful, if this is at all attractive to you the [git core tutorial](https://www.kernel.org/pub/software/scm/git/docs/gitcore-tutorial.html) is a good overview.
Using the command below skips the staging area and commits directly from the working directory. ``` git commit -a ``` Note that you still need to add new untracked files.
12,097,690
Using .php for a file extension allows for all HTML, CSS, JS, and PHP content, etc., while .html does not allow PHP code to be read by the server-side engine. As a rule of thumb I just use .php for my files even if I have no PHP code in them. So... Is there ever a time when, for some reason, one ought to use .html specifically? Perhaps search engines index the file differently/better or it loads faster or something? But as of now I see no reason to do so, even with a file that has no PHP content. Apparently no one is understanding the question: Does it make *any* difference at all if I save a file as .html over .php when I have no PHP content? Shouldn't there be some difference? The file is clearly a different entity when saved with a different extension.
2012/08/23
[ "https://Stackoverflow.com/questions/12097690", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1493707/" ]
When you give a plain HTML file a .php extension, it causes the PHP engine to parse it. While the performance hit is negligible, it's still an unnecessary waste of resources and a best practice would be to avoid it by giving your non php pages an extension of html.
Hopefully this satisfies this tough question. PHP = server side language, meaning additional resources are used by the server. HTML = client side language, which is just displayed by browser.
48,605,736
**<https://stackblitz.com/edit/angular-xpamld>** **Question:** Can someone help me understand why my prototype's `changeDetection: ChangeDetectionStrategy.OnPush` still allows me to update the inner value `name`? If this is not what `ChangeDetectionStrategy.OnPush` suppose to prevent, what should it be doing? **app.component.ts:** ``` @Component({ selector: 'my-app', templateUrl: './app.component.html', styleUrls: [ './app.component.css' ], changeDetection: ChangeDetectionStrategy.OnPush, }) export class AppComponent { public name = 'Angular 5'; public changeName() { this.name = 'Outer'; } } ``` **app.component.html:** ``` <hello name="{{ name }}"></hello> <button (click)="changeName()">Outter Change</button> <p>{{name}}-- outer</p> <p> Start editing to see some magic happen :) </p> ``` **hello.component.ts:** ``` @Component({ selector: 'hello', template: `<h1>Hello {{name}}!</h1> <button (click)="changeName()">inner Change</button>`, styles: [`h1 { font-family: Lato; }`], changeDetection: ChangeDetectionStrategy.OnPush, }) export class HelloComponent { @Input() name: string; public changeName() { this.name = 'Inner'; } } ```
2018/02/04
[ "https://Stackoverflow.com/questions/48605736", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1191635/" ]
Because primitive datatype is immutable - if you change it, its reference also changes, so `ChangeDetectorRef`of your component knows it must detect changes (because `OnPush` looks for references changes, not data mutations in arrays, objects). If you want to avoid that on primitives, you can manually deactivate/activate this on ChangeDetectorRef instance with `detach()`/ `reattach()`: ``` import { ChangeDetectorRef } from '@angular/core'; export class HelloComponent { @Input() name: string; constructor(private ref: ChangeDetectorRef) {} public changeName() { this.ref.detach(); this.name = 'Inner'; } } ```
> > The state is updated only if parent view bindings changed and child > component view was initialized with ChangeDetectionStrategy.OnPush. > > > In the Example you stated just add the following lines to the child Hello Component. ``` ngOnChanges(simpleChange : SimpleChanges){ console.log(simpleChange) } ``` You will see that that upon click of a button the view changes as the parent Bindings has changes that is the reason the view is updated in both parent and Child.
48,605,736
**<https://stackblitz.com/edit/angular-xpamld>** **Question:** Can someone help me understand why my prototype's `changeDetection: ChangeDetectionStrategy.OnPush` still allows me to update the inner value `name`? If this is not what `ChangeDetectionStrategy.OnPush` suppose to prevent, what should it be doing? **app.component.ts:** ``` @Component({ selector: 'my-app', templateUrl: './app.component.html', styleUrls: [ './app.component.css' ], changeDetection: ChangeDetectionStrategy.OnPush, }) export class AppComponent { public name = 'Angular 5'; public changeName() { this.name = 'Outer'; } } ``` **app.component.html:** ``` <hello name="{{ name }}"></hello> <button (click)="changeName()">Outter Change</button> <p>{{name}}-- outer</p> <p> Start editing to see some magic happen :) </p> ``` **hello.component.ts:** ``` @Component({ selector: 'hello', template: `<h1>Hello {{name}}!</h1> <button (click)="changeName()">inner Change</button>`, styles: [`h1 { font-family: Lato; }`], changeDetection: ChangeDetectionStrategy.OnPush, }) export class HelloComponent { @Input() name: string; public changeName() { this.name = 'Inner'; } } ```
2018/02/04
[ "https://Stackoverflow.com/questions/48605736", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1191635/" ]
Because primitive datatype is immutable - if you change it, its reference also changes, so `ChangeDetectorRef`of your component knows it must detect changes (because `OnPush` looks for references changes, not data mutations in arrays, objects). If you want to avoid that on primitives, you can manually deactivate/activate this on ChangeDetectorRef instance with `detach()`/ `reattach()`: ``` import { ChangeDetectorRef } from '@angular/core'; export class HelloComponent { @Input() name: string; constructor(private ref: ChangeDetectorRef) {} public changeName() { this.ref.detach(); this.name = 'Inner'; } } ```
The default change detection strategy is to be conservative and check all its bindings for something that ***might*** have changed. Typically, a change detection cycle is triggered whenever an *[input]* changes, or an *(event)* occurs from *any* component. By changing a component's change detection strategy to *OnPush*, Angular only checks for updates when the component's inputs ***have*** actually changed. This allows Angular to be more efficient with change detection by allowing entire sub-trees to be skipped during change detection. Here is a good article on it: <https://vsavkin.com/immutability-vs-encapsulation-90549ab74487> Some points to help with the understanding is: 1. By default, when a change detection digest is triggered, all bindings are checked for updates from all components, regardless of where the change originally came from. 2. Change detection occurs to establish the original bindings (Input Bindings) or it can be triggered by a browser event (i.e. Output Bindings). Once triggered, #1 applies. 3. Change detection occurs top-down, starting from the root component towards the leaves. Think of this as a unidirectional tree of connected components, that starts with an AppComponent for the root. 4. When a component's change detection strategy is changed to `OnPush` then during change detection, it will skip a component's entire sub-tree if the inputs have not changed.
21,886,147
I am using following code to create a new file **cat15** using **cat** command in UNIX ``` # cat > cat15 ``` this command adds a new file **cat15** in root directory and whatever I type after this command is being stored into the file created. But I am not able to exit from this editor. In other word, I am not getting Shell prompt symbol **#**
2014/02/19
[ "https://Stackoverflow.com/questions/21886147", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1969750/" ]
The `cat` command reads from STDIN if you don't specify a filename. It continues to do this until it receives an EOF or is killed. You can send an EOF and get your terminal back by typing `<ctrl>+d`. What people generally do is to either use ``` touch filename ``` or ``` echo -n > filename ``` to create an empty file. As Charles correctly notes below, "echo -n" is not always a good idea (though you can usually count on it under "popular" Linux distros); I'd strongly suggest just using touch.
If you just want to create an empty file, regardless of whether one existed or not, you can just use ">" like this: ``` > cat15 ``` It will clobber anything that already exists by that name.
5,080,374
Say I want to change a container's class when the image it contains is loaded, probably something like this: ``` $('.image').load(function(){ $(this).parents('.image-wrapper').removeClass('image-wrapper').addClass('image-wrapper-new'); }); ``` …And then add a click event, referencing the newly-added class, like this: ``` $('.image-wrapper-new').click(function(){ //Do stuff }); ``` I've tried something similar to this, with no success. Am I missing something? Using Developer Tools, it appears that the browser is rendering it as .image-wrapper-new, but since it retains the .image-wrapper class in the physical code, Jquery/JS doesn't honor it. Is that possible? Thanks. -Ryan
2011/02/22
[ "https://Stackoverflow.com/questions/5080374", "https://Stackoverflow.com", "https://Stackoverflow.com/users/601883/" ]
To fix the syntax error: ``` $('.image').load(function(){ $(this).parents('.image-wrapper').removeClass('image-wrapper').addClass('image-wrapper-new'); }); ``` I would also recommend using [`.on()`](http://api.jquery.com/on) rather than `.click()` so you don't have to re-bind event handlers every time you change the class: ``` $(document).on('click', '.image-wrapper-new', function(){ //Do stuff }); ```
Just add your click event handler in the same function, as you change class: ``` $('.image').load(function(){ $(this).parents('.image-wrapper') .removeClass('image-wrapper') .addClass('image-wrapper-new') .click(function(){ //Do stuff }); }); ```
5,080,374
Say I want to change a container's class when the image it contains is loaded, probably something like this: ``` $('.image').load(function(){ $(this).parents('.image-wrapper').removeClass('image-wrapper').addClass('image-wrapper-new'); }); ``` …And then add a click event, referencing the newly-added class, like this: ``` $('.image-wrapper-new').click(function(){ //Do stuff }); ``` I've tried something similar to this, with no success. Am I missing something? Using Developer Tools, it appears that the browser is rendering it as .image-wrapper-new, but since it retains the .image-wrapper class in the physical code, Jquery/JS doesn't honor it. Is that possible? Thanks. -Ryan
2011/02/22
[ "https://Stackoverflow.com/questions/5080374", "https://Stackoverflow.com", "https://Stackoverflow.com/users/601883/" ]
To fix the syntax error: ``` $('.image').load(function(){ $(this).parents('.image-wrapper').removeClass('image-wrapper').addClass('image-wrapper-new'); }); ``` I would also recommend using [`.on()`](http://api.jquery.com/on) rather than `.click()` so you don't have to re-bind event handlers every time you change the class: ``` $(document).on('click', '.image-wrapper-new', function(){ //Do stuff }); ```
You should be using .live('click', function() {}); due to the fact that you are updating the DOM. .click() will not pick up on new data automatically. If you are building an ajax application this should be standard imo
5,080,374
Say I want to change a container's class when the image it contains is loaded, probably something like this: ``` $('.image').load(function(){ $(this).parents('.image-wrapper').removeClass('image-wrapper').addClass('image-wrapper-new'); }); ``` …And then add a click event, referencing the newly-added class, like this: ``` $('.image-wrapper-new').click(function(){ //Do stuff }); ``` I've tried something similar to this, with no success. Am I missing something? Using Developer Tools, it appears that the browser is rendering it as .image-wrapper-new, but since it retains the .image-wrapper class in the physical code, Jquery/JS doesn't honor it. Is that possible? Thanks. -Ryan
2011/02/22
[ "https://Stackoverflow.com/questions/5080374", "https://Stackoverflow.com", "https://Stackoverflow.com/users/601883/" ]
You should be using .live('click', function() {}); due to the fact that you are updating the DOM. .click() will not pick up on new data automatically. If you are building an ajax application this should be standard imo
Just add your click event handler in the same function, as you change class: ``` $('.image').load(function(){ $(this).parents('.image-wrapper') .removeClass('image-wrapper') .addClass('image-wrapper-new') .click(function(){ //Do stuff }); }); ```
121,329
After upgrading to Firefox 3.6, I noticed that there no longer seems to be a way to have tabs all displayed in several rows when there are too many to fit in the window: ![enter image description here](https://i.stack.imgur.com/i4dcL.jpg) I find it very inconvenient to have to click on the down arrow at the far-right side to go through the list of open tabs. The TabMixPlus add-on is incompatible with ReloadEvery 3.6.2, so that's not a good solution either. Does someone know if it's possible to either configure FireFox 3.6 to go back to the previous way of displaying multiple tabs, or if there's an add-on that's compatible with ReloadEvery that would do the trick? --- **Edit**: The solution if you need support for both multiple-row tabs + being able to reload one of the tabs automatically every so often, is to just use [TabMixPlus](https://addons.mozilla.org/en-US/firefox/addon/1122), which does both and is compatible with Firefox 3.6.
2010/03/18
[ "https://superuser.com/questions/121329", "https://superuser.com", "https://superuser.com/users/3906/" ]
You can try the [TooManyTabs](https://addons.mozilla.org/en-US/firefox/addon/9429) add-on. > > TooManyTabs allows you to store as many tabs as you like by adding > extra rows in the Firefox! It saves your browser's space and memory as > idle tabs are put aside. The extra rows also help to better prioritize > and visualize your tabs. > > >
Have you tried with [TabKit](https://addons.mozilla.org/en-US/firefox/addon/5447) ? also I think that you'll have to take a look at [this solution](https://forums.addons.mozilla.org/viewtopic.php?f=9&t=789&p=1937). Hope this helps.
58,647,340
I am using Python and have a data frame with a datetime index, a grouping variable (gvar) and a value variable (x). I would like to find all the common datetimes between the groups. I already have a solution using functools, but I am seeking a way to do it using pandas functionalities only (if possible). ``` import functools import pandas as pd gvar = ['A', 'A', 'A', 'B', 'B', 'B'] x = [100, 200, 100, 200 , 100, 200] ind = ['2018-01-01','2018-01-02', '2018-01-03', '2018-01-03', '2018-01-04', '2018-01-05' ] df = pd.DataFrame(data={'gvar':gvar, 'x': x}, index=pd.to_datetime(ind)) common_time = functools.reduce(lambda x, y: pd.np.intersect1d(x, y), [df[df.gvar == x].index for x in set(df.gvar)]) common_time Out[39]: array(['2018-01-03T00:00:00.000000000'], dtype='datetime64[ns]') ``` All suggestions are welcome.
2019/10/31
[ "https://Stackoverflow.com/questions/58647340", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9576116/" ]
This is what you need to know about bash variables and quoting: For the following examples, the variable `${text}` is set to `Hello`: 1. Variables are expanded inside double quotes. e.g. `"${text}"` => `Hello` 2. Variables are **not** expanded inside single quotes. e.g. `'${text}'` => `${text}` 3. Single quotes have no special meaning inside double quotes and vice-versa. e.g. `"'${text}'"` => `'Hello'` and `'"${text}"'` => `"${text}"` 4. If you need to place a double-quote inside a double-quoted string, or a single quote inside a single-quoted string, then it must be escaped. e.g. `"\"${text}\""` => `"Hello"` and `'\'${text}\''` => `'${text}'` With all that said, in your case, you want the variables to be expanded, so you should enclose the entire --extra-vars value in double quotes. According to the Ansible website, the value of each of these extra variables does not need to be quoted, unless it contains spaces. To be safe, you can quote the variables as you might not be able to control their values. Try this. I have added extra line breaks to make the code easier to understand: ``` ansible-playbook -i inventory.yml playbook.yml --extra-vars \ "username='${login}' \ fullname='${username}' \ password='${password}' \ groups=['Users','Remote Desktop Users'] \ " ```
It seems that variable name 'groups' is reserved by ansible. I changed name, and script starts working. The answer of Andrew Vickers is also correct.
15,258,267
I am developing a news application. At the main page, I am fetching the news from a server, using JSON. I am putting the title of this new in the listview alongside a thumbnail image. The main text of the news (which might be more than 15 lines) does not appear here. Where I want it to appear is when the user clicks on the title in a specific row in the ListView, the user is taken into a new activity, where a bigger image is shown, alongside the title and the text of the news. My question is the following. - Which approach is better ? 1 - getting all the data in the first listview, and send them as extras to the second page ? (my concern is that the jsons can get a bit too long sometimes) and show them there ? 2 - just get the title in the first listview, and get another link for the big text (and images) then when the user clicks on the news, open the other activity, and re post/get the data this time with the new link. Any other suggestions are welcomed.
2013/03/06
[ "https://Stackoverflow.com/questions/15258267", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2102389/" ]
I would prefer the second option. Because user might not be interested in all the news. Practically, user will read only few news. Say 4 or 5. If you do by second option, you will be fetching only those 4 or 5 data. You fetching all the available data at once will consume large data traffic and time to load the list.
Roughly if you don't want your app to work offline @Karthik Palanivelu is right, and you should only request the extra data if the user wants to read it. If you do, then that really depends on how many items your list has and how much do you care about the data traffic. If you have 1000 items, 15 lines, let's say 100 characters per line. That's roughly 1,5Mb. Might be a lot if the user is using mobile data, but also might be a little bit if the user is on Wifi. I personally like to give the user the option to always browse the app offline, so in that case I would fetch all the text right away. (Or at least some of the options, maybe the latest 100 or so. But that's my personal opinion) Bear in mind that's just for the text, you should not fetch all the large images, or it'll consume a lot. Nowadays a lot of people use mobile data, so you should always try to keep the data consumption at a minimum but also give the user a nice experience.
19,486,423
Here's my folder structure (all blacked out is just name of project, just assume 'myproject'): ![enter image description here](https://i.stack.imgur.com/kfKZR.png) I want to set my home page, ie `http://mydomain.com/`, as a template HTML. So following [this SO post](https://stackoverflow.com/questions/1940528/django-index-page-best-most-common-practice), I set this as my `url.py` in my `myproject` project folder: ``` from django.conf.urls import patterns, include, url from django.views.generic import TemplateView from django.contrib import admin admin.autodiscover() urlpatterns = patterns('', url(r'^$', TemplateView.as_view(template_name="index.html")), url(r'^events/', include('events.urls', namespace='events')), url(r'^admin/', include(admin.site.urls)), ) ``` But Django keeps trying to append this path to the events folder. The `DEBUG = True` output from the browser indicates that it cannot find this template at ``` /home/ubuntu/django/myproject/events/templates/templates/myproject/index.html ``` which of course is not what I was trying to point to. How do I fix this?
2013/10/21
[ "https://Stackoverflow.com/questions/19486423", "https://Stackoverflow.com", "https://Stackoverflow.com/users/712997/" ]
Using numpy indexing/slicing notation, you use commas to delimit the slice for each dimension: ``` import numpy as np a = np.array([[1,2,3],[1,2,3],[1,2,3]]) print a[:,1:] ``` output: ``` [[2 3] [2 3] [2 3]] ``` For additional reading on numpy indexing: <http://docs.scipy.org/doc/numpy/reference/arrays.indexing.html>
You can use [list comprehensions](http://docs.python.org/2/tutorial/datastructures.html#list-comprehensions): ``` b = [x[1:] for x in a] ``` Demo: ``` >>> a = [[1, 2, 3], [4, 5, 6], [7, 8, 9]] >>> b = [x[1:] for x in a] >>> b [[2, 3], [5, 6], [8, 9]] >>> ```
19,486,423
Here's my folder structure (all blacked out is just name of project, just assume 'myproject'): ![enter image description here](https://i.stack.imgur.com/kfKZR.png) I want to set my home page, ie `http://mydomain.com/`, as a template HTML. So following [this SO post](https://stackoverflow.com/questions/1940528/django-index-page-best-most-common-practice), I set this as my `url.py` in my `myproject` project folder: ``` from django.conf.urls import patterns, include, url from django.views.generic import TemplateView from django.contrib import admin admin.autodiscover() urlpatterns = patterns('', url(r'^$', TemplateView.as_view(template_name="index.html")), url(r'^events/', include('events.urls', namespace='events')), url(r'^admin/', include(admin.site.urls)), ) ``` But Django keeps trying to append this path to the events folder. The `DEBUG = True` output from the browser indicates that it cannot find this template at ``` /home/ubuntu/django/myproject/events/templates/templates/myproject/index.html ``` which of course is not what I was trying to point to. How do I fix this?
2013/10/21
[ "https://Stackoverflow.com/questions/19486423", "https://Stackoverflow.com", "https://Stackoverflow.com/users/712997/" ]
You can use [list comprehensions](http://docs.python.org/2/tutorial/datastructures.html#list-comprehensions): ``` b = [x[1:] for x in a] ``` Demo: ``` >>> a = [[1, 2, 3], [4, 5, 6], [7, 8, 9]] >>> b = [x[1:] for x in a] >>> b [[2, 3], [5, 6], [8, 9]] >>> ```
in python 3 you can also use \* ``` b = [x for _,*x in a] ``` this approach is more flexible since you can for example left first and last elements of the inside list, no matter how long is the list: ``` b = [first,last for first,*middle,last in a] ```
19,486,423
Here's my folder structure (all blacked out is just name of project, just assume 'myproject'): ![enter image description here](https://i.stack.imgur.com/kfKZR.png) I want to set my home page, ie `http://mydomain.com/`, as a template HTML. So following [this SO post](https://stackoverflow.com/questions/1940528/django-index-page-best-most-common-practice), I set this as my `url.py` in my `myproject` project folder: ``` from django.conf.urls import patterns, include, url from django.views.generic import TemplateView from django.contrib import admin admin.autodiscover() urlpatterns = patterns('', url(r'^$', TemplateView.as_view(template_name="index.html")), url(r'^events/', include('events.urls', namespace='events')), url(r'^admin/', include(admin.site.urls)), ) ``` But Django keeps trying to append this path to the events folder. The `DEBUG = True` output from the browser indicates that it cannot find this template at ``` /home/ubuntu/django/myproject/events/templates/templates/myproject/index.html ``` which of course is not what I was trying to point to. How do I fix this?
2013/10/21
[ "https://Stackoverflow.com/questions/19486423", "https://Stackoverflow.com", "https://Stackoverflow.com/users/712997/" ]
Using numpy indexing/slicing notation, you use commas to delimit the slice for each dimension: ``` import numpy as np a = np.array([[1,2,3],[1,2,3],[1,2,3]]) print a[:,1:] ``` output: ``` [[2 3] [2 3] [2 3]] ``` For additional reading on numpy indexing: <http://docs.scipy.org/doc/numpy/reference/arrays.indexing.html>
in python 3 you can also use \* ``` b = [x for _,*x in a] ``` this approach is more flexible since you can for example left first and last elements of the inside list, no matter how long is the list: ``` b = [first,last for first,*middle,last in a] ```
34,605,463
the adutomatic crud operation generated by symfony and also the symfony demo application has the following code structure for the delete action ``` /** * Deletes a testing entity. * * @Route("/{id}", name="testing_delete") * @Method("DELETE") */ public function deleteAction(Request $request, testing $testing) { $form = $this->createDeleteForm($testing); $form->handleRequest($request); if ($form->isSubmitted() && $form->isValid()) { $em = $this->getDoctrine()->getManager(); $em->remove($testing); $em->flush(); } return $this->redirectToRoute('testing_index'); } /** * Creates a form to delete a testing entity. * * @param testing $testing The testing entity * * @return \Symfony\Component\Form\Form The form */ private function createDeleteForm(testing $testing) { return $this->createFormBuilder() ->setAction($this->generateUrl('testing_delete', array('id' => $testing->getId()))) ->setMethod('DELETE') ->getForm() ; } ``` my question is why do we need a form to delete? cant we just have a link in the twig with an `id` parameter set accordingly, cant we just do the following, why do we need to check if the entity `isValid()` inside a form before deleteing it? ``` /** * test delete * @Route("/{id}", name="testing_delete") * @Method("DELETE") */ public function deleteAction(testing $testing) { $em = $this->getDoctrine()->getManager(); $em->remove($testing); $em->flush(); return $this->redirectToRoute('testing_showall'); } ```
2016/01/05
[ "https://Stackoverflow.com/questions/34605463", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5211278/" ]
If you used link for delete with id, it's possible to robot can delete you data with looping. In Symfony action check "DELETE" method as well as if your crsf token verify with method isValid "$form->isValid()" That's security reason it's create form and validate
Not using a simple link to delete data denotes to the concept of [safe methods](https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol#Safe_methods) in HTTP (if you had just a simple link, you would have to send a `GET` request to the URL): > > Some of the methods (for example, HEAD, GET, OPTIONS and TRACE) are, by convention, defined as safe, which means they are intended only for information retrieval and should not change the state of the server. In other words, they should not have side effects [...] > > >
34,605,463
the adutomatic crud operation generated by symfony and also the symfony demo application has the following code structure for the delete action ``` /** * Deletes a testing entity. * * @Route("/{id}", name="testing_delete") * @Method("DELETE") */ public function deleteAction(Request $request, testing $testing) { $form = $this->createDeleteForm($testing); $form->handleRequest($request); if ($form->isSubmitted() && $form->isValid()) { $em = $this->getDoctrine()->getManager(); $em->remove($testing); $em->flush(); } return $this->redirectToRoute('testing_index'); } /** * Creates a form to delete a testing entity. * * @param testing $testing The testing entity * * @return \Symfony\Component\Form\Form The form */ private function createDeleteForm(testing $testing) { return $this->createFormBuilder() ->setAction($this->generateUrl('testing_delete', array('id' => $testing->getId()))) ->setMethod('DELETE') ->getForm() ; } ``` my question is why do we need a form to delete? cant we just have a link in the twig with an `id` parameter set accordingly, cant we just do the following, why do we need to check if the entity `isValid()` inside a form before deleteing it? ``` /** * test delete * @Route("/{id}", name="testing_delete") * @Method("DELETE") */ public function deleteAction(testing $testing) { $em = $this->getDoctrine()->getManager(); $em->remove($testing); $em->flush(); return $this->redirectToRoute('testing_showall'); } ```
2016/01/05
[ "https://Stackoverflow.com/questions/34605463", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5211278/" ]
If you used link for delete with id, it's possible to robot can delete you data with looping. In Symfony action check "DELETE" method as well as if your crsf token verify with method isValid "$form->isValid()" That's security reason it's create form and validate
I think it's important to write a word about [CSRF](https://www.owasp.org/index.php/Cross-Site_Request_Forgery_(CSRF)). By using a Symfony form, it creates a CSRF token that ensure the user who deletes the entity is the same user who wanted it. If there was no form and only a link `/{id}`, it would be possible by using a bad link in a mail, or an XSS attack, to make someone else sending the request to delete an entity. If Bob uses an XSS breach or something else to make Alice (the admin) sending a request for deleting an entity, the request is sent by Alice, event if it's an attack from Bob. So, Bob hasn't the rights for this request but he used the session of Alice, who has the rights. The entity is deleted. To protect against CSRF attacks, using a CSRF token is really important. Symfony's Form includes it automatically, and check if in `isValid()`.
34,605,463
the adutomatic crud operation generated by symfony and also the symfony demo application has the following code structure for the delete action ``` /** * Deletes a testing entity. * * @Route("/{id}", name="testing_delete") * @Method("DELETE") */ public function deleteAction(Request $request, testing $testing) { $form = $this->createDeleteForm($testing); $form->handleRequest($request); if ($form->isSubmitted() && $form->isValid()) { $em = $this->getDoctrine()->getManager(); $em->remove($testing); $em->flush(); } return $this->redirectToRoute('testing_index'); } /** * Creates a form to delete a testing entity. * * @param testing $testing The testing entity * * @return \Symfony\Component\Form\Form The form */ private function createDeleteForm(testing $testing) { return $this->createFormBuilder() ->setAction($this->generateUrl('testing_delete', array('id' => $testing->getId()))) ->setMethod('DELETE') ->getForm() ; } ``` my question is why do we need a form to delete? cant we just have a link in the twig with an `id` parameter set accordingly, cant we just do the following, why do we need to check if the entity `isValid()` inside a form before deleteing it? ``` /** * test delete * @Route("/{id}", name="testing_delete") * @Method("DELETE") */ public function deleteAction(testing $testing) { $em = $this->getDoctrine()->getManager(); $em->remove($testing); $em->flush(); return $this->redirectToRoute('testing_showall'); } ```
2016/01/05
[ "https://Stackoverflow.com/questions/34605463", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5211278/" ]
Not using a simple link to delete data denotes to the concept of [safe methods](https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol#Safe_methods) in HTTP (if you had just a simple link, you would have to send a `GET` request to the URL): > > Some of the methods (for example, HEAD, GET, OPTIONS and TRACE) are, by convention, defined as safe, which means they are intended only for information retrieval and should not change the state of the server. In other words, they should not have side effects [...] > > >
I think it's important to write a word about [CSRF](https://www.owasp.org/index.php/Cross-Site_Request_Forgery_(CSRF)). By using a Symfony form, it creates a CSRF token that ensure the user who deletes the entity is the same user who wanted it. If there was no form and only a link `/{id}`, it would be possible by using a bad link in a mail, or an XSS attack, to make someone else sending the request to delete an entity. If Bob uses an XSS breach or something else to make Alice (the admin) sending a request for deleting an entity, the request is sent by Alice, event if it's an attack from Bob. So, Bob hasn't the rights for this request but he used the session of Alice, who has the rights. The entity is deleted. To protect against CSRF attacks, using a CSRF token is really important. Symfony's Form includes it automatically, and check if in `isValid()`.
41,429,445
here is my code that generates random characters How can i get this random characters when i click my button 'submit' . and get that as a variable to save on database. please help this is my button ``` <span class="input-group-btn"> <button class="btn btn-info" type="submit" name="submit">POST</button> </span> ``` this generates random characters ``` <?php $result = ""; $chars = "abcdefghijklmnopqrstuvwxyz0123456789"; $chararray = str_split($chars); for($i = 0; $i < 7 ; $i++){ $randitem = array_rand($chararray); $result .= "".$chararray[$randitem]; } echo $result; ?> ``` i want to get that random character as a variable like `$post_randomid = $_POST[random_id];`
2017/01/02
[ "https://Stackoverflow.com/questions/41429445", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7365857/" ]
``` <?php if(isset($_POST['submit'])) { if(isset($_POST['rand'])) { echo $_POST['rand']; } } ?> <form method="POST" > //this generates random characters <?php $result = ""; $chars = "abcdefghijklmnopqrstuvwxyz0123456789"; $chararray = str_split($chars); for($i = 0; $i < 7 ; $i++){ $randitem = array_rand($chararray); $result .= "".$chararray[$randitem]; } echo $result; // i want to get that random character as a variable like $post_randomid =$_POST[random_id]; ?> <input type="hidden" value="<?php echo $result;?>" name="rand" /> //this is my button <span class="input-group-btn"> <button class="btn btn-info" type="submit" name="submit">POST</button> </span> </form> ```
Send the value either in the session on the server or create a hidden input type on the client. The second option solves your question.
41,429,445
here is my code that generates random characters How can i get this random characters when i click my button 'submit' . and get that as a variable to save on database. please help this is my button ``` <span class="input-group-btn"> <button class="btn btn-info" type="submit" name="submit">POST</button> </span> ``` this generates random characters ``` <?php $result = ""; $chars = "abcdefghijklmnopqrstuvwxyz0123456789"; $chararray = str_split($chars); for($i = 0; $i < 7 ; $i++){ $randitem = array_rand($chararray); $result .= "".$chararray[$randitem]; } echo $result; ?> ``` i want to get that random character as a variable like `$post_randomid = $_POST[random_id];`
2017/01/02
[ "https://Stackoverflow.com/questions/41429445", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7365857/" ]
``` <?php if(isset($_POST['submit'])) { if(isset($_POST['rand'])) { echo $_POST['rand']; } } ?> <form method="POST" > //this generates random characters <?php $result = ""; $chars = "abcdefghijklmnopqrstuvwxyz0123456789"; $chararray = str_split($chars); for($i = 0; $i < 7 ; $i++){ $randitem = array_rand($chararray); $result .= "".$chararray[$randitem]; } echo $result; // i want to get that random character as a variable like $post_randomid =$_POST[random_id]; ?> <input type="hidden" value="<?php echo $result;?>" name="rand" /> //this is my button <span class="input-group-btn"> <button class="btn btn-info" type="submit" name="submit">POST</button> </span> </form> ```
``` <?php $result = ""; $chars = "abcdefghijklmnopqrstuvwxyz0123456789"; $chararray = str_split($chars); for($i = 0; $i < 7 ; $i++){ $randitem = array_rand($chararray); $result .= "".$chararray[$randitem]; } ?> <form action="my_php_database_script.php" method="POST"> <input name="chars" type="hidden" value="<?php echo $result; ?>" /> <button type="submit" name="submit">POST</button> </form> ``` You could access your result with $\_POST["chars"] in your script php (*my\_php\_database\_script.php*) to save it in database. If you want to do it asynchronously without leaving this page, you have to deal with AJAX.
13,483,724
I am presenting a modal view controller from another modal view controller, and this worked fine under all iOS versions prior to iOS6. But under iOS6 I am getting the following warning message in the emulator: ``` Warning: Attempt to present <UINavigationController: 0x14e93680> on <UINavigationController: 0x9fc6b70> while a presentation is in progress! ``` The modal view controller is not shown if this warning appears. Basically I am using code like this to show the modal view controller: ``` WebAuthViewController *authController = [[WebAuthViewController alloc] initWithNibName:nil bundle:nil]; authController.challenge = challenge; authController.delegate = self; UINavigationController *aNavController = [[UINavigationController alloc] initWithRootViewController:authController]; [self presentModalViewController:aNavController animated:YES]; [aNavController release]; [authController release]; ``` The view that is already shown is a UIWebView also shown in a modal view, like this: ``` WebViewController *addController = [[WebViewController alloc] initWithNibName:nil bundle:nil]; addController.urlToLoad = [NSURL URLWithString:urlString]; addController.delegate = self; UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:addController]; navigationController.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal; [self presentModalViewController:navigationController animated:YES]; [navigationController release]; [addController release]; ``` The apple docs still suggest that one is supposed to be able to stack navigation controllers like this, so I am at a loss to explain why this happens. Any hints?
2012/11/20
[ "https://Stackoverflow.com/questions/13483724", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1840362/" ]
You can use an **EditorTemplates** for this. The below example shows the normal form posting example. You can ajaxify it if you need by using the `serialize` method and sending form values. Assuming You need to Edit the List of Student Names for a course. So Let's create some viewmodels for that ``` public class Course { public int ID { set;get;} public string CourseName { set;get;} public List<Student> Students { set;get;} public Course() { Students=new List<Student>(); } } public class Student { public int ID { set;get;} public string FirstName { set;get;} } ``` Now in your `GET` action method, you create an object of our view model, initialize the `Students` collection and send it to our strongly typed view. ``` public ActionResult StudentList() { Course courseVM=new Course(); courseVM.CourseName="Some course from your DB here"; //Hard coded for demo. You may replace this with DB data. courseVM.Students.Add(new Student { ID=1, FirstName="Jon" }); courseVM.Students.Add(new Student { ID=2, FirstName="Scott" }); return View(courseVM); } ``` Now Create a folder called **EditorTemplates** under **Views/*YourControllerName***. Then create a new view under that called `Student.cshtml` with below content ``` @model Student @{ Layout = null; } <tr> <td> @Html.HiddenFor(x => x.ID) @Html.TextBoxFor(x => x.FirstName ) </td> </tr> ``` Now in our main view (StudentList.cshtml), Use EditorTemplate HTML helper method to bring this view. ``` @model Course <h2>@Model.CourseName</h2> @using(Html.BeginForm()) { <table> @Html.EditorFor(x=>x.Students) </table> <input type="submit" id="btnSave" /> } ``` This will bring all the UI with each of your student name in a text box contained in a table row. Now when the form is posted, MVC model binding will have all text box value in the `Students` property of our viewmodel. ``` [HttpPost] public ActionResult StudentList(Course model) { //check for model.Students collection for each student name. //Save and redirect. (PRG pattern) } ``` **Ajaxified solution** If you want to Ajaxify this, you can listen for the submit button click, get the form and serialize it and send to the same post action method. Instead of redirecting after saving, you can return some JSON which indicates the status of the operation. ``` $(function(){ $("#btnSave").click(function(e){ e.preventDefault(); //prevent default form submit behaviour $.post("@Url.Action("StudentList",YourcontrollerName")", $(this).closest("form").serialize(),function(response){ //do something with the response from the action method }); }); }); ```
You just need to specify the right model, list of example, and send the ajax with have information on each row (element of the array), read it on the server side and update each element accordingly. For this goal you use Post request. Just pass the list of elements as a parameters into the controller and pass it using the ajax. For example you controller could be defined as: ``` public ActionResult Update(List<MyEntity> list) { ... } public class MyEntity { public string Name {get; set;} public int Count {get; set;} } ``` and JavaScript could be as: ``` var myList = new Array(); // fill the list up or do something with it. $.ajax( { url: "/Update/", type: "POST", data: {list: myList} } ); ``` And of course your "Save" button has click event handler that will call that functionality with the ajax call. For your convenience you can consider using KnockoutJS or other MVVM frameworks to bind the data with the DOM on the client side.
25,243,792
Hey guys I have this jQuery content toggle setup here: <http://jsfiddle.net/DTcHh/848/> I am trying to remove the class for the span that contains the plus glyphicon and replace it with the minus glyphicon when the content is visible. Here is my jQuery: ``` $(document).ready(function () { $('#toggle-view li').click(function () { var text = $(this).children('div.panel'); if (text.is(':hidden')) { text.slideDown('200'); $(this).children('span').html('-'); } else { text.slideUp('200'); $(this).children('span').html('+'); } }); }); ``` Here is my HTML: ``` <ul id="toggle-view"> <li class="li-toggle"> <h3 class="toggle-h3">Title 1<span class="glyphicon glyphicon-plus glyph-plus-toggle"></span></h3> <div class="panel"> <p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Morbi commodo, ipsum sed pharetra gravida, orci magna rhoncus neque, id pulvinar odio lorem non turpis. Nullam sit amet enim.</p> </div> </li> </ul> ``` I have tried implementing this code to try and remove the plus glyph and replace it with the minus glyph however I can't get it to work: ``` $(this).children('span')removeClass(glyphicon glyphicon-plus glyph-plus-toggle).addClass(glyphicon glyphicon-minus glyph-minus-toggle); ``` Any idea where I am going wrong? Thanks :)
2014/08/11
[ "https://Stackoverflow.com/questions/25243792", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3929619/" ]
The `addClass` and `removeClass` functions require strings, to know what classes you are talking about. A string is declared by putting quotes around the text. Because those are missing, it now thinks those are variables, which they aren't. Added to that, you were missing a dot before `removeClass`. Try this: ``` $(this).children('span').removeClass("glyphicon glyphicon-plus glyph-plus-toggle").addClass("glyphicon glyphicon-minus glyph-minus-toggle"); ``` --- Edit: I changed it, and it works: [See the fiddle](http://jsfiddle.net/Koedood/DTcHh/858/) The problem was your use of `.children()`. I changed it with `.find()`. Taken from [this](http://api.jquery.com/children/) page: > > The .children() method differs from .find() in that .children() only travels a single level down the DOM tree while .find() can traverse down multiple levels to select descendant elements (grandchildren, etc.) as well. > > > Since the elements you were looking for aren't direct children, they didn't get selected.
**Problems:** 1. You put `removeClass` right after the children() function, without using a dot. 2. You didn't use brackets (" or ') for your string. 3. You've tried to remove/append multiple classes at once by seprating the classes with a space. I don't think this is possible. Also, you put a number in a string, wich is unnecessary. You don't need to use brackets if you want to have an integer.
25,243,792
Hey guys I have this jQuery content toggle setup here: <http://jsfiddle.net/DTcHh/848/> I am trying to remove the class for the span that contains the plus glyphicon and replace it with the minus glyphicon when the content is visible. Here is my jQuery: ``` $(document).ready(function () { $('#toggle-view li').click(function () { var text = $(this).children('div.panel'); if (text.is(':hidden')) { text.slideDown('200'); $(this).children('span').html('-'); } else { text.slideUp('200'); $(this).children('span').html('+'); } }); }); ``` Here is my HTML: ``` <ul id="toggle-view"> <li class="li-toggle"> <h3 class="toggle-h3">Title 1<span class="glyphicon glyphicon-plus glyph-plus-toggle"></span></h3> <div class="panel"> <p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Morbi commodo, ipsum sed pharetra gravida, orci magna rhoncus neque, id pulvinar odio lorem non turpis. Nullam sit amet enim.</p> </div> </li> </ul> ``` I have tried implementing this code to try and remove the plus glyph and replace it with the minus glyph however I can't get it to work: ``` $(this).children('span')removeClass(glyphicon glyphicon-plus glyph-plus-toggle).addClass(glyphicon glyphicon-minus glyph-minus-toggle); ``` Any idea where I am going wrong? Thanks :)
2014/08/11
[ "https://Stackoverflow.com/questions/25243792", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3929619/" ]
The `addClass` and `removeClass` functions require strings, to know what classes you are talking about. A string is declared by putting quotes around the text. Because those are missing, it now thinks those are variables, which they aren't. Added to that, you were missing a dot before `removeClass`. Try this: ``` $(this).children('span').removeClass("glyphicon glyphicon-plus glyph-plus-toggle").addClass("glyphicon glyphicon-minus glyph-minus-toggle"); ``` --- Edit: I changed it, and it works: [See the fiddle](http://jsfiddle.net/Koedood/DTcHh/858/) The problem was your use of `.children()`. I changed it with `.find()`. Taken from [this](http://api.jquery.com/children/) page: > > The .children() method differs from .find() in that .children() only travels a single level down the DOM tree while .find() can traverse down multiple levels to select descendant elements (grandchildren, etc.) as well. > > > Since the elements you were looking for aren't direct children, they didn't get selected.
I`m not sure about .children() method... You can try find() like this and just use .addClass("classname") or .removeClass("classname"). Note that "." (dots) are not needed. ``` $(document).ready(function () { $('#toggle-view li').click(function () { var text = $(this).children('div.panel'); if (text.is(':hidden')) { text.slideDown('200'); $(this).find('span').removeClass("glyphicon-plus"); $(this).find('span').addClass("glyphicon-minus"); } else { text.slideUp('200'); $(this).find('span').addClass("glyphicon-plus"); $(this).find('span').removeClass("glyphicon-minus"); } }); }); ```
25,234,696
I have this MYSQL query ``` SELECT username,password,enabled FROM USERS WHERE username=? ``` that outputs 3 columns: username, password, enabled. Now what I want to do is include email\_address in the query and **OUTPUT IT ALSO UNDER USERNAME** column ``` SELECT username,password,enabled FROM USERS WHERE username=? or email_address=? ``` and still outputs 3 columns: username(could be from email\_address), password, enabled. *Can I do that? How?*
2014/08/11
[ "https://Stackoverflow.com/questions/25234696", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2016628/" ]
Try the following: ``` // mainwindow.h class MainWindow : public QMainWindow { private: QScopedPointer<QTimer> timer2; }; ``` If you want to create the instance in the constructor, use the following: ``` // mainwindow.cpp MainWindow::MainWindow() :timer2(new QTimer) { } ``` Alternately, if you want to create the instance in some arbitrary member function of `MainWindow`, use this: ``` // mainwindow.cpp void MainWindow::someFunction() { timer2.reset(new QTimer); } ``` It's also worth reviewing initialization lists in C++ and the documentation for [`QScopedPointer`](http://qt-project.org/doc/qt-5/qscopedpointer.html).
Use method `reset` of QScopedPointer ``` timer2.reset(new QTimer()); ```
25,234,696
I have this MYSQL query ``` SELECT username,password,enabled FROM USERS WHERE username=? ``` that outputs 3 columns: username, password, enabled. Now what I want to do is include email\_address in the query and **OUTPUT IT ALSO UNDER USERNAME** column ``` SELECT username,password,enabled FROM USERS WHERE username=? or email_address=? ``` and still outputs 3 columns: username(could be from email\_address), password, enabled. *Can I do that? How?*
2014/08/11
[ "https://Stackoverflow.com/questions/25234696", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2016628/" ]
Use method `reset` of QScopedPointer ``` timer2.reset(new QTimer()); ```
What you're doing amounts to a premature pessimization. You're creating members of a `MainWindow` class *separately and individually* on the heap, when you should be simply putting them into the class as members: ``` // interface #include <QMainWindow> #include <QTimer> class MainWindow : public QMainWindow { Q_OBJECT QTimer m_timer; public: MainWindow(QWidget * parent = 0, Qt::WindowFlags flags = 0); }; // implementation MainWindow::MainWindow(QWidget * parent, Qt::WindowFlags flags) : QMainWindow(parent, flags), m_timer() { ... } ``` Of course, you would ordinarily not want to expose all the details of the `MainWindow`'s implementation in the interface (header) file. Thus you would leverage the [PIMPL](https://stackoverflow.com/questions/60570/why-should-the-pimpl-idiom-be-used) idiom: ``` // interface #include <QMainWindow> class MainWindowPrivate; class MainWindow : public QMainWindow { Q_OBJECT Q_DECLARE_PRIVATE(MainWindow) QScopedPointer<MainWindowPrivate> const d_ptr; public: MainWindow(QWidget * parent = 0, Qt::WindowFlags flags = 0); } // implementation #include "MainWindow.h" #include <QTimer> class MainWindowPrivate { public: QTimer timer; } MainWindow::MainWindow(QWidget * parent, Qt::WindowFlags flags) : QMainWindow(parent, flags), d_ptr(new(MainWindowPrivate()) { Q_D(MainWindow); d->timer.start( ... ); ... } ```
25,234,696
I have this MYSQL query ``` SELECT username,password,enabled FROM USERS WHERE username=? ``` that outputs 3 columns: username, password, enabled. Now what I want to do is include email\_address in the query and **OUTPUT IT ALSO UNDER USERNAME** column ``` SELECT username,password,enabled FROM USERS WHERE username=? or email_address=? ``` and still outputs 3 columns: username(could be from email\_address), password, enabled. *Can I do that? How?*
2014/08/11
[ "https://Stackoverflow.com/questions/25234696", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2016628/" ]
Try the following: ``` // mainwindow.h class MainWindow : public QMainWindow { private: QScopedPointer<QTimer> timer2; }; ``` If you want to create the instance in the constructor, use the following: ``` // mainwindow.cpp MainWindow::MainWindow() :timer2(new QTimer) { } ``` Alternately, if you want to create the instance in some arbitrary member function of `MainWindow`, use this: ``` // mainwindow.cpp void MainWindow::someFunction() { timer2.reset(new QTimer); } ``` It's also worth reviewing initialization lists in C++ and the documentation for [`QScopedPointer`](http://qt-project.org/doc/qt-5/qscopedpointer.html).
What you're doing amounts to a premature pessimization. You're creating members of a `MainWindow` class *separately and individually* on the heap, when you should be simply putting them into the class as members: ``` // interface #include <QMainWindow> #include <QTimer> class MainWindow : public QMainWindow { Q_OBJECT QTimer m_timer; public: MainWindow(QWidget * parent = 0, Qt::WindowFlags flags = 0); }; // implementation MainWindow::MainWindow(QWidget * parent, Qt::WindowFlags flags) : QMainWindow(parent, flags), m_timer() { ... } ``` Of course, you would ordinarily not want to expose all the details of the `MainWindow`'s implementation in the interface (header) file. Thus you would leverage the [PIMPL](https://stackoverflow.com/questions/60570/why-should-the-pimpl-idiom-be-used) idiom: ``` // interface #include <QMainWindow> class MainWindowPrivate; class MainWindow : public QMainWindow { Q_OBJECT Q_DECLARE_PRIVATE(MainWindow) QScopedPointer<MainWindowPrivate> const d_ptr; public: MainWindow(QWidget * parent = 0, Qt::WindowFlags flags = 0); } // implementation #include "MainWindow.h" #include <QTimer> class MainWindowPrivate { public: QTimer timer; } MainWindow::MainWindow(QWidget * parent, Qt::WindowFlags flags) : QMainWindow(parent, flags), d_ptr(new(MainWindowPrivate()) { Q_D(MainWindow); d->timer.start( ... ); ... } ```
27,933,198
In the [official documentation](http://www.yiiframework.com/doc-2.0/guide-start-databases.html#preparing-the-database) example "Country" database. I decided to add new field (Property) for the country, namely, `area`. I added a field named to the MySQL database's table named `country` with the name `area` with the following structure: ``` `area` float DEFAULT NULL ``` The new field's values in the database takes the default value `0` and in the view it displayed as `0.00` like the following screen shot shows: ![enter image description here](https://i.stack.imgur.com/3gzr0.png) In the update form, I added an input field for `area` like the following: ``` // In views/country/_form.php, I added the following line to the form: <?= $form->field($model, 'area')->textInput() ?> //In models/Country.php, I did not set any validation rules for area field. public function attributeLabels() { return [ 'code' => 'Code', 'name' => 'Name', 'population' => 'Population', 'area' => 'Area in KM<sup>2</sup>' ]; } ``` Now all fields in update view, are updated successfully, except the new field `area`. It, simply, does not updated at all without any error messages. **Why?** Also, as the screen shot shows, in the view `area` label is printed out correctly, however, in the update view it shows as its HTML entity i.e `Area in KM<sup>2</sup>`. **Why?** In another aspect, I did not like the presentation of area for non defined area country by 0.00, so I decidd to make it to be `N/A` so I have made the following callback method in models/Country.php: ``` public function afterFind() { if ($this->area == NULL){ $this->area = 'N/A'; } return true; } ``` However, the above solution generates error in the action view: > > **'N/A' is not a numeric value.** > > > So, I replaced `N/A` with `NULL` and the view action works fine and assigned non defined area countries with `(not set)` in the view instead of `0.00`. **The last question here,** is there any way to make the view printout `N\A` for non defined area countries? The action view uses `DetailView::widget`
2015/01/13
[ "https://Stackoverflow.com/questions/27933198", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1592845/" ]
> > Now all fields in update view, are updated successfully, except the > new field area. It, simply, does not updated at all without any error > messages. Why? > > > Because it's not safe attribute. You said that it's not presented in the rules. If you don't want validate it, but want to be able to massively assign it, you should explicitly specify it in the validation rules like so: ``` ['area', 'safe'], ``` Read more about model [safe attributes](http://www.yiiframework.com/doc-2.0/guide-structure-models.html#safe-attributes) in official documentation. > > Also, as the screen shot shows, in the view area label is printed out > correctly, however, in the update view it shows as its HTML entity i.e > Area in KM`<sup>2</sup>`. Why? > > > That's how attribute label renders in `DetailView`: <https://github.com/yiisoft/yii2/blob/master/framework/widgets/DetailView.php#L206> And in `Html::activeLabel()` which is used by `ActiveForm's` `field()`: <https://github.com/yiisoft/yii2/blob/master/framework/helpers/BaseHtml.php#L1048> If it's not specified explicitly and automatically taken from `attributeLabels()`, encoding applies regargless of the options. As as a workaround in `ActiveForm` I recommend passing it like this: ``` <?= $form->field($model, 'area')->label('Area in KM<sup>2</sup>') ?> ``` I think it's not a big deal to copy such content, because it's not code logic and rarely changed. And even if it will change, it's very easy to replace it with global search in your editor. If you highly against that, maybe it's better to declare it additionally in your model. If you want, you can create issue on Github about that. Maybe I missed something but I didn't find a way to disable encoding for labels in `ActiveForm`. And another workaround is to simply replace html by text representation, something like `square km.` It's a bit longer, but does not have this problems with encoding. > > The last question here, is there any way to make the view printout N\A > for non defined area countries? > > > I think what you doing in `afterFind()` is not good because you replace the actual model value with display value. It can be used somewhere else, for example in update process and lead to some bugs. You can do it at least with two options in your view. **1)** If the null values are presented only in `area`, or you want to display `N\A` for other attributes `null` values too, you can simply replace default `null` representation like so: ``` use Yii; ... Yii::$app->formatter->nullDisplay = 'N\A'; ``` You should place this code before rendering `DetailView` Read more in [official documentation](http://www.yiiframework.com/doc-2.0/yii-i18n-formatter.html#$nullDisplay-detail). **2)** Otherwise just extend defition of attribute `area` in `DetailView` `attributes` section: ``` [ 'attribute' => 'area', 'value' => $model->area === null ? 'N\A' : $model->area, ], ```
You can validate Float type validation by defining rule in model Like... ``` ....other rules.... [['area'],'integer', 'integerOnly' => false,], ...other rule... ```
25,667,492
Example: We have an employee list page, that consists of filter criteria form and employee list grid. One of the criteria you can filter by is manager. If the user wants to pick a manager to filter by, he uses the lookup control and popup window is opened, that also has filter criteria and employee list grid. Now the problem is, that if the popup window is not an iframe, some of the popup elements will have same names and ids as the owner page. Duplicate ids cause Kendo UI to break as by default MVC wrapper generates script tags with $("#id").kendoThingie. I have used iframe in the past, but content that does not fit in iframe window like long dropdown lists gets cut off and now IE11 especially causes various issues like <https://connect.microsoft.com/IE/feedback/details/802251/script70-permission-denied-error-when-trying-to-access-old-document-from-reloaded-iframe>. What would be the best solution here? Generate unique ids for all elements on Razor pages? Modify partial page content that is retrieved by Ajax making ids unique? Something else?
2014/09/04
[ "https://Stackoverflow.com/questions/25667492", "https://Stackoverflow.com", "https://Stackoverflow.com/users/190474/" ]
It sounds like you are using a partial page as the content to a Kendo window. If this is the case then just provide your partial with a prefix like so at the top of the page. ``` @{ ViewData.TemplateInfo.HtmlFieldPrefix = "MyPrefix" } ``` Now when you create a kendo control via the MVC wrapper like so ``` @(Html.Kendo().DropDownListFor(o => o.SomeProperty) ..... ) ``` The name attribute will be generated as "MyPrefix.SomeProperty" and the id attribute will be generated as "MyPrefix\_SomeProperty". When accessing it within Jquery I like a shorter variable name so I usually do ``` string Prefix = ViewData.TemplateInfo.HtmlFieldPrefix ``` After setting the prefix. Then use ``` var val = $('#@(Prefix)_SomeProperty').data('kendoDropDownList').value(); ``` Note after this change. If you are posting a form from that partial you will need to add the following attribute to your model parameter on the controller method like so. So that binding happens correctly. ``` [HttpPost] public ActionResult MyPartialModal([Bind(Prefix = "MyPrefix")] ModeViewModel model) { ..... } ``` Now with all of that said. As long as you keep your prefixes different for each partial your control ids and names will be unique. To ensure this I usually make my prefix name be the same as my cshtml page that I am creating. You would just need to worry about JS function names. Also, note when closing a kendo window all DOM still exist. You just hide it. If this causes you the same issue you just need to be sure to clear the DOM of the modal on close. Similar to how BurnsBA mentioned. Note because of this is the reason why I try to make sure I use the least amount of kendo windows as possible and just reuse them via the refresh function pointing to a different URL. ``` $('#my-window').data('kendoWindow').refresh({ url: someUrlString , data: { someId: '@Model.MyId' } }).open().center(); ``` Then on the modal page itself. When posting I do the following assuming nothing complicated needs to happen when posting. ``` var form = $('#my-form'); //Probably want this to be unique. What I do is provide a GUID on the view model $('#my-window').data('kendoWindow').refresh({ url: form.attr('action') , data: form.serialize() , type: 'POST' }).open().center(); ```
We do something similar, and have the same problem. We have create/edit/delete popups that fetch data via ajax. Different viewmodels might reference the same model on the same page, and if you open multiple popups (create item type 1, create item type 2) then the second and subsequent popups can be broken (kendo ui error such that a dropdown is now just a plain textbox). Our solution is to delete all dom entries when the popup is closed so there are no conflicts between ids in different popups. We use bootstrap, so it looks like ``` <script type="text/javascript"> $('body').on( // hook close even on bootstrap popup 'hidden.bs.modal', '.modal', function () { $(this).removeData('bs.modal'); $(this).find('.modal-content').html(''); // clear dom in popup }); </script> ``` Note that our popup has some outer html elements and identifiers, but the content is all in ``` <div class="modal-content"> ... </div> ```
72,331,017
I'm new to React, but following multiple guides I have an issue with buttons not selecting the correct style based on "checkButtonStyle", only rendering with the fallback options. My code is: (Button.jsx) ``` import React from 'react'; import './Button.css'; const STYLES = ['btn--primary', 'btn--light', 'btn--dark', 'btn--outline', 'btn--outline--light', 'btn--outline--dark']; const SIZES = ['btn--medium', 'btn--large']; export const Button = ({children, type, onClick, buttonStyle, buttonSize}) => { const checkButtonStyle = STYLES.includes(buttonStyle) ? buttonStyle : STYLES[0]; const checkButtonSize = SIZES.includes(buttonSize) ? buttonSize : SIZES[0]; return ( <button className={'btn ${checkButtonStyle} ${checkButtonSize}'} onClick={onClick} type={type}> {children} </button> ) }; ``` (Button.css) ``` :root { --primary: #EF1B71; --light: #FFFFFF; } .btn { font-family: 'Lato', sans-serif; font-weight: 400; border-radius: 4px; cursor: pointer; transition: 500ms ease; } .btn--primary { background-color: var(--primary); color: var(--light); border: 1px solid var(--primary); } .btn--medium { padding: 8px 20px; } ``` (HeroSection) ``` import React from 'react'; import '../App.css'; import { Button } from './Button'; import './HeroSection.css'; function HeroSection() { return ( <div className='hero-container'> <video src='/videos/home-hero-video-2.mp4' autoPlay loop muted /> <div className="hero-btns"> <Button type='button' buttonStyle='btn--primary' buttonSize="btn--medium">Enquire</Button> </div> </div> ) } ``` I have tried everything I can think of, with no errors showing in console for the button, however the only result I am getting is the .btn style within Button.css and not the btn--primary or btn--medium styles. Thank you
2022/05/21
[ "https://Stackoverflow.com/questions/72331017", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19168726/" ]
``` className={ checkButtonSizes + " " + checkButtonStyle + " btn"} ``` You have to pass the variables in the format mentioned above to make it work. It works for me. Please try and let me know.
In JavaScript, it's possible to use variables in strings with a [JavaScript template literal](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals). However, this requires the use of backticks (`) rather than single (') or double (") quotes. This line uses single quotes rather than backticks. Thus, `${checkButtonStyle}` and `${checkButtonSize}` will be rendered as strings and not their assigned values. ``` <button className={'btn ${checkButtonStyle} ${checkButtonSize}'} onClick={onClick} type={type}> ```
64,742,999
I have a Node/Express server running on an AWS Lightsail instance with PM2 as a process manager. The server is currently listening on port 4000. The IP address for the instance is attached to a subdomain that has a valid SSL certificate and automatically redirects from HTTP to HTTPS. Visiting <https://example.com> at the moment shows the 'Congratulations! You are now running Bitnami Node.js 12.18.3 in the Cloud." page. Currently, all the Express endpoints are only accessible through <http://example.com:4000/endpoint>, but I want the Express app to run on port 443 so that the endpoints are accessible immediately on <https://example.com/endpoint>. I read that PM2 is able to listen on ports 80 and 443 and tried the method mentioned in the [documentation](https://pm2.keymetrics.io/docs/usage/specifics/#listening-on-port-80-w-o-root), but whenever I change the port number in the .env file to 443 and reload the app using `pm2 reload app`, I get the following error: ``` 0|app | Error: listen EADDRINUSE: address already in use :::443 0|app | at Server.setupListenHandle [as _listen2] (net.js:1313:16) 0|app | at listenInCluster (net.js:1361:12) 0|app | at Server.listen (net.js:1447:7) 0|app | at Function.listen (/opt/bitnami/apache/htdocs/node_modules/express/lib/application.js:618:24) 0|app | at Object.<anonymous> (/opt/bitnami/apache/htdocs/app.js:44:5) 0|app | at Module._compile (internal/modules/cjs/loader.js:1137:30) 0|app | at Object.Module._extensions..js (internal/modules/cjs/loader.js:1157:10) 0|app | at Module.load (internal/modules/cjs/loader.js:985:32) 0|app | at Function.Module._load (internal/modules/cjs/loader.js:878:14) 0|app | at Object.<anonymous> (/opt/bitnami/node/lib/node_modules/pm2/lib/ProcessContainerFork.js:33:23) { 0|app | code: 'EADDRINUSE', 0|app | errno: 'EADDRINUSE', 0|app | syscall: 'listen', 0|app | address: '::', 0|app | port: 443 0|app | } ``` App.js ```js const express = require('express'); const dotenv = require('dotenv'); const app = express(); app.use(express.json()); // for parsing POST bodies dotenv.config(); app.get("/hello", (req, res) => res.send("Hello World!")); app.listen(process.env.PORT, () => { console.log(` App listening on port ${process.env.PORT}!`); }); ``` .env ``` PORT=443 ``` Edit: [pm2 status output](https://i.stack.imgur.com/aSXDK.png)
2020/11/08
[ "https://Stackoverflow.com/questions/64742999", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9206151/" ]
Precision, recall and f1-score values depend on the probability threshold. Changes in the threshold that we select to use as a cut-off to determine that a sample belongs to the positive class will affect the precision, recall and therefore f1-score. I share my attempt to plot precision, recall and f1-score depending on discrimination threshold. The plot also determines the optimal threshold for the dataset and the model to classify a sample as a member of the positive class. The optimal threshold is that at which f1-score is highest by default. ```py import pandas as pd import pathlib import matplotlib.pyplot as plt from matplotlib.ticker import (MultipleLocator, AutoMinorLocator) from sklearn.metrics import confusion_matrix as cm_sklearn from sklearn.metrics import precision_score from sklearn.metrics import recall_score from sklearn.metrics import f1_score def plot_discrimination_threshold(clf, X_test, y_test, argmax='f1', title='Metrics vs Discriminant Threshold', fig_size=(10, 8), dpi=100, save_fig_path=None): """ Plot precision, recall and f1-score vs discriminant threshold for the given pipeline model Parameters ---------- clf : estimator instance (either sklearn.Pipeline, imblearn.Pipeline or a classifier) PRE-FITTED classifier or a PRE-FITTED Pipeline in which the last estimator is a classifier. X_test : pandas.DataFrame of shape (n_samples, n_features) Test features. y_test : pandas.Series of shape (n_samples,) Target values. argmax : str, default: 'f1' Annotate the threshold maximized by the supplied metric. Options: 'f1', 'precision', 'recall' title : str, default ='FPR and FNR vs Discriminant Threshold' Plot title. fig_size : tuple, default = (10, 8) Size (inches) of the plot. dpi : int, default = 100 Image DPI. save_fig_path : str, defaut=None Full path where to save the plot. Will generate the folders if they don't exist already. Returns ------- fig : Matplotlib.pyplot.Figure Figure from matplotlib ax : Matplotlib.pyplot.Axe Axe object from matplotlib """ thresholds = np.linspace(0, 1, 100) precision_ls = [] recall_ls = [] f1_ls = [] fpr_ls = [] fnr_ls = [] # obtain probabilities probs = clf.predict_proba(X_test)[:,1] for threshold in thresholds: # obtain class prediction based on threshold y_predictions = np.where(probs>=threshold, 1, 0) # obtain confusion matrix tn, fp, fn, tp = cm_sklearn(y_test, y_predictions).ravel() # obtain FRP and FNR FPR = fp / (tn + fp) FNR = fn / (tp + fn) # obtain precision, recall and f1 scores precision = precision_score(y_test, y_predictions, average='binary') recall = recall_score(y_test, y_predictions, average='binary') f1 = f1_score(y_test, y_predictions, average='binary') precision_ls.append(precision) recall_ls.append(recall) f1_ls.append(f1) fpr_ls.append(FPR) fnr_ls.append(FNR) metrics = pd.concat([ pd.Series(precision_ls), pd.Series(recall_ls), pd.Series(f1_ls), pd.Series(fpr_ls), pd.Series(fnr_ls)], axis=1) metrics.columns = ['precision', 'recall', 'f1', 'fpr', 'fnr'] metrics.index = thresholds plt.rcParams["figure.facecolor"] = 'white' plt.rcParams["axes.facecolor"] = 'white' plt.rcParams["savefig.facecolor"] = 'white' fig, ax = plt.subplots(1, 1, figsize=fig_size, dpi=dpi) ax.plot(metrics['precision'], label='Precision') ax.plot(metrics['recall'], label='Recall') ax.plot(metrics['f1'], label='f1') ax.plot(metrics['fpr'], label='False Positive Rate (FPR)', linestyle='dotted') ax.plot(metrics['fnr'], label='False Negative Rate (FNR)', linestyle='dotted') # Draw a threshold line disc_threshold = round(metrics[argmax].idxmax(), 2) ax.axvline(x=metrics[argmax].idxmax(), color='black', linestyle='dashed', label="$t_r$="+str(disc_threshold)) ax.xaxis.set_major_locator(MultipleLocator(0.1)) ax.xaxis.set_major_formatter('{x:.1f}') ax.yaxis.set_major_locator(MultipleLocator(0.1)) ax.yaxis.set_major_formatter('{x:.1f}') ax.xaxis.set_minor_locator(MultipleLocator(0.05)) ax.yaxis.set_minor_locator(MultipleLocator(0.05)) ax.tick_params(which='both', width=2) ax.tick_params(which='major', length=7) ax.tick_params(which='minor', length=4, color='black') plt.grid(True) plt.xlabel('Probability Threshold', fontsize=18) plt.ylabel('Scores', fontsize=18) plt.title(title, fontsize=18) leg = ax.legend(loc='best', frameon=True, framealpha=0.7) leg_frame = leg.get_frame() leg_frame.set_color('gold') plt.show() if (save_fig_path != None): path = pathlib.Path(save_fig_path) path.parent.mkdir(parents=True, exist_ok=True) fig.savefig(save_fig_path, dpi=dpi) return fig, ax, disc_threshold ``` [![enter image description here](https://i.stack.imgur.com/gkgLt.png)](https://i.stack.imgur.com/gkgLt.png)
You seem to have a native 90% accuracy ``` delt = predicted - ground_truth # where all but 2 of 20 appear within .4 ``` Other/ more examples of (model) predicted would illustrate ranges perhaps?
732,836
I have a requirement to setup a website that allows users, user blogs, a forum and is flexible enough to add other features via .net. I'm just about to evaluate Umbraco, but for another website that's clearly up the CMS alley, however the aforementioned project needs faster turnaround.
2009/04/09
[ "https://Stackoverflow.com/questions/732836", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13954/" ]
Umbraco supports users, as in backend users with various editing and publishing permissions. There are a couple of blog and comments packages for backend users. Umbraco v4 also has Canvas (editing in place, within the website). It also supports Membership which is front end website 'members'. You could provide blogs for these 'members' using an extension like Doc2Form. Umbraco v4 now uses the standard .NET login controls so it's fairly easy to set up membership & registration. For a forum Umbraco typically is paired with YAF. There is an article on how to do that at <http://www.createsoft.co.uk/blog/> That article describes how to integrate YAF as a .NET control in Umbraco. If you are using Membership for other things, the forum will use a seperate username&password to the membership id. You'll need to ask on the Umbraco forum for info on how to get around that (it has been done) It is easy to use or develop .Net controls in Umbraco. YAF and Doc2Form are 2 examples mentioned here.
Umbraco is great for programmers, though (IMO) not so much for people less technically inclined. It does cater for all the things you have described, though in my experience, the relative lack of documentation make it a bit more difficult to work with users/groups and permissions (this is users and groups of a website not the actual Umbraco app). Otherwise I found Umbraco to be great for any type of site and it is my CMS of choice. NOTE: The last time I used Umbraco was about a year ago, so there might be much more docs now days.
732,836
I have a requirement to setup a website that allows users, user blogs, a forum and is flexible enough to add other features via .net. I'm just about to evaluate Umbraco, but for another website that's clearly up the CMS alley, however the aforementioned project needs faster turnaround.
2009/04/09
[ "https://Stackoverflow.com/questions/732836", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13954/" ]
Umbraco is great for programmers, though (IMO) not so much for people less technically inclined. It does cater for all the things you have described, though in my experience, the relative lack of documentation make it a bit more difficult to work with users/groups and permissions (this is users and groups of a website not the actual Umbraco app). Otherwise I found Umbraco to be great for any type of site and it is my CMS of choice. NOTE: The last time I used Umbraco was about a year ago, so there might be much more docs now days.
For learning, umbraco.tv has been great. Its worth a subscription for a month or two at least just to get up to speed quickly.
732,836
I have a requirement to setup a website that allows users, user blogs, a forum and is flexible enough to add other features via .net. I'm just about to evaluate Umbraco, but for another website that's clearly up the CMS alley, however the aforementioned project needs faster turnaround.
2009/04/09
[ "https://Stackoverflow.com/questions/732836", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13954/" ]
Umbraco is great for programmers, though (IMO) not so much for people less technically inclined. It does cater for all the things you have described, though in my experience, the relative lack of documentation make it a bit more difficult to work with users/groups and permissions (this is users and groups of a website not the actual Umbraco app). Otherwise I found Umbraco to be great for any type of site and it is my CMS of choice. NOTE: The last time I used Umbraco was about a year ago, so there might be much more docs now days.
use simple form package or nforum package for such like requirement. Here is the link of Simple form,where u may download this package ``` http://our.umbraco.org/projects/developer-tools/simple-forms ```
732,836
I have a requirement to setup a website that allows users, user blogs, a forum and is flexible enough to add other features via .net. I'm just about to evaluate Umbraco, but for another website that's clearly up the CMS alley, however the aforementioned project needs faster turnaround.
2009/04/09
[ "https://Stackoverflow.com/questions/732836", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13954/" ]
Umbraco supports users, as in backend users with various editing and publishing permissions. There are a couple of blog and comments packages for backend users. Umbraco v4 also has Canvas (editing in place, within the website). It also supports Membership which is front end website 'members'. You could provide blogs for these 'members' using an extension like Doc2Form. Umbraco v4 now uses the standard .NET login controls so it's fairly easy to set up membership & registration. For a forum Umbraco typically is paired with YAF. There is an article on how to do that at <http://www.createsoft.co.uk/blog/> That article describes how to integrate YAF as a .NET control in Umbraco. If you are using Membership for other things, the forum will use a seperate username&password to the membership id. You'll need to ask on the Umbraco forum for info on how to get around that (it has been done) It is easy to use or develop .Net controls in Umbraco. YAF and Doc2Form are 2 examples mentioned here.
For learning, umbraco.tv has been great. Its worth a subscription for a month or two at least just to get up to speed quickly.
732,836
I have a requirement to setup a website that allows users, user blogs, a forum and is flexible enough to add other features via .net. I'm just about to evaluate Umbraco, but for another website that's clearly up the CMS alley, however the aforementioned project needs faster turnaround.
2009/04/09
[ "https://Stackoverflow.com/questions/732836", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13954/" ]
Umbraco supports users, as in backend users with various editing and publishing permissions. There are a couple of blog and comments packages for backend users. Umbraco v4 also has Canvas (editing in place, within the website). It also supports Membership which is front end website 'members'. You could provide blogs for these 'members' using an extension like Doc2Form. Umbraco v4 now uses the standard .NET login controls so it's fairly easy to set up membership & registration. For a forum Umbraco typically is paired with YAF. There is an article on how to do that at <http://www.createsoft.co.uk/blog/> That article describes how to integrate YAF as a .NET control in Umbraco. If you are using Membership for other things, the forum will use a seperate username&password to the membership id. You'll need to ask on the Umbraco forum for info on how to get around that (it has been done) It is easy to use or develop .Net controls in Umbraco. YAF and Doc2Form are 2 examples mentioned here.
Umbraco is a brilliant CMS - my personal favourite. It can be a bit over-whelming at the start (especially if you don't like XSLT) but it is so flexible and can do anything! * Umbraco has built in membership system which is very easy to use and you can also use custom .net membership providers. * [Blog4Umbraco is a great Umbraco blog package](http://www.nibble.be/?p=57) (don't use Doc2Form!). * Whilst YAF is good, there is a new forum package for Umnbraco called [uForum](http://our.umbraco.org/projects/uforum-basics) - this actually powers the [OurUmbraco Forum](http://our.umbraco.org/forum). * Umbraco can be extended easily via .NET controls or XSLT (it has a full API).
732,836
I have a requirement to setup a website that allows users, user blogs, a forum and is flexible enough to add other features via .net. I'm just about to evaluate Umbraco, but for another website that's clearly up the CMS alley, however the aforementioned project needs faster turnaround.
2009/04/09
[ "https://Stackoverflow.com/questions/732836", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13954/" ]
Umbraco supports users, as in backend users with various editing and publishing permissions. There are a couple of blog and comments packages for backend users. Umbraco v4 also has Canvas (editing in place, within the website). It also supports Membership which is front end website 'members'. You could provide blogs for these 'members' using an extension like Doc2Form. Umbraco v4 now uses the standard .NET login controls so it's fairly easy to set up membership & registration. For a forum Umbraco typically is paired with YAF. There is an article on how to do that at <http://www.createsoft.co.uk/blog/> That article describes how to integrate YAF as a .NET control in Umbraco. If you are using Membership for other things, the forum will use a seperate username&password to the membership id. You'll need to ask on the Umbraco forum for info on how to get around that (it has been done) It is easy to use or develop .Net controls in Umbraco. YAF and Doc2Form are 2 examples mentioned here.
use simple form package or nforum package for such like requirement. Here is the link of Simple form,where u may download this package ``` http://our.umbraco.org/projects/developer-tools/simple-forms ```
732,836
I have a requirement to setup a website that allows users, user blogs, a forum and is flexible enough to add other features via .net. I'm just about to evaluate Umbraco, but for another website that's clearly up the CMS alley, however the aforementioned project needs faster turnaround.
2009/04/09
[ "https://Stackoverflow.com/questions/732836", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13954/" ]
Umbraco is a brilliant CMS - my personal favourite. It can be a bit over-whelming at the start (especially if you don't like XSLT) but it is so flexible and can do anything! * Umbraco has built in membership system which is very easy to use and you can also use custom .net membership providers. * [Blog4Umbraco is a great Umbraco blog package](http://www.nibble.be/?p=57) (don't use Doc2Form!). * Whilst YAF is good, there is a new forum package for Umnbraco called [uForum](http://our.umbraco.org/projects/uforum-basics) - this actually powers the [OurUmbraco Forum](http://our.umbraco.org/forum). * Umbraco can be extended easily via .NET controls or XSLT (it has a full API).
For learning, umbraco.tv has been great. Its worth a subscription for a month or two at least just to get up to speed quickly.
732,836
I have a requirement to setup a website that allows users, user blogs, a forum and is flexible enough to add other features via .net. I'm just about to evaluate Umbraco, but for another website that's clearly up the CMS alley, however the aforementioned project needs faster turnaround.
2009/04/09
[ "https://Stackoverflow.com/questions/732836", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13954/" ]
Umbraco is a brilliant CMS - my personal favourite. It can be a bit over-whelming at the start (especially if you don't like XSLT) but it is so flexible and can do anything! * Umbraco has built in membership system which is very easy to use and you can also use custom .net membership providers. * [Blog4Umbraco is a great Umbraco blog package](http://www.nibble.be/?p=57) (don't use Doc2Form!). * Whilst YAF is good, there is a new forum package for Umnbraco called [uForum](http://our.umbraco.org/projects/uforum-basics) - this actually powers the [OurUmbraco Forum](http://our.umbraco.org/forum). * Umbraco can be extended easily via .NET controls or XSLT (it has a full API).
use simple form package or nforum package for such like requirement. Here is the link of Simple form,where u may download this package ``` http://our.umbraco.org/projects/developer-tools/simple-forms ```
7,949,015
How do I go about drawing my own custom selection style for a view based `NSTableView`? I tried putting a `BOOL` var in my `NSTableCellView` subclass and set that to `YES` if it is clicked and then I can successfully draw my custom selection. But how do I change that `BOOL` var to `NO` when another view is clicked? Thanks for any help. EDIT: After reading through the NSTableView docs, it looks like I need to subclass NSTableRowView to override the selection drawing, but what do I do with my NSTableRowView subclass? How do I get the table to use it?
2011/10/31
[ "https://Stackoverflow.com/questions/7949015", "https://Stackoverflow.com", "https://Stackoverflow.com/users/639668/" ]
Alright, I figured it out. You just have to subclass `NSTableRowView`. It has methods for drawing the background for selected and deselected rows. To get the table view to use your subclass just implement the table view delegate method `tableView:rowViewForRow:` and return an instance of your subclass.
To make things clear, I think we should give the code of the delegate method : ``` - (NSTableRowView *)tableView:(NSTableView *)tableView rowViewForRow:(NSInteger)row { MyNSTableRowView *rowView = [[MyNSTableRowView alloc]init]; return rowView; } ```
72,383,721
I have patients with baseline pain scores and follow up of 6 months, 1 year and 2 years (each their own variable column). I have 26,000+ patients. There is missing data at those various time points. I can easily analyse pain score outcomes at one year excluding missing, 6mths and two years etc.... What I would like to do is analyse outcomes in those with data at EITHER 6mths, one year or two year. Some patients will have more than one and some will have missing data for all three. Any ideas how to code this? Maybe another column with mutate() ... that creates 'vas.outcome' and then in this variable I can have one-year data, if missing one-year then two-year, and if missing two-year then 6-month. If all three missing then code as NA. ``` # A tibble: 6 x 4 vas.base vas.6mth vas.year vas.two <dbl> <dbl> <dbl> <dbl> 1 5 NA NA 4 2 9 2.3 1.2 NA 3 8.1 NA NA NA 4 10 NA NA 3.3 5 6.5 6.5 NA NA 6 8 NA NA 3 ```
2022/05/25
[ "https://Stackoverflow.com/questions/72383721", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17413243/" ]
one approach: ``` library(dplyr) your_data_frame %>% mutate(vas.outcome = coalesce(vas.6mth, vas.year, vas.two)) ```
I'm not 100% sure what you want your final dataset to look like, and I'm sure there are more elegant ways, but to choose the first occurrence of an outcome (after baseline), you can do: Data ``` df <- read.table(text = "id vas.base vas.6mth vas.year vas.two 1 5 NA NA 4 2 9 2.3 1.2 NA 3 8.1 NA NA NA 4 10 NA NA 3.3 5 6.5 6.5 NA NA 6 8 NA NA 3", header = TRUE) ``` `dplyr` approach: ``` library(tidyr) df %>% pivot_longer(starts_with("vas")[-1], names_to = "visit") %>% group_by(id) %>% mutate(vas.outcome = first(na.omit(value))) %>% slice(1) %>% select(id, vas.outcome) %>% left_join(df, by = "id") ``` Output: ``` # id vas.outcome vas.base vas.6mth vas.year vas.two # <int> <dbl> <dbl> <dbl> <dbl> <dbl> # 1 1 4 5 NA NA 4 # 2 2 2.3 9 2.3 1.2 NA # 3 3 NA 8.1 NA NA NA # 4 4 3.3 10 NA NA 3.3 # 5 5 6.5 6.5 6.5 NA NA # 6 6 3 8 NA NA 3 ```
72,383,721
I have patients with baseline pain scores and follow up of 6 months, 1 year and 2 years (each their own variable column). I have 26,000+ patients. There is missing data at those various time points. I can easily analyse pain score outcomes at one year excluding missing, 6mths and two years etc.... What I would like to do is analyse outcomes in those with data at EITHER 6mths, one year or two year. Some patients will have more than one and some will have missing data for all three. Any ideas how to code this? Maybe another column with mutate() ... that creates 'vas.outcome' and then in this variable I can have one-year data, if missing one-year then two-year, and if missing two-year then 6-month. If all three missing then code as NA. ``` # A tibble: 6 x 4 vas.base vas.6mth vas.year vas.two <dbl> <dbl> <dbl> <dbl> 1 5 NA NA 4 2 9 2.3 1.2 NA 3 8.1 NA NA NA 4 10 NA NA 3.3 5 6.5 6.5 NA NA 6 8 NA NA 3 ```
2022/05/25
[ "https://Stackoverflow.com/questions/72383721", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17413243/" ]
one approach: ``` library(dplyr) your_data_frame %>% mutate(vas.outcome = coalesce(vas.6mth, vas.year, vas.two)) ```
You could use a `case_when()/fcase()` approach ``` dt[, pain:=fcase( !is.na(vas.year), vas.year, !is.na(vas.two), vas.two, !is.na(vas.6mth), vas.6mth, default = NA )] ``` or ``` dt %>% mutate(pain:=case_when( !is.na(vas.year)~vas.year, !is.na(vas.two)~vas.two, TRUE~vas.6mth )) ``` Output: ``` vas.base vas.6mth vas.year vas.two pain 1: 5.0 NA NA 4.0 4.0 2: 9.0 2.3 1.2 NA 1.2 3: 8.1 NA NA NA NA 4: 10.0 NA NA 3.3 3.3 5: 6.5 6.5 NA NA 6.5 6: 8.0 NA NA 3.0 3.0 ```
654,204
Find all linear fractional transformation that maps {$z:Im(z)>0$} to {$w:|w|<1$} I don't know anything about this.. Can you help me?
2014/01/28
[ "https://math.stackexchange.com/questions/654204", "https://math.stackexchange.com", "https://math.stackexchange.com/users/114952/" ]
**Theorem:** If $d\equiv 1\pmod{4}$, then $\mathcal{O}\_{\mathbf{Q}[\sqrt{d}]}=\mathbf{Z}\left[\frac{-1+\sqrt{d}}{2}\right]$. Otherwise, $\mathcal{O}\_{\mathbf{Q}[\sqrt{d}]}=\mathbf{Z}[\sqrt{d}]$. *Proof:* Let $\alpha=r+s\sqrt{d}\in\mathbf{Q}(\sqrt{d})$. Then, $\alpha\in\mathcal{O}\_{\mathbf{Q}[\sqrt{d}]}$ iff $2r, r^2-s^2d\in\mathbf{Z}$. Clearly $2r\in\mathbf{Z}$, so $4s^2d\in\mathbf{Z}$, and since $d$ is squarefree, $2s\in\mathbf{Z}$. Substituting $m=2r, n=2s$, we get $r^2-ds^2\in\mathbf{Z}\implies 4|(m^2-dn^2)$. Now, if $d\equiv 2,3\pmod{4}$, then $$m^2-dn^2\equiv m^2+2n^2, m^2+n^2\pmod{4}.$$ Note that for these to be divisible by $4$, we must have that $m,n$ are both even, which happens iff $r,s\in\mathbf{Z}$, so this takes care of the case where $d\not\equiv 1\pmod{4}$. Now if $d\equiv 1\pmod{4}$, then $m^2-dn^2\equiv m^2-n^2\pmod{4}$, but since $4|(m^2-n^2)$ iff $m\equiv n\pmod{2}$, we get $$\mathcal{O}\_{\mathbf{Q}(\sqrt{d})}=\left\{\frac{m+n\sqrt{d}}{2}:m\equiv n\pmod{2}\right\}.$$ Now, note that $$\frac{1}{2}(m+n\sqrt{d})=\frac{m+n}{2}+n\left(\frac{-1+\sqrt{d}}{2}\right).$$ Since $m$ and $n$ have the same parity, $\frac{m+n}{2}$ is an integer, so $\mathcal{O}\_{\mathbf{Q}(\sqrt{d})}\subset \mathbf{Z}+\frac{-1+\sqrt{d}}{2}\mathbf{Z}$, and to see the reverse just note that since $d$ is of the shape $4k+1$, $\frac{1}{2}(-1+\sqrt{d})\in\mathcal{O}\_{\mathbf{Q}(\sqrt{d})}$, so we're done. $\Box$ $17\equiv 1\pmod{4}$, so $\mathcal{O}\_{\mathbf{Q}[\sqrt{17}]}=\mathbf{Z}\left[\frac{-1+\sqrt{17}}{2}\right]$.
Let $D$ be a squarefree number. The element $a+b\sqrt{D}\in\Bbb Q(\sqrt{D})=K$ has minimal polynomial $$x^2-2ax+(a^2-Db^2).$$ Thus $a+b\sqrt{d}\in{\cal O}\_K\Leftrightarrow a\in\frac{1}{2}\Bbb Z,a^2-Db^2\in\Bbb Z$. If $b$ is not an integer, then can $a$ an integer? And, furthermore, what is the only possible denominator for $b$? Now try to show that $a,b$ can be the appropriate types of fractions if and only if $D$ is a quadratic residue mod $4$.
31,081,468
I'm trying to write my first module in Ansible, which is essentially a wrapper around another module. Here is my module: ``` #!/usr/bin/python import ansible.runner import sys def main(): module.exit_json(changed=False) from ansible.module_utils.basic import * main() ``` and here is the error it gives me (stripped from 'msg'): > > ImportError: No module named ansible.runner > > > I am on ubuntu and installed ansible with aptitude, version is 1.9.1 Any ideas?
2015/06/26
[ "https://Stackoverflow.com/questions/31081468", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5025644/" ]
There is the `indexPathForSelectedRow` definition in **Swift 1.2**: ``` - (NSIndexPath *)indexPathForSelectedRow; // returns nil or index path representing section and row of selection. ``` There is its definition in **Swift 2.0**: ``` var indexPathForSelectedRow: NSIndexPath? { get } // returns nil or index path representing section and row of selection. ``` In Swift 2.0, the `indexPathForSelectedRow` is a property not a method, so you should change: ``` let indexpath = tableView.indexPathForSelectedRow() ``` to ``` let indexpath = tableView.indexPathForSelectedRow ```
Sounds like there is no reference to `tableView` or it's not of type `UITableView`.
31,081,468
I'm trying to write my first module in Ansible, which is essentially a wrapper around another module. Here is my module: ``` #!/usr/bin/python import ansible.runner import sys def main(): module.exit_json(changed=False) from ansible.module_utils.basic import * main() ``` and here is the error it gives me (stripped from 'msg'): > > ImportError: No module named ansible.runner > > > I am on ubuntu and installed ansible with aptitude, version is 1.9.1 Any ideas?
2015/06/26
[ "https://Stackoverflow.com/questions/31081468", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5025644/" ]
There is the `indexPathForSelectedRow` definition in **Swift 1.2**: ``` - (NSIndexPath *)indexPathForSelectedRow; // returns nil or index path representing section and row of selection. ``` There is its definition in **Swift 2.0**: ``` var indexPathForSelectedRow: NSIndexPath? { get } // returns nil or index path representing section and row of selection. ``` In Swift 2.0, the `indexPathForSelectedRow` is a property not a method, so you should change: ``` let indexpath = tableView.indexPathForSelectedRow() ``` to ``` let indexpath = tableView.indexPathForSelectedRow ```
``` override func prepareForSegue(segue: UIStoryboardSegue , sender: AnyObject?) { if segue.identifier == "show" { let indexpath = self.tableView.indexPathsForSelectedRows()! let detailv:fiveViewController = segue.destinationViewController as! fiveViewController detailv.pic = self.menu[indexpath.row].picName } ``` this link for the pic " my problem " [![](https://i.stack.imgur.com/hsx3G.jpg)](https://i.stack.imgur.com/hsx3G.jpg)
43,050,866
Assume I have a function like below: ``` void func1(...) { ... ... func2(...); ... ... } ``` In the compilation phase, I call the `func1()` function in two places. However, in one of the places I don't want the `func2()` to be executed. So, I need two versions of `func1()` during **compilation**: one **with** `func2()` and one **without** `func2()`. I know about following approaches. They require deforming the current source, which I hesitate to do 1. Putting the whole body of function in `#define` -> then defining two functions with different names using this macro. 2. Putting the body of the function into another header file and using `#define` macros to control the execution path. Do you know any other methods besides above methods?
2017/03/27
[ "https://Stackoverflow.com/questions/43050866", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1609345/" ]
A pretty common way is to define a token and wrap the call in an `#ifdef` block (checking for the token), no need to duplicate `func1` i.e. : ``` #define _INCLUDE_FUNC2_BUILD// or something void func1(...) { ... ... #ifdef _INCLUDE_FUNC2_BUILD func2(...); #endif // _INCLUDE_FUNC2_BUILD ... ... } ``` Obviously it's up to you how/where you want to include the `#define` you could use something like [Jam](https://www.perforce.com/resources/documentation/jam).
Rather than conditional compilation, especially if the rest of the function is substantial, you can pass a parameter to indicate whether `func2()` should be called. The function might be defined as: ``` void func1(..., bool call_func2) { ... ... if (call_func2) func2(...); ... ... } ``` and one call might be `func1(..., true)` and the other `func1(..., false)`. If you decide you sometimes need to call `func2()`, and sometimes `func3()`, and sometimes nothing, you might change the function parameter into a pointer to function: ``` void func1(..., void (*funcN)(...)) { ... ... if (funcN) funcN(...); ... ... } ``` and then you can have `func1(..., func2)`, `func1(..., func3)`, and `func1(..., NULL)`. Ring the changes to suit. Note that the function pointer scheme assumes that the `funcN` functions have a uniform interface. Otherwise, look to see whether you need to refactor the function. ``` void func1A(...) { ... ... ...before call to func2... } void func1B(...) { ...after call to func2... ... ... } void func1(...) { func1A(...); func1B(...); } void func1plus2(...) { func1A(...); func2(...); func1B(...); } ``` These are all better than `#ifdef` conditional compilation. In the first instance, I'd probably go with the flag variable in the interface.
16,501,293
So, this is a part of my "linked\_list.h" header: ``` template <typename T> class Linked_list { public: Linked_list(); ~Linked_list(); void add_first(const T& x); //... }; ``` And a part of my implementation: ``` template <typename T> line 22: void Linked_list<T> :: add_first(const T& x) { Node<T>* aux; aux = new Node<T>; aux->info = x; aux->prev = nil; aux->next = nil->next; nil->next->prev = aux; nil->next = aux; } ``` and I'm trying to make a linked list of linked lists of strings and add strings in one linked list of my linked list, like this: ``` Linked_list<Linked_list<string> > *l; l[0]->add_first("list"); //also I've tried l[0].add_first("list"); but it didn't work either ``` Thank you. Later edit: When I try l[0]->add\_first("list") these are the errors: ``` main.cc: In function ‘int main()’: main.cc:22:22: error: no matching function for call to‘Linked_list<Linked_list<std::basic_string<char> > >::add_first(const char [4])’ main.cc:22:22: note: candidate is: In file included from main.cc:6:0: linked_list.cc:28:6: note: void Linked_list<T>::add_first(const T&) [with T = Linked_list<std::basic_string<char> >] linked_list.cc:28:6: note: no known conversion for argument 1 from ‘const char [4]’ to ‘const Linked_list<std::basic_string<char> >&’ ``` Later later edit: It worked finally, thank you for the ideas: I did just this and it's okay now: ``` Linked_list<Linked_list<string> > l; l[0].add_first("list"); ``` And it works :D. Thanks again ! Neah..actually it doesn't work..
2013/05/11
[ "https://Stackoverflow.com/questions/16501293", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1261480/" ]
``` App.ViewModel.Items.Insert(0, new ItemViewModel() { ThingOne = "Blah", ThingTwo = "BlahBlahBlah"}); ```
> > Can I specify this behavior within the Items.Add() statement? > > > User `Insert` instead :[Collection.Insert Method](http://msdn.microsoft.com/en-us/library/ms132411%28v=vs.100%29.aspx)
2,971
I love that video of Ben Burt showing how he made winds for WALL-E by dragging that boxing bag around on a lino floor - see at 7 minutes in this video <http://www.youtube.com/watch?v=TSf8Er2gV_Q> So what interesting things have you done to create wind sounds? (No fart jokes thanks) I'm working on a short film Goutte d'Or at the moment and just made some spooky winds using howling wolves pitched down 2 octaves and same for dragging a heavy wooden couch around on a wood floor....
2010/08/20
[ "https://sound.stackexchange.com/questions/2971", "https://sound.stackexchange.com", "https://sound.stackexchange.com/users/-1/" ]
Forgive me if I go a little off topic but for the last few days I've been wanting to try something; make a really spooky wind sound with a voice element. Here's what I did... Open izotopeRX DeNoiser and train it using a voice recording (a crowd in a concert hall), then apply that to some wind. [THIS](http://soundcloud.com/ianjpalmer/heavy-wind) is the original wind, [THIS](http://soundcloud.com/ianjpalmer/crowdconcerthall) is the crowd, [THIS](http://soundcloud.com/ianjpalmer/heavy-wind-rxdenoise) is the result All the sounds are from the library at work, they've been relabeled so not sure which library exactly. Might have to have a bash at your ideas too somewhen @Tim @Jay
Always having a recorder is half the battle; got some amazing wind sounds in a cabin on NZ's Queen Charlotte Track. Anywhere there are wires or small holes and high winds, set your ears to "stun." Another classic is holding blankets or foam over air conditioners. This can create wind whistles you can "play," although one may have to filter out the machinery noise...but sometimes those whistles get loud enough to provide a decent signal:noise ratio.
2,971
I love that video of Ben Burt showing how he made winds for WALL-E by dragging that boxing bag around on a lino floor - see at 7 minutes in this video <http://www.youtube.com/watch?v=TSf8Er2gV_Q> So what interesting things have you done to create wind sounds? (No fart jokes thanks) I'm working on a short film Goutte d'Or at the moment and just made some spooky winds using howling wolves pitched down 2 octaves and same for dragging a heavy wooden couch around on a wood floor....
2010/08/20
[ "https://sound.stackexchange.com/questions/2971", "https://sound.stackexchange.com", "https://sound.stackexchange.com/users/-1/" ]
what a cool topic! i have a studio door that when its half-cracked makes the craziest whining wind sound. I've been meaning to record it for years, but I'd better do it before we move out of this building. I'll post an update when I have it done.
I was going to create a desert wind loop for a fps videogame and decided to have a look around... Thanks to the great solutions presented here I finally find the most suitable as follows: I have basically 2 tracks, one is a sound I recorded in my tent one very windy night on a very windy peak, I slowed it down with paulstretch (what an aweseome tool!!), eqed it enhancing around 90hz and 770hz, hicut above, the second sound is a pink noise track with a wide reverb and a narrow bandpass filter that I automated moving it very slowly and in small amounts at a time to avoid making it sound like a sci-fi laser. That's it for now, as the game design goes on I'm planning to record some recorder's whistles and squeaks to be assigned to buildings corners and I already recorded some spelt flour rolling on a sheet, to simulate sand gusts to assign to certain areas.
2,971
I love that video of Ben Burt showing how he made winds for WALL-E by dragging that boxing bag around on a lino floor - see at 7 minutes in this video <http://www.youtube.com/watch?v=TSf8Er2gV_Q> So what interesting things have you done to create wind sounds? (No fart jokes thanks) I'm working on a short film Goutte d'Or at the moment and just made some spooky winds using howling wolves pitched down 2 octaves and same for dragging a heavy wooden couch around on a wood floor....
2010/08/20
[ "https://sound.stackexchange.com/questions/2971", "https://sound.stackexchange.com", "https://sound.stackexchange.com/users/-1/" ]
Great timing! I have been working on some eerie wind today. Its still a bit of a work in progress but seems to be coming out ok. I have been stretching some cable swishes (bet you've got a few of them lying around Tim) with [paulstretch](http://hypermammut.sourceforge.net/paulstretch/) then adding a little bit of eq, reverb & delay to each individual swish. Example <http://soundcloud.com/andrew-quinn/wind02>
what a cool topic! i have a studio door that when its half-cracked makes the craziest whining wind sound. I've been meaning to record it for years, but I'd better do it before we move out of this building. I'll post an update when I have it done.
2,971
I love that video of Ben Burt showing how he made winds for WALL-E by dragging that boxing bag around on a lino floor - see at 7 minutes in this video <http://www.youtube.com/watch?v=TSf8Er2gV_Q> So what interesting things have you done to create wind sounds? (No fart jokes thanks) I'm working on a short film Goutte d'Or at the moment and just made some spooky winds using howling wolves pitched down 2 octaves and same for dragging a heavy wooden couch around on a wood floor....
2010/08/20
[ "https://sound.stackexchange.com/questions/2971", "https://sound.stackexchange.com", "https://sound.stackexchange.com/users/-1/" ]
Great timing! I have been working on some eerie wind today. Its still a bit of a work in progress but seems to be coming out ok. I have been stretching some cable swishes (bet you've got a few of them lying around Tim) with [paulstretch](http://hypermammut.sourceforge.net/paulstretch/) then adding a little bit of eq, reverb & delay to each individual swish. Example <http://soundcloud.com/andrew-quinn/wind02>
white or pink noise tones with audiosuite EQs, pitch shift, and a slow doppler, and then i let UDK do the rest, oscillation, pitch variation etc.
2,971
I love that video of Ben Burt showing how he made winds for WALL-E by dragging that boxing bag around on a lino floor - see at 7 minutes in this video <http://www.youtube.com/watch?v=TSf8Er2gV_Q> So what interesting things have you done to create wind sounds? (No fart jokes thanks) I'm working on a short film Goutte d'Or at the moment and just made some spooky winds using howling wolves pitched down 2 octaves and same for dragging a heavy wooden couch around on a wood floor....
2010/08/20
[ "https://sound.stackexchange.com/questions/2971", "https://sound.stackexchange.com", "https://sound.stackexchange.com/users/-1/" ]
Always having a recorder is half the battle; got some amazing wind sounds in a cabin on NZ's Queen Charlotte Track. Anywhere there are wires or small holes and high winds, set your ears to "stun." Another classic is holding blankets or foam over air conditioners. This can create wind whistles you can "play," although one may have to filter out the machinery noise...but sometimes those whistles get loud enough to provide a decent signal:noise ratio.
I might be lending the thread a bit, but I'm looking for a particular type of wind and would like to know if anyone knows libraries which might include what I'm looking for. My last resort is to try to whistle or synthesize it. What I'm looking for is this type of howling wind (00:10 onwards): <http://www.soundsnap.com/node/10399>. But that particular recording obviously has very bad quality.
2,971
I love that video of Ben Burt showing how he made winds for WALL-E by dragging that boxing bag around on a lino floor - see at 7 minutes in this video <http://www.youtube.com/watch?v=TSf8Er2gV_Q> So what interesting things have you done to create wind sounds? (No fart jokes thanks) I'm working on a short film Goutte d'Or at the moment and just made some spooky winds using howling wolves pitched down 2 octaves and same for dragging a heavy wooden couch around on a wood floor....
2010/08/20
[ "https://sound.stackexchange.com/questions/2971", "https://sound.stackexchange.com", "https://sound.stackexchange.com/users/-1/" ]
Great timing! I have been working on some eerie wind today. Its still a bit of a work in progress but seems to be coming out ok. I have been stretching some cable swishes (bet you've got a few of them lying around Tim) with [paulstretch](http://hypermammut.sourceforge.net/paulstretch/) then adding a little bit of eq, reverb & delay to each individual swish. Example <http://soundcloud.com/andrew-quinn/wind02>
Always having a recorder is half the battle; got some amazing wind sounds in a cabin on NZ's Queen Charlotte Track. Anywhere there are wires or small holes and high winds, set your ears to "stun." Another classic is holding blankets or foam over air conditioners. This can create wind whistles you can "play," although one may have to filter out the machinery noise...but sometimes those whistles get loud enough to provide a decent signal:noise ratio.
2,971
I love that video of Ben Burt showing how he made winds for WALL-E by dragging that boxing bag around on a lino floor - see at 7 minutes in this video <http://www.youtube.com/watch?v=TSf8Er2gV_Q> So what interesting things have you done to create wind sounds? (No fart jokes thanks) I'm working on a short film Goutte d'Or at the moment and just made some spooky winds using howling wolves pitched down 2 octaves and same for dragging a heavy wooden couch around on a wood floor....
2010/08/20
[ "https://sound.stackexchange.com/questions/2971", "https://sound.stackexchange.com", "https://sound.stackexchange.com/users/-1/" ]
Great timing! I have been working on some eerie wind today. Its still a bit of a work in progress but seems to be coming out ok. I have been stretching some cable swishes (bet you've got a few of them lying around Tim) with [paulstretch](http://hypermammut.sourceforge.net/paulstretch/) then adding a little bit of eq, reverb & delay to each individual swish. Example <http://soundcloud.com/andrew-quinn/wind02>
Not my own trick, but I've always been impressed with how Richard King and crew created the windstorm sounds in the movie Master and Commander. They basically rigged a flatbed truck with a bunch of interesting props and took it out to the Mojave Desert, got it up to 70mph or so and recorded. Brilliant: Magazine piece: <http://www.newyorker.com/archive/2003/10/20/031020fa_fact1> Radio piece: <http://www.npr.org/templates/story/story.php?storyId=1505241>
2,971
I love that video of Ben Burt showing how he made winds for WALL-E by dragging that boxing bag around on a lino floor - see at 7 minutes in this video <http://www.youtube.com/watch?v=TSf8Er2gV_Q> So what interesting things have you done to create wind sounds? (No fart jokes thanks) I'm working on a short film Goutte d'Or at the moment and just made some spooky winds using howling wolves pitched down 2 octaves and same for dragging a heavy wooden couch around on a wood floor....
2010/08/20
[ "https://sound.stackexchange.com/questions/2971", "https://sound.stackexchange.com", "https://sound.stackexchange.com/users/-1/" ]
Recently, I undertook the same task and ended up taking a different route - which was not entirely successful but, with more time spent, could be well worth it. I went through my library and pulled as many whispering fx as I could find and then used those as IRs for Altiverb. The idea was to process regular wind recordings through those IRs and come out the other side with "whispering winds". Again, time got the better of me and I wasn't able to fully realize my vision, but I'm keeping those IRs for another go round sometime in the future.
what a cool topic! i have a studio door that when its half-cracked makes the craziest whining wind sound. I've been meaning to record it for years, but I'd better do it before we move out of this building. I'll post an update when I have it done.
2,971
I love that video of Ben Burt showing how he made winds for WALL-E by dragging that boxing bag around on a lino floor - see at 7 minutes in this video <http://www.youtube.com/watch?v=TSf8Er2gV_Q> So what interesting things have you done to create wind sounds? (No fart jokes thanks) I'm working on a short film Goutte d'Or at the moment and just made some spooky winds using howling wolves pitched down 2 octaves and same for dragging a heavy wooden couch around on a wood floor....
2010/08/20
[ "https://sound.stackexchange.com/questions/2971", "https://sound.stackexchange.com", "https://sound.stackexchange.com/users/-1/" ]
Not my own trick, but I've always been impressed with how Richard King and crew created the windstorm sounds in the movie Master and Commander. They basically rigged a flatbed truck with a bunch of interesting props and took it out to the Mojave Desert, got it up to 70mph or so and recorded. Brilliant: Magazine piece: <http://www.newyorker.com/archive/2003/10/20/031020fa_fact1> Radio piece: <http://www.npr.org/templates/story/story.php?storyId=1505241>
I might be lending the thread a bit, but I'm looking for a particular type of wind and would like to know if anyone knows libraries which might include what I'm looking for. My last resort is to try to whistle or synthesize it. What I'm looking for is this type of howling wind (00:10 onwards): <http://www.soundsnap.com/node/10399>. But that particular recording obviously has very bad quality.
2,971
I love that video of Ben Burt showing how he made winds for WALL-E by dragging that boxing bag around on a lino floor - see at 7 minutes in this video <http://www.youtube.com/watch?v=TSf8Er2gV_Q> So what interesting things have you done to create wind sounds? (No fart jokes thanks) I'm working on a short film Goutte d'Or at the moment and just made some spooky winds using howling wolves pitched down 2 octaves and same for dragging a heavy wooden couch around on a wood floor....
2010/08/20
[ "https://sound.stackexchange.com/questions/2971", "https://sound.stackexchange.com", "https://sound.stackexchange.com/users/-1/" ]
Great timing! I have been working on some eerie wind today. Its still a bit of a work in progress but seems to be coming out ok. I have been stretching some cable swishes (bet you've got a few of them lying around Tim) with [paulstretch](http://hypermammut.sourceforge.net/paulstretch/) then adding a little bit of eq, reverb & delay to each individual swish. Example <http://soundcloud.com/andrew-quinn/wind02>
I might be lending the thread a bit, but I'm looking for a particular type of wind and would like to know if anyone knows libraries which might include what I'm looking for. My last resort is to try to whistle or synthesize it. What I'm looking for is this type of howling wind (00:10 onwards): <http://www.soundsnap.com/node/10399>. But that particular recording obviously has very bad quality.
26,013,509
I have a textarea and i want type keywords into this and want it add comma automatically after press `Enter` key, for example you type a words or sentence then you press `Enter` key and it will add comma after each words or .. i write a simple code but it have two problem, first it will add comma everytime you press `Enter` and it just will add comma after first words but i want it add comma after each words not just one. second problem is i dont want it goes to new line when you press `Enter`. ``` $('#formID').live("keypress", function(e){ if (e.keyCode == 13) { $("textarea").each(function() { $(this).val($(this).val().replace(/ /g, " ، ")); }); } }); ``` **[JSFiddle](http://jsfiddle.net/HsFbN/100/)**
2014/09/24
[ "https://Stackoverflow.com/questions/26013509", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3815083/" ]
Try this: ``` $('textarea').keypress(function(e){ if (e.keyCode == 13) { // alert($('textarea').val()); $('textarea').val($('textarea').val() + ', '); } }); ```
Hello thank you for question, Try out below code once ```js $('textarea').keypress(function(e){ if (e.keyCode == 13) { e.preventDefault(); $(this).val($(this).val() + ' , ') } }); ``` ```html <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <form id=formID><textarea></textarea><input type=submit></form> ```
29,299,263
I need this time a help with this example: [DEMO](http://plnkr.co/edit/AU4AsLiUpANTRBQHO5as?p=preview) You can see that the css on example **1** goes good. When you click on the button the state of the button change (press) On example **2** i can't do the same. **on my app i need that the "radio button" appear on vertical line (*i get it*)**. But when i press the button, when i click out i back to the first state (don't press) ``` <h4>Exmaple 2</h4> <div class="btn-group" data-toggle="buttons-radio"> <div class="row" ng-repeat="company in vm_login.decimals"> <button type="button" class="btn btn-primary" ng-model="radioModel.id" btn-radio="company.id"> {{company.desc}} </button> </div> </div> ``` ***Can anybody help me?***
2015/03/27
[ "https://Stackoverflow.com/questions/29299263", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4071209/" ]
I got a final version and this is how i need **[DEMO](http://plnkr.co/edit/VLK98Kce7JXy5Zvl1rhK?p=preview)** Thanks for all ``` <div class="btn-group-vertical" > <button ng-repeat="value in vm_login.options" class="btn btn-primary" type="button" ng-model="vm_login.model" btn-radio="value.id"> {{value.desc}} </button> </div> <p>texto aqui: {{vm_login.model}}</p> ```
The `btn-group` classed element expects it's children to be buttons (a `btn` classed element). Not a `div` element. Take out the `div` and move the `ng-repeat` to the actual button. Now if you want your button to align verticaly you'll need to use `btn-group-vertical` instead of `btn-group` as stated in the [bootstrap documentation](http://getbootstrap.com/components/#btn-groups-vertical). Here's the update code: ``` <div class="btn-group-vertical" data-toggle="buttons-radio"> <button ng-repeat="company in vm_login.decimals" type="button" class="btn btn-primary" ng-model="radioModel.id" btn-radio="company.id"> {{company.desc}} </button> </div> ``` Updated Plunker: <http://plnkr.co/edit/kVFqNAXisMgkMVqy0WAF?p=preview>
29,299,263
I need this time a help with this example: [DEMO](http://plnkr.co/edit/AU4AsLiUpANTRBQHO5as?p=preview) You can see that the css on example **1** goes good. When you click on the button the state of the button change (press) On example **2** i can't do the same. **on my app i need that the "radio button" appear on vertical line (*i get it*)**. But when i press the button, when i click out i back to the first state (don't press) ``` <h4>Exmaple 2</h4> <div class="btn-group" data-toggle="buttons-radio"> <div class="row" ng-repeat="company in vm_login.decimals"> <button type="button" class="btn btn-primary" ng-model="radioModel.id" btn-radio="company.id"> {{company.desc}} </button> </div> </div> ``` ***Can anybody help me?***
2015/03/27
[ "https://Stackoverflow.com/questions/29299263", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4071209/" ]
I got a final version and this is how i need **[DEMO](http://plnkr.co/edit/VLK98Kce7JXy5Zvl1rhK?p=preview)** Thanks for all ``` <div class="btn-group-vertical" > <button ng-repeat="value in vm_login.options" class="btn btn-primary" type="button" ng-model="vm_login.model" btn-radio="value.id"> {{value.desc}} </button> </div> <p>texto aqui: {{vm_login.model}}</p> ```
This worked for me try this approach in one line without using buttons: ``` <div class="btn-group"> <label class="btn btn-primary" ng-repeat="company in vm_login.decimals" ng-model="radioModel" ng-model="radioModel.id" btn-radio="company.id">{{company.desc}}</label> </div> ```
7,804,911
on my project I have a huuuuge XSLT used to convert some XML files to HTML. The problem is that this file is growing up day by day, it's hard to read, debug and test. So I was thinking about moving all the parsing process to Java. Do you think is a good idea? In case what libraries to parse XML and generate HTML(XML) do u suggest? performances will be better or worse? If it's not a good idea any alternative idea? Thanks Randomize
2011/10/18
[ "https://Stackoverflow.com/questions/7804911", "https://Stackoverflow.com", "https://Stackoverflow.com/users/324315/" ]
You need to set a locale on the date formatters. ``` NSLocale *locale = [[NSLocale alloc] initWithLocaleIdentifier:@"en_US_POSIX"]; //... formater1.locale = locale; //... formater2.locale = locale; //... [locale release]; ``` If you don't set the locale then user's settings can change the provided string to conform with user's setting, such as change 12h to 24h clock or vice versa.
This could be because the device is not set to english, thus it can't parse the `Tue` and `Oct` in the `pubDat`. Try adding a an locale to the `NSDateFormatter`: ``` [formater1 setLocale:[[[NSLocale alloc] initWithLocaleIdentifier:@"EN"] autorelease]]; ```
455,802
There is a beverage company here that claims to have a selection of 200 different beers. They have a special deal where you can build your own six pack at a discount. They advertise that there are 1.4B ways to build said six pack, and I am trying to determine if they're correct. I thought that this would be a combination with repetition problem. You have $n=200$ items with $r=6$ choices. The formula $$x=(n+r-1)!/(r!(n-1)!)$$ yields $x=95,746,959,700$. Then I tried to work backwards using $x=1400000000$. I plugged $$1400000000=n!(n-1)!(n-2)!(n-3)!(n-4)!(n-5)!$$ into Wolfram Alpha to get the solution. It showed that the alternate form is a gamma function $$1400000000 = Γ(x-4)Γ(x-3)Γ(x-2)Γ(x-1)Γ(x)Γ(x+1)$$ That solution is approximately $n=6.496$. My experience with combinatorics is limited to pre-calculus permutations and combinations, so gamma functions is somethings that I stumbled upon literally half an hour ago. So I ask: How many ways can you build a six pack with 200 beers? Note: I understand that you *could* use $x=n^r$, because technically three Bud Lights and three Coors Lights are different from three Coors Lights and three Bud Lights. The answer for that permutation is $x=64,000,0,000,000$.
2013/07/30
[ "https://math.stackexchange.com/questions/455802", "https://math.stackexchange.com", "https://math.stackexchange.com/users/88308/" ]
I distrust advertising numbers like this. The original [Rubik's cube](http://en.wikipedia.org/wiki/Rubik_cube) promised billions of positions. They were technically correct, the correct number is $43,252,003,274,489,856,000$ or 43 billions of billions. To get it exactly right, you would have to make a list of all the partitions of $6$, figure the multinomial coefficient for each one, and add them up. But calculation of ${200 \choose 6}=82,408,626,300$, the number with six distinct beers, already shows there are many more than $1.4E9$.
If we count permutations as distinct combinations, then it should be $\frac{200!}{194!}$ which is in the order of $10^{13}$. Otherwise it should be $\binom{200}{6}$, which is in the order of $10^{10}$.
455,802
There is a beverage company here that claims to have a selection of 200 different beers. They have a special deal where you can build your own six pack at a discount. They advertise that there are 1.4B ways to build said six pack, and I am trying to determine if they're correct. I thought that this would be a combination with repetition problem. You have $n=200$ items with $r=6$ choices. The formula $$x=(n+r-1)!/(r!(n-1)!)$$ yields $x=95,746,959,700$. Then I tried to work backwards using $x=1400000000$. I plugged $$1400000000=n!(n-1)!(n-2)!(n-3)!(n-4)!(n-5)!$$ into Wolfram Alpha to get the solution. It showed that the alternate form is a gamma function $$1400000000 = Γ(x-4)Γ(x-3)Γ(x-2)Γ(x-1)Γ(x)Γ(x+1)$$ That solution is approximately $n=6.496$. My experience with combinatorics is limited to pre-calculus permutations and combinations, so gamma functions is somethings that I stumbled upon literally half an hour ago. So I ask: How many ways can you build a six pack with 200 beers? Note: I understand that you *could* use $x=n^r$, because technically three Bud Lights and three Coors Lights are different from three Coors Lights and three Bud Lights. The answer for that permutation is $x=64,000,0,000,000$.
2013/07/30
[ "https://math.stackexchange.com/questions/455802", "https://math.stackexchange.com", "https://math.stackexchange.com/users/88308/" ]
Let $(a\_1, \dots, a\_l) \in \mathbb{N}^l$ be notation for $a\_j$ bottles of the $j^{\text{th}}$ beer. We need to consider how many different types of beer there are in the six pack. Obviously, there could be one, two, three, four, five, or six. Let's consider each case individually. **One type:** The only way this can occur is if there are six bottles of the same beer. There are ${200 \choose 1} = 200$ ways of choosing that type. **Two types:** There are three ways this can occur: $(5,1)$, $(4,2)$, and $(3,3)$ - note, the order of the beers (i.e. which type you call first and which you call second) doesn't count. There are ${200 \choose 2}$ ways of choosing the two types of beer. There are three possibilities for the six pack that can be made with those two types. So there are ${200 \choose 2}\times 3 = 59,700$ ways of creating a six pack with two types of beer. **Three types:** There are two ways this can occur: $(4,1,1)$ and $(3,2,1)$. There are ${200 \choose 3}$ ways of choosing the three types of beer. There are two possibilities for the six pack that can be made with those three types. So there are ${200 \choose 3}\times 2 = 2,626,800$ ways of creating a six pack with three types of beer. **Four types:** There are two ways this can occur: $(3,1,1,1)$ and $(2,2,1,1)$. By a similar argument, there are ${200 \choose 4}\times 2 = 129,369,900$ ways of creating a six pack with four types of beers. **Five types:** There is only one way this can occur: $(2,1,1,1,1)$. There are ${200 \choose 5} = 2,535,650,040$ ways of creating a six pack with five types of beers. **Six types:** There is only one way this can occur: $(1,1,1,1,1,1)$. There are ${200 \choose 6} = 82,408,626,300$ ways of creating a six pack with six types of beers. Therefore the number of possible six packs that can be made is $${200 \choose 1} + {200 \choose 2}\times 3 + {200 \choose 3}\times 2 + {200 \choose 4}\times 2 + {200 \choose 5} + {200 \choose 6} = 85,076,332,940.$$ So, in short, they are not correct. --- More generally, suppose you have $n$ types of object and you wish to choose $k$ objects which can include any number of each type. How many ways are there of doing this? By the same logic, there are $$\sum\_{i=1}^k {n \choose i}\times P(k, i)$$ ways where $P(k, i)$ is the number of [partitions](http://en.wikipedia.org/wiki/Partition_%28number_theory%29) of $k$ into $i$ parts, i.e. the number of ways $k$ can be written as a sum of $i$ positive integers.
I distrust advertising numbers like this. The original [Rubik's cube](http://en.wikipedia.org/wiki/Rubik_cube) promised billions of positions. They were technically correct, the correct number is $43,252,003,274,489,856,000$ or 43 billions of billions. To get it exactly right, you would have to make a list of all the partitions of $6$, figure the multinomial coefficient for each one, and add them up. But calculation of ${200 \choose 6}=82,408,626,300$, the number with six distinct beers, already shows there are many more than $1.4E9$.
455,802
There is a beverage company here that claims to have a selection of 200 different beers. They have a special deal where you can build your own six pack at a discount. They advertise that there are 1.4B ways to build said six pack, and I am trying to determine if they're correct. I thought that this would be a combination with repetition problem. You have $n=200$ items with $r=6$ choices. The formula $$x=(n+r-1)!/(r!(n-1)!)$$ yields $x=95,746,959,700$. Then I tried to work backwards using $x=1400000000$. I plugged $$1400000000=n!(n-1)!(n-2)!(n-3)!(n-4)!(n-5)!$$ into Wolfram Alpha to get the solution. It showed that the alternate form is a gamma function $$1400000000 = Γ(x-4)Γ(x-3)Γ(x-2)Γ(x-1)Γ(x)Γ(x+1)$$ That solution is approximately $n=6.496$. My experience with combinatorics is limited to pre-calculus permutations and combinations, so gamma functions is somethings that I stumbled upon literally half an hour ago. So I ask: How many ways can you build a six pack with 200 beers? Note: I understand that you *could* use $x=n^r$, because technically three Bud Lights and three Coors Lights are different from three Coors Lights and three Bud Lights. The answer for that permutation is $x=64,000,0,000,000$.
2013/07/30
[ "https://math.stackexchange.com/questions/455802", "https://math.stackexchange.com", "https://math.stackexchange.com/users/88308/" ]
Let $(a\_1, \dots, a\_l) \in \mathbb{N}^l$ be notation for $a\_j$ bottles of the $j^{\text{th}}$ beer. We need to consider how many different types of beer there are in the six pack. Obviously, there could be one, two, three, four, five, or six. Let's consider each case individually. **One type:** The only way this can occur is if there are six bottles of the same beer. There are ${200 \choose 1} = 200$ ways of choosing that type. **Two types:** There are three ways this can occur: $(5,1)$, $(4,2)$, and $(3,3)$ - note, the order of the beers (i.e. which type you call first and which you call second) doesn't count. There are ${200 \choose 2}$ ways of choosing the two types of beer. There are three possibilities for the six pack that can be made with those two types. So there are ${200 \choose 2}\times 3 = 59,700$ ways of creating a six pack with two types of beer. **Three types:** There are two ways this can occur: $(4,1,1)$ and $(3,2,1)$. There are ${200 \choose 3}$ ways of choosing the three types of beer. There are two possibilities for the six pack that can be made with those three types. So there are ${200 \choose 3}\times 2 = 2,626,800$ ways of creating a six pack with three types of beer. **Four types:** There are two ways this can occur: $(3,1,1,1)$ and $(2,2,1,1)$. By a similar argument, there are ${200 \choose 4}\times 2 = 129,369,900$ ways of creating a six pack with four types of beers. **Five types:** There is only one way this can occur: $(2,1,1,1,1)$. There are ${200 \choose 5} = 2,535,650,040$ ways of creating a six pack with five types of beers. **Six types:** There is only one way this can occur: $(1,1,1,1,1,1)$. There are ${200 \choose 6} = 82,408,626,300$ ways of creating a six pack with six types of beers. Therefore the number of possible six packs that can be made is $${200 \choose 1} + {200 \choose 2}\times 3 + {200 \choose 3}\times 2 + {200 \choose 4}\times 2 + {200 \choose 5} + {200 \choose 6} = 85,076,332,940.$$ So, in short, they are not correct. --- More generally, suppose you have $n$ types of object and you wish to choose $k$ objects which can include any number of each type. How many ways are there of doing this? By the same logic, there are $$\sum\_{i=1}^k {n \choose i}\times P(k, i)$$ ways where $P(k, i)$ is the number of [partitions](http://en.wikipedia.org/wiki/Partition_%28number_theory%29) of $k$ into $i$ parts, i.e. the number of ways $k$ can be written as a sum of $i$ positive integers.
If we count permutations as distinct combinations, then it should be $\frac{200!}{194!}$ which is in the order of $10^{13}$. Otherwise it should be $\binom{200}{6}$, which is in the order of $10^{10}$.
1,735
The bardic lore skill always left me baffled. I never had clear the terms of such skill. A bard can roll a bard lore throw to know some abstruse information. The fact is that the throw is bound to a specific need or question, and it can very well be that the bard knows nothing about one topic, and a lot of a very related topic, as beautifully depicted in [The Gamers 2](http://www.youtube.com/watch?v=90wFS7cDQCg&feature=related&t=8m14s). What is the real meaning of the bardic lore skill, in game terms ?
2010/08/29
[ "https://rpg.stackexchange.com/questions/1735", "https://rpg.stackexchange.com", "https://rpg.stackexchange.com/users/113/" ]
Original celtic bards were actually historians. All of celtic tradition was oral, so someone had to remeber it and pass it on. The poetry and music were only added to make it easier to remember. We can imagine the D&D Bard as a kind of wandering historian-in-training. He already knows some of the songs/stories, but has a long way to go - as he gains experience, he learns more and more of them. But he isn't performing what we would call a scientific reaserch - he is wandering the land, collecting pieces of lore and legend. So, for example, he may know that a vampire can be killed by putting a stake through his heart, beacause he knows "The Song of Barabarus, the Mighty Vampire Slayer", but he doesn't need to know that the same vampire is weak to light, since it isn't mentioned in this song. He would need to know "The Legend of Saint Carnus and the Dark Beast" - which, while technically covering the same topic, is about a completly different person from completly different land, and thus not a part of "a pack". For someone which aproperiate scholary knowledge, this two facts are tied together as a part of vampire lore. For bards, those are separate things, tied to specific places, clans and stories.
When my player rolls and succeeds I start my answer as follows: "Actually you have heard an old gypsy prayer song back in Manigmar about the mountain gods and it seems to you now, in light of the info you just gained, that they might refer to a coven of wizards hiding up there somewhere. There is a circle of ancient stone faces in ..." So basically the bard just recalls a random song with a bit of info on a topic that he knows nothing about in terms of scholarly knowledge.
1,735
The bardic lore skill always left me baffled. I never had clear the terms of such skill. A bard can roll a bard lore throw to know some abstruse information. The fact is that the throw is bound to a specific need or question, and it can very well be that the bard knows nothing about one topic, and a lot of a very related topic, as beautifully depicted in [The Gamers 2](http://www.youtube.com/watch?v=90wFS7cDQCg&feature=related&t=8m14s). What is the real meaning of the bardic lore skill, in game terms ?
2010/08/29
[ "https://rpg.stackexchange.com/questions/1735", "https://rpg.stackexchange.com", "https://rpg.stackexchange.com/users/113/" ]
When my player rolls and succeeds I start my answer as follows: "Actually you have heard an old gypsy prayer song back in Manigmar about the mountain gods and it seems to you now, in light of the info you just gained, that they might refer to a coven of wizards hiding up there somewhere. There is a circle of ancient stone faces in ..." So basically the bard just recalls a random song with a bit of info on a topic that he knows nothing about in terms of scholarly knowledge.
Bardic lore is a real life skill. Heck, a lot of people possess it. It's just having information about something that given your background, learning, or skill set you generally wouldn't be expected to know. Just being well read and having general knowledge of a host of different skills, professions, situations, histories is basically all Bardic lore is. They've read a bunch of books, or talked with a bunch of people, or heard songs from long standing oral traditions talking about places, people or items from bygone ages and by checking for it, they might remember hearing at least a little bit about it, though full knowledge of something pretty rare.