qid
int64
1
74.7M
question
stringlengths
0
58.3k
date
stringlengths
10
10
metadata
sequence
response_j
stringlengths
2
48.3k
response_k
stringlengths
2
40.5k
39,131,812
if I want to express something like [just a simple example]: ``` int a = 0; for (int x = 0; x < n; x += 1) a = 1 - a; ``` what should I do in Haskell, *since it doesn't have variable concept?* (maybe wrong, see: [Does Haskell have variables?](https://stackoverflow.com/questions/993124/does-haskell-have-variables))
2016/08/24
[ "https://Stackoverflow.com/questions/39131812", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4280916/" ]
Often, repetition that you would perform with a loop in a procedural language is accomplished with [recursion](http://learnyouahaskell.com/recursion) in Haskell. In this case, you should think about what the result of the loop is. It appears to alternate between 0 and 1. There are several ways to do this in Haskell. One way is ``` alternatingList n = take n alternating0and1 alternating0and1 = 0 : alternating1and0 alternating1and0 = 1 : alternating0and1 ```
There are a few options. First, you can rewrite the problem with naive recursion: ``` loop :: Int -> Int loop n = loop' n 0 where loop' 0 a = a loop' n a = loop' (n - 1) (1 - a) ``` Next, you can restate recursion as a fold: ``` loop :: Int -> Int loop n = foldr (\a _ -> 1 - a) 0 [0..n] ``` Or you can use `State` to simulate a for loop: ``` import Control.Monad import Control.Monad.State loop :: Int -> Int loop n = execState (forM_ [0..n] (\_ -> modify (\a -> 1 - a))) 0 ```
39,131,812
if I want to express something like [just a simple example]: ``` int a = 0; for (int x = 0; x < n; x += 1) a = 1 - a; ``` what should I do in Haskell, *since it doesn't have variable concept?* (maybe wrong, see: [Does Haskell have variables?](https://stackoverflow.com/questions/993124/does-haskell-have-variables))
2016/08/24
[ "https://Stackoverflow.com/questions/39131812", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4280916/" ]
Often, repetition that you would perform with a loop in a procedural language is accomplished with [recursion](http://learnyouahaskell.com/recursion) in Haskell. In this case, you should think about what the result of the loop is. It appears to alternate between 0 and 1. There are several ways to do this in Haskell. One way is ``` alternatingList n = take n alternating0and1 alternating0and1 = 0 : alternating1and0 alternating1and0 = 1 : alternating0and1 ```
Another option: ``` iterate (\a -> 1-a) 0 !! n -- or even iterate (1-) 0 !! n ``` The snippet `iterate (\a -> 1-a) 0` produces an infinite lazy list of all the values obtained starting from `0` and repeatedly applying the function `(\a -> 1-a)`. Then `!! n` takes the n-th element. To be completely honest, in this case, I'd also look for a stricter definition of `iterate` which does not create so many lazy thunks.
39,131,812
if I want to express something like [just a simple example]: ``` int a = 0; for (int x = 0; x < n; x += 1) a = 1 - a; ``` what should I do in Haskell, *since it doesn't have variable concept?* (maybe wrong, see: [Does Haskell have variables?](https://stackoverflow.com/questions/993124/does-haskell-have-variables))
2016/08/24
[ "https://Stackoverflow.com/questions/39131812", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4280916/" ]
Often, repetition that you would perform with a loop in a procedural language is accomplished with [recursion](http://learnyouahaskell.com/recursion) in Haskell. In this case, you should think about what the result of the loop is. It appears to alternate between 0 and 1. There are several ways to do this in Haskell. One way is ``` alternatingList n = take n alternating0and1 alternating0and1 = 0 : alternating1and0 alternating1and0 = 1 : alternating0and1 ```
The other answers have already explained how you would approach a problem like this functionally, in Haskell. However, Haskell does have mutable variables (or references) in the form of [ST](https://hackage.haskell.org/package/base-4.9.0.0/docs/Control-Monad-ST.html) actions and [STRef](https://hackage.haskell.org/package/base-4.9.0.0/docs/Data-STRef.html). Using them is usually not very pretty, but it does allow you to express imperative, variable-mutating code faithfully in Haskell, if you really want to. Just for fun, here's how you might use them to express your example problem. (The following code also uses [whileM\_](http://hackage.haskell.org/package/monad-loops-0.4.3/docs/Control-Monad-Loops.html#v:whileM_) from the [monad-loops](http://hackage.haskell.org/package/monad-loops) package, for convenience.) ``` import Control.Monad.Loops import Control.Monad.ST import Data.STRef -- First, we define some infix operators on STRefs, -- to make the following code less verbose. -- Assignment to refs. r @= x = writeSTRef r =<< x r += n = r @= ((n +) <$> readSTRef r) -- Binary operators on refs. (Mnemonic: the ? is on the side of the ref.) n -? r = (-) <$> pure n <*> readSTRef r r ?< n = (<) <$> readSTRef r <*> pure n -- Armed with these, we can transliterate the original example to Haskell. -- This declares refs a and x, mutates them, and returns the final value of a. foo n = do a <- newSTRef 0 x <- newSTRef 0 whileM_ (x ?< n) $ do x += 1 a @= (1 -? a) readSTRef a -- To run it: main = print =<< stToIO (foo 10) ```
39,131,812
if I want to express something like [just a simple example]: ``` int a = 0; for (int x = 0; x < n; x += 1) a = 1 - a; ``` what should I do in Haskell, *since it doesn't have variable concept?* (maybe wrong, see: [Does Haskell have variables?](https://stackoverflow.com/questions/993124/does-haskell-have-variables))
2016/08/24
[ "https://Stackoverflow.com/questions/39131812", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4280916/" ]
There are a few options. First, you can rewrite the problem with naive recursion: ``` loop :: Int -> Int loop n = loop' n 0 where loop' 0 a = a loop' n a = loop' (n - 1) (1 - a) ``` Next, you can restate recursion as a fold: ``` loop :: Int -> Int loop n = foldr (\a _ -> 1 - a) 0 [0..n] ``` Or you can use `State` to simulate a for loop: ``` import Control.Monad import Control.Monad.State loop :: Int -> Int loop n = execState (forM_ [0..n] (\_ -> modify (\a -> 1 - a))) 0 ```
Another option: ``` iterate (\a -> 1-a) 0 !! n -- or even iterate (1-) 0 !! n ``` The snippet `iterate (\a -> 1-a) 0` produces an infinite lazy list of all the values obtained starting from `0` and repeatedly applying the function `(\a -> 1-a)`. Then `!! n` takes the n-th element. To be completely honest, in this case, I'd also look for a stricter definition of `iterate` which does not create so many lazy thunks.
39,131,812
if I want to express something like [just a simple example]: ``` int a = 0; for (int x = 0; x < n; x += 1) a = 1 - a; ``` what should I do in Haskell, *since it doesn't have variable concept?* (maybe wrong, see: [Does Haskell have variables?](https://stackoverflow.com/questions/993124/does-haskell-have-variables))
2016/08/24
[ "https://Stackoverflow.com/questions/39131812", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4280916/" ]
There are a few options. First, you can rewrite the problem with naive recursion: ``` loop :: Int -> Int loop n = loop' n 0 where loop' 0 a = a loop' n a = loop' (n - 1) (1 - a) ``` Next, you can restate recursion as a fold: ``` loop :: Int -> Int loop n = foldr (\a _ -> 1 - a) 0 [0..n] ``` Or you can use `State` to simulate a for loop: ``` import Control.Monad import Control.Monad.State loop :: Int -> Int loop n = execState (forM_ [0..n] (\_ -> modify (\a -> 1 - a))) 0 ```
The other answers have already explained how you would approach a problem like this functionally, in Haskell. However, Haskell does have mutable variables (or references) in the form of [ST](https://hackage.haskell.org/package/base-4.9.0.0/docs/Control-Monad-ST.html) actions and [STRef](https://hackage.haskell.org/package/base-4.9.0.0/docs/Data-STRef.html). Using them is usually not very pretty, but it does allow you to express imperative, variable-mutating code faithfully in Haskell, if you really want to. Just for fun, here's how you might use them to express your example problem. (The following code also uses [whileM\_](http://hackage.haskell.org/package/monad-loops-0.4.3/docs/Control-Monad-Loops.html#v:whileM_) from the [monad-loops](http://hackage.haskell.org/package/monad-loops) package, for convenience.) ``` import Control.Monad.Loops import Control.Monad.ST import Data.STRef -- First, we define some infix operators on STRefs, -- to make the following code less verbose. -- Assignment to refs. r @= x = writeSTRef r =<< x r += n = r @= ((n +) <$> readSTRef r) -- Binary operators on refs. (Mnemonic: the ? is on the side of the ref.) n -? r = (-) <$> pure n <*> readSTRef r r ?< n = (<) <$> readSTRef r <*> pure n -- Armed with these, we can transliterate the original example to Haskell. -- This declares refs a and x, mutates them, and returns the final value of a. foo n = do a <- newSTRef 0 x <- newSTRef 0 whileM_ (x ?< n) $ do x += 1 a @= (1 -? a) readSTRef a -- To run it: main = print =<< stToIO (foo 10) ```
34,176,782
Inspired by the following thread: [PyQt: How to set Combobox Items be Checkable?](https://stackoverflow.com/questions/22775095/pyqt-how-to-set-combobox-items-be-checkable) I was able to create a simple checkable "combobox" by using a QToolButton and adding checkable items to it using addAction. See simple code example: ``` from PyQt4 import QtCore, QtGui import sys class Ui_Dialog(object): def setupUi(self, Dialog): Dialog.setObjectName("Dialog") Dialog.resize(198, 157) self.toolButton = QtGui.QToolButton(Dialog) self.toolButton.setGeometry(QtCore.QRect(60, 50, 71, 19)) self.toolButton.setObjectName("toolButton") self.toolButton.setText("MyButton") QtCore.QMetaObject.connectSlotsByName(Dialog) class MyDialog(QtGui.QDialog): def __init__(self, parent=None): QtGui.QWidget.__init__(self, parent) self.ui = Ui_Dialog() self.ui.setupUi(self) self.toolMenu = QtGui.QMenu(self.ui.toolButton) for i in range(3): action = self.toolMenu.addAction("Category " + str(i)) action.setCheckable(True) self.ui.toolButton.setMenu(self.toolMenu) self.ui.toolButton.setPopupMode(QtGui.QToolButton.InstantPopup) if __name__ == "__main__": app = QtGui.QApplication(sys.argv) myapp = MyDialog() myapp.show() sys.exit(app.exec_()) ``` But how can I capture which of the QToolButton actions (i.e. *Category 1* and/or *Category 2/3*) that has been checked in my dialog?
2015/12/09
[ "https://Stackoverflow.com/questions/34176782", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5656718/" ]
Alternatively you can define your [`QActionGroup`](http://pyqt.sourceforge.net/Docs/PyQt4/qactiongroup.html) to collect all of your `action`s, then `connect` the signal `triggered` to callback method, this way: ``` class MyDialog(QtGui.QDialog): def __init__(self, parent=None): QtGui.QWidget.__init__(self, parent) self.ui = Ui_Dialog() self.ui.setupUi(self) self.toolMenu = QtGui.QMenu(self.ui.toolButton) group = QtGui.QActionGroup(self.toolMenu) for i in range(3): action = self.toolMenu.addAction("Category %d" % i) action.setCheckable(True) action.setActionGroup(group) action.setData(i) self.ui.toolButton.setMenu(self.toolMenu) self.ui.toolButton.setPopupMode(QtGui.QToolButton.InstantPopup) group.triggered.connect(self.test) def test(self, act): print 'Action' , act.data().toInt()[0] ``` Here in `test()` method, reading the `data` of each `action` returns a [`QVariant`](http://pyqt.sourceforge.net/Docs/PyQt4/qvariant.html#toInt) which you need to convert it back to `int` using `toInt` method returning `(int, bool)` tuple, thus `[0]`
First we need to loop through the actions of the menu.There's no convenience function to do this, but every widget has a method `findChildren`. To get a list of all the children of type `QAction`, you do: ``` self.toolMenu.findChildren(QtGui.QAction) ``` For every action, we can use `QAction.isChecked()` to get a boolean. Full example: ``` def whatIsChecked(self): for action in self.toolMenu.findChildren(QtGui.QAction): if action.isChecked(): print(action.text(),"is checked") else: print(action.text(),"is not checked") ```
47,355,843
Today I updated Android Studio to version 3.0 And after that I couldn't build project successfully. I got these errors: ``` Unable to resolve dependency for ':app@release/compileClasspath': could not resolve com.android.support:appcompat-v7:27.0.1. ``` I tried using VPN or proxy etc. but none of them worked. It's been a long day. I hope you may help me. This is my build.gradle(app) : ``` apply plugin: 'com.android.application' apply plugin: 'kotlin-android' apply plugin: 'kotlin-android-extensions' android { compileSdkVersion 27 defaultConfig { applicationId "ir.hetbo.kotlin_tutorial" minSdkVersion 15 targetSdkVersion 27 versionCode 1 versionName "1.0" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } } dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) implementation"org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version" implementation 'com.android.support:appcompat-v7:27.0.1' implementation 'com.android.support.constraint:constraint-layout:1.0.2' } ``` and this is build.gradle(project): ``` // Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript { ext.kotlin_version = '1.1.60' repositories { google() jcenter() maven { url "https://maven.google.com" } } dependencies { classpath 'com.android.tools.build:gradle:3.0.0' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files } } allprojects { repositories { google() jcenter() maven { url "https://maven.google.com" } } } task clean(type: Delete) { delete rootProject.buildDir } ``` I did a lot of things to fix it but every time it failed. I use gradle 4.3.1 And here is gradle wrapper properties : ``` #Sat Nov 18 10:16:45 IRST 2017 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists distributionUrl=https\://services.gradle.org/distributions/gradle-4.3.1-all.zip ```
2017/11/17
[ "https://Stackoverflow.com/questions/47355843", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7577206/" ]
with the new features of **gradle 4.1** and the **classpath 'com.android.tools.build:gradle:3.0.0'** > > distributionBase=GRADLE\_USER\_HOME distributionPath=wrapper/dists > zipStoreBase=GRADLE\_USER\_HOME zipStorePath=wrapper/dists > distributionUrl=<https://services.gradle.org/distributions/gradle-4.1-all.zip> > > > and and this is build.gradle(project): ``` // Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript { ext.kotlin_version = '1.1.60' repositories { google() jcenter() } dependencies { classpath 'com.android.tools.build:gradle:3.0.0' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files } } allprojects { repositories { google() jcenter() } } task clean(type: Delete) { delete rootProject.buildDir } ```
As of the new versions, the libraries are now inside the `maven` not inside `Jcenter`. So inside your gradle file, you have to add `maven` like the below: ``` allprojects { repositories { jcenter() maven { url "https://maven.google.com" } } } ``` This link may help you: [Adding support libraries](https://developer.android.com/topic/libraries/support-library/setup.html)
47,355,843
Today I updated Android Studio to version 3.0 And after that I couldn't build project successfully. I got these errors: ``` Unable to resolve dependency for ':app@release/compileClasspath': could not resolve com.android.support:appcompat-v7:27.0.1. ``` I tried using VPN or proxy etc. but none of them worked. It's been a long day. I hope you may help me. This is my build.gradle(app) : ``` apply plugin: 'com.android.application' apply plugin: 'kotlin-android' apply plugin: 'kotlin-android-extensions' android { compileSdkVersion 27 defaultConfig { applicationId "ir.hetbo.kotlin_tutorial" minSdkVersion 15 targetSdkVersion 27 versionCode 1 versionName "1.0" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } } dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) implementation"org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version" implementation 'com.android.support:appcompat-v7:27.0.1' implementation 'com.android.support.constraint:constraint-layout:1.0.2' } ``` and this is build.gradle(project): ``` // Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript { ext.kotlin_version = '1.1.60' repositories { google() jcenter() maven { url "https://maven.google.com" } } dependencies { classpath 'com.android.tools.build:gradle:3.0.0' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files } } allprojects { repositories { google() jcenter() maven { url "https://maven.google.com" } } } task clean(type: Delete) { delete rootProject.buildDir } ``` I did a lot of things to fix it but every time it failed. I use gradle 4.3.1 And here is gradle wrapper properties : ``` #Sat Nov 18 10:16:45 IRST 2017 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists distributionUrl=https\://services.gradle.org/distributions/gradle-4.3.1-all.zip ```
2017/11/17
[ "https://Stackoverflow.com/questions/47355843", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7577206/" ]
with the new features of **gradle 4.1** and the **classpath 'com.android.tools.build:gradle:3.0.0'** > > distributionBase=GRADLE\_USER\_HOME distributionPath=wrapper/dists > zipStoreBase=GRADLE\_USER\_HOME zipStorePath=wrapper/dists > distributionUrl=<https://services.gradle.org/distributions/gradle-4.1-all.zip> > > > and and this is build.gradle(project): ``` // Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript { ext.kotlin_version = '1.1.60' repositories { google() jcenter() } dependencies { classpath 'com.android.tools.build:gradle:3.0.0' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files } } allprojects { repositories { google() jcenter() } } task clean(type: Delete) { delete rootProject.buildDir } ```
There is one build.gradle file for whole projects and one for each modules. Need to add below code in the application build.gradle file. ``` buildscript { repositories { jcenter() } dependencies { classpath 'com.android.tools.build:gradle:2.3.2' } } allprojects { repositories { jcenter() maven { url "https://maven.google.com" } } } ```
47,355,843
Today I updated Android Studio to version 3.0 And after that I couldn't build project successfully. I got these errors: ``` Unable to resolve dependency for ':app@release/compileClasspath': could not resolve com.android.support:appcompat-v7:27.0.1. ``` I tried using VPN or proxy etc. but none of them worked. It's been a long day. I hope you may help me. This is my build.gradle(app) : ``` apply plugin: 'com.android.application' apply plugin: 'kotlin-android' apply plugin: 'kotlin-android-extensions' android { compileSdkVersion 27 defaultConfig { applicationId "ir.hetbo.kotlin_tutorial" minSdkVersion 15 targetSdkVersion 27 versionCode 1 versionName "1.0" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } } dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) implementation"org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version" implementation 'com.android.support:appcompat-v7:27.0.1' implementation 'com.android.support.constraint:constraint-layout:1.0.2' } ``` and this is build.gradle(project): ``` // Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript { ext.kotlin_version = '1.1.60' repositories { google() jcenter() maven { url "https://maven.google.com" } } dependencies { classpath 'com.android.tools.build:gradle:3.0.0' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files } } allprojects { repositories { google() jcenter() maven { url "https://maven.google.com" } } } task clean(type: Delete) { delete rootProject.buildDir } ``` I did a lot of things to fix it but every time it failed. I use gradle 4.3.1 And here is gradle wrapper properties : ``` #Sat Nov 18 10:16:45 IRST 2017 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists distributionUrl=https\://services.gradle.org/distributions/gradle-4.3.1-all.zip ```
2017/11/17
[ "https://Stackoverflow.com/questions/47355843", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7577206/" ]
with the new features of **gradle 4.1** and the **classpath 'com.android.tools.build:gradle:3.0.0'** > > distributionBase=GRADLE\_USER\_HOME distributionPath=wrapper/dists > zipStoreBase=GRADLE\_USER\_HOME zipStorePath=wrapper/dists > distributionUrl=<https://services.gradle.org/distributions/gradle-4.1-all.zip> > > > and and this is build.gradle(project): ``` // Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript { ext.kotlin_version = '1.1.60' repositories { google() jcenter() } dependencies { classpath 'com.android.tools.build:gradle:3.0.0' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files } } allprojects { repositories { google() jcenter() } } task clean(type: Delete) { delete rootProject.buildDir } ```
Try this code in build.gradle(Project) : ``` buildscript { ext.kotlin_version = '1.1.51' repositories { google() jcenter() } dependencies { classpath 'com.android.tools.build:gradle:3.0.0' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files } } allprojects { repositories { google() jcenter() } } task clean(type: Delete) { delete rootProject.buildDir } ```
28,672,134
eg. JBB Inc. Headquarters 20 West RiverCenter Blvd Covington KY 41011 USA
2015/02/23
[ "https://Stackoverflow.com/questions/28672134", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4574324/" ]
This error can be caused by an incorrect **merchant ID**, an **incorrect access code**, or if the order originates from an **unregistered URL**. Make sure that all three of these values are correct. > > For your security, CCAvenue does not report exactly which of these three values might be in error. > > > **Update:** 1. You can find CCAvenue setup for ASP.net from here: <http://aravin.net/complete-guide-integrate-ccavenue-payment-gateway-asp-net-website-screenshot/> 2. Also, you can find steps to solve the 10002 here: <http://aravin.net/how-to-test-ccavenue-payment-gateway-in-localhost-avoid-error-code-10002-merchant-authentication-failed/>
**The Error code 10002 means that Access code or URL not valid so request you to confirm that you are posting the Access code value to CCAvenue and also confirm that the request URL posting to CCAvenue has to be the same as the registered URL with us, as we are having the URL Validation at our end.** The post action URL must be <https://secure.ccavenue.com/transaction/transaction.do?command=initiateTransaction> Kindly confirm that you're passing the correct API keys in the integration kit. We would like to inform you that the API keys that are generated in your account, are for the live website URL and live server (i.e. secure.ccavenue.com). Thus, if we receive any request other that the website URL, (e.g. Local host / sub-domain), or for the test server (i.e. <https://test.ccavenue.com/transaction/transaction.do?command=initiateTransaction>), you will get the merchant authentication failed error. We request you to kindly check at your end.
28,672,134
eg. JBB Inc. Headquarters 20 West RiverCenter Blvd Covington KY 41011 USA
2015/02/23
[ "https://Stackoverflow.com/questions/28672134", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4574324/" ]
This error can be caused by an incorrect **merchant ID**, an **incorrect access code**, or if the order originates from an **unregistered URL**. Make sure that all three of these values are correct. > > For your security, CCAvenue does not report exactly which of these three values might be in error. > > > **Update:** 1. You can find CCAvenue setup for ASP.net from here: <http://aravin.net/complete-guide-integrate-ccavenue-payment-gateway-asp-net-website-screenshot/> 2. Also, you can find steps to solve the 10002 here: <http://aravin.net/how-to-test-ccavenue-payment-gateway-in-localhost-avoid-error-code-10002-merchant-authentication-failed/>
Error Code: 10002 Merchant Authentication failed. ================================================= Don't worry... It happens to the best of us. ============================================ This might be due to incorrect MERCHANT ID, WORKING KEY or ACCESS CODE. The most likely it is possible due to incorrect URL so to make sure this is implemented on the Registered Domain for Testing URL/Live url for which the API keys are issued. Please check the registered ccavenue Testing/Live URL for the same.
28,672,134
eg. JBB Inc. Headquarters 20 West RiverCenter Blvd Covington KY 41011 USA
2015/02/23
[ "https://Stackoverflow.com/questions/28672134", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4574324/" ]
This error can be caused by an incorrect **merchant ID**, an **incorrect access code**, or if the order originates from an **unregistered URL**. Make sure that all three of these values are correct. > > For your security, CCAvenue does not report exactly which of these three values might be in error. > > > **Update:** 1. You can find CCAvenue setup for ASP.net from here: <http://aravin.net/complete-guide-integrate-ccavenue-payment-gateway-asp-net-website-screenshot/> 2. Also, you can find steps to solve the 10002 here: <http://aravin.net/how-to-test-ccavenue-payment-gateway-in-localhost-avoid-error-code-10002-merchant-authentication-failed/>
Are you using it on localhost? If you need to test your code from your local machine, you should write to CCAvenue service desk at [email protected] with your merchant ID and localhost URL to white-list. Else CCAvenue will throw error "Merchant Authentication Failed". Otherwise this error can be caused by an incorrect access code or if the order originates from an unregistered URL. Make sure that all three of these values are correct. After your web address gets approved then recheck the new access key and working key Also use <https://secure.ccavenue.com/transaction/transaction.do?command=initiateTransaction> this URL for payments
28,672,134
eg. JBB Inc. Headquarters 20 West RiverCenter Blvd Covington KY 41011 USA
2015/02/23
[ "https://Stackoverflow.com/questions/28672134", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4574324/" ]
This error can be caused by an incorrect **merchant ID**, an **incorrect access code**, or if the order originates from an **unregistered URL**. Make sure that all three of these values are correct. > > For your security, CCAvenue does not report exactly which of these three values might be in error. > > > **Update:** 1. You can find CCAvenue setup for ASP.net from here: <http://aravin.net/complete-guide-integrate-ccavenue-payment-gateway-asp-net-website-screenshot/> 2. Also, you can find steps to solve the 10002 here: <http://aravin.net/how-to-test-ccavenue-payment-gateway-in-localhost-avoid-error-code-10002-merchant-authentication-failed/>
**I was having same error.** *Note below points* 1. whitelist your **IP** or **Domain** - ask ccavenue care, they will do whitelist it. 2. it will work default in live envirement for URL `https://secure.ccavenue.com/xyz` 3. for development or test enrolment we need to ask ccavenue to **enable** our merchant id(need to give our merchant id) **for test environment** for URL `https://test.ccavenue.com/xyz` Once it enable, then it will work. also double check your merchant\_id and access\_code too.
28,672,134
eg. JBB Inc. Headquarters 20 West RiverCenter Blvd Covington KY 41011 USA
2015/02/23
[ "https://Stackoverflow.com/questions/28672134", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4574324/" ]
**The Error code 10002 means that Access code or URL not valid so request you to confirm that you are posting the Access code value to CCAvenue and also confirm that the request URL posting to CCAvenue has to be the same as the registered URL with us, as we are having the URL Validation at our end.** The post action URL must be <https://secure.ccavenue.com/transaction/transaction.do?command=initiateTransaction> Kindly confirm that you're passing the correct API keys in the integration kit. We would like to inform you that the API keys that are generated in your account, are for the live website URL and live server (i.e. secure.ccavenue.com). Thus, if we receive any request other that the website URL, (e.g. Local host / sub-domain), or for the test server (i.e. <https://test.ccavenue.com/transaction/transaction.do?command=initiateTransaction>), you will get the merchant authentication failed error. We request you to kindly check at your end.
Error Code: 10002 Merchant Authentication failed. ================================================= Don't worry... It happens to the best of us. ============================================ This might be due to incorrect MERCHANT ID, WORKING KEY or ACCESS CODE. The most likely it is possible due to incorrect URL so to make sure this is implemented on the Registered Domain for Testing URL/Live url for which the API keys are issued. Please check the registered ccavenue Testing/Live URL for the same.
28,672,134
eg. JBB Inc. Headquarters 20 West RiverCenter Blvd Covington KY 41011 USA
2015/02/23
[ "https://Stackoverflow.com/questions/28672134", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4574324/" ]
**The Error code 10002 means that Access code or URL not valid so request you to confirm that you are posting the Access code value to CCAvenue and also confirm that the request URL posting to CCAvenue has to be the same as the registered URL with us, as we are having the URL Validation at our end.** The post action URL must be <https://secure.ccavenue.com/transaction/transaction.do?command=initiateTransaction> Kindly confirm that you're passing the correct API keys in the integration kit. We would like to inform you that the API keys that are generated in your account, are for the live website URL and live server (i.e. secure.ccavenue.com). Thus, if we receive any request other that the website URL, (e.g. Local host / sub-domain), or for the test server (i.e. <https://test.ccavenue.com/transaction/transaction.do?command=initiateTransaction>), you will get the merchant authentication failed error. We request you to kindly check at your end.
Are you using it on localhost? If you need to test your code from your local machine, you should write to CCAvenue service desk at [email protected] with your merchant ID and localhost URL to white-list. Else CCAvenue will throw error "Merchant Authentication Failed". Otherwise this error can be caused by an incorrect access code or if the order originates from an unregistered URL. Make sure that all three of these values are correct. After your web address gets approved then recheck the new access key and working key Also use <https://secure.ccavenue.com/transaction/transaction.do?command=initiateTransaction> this URL for payments
28,672,134
eg. JBB Inc. Headquarters 20 West RiverCenter Blvd Covington KY 41011 USA
2015/02/23
[ "https://Stackoverflow.com/questions/28672134", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4574324/" ]
**The Error code 10002 means that Access code or URL not valid so request you to confirm that you are posting the Access code value to CCAvenue and also confirm that the request URL posting to CCAvenue has to be the same as the registered URL with us, as we are having the URL Validation at our end.** The post action URL must be <https://secure.ccavenue.com/transaction/transaction.do?command=initiateTransaction> Kindly confirm that you're passing the correct API keys in the integration kit. We would like to inform you that the API keys that are generated in your account, are for the live website URL and live server (i.e. secure.ccavenue.com). Thus, if we receive any request other that the website URL, (e.g. Local host / sub-domain), or for the test server (i.e. <https://test.ccavenue.com/transaction/transaction.do?command=initiateTransaction>), you will get the merchant authentication failed error. We request you to kindly check at your end.
**I was having same error.** *Note below points* 1. whitelist your **IP** or **Domain** - ask ccavenue care, they will do whitelist it. 2. it will work default in live envirement for URL `https://secure.ccavenue.com/xyz` 3. for development or test enrolment we need to ask ccavenue to **enable** our merchant id(need to give our merchant id) **for test environment** for URL `https://test.ccavenue.com/xyz` Once it enable, then it will work. also double check your merchant\_id and access\_code too.
37,318,319
I have Two Question related to Native App Performance Testing? 1)I have a Payment App, and it comes with bank security which is installed at the time of app installation. It sends an token number and rest of the data in encrypted format. Is it possible to handle such kind of request using Jmeter or any other performance testing tool, do i need to change some setting in app server or jmeter to get this done ? 2)Mobile App uses Device ID, so if i simulated load on cloud server it will use same Device ID which i used while creating script? is it possible to simulate different mobile ID to make it real-time? any Help or references will be appreciated ..:)
2016/05/19
[ "https://Stackoverflow.com/questions/37318319", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4252313/" ]
(1) Yes. This is why performance testing tools are built around general purpose programming languages, to allow you (as the tester) to leverage your foundation skills in programming to leverage the appropriate algorithms and libraries to represent the same behavior as the client (2) This is why performance testing tools allow for parameterization of the sending datastream to the server/application under test
I'm not an expert in JMeter. But work a lot with Loadrunner (LR) (Performance Testing Tool from HP). Though JMeter and LR are different tools, they work under same principle and objective and so objective of performance testing. As James Pulley mentioned, the performance testing tool may have the capability. But the question is, Have your tried recording your app with JMeter? Since your app is a native kind, please do the recording from simulator/emulator and check the feasibility. JMeter might not be the right candidate for mobile app load testing. Alternatively there are lot of other tools available (both commercial and opensource) in market for your objective. Best Regards
37,318,319
I have Two Question related to Native App Performance Testing? 1)I have a Payment App, and it comes with bank security which is installed at the time of app installation. It sends an token number and rest of the data in encrypted format. Is it possible to handle such kind of request using Jmeter or any other performance testing tool, do i need to change some setting in app server or jmeter to get this done ? 2)Mobile App uses Device ID, so if i simulated load on cloud server it will use same Device ID which i used while creating script? is it possible to simulate different mobile ID to make it real-time? any Help or references will be appreciated ..:)
2016/05/19
[ "https://Stackoverflow.com/questions/37318319", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4252313/" ]
(1) Yes. This is why performance testing tools are built around general purpose programming languages, to allow you (as the tester) to leverage your foundation skills in programming to leverage the appropriate algorithms and libraries to represent the same behavior as the client (2) This is why performance testing tools allow for parameterization of the sending datastream to the server/application under test
With the raise of several mobile network technologies, load testing a mobile application has become a different ball game in comparison with normal web app load testing. This is because of the differences in the response times that occur in different mobile networks such as 2G, 3G, 4G, etc. Additionally the client being a mobile device has plenty of physical constraints such as limited CPU, RAM, internal storage etc. All of these need to be considered while conducting performance testing of a mobile application if one wants to simulate a scenario close to a real time condition. Coming to your 2 questions, 1) Yes it is possible but the amount of manual effort that needs to be invested to make the script execution ready might vary (since you are mentioning there is data in encrypted format - some are easy to understand and some are just crude and difficult to handle using JMeter). But there might not be any app server setting that would be required to change (unless of course you are unable to handle the encryption with JMeter in which case, the encryption might have to be disabled for QA phase) 2) As rightly said by James Pulley, these values can be parameterized. However, I fear that these values will be validated by the app server and hence the values need to be appropriately fed in the requests. You can refer to this link for reference on how to do Mobile Performance Testing for Native application <http://www.neotys.com/documents/doc/neoload/latest/en/html/#4234.htm#o4237> .The same could be extrapolated to JMeter to an extent.
39,019,266
hello i want to apply css for nav bar, i am retrivig nav bar values from database using Ajax.ActionLink, i tried javascript but i am getting error called > > jQuery is not defined", > > > here is my code. and Test\_Section is my Model. ``` <table style="width:auto"> @foreach (Test_Section p in Model) { <tr> <td> <div id="ajaxnav" class="navbar-left"> <ul class="nav nav-tabs nav-stacked"> <li> @Ajax.ActionLink(p.SectionName, p.Title, new { id = p.StdSectionId , @class = "navigationLink"}, new AjaxOptions { UpdateTargetId = "getHtml", InsertionMode = InsertionMode.Replace, HttpMethod = "GET" }, new { style = "color:#428bca" , @class = "navigationLink" }) </li> </ul> </div> </td> </tr> } </table> <script type="text/javascript"> $('.navigationLink').click(function () { $('.navigationLink').removeClass('active'); $(this).addClass('active'); }); </script> ``` Please help me.
2016/08/18
[ "https://Stackoverflow.com/questions/39019266", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6459059/" ]
You need to include jQuery to your application by referencing it in your page, because the Error `jQuery is not defined` or `$ is not defined` occurs when jQuery is not (correctly) included in your page. You should add this line before the `<script>` section in your posted code: ``` <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script> ``` Hope this help you.
You need to use `.click` inside ``` $(document).ready(function(){//...onclick(...)}) ``` But first make sure, you include jquery script file in your html.
57,129,646
Is there some way I can have a function whose return type varies based on one of its arguments? For example: ``` interface Person { name: string; job: string; } interface Animal { name: string; deadly: boolean; } function getPerson(): Person { return { name: 'Bob', job: 'Manager', }; } function getAnimal(): Animal { return { name: 'Spot', deadly: false, }; } function create(generator: () => Person | Animal): ReturnType<typeof generator>[] { return [] } const people = create(getPerson); ``` This is kind of close, except the type of `people` is `(Person | Animal)[]`. I need it to be `Person[]` - in other words, it can look at the `getPerson` argument and know that this function will return a `Person`. I realize, of course, I could rewrite the function so I can do this: ``` const people = create<Person>(getPerson); ``` But I'd rather have it infer this from the arguments somehow.
2019/07/21
[ "https://Stackoverflow.com/questions/57129646", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5228806/" ]
You have have multiple `=` in a single match. ``` %{"name" => name} = identity = RedditOAuth2.get_identity(access_token) ``` `identity` will have the entire map assigned to it and `name` will have whatever was in the `"name"` key.
If you're wanting to discard everything else from the identity and are okay adding another function, you may be looking for [`Map.split/2`](https://hexdocs.pm/elixir/Map.html#split/2). ```rb {%{"name" => name}, identity} = access_token |> RedditOAuth2.get_identity() |> Map.split(["name"]) ```
30,362
My mate always tells me to remove the germ (the center) from garlic and onions, especially if it's turning green. What are the pros and cons of the germs of these plants?
2013/01/24
[ "https://cooking.stackexchange.com/questions/30362", "https://cooking.stackexchange.com", "https://cooking.stackexchange.com/users/15265/" ]
So... I was always taught that you remove it because it's bitter. I generally remove it if it's big enough. However, there seems to be some contention as to whether this is true (and to what degree it's true). See: <http://www.examiner.com/article/remove-the-garlic-germ-few-do-this-anymore> and <http://ruhlman.com/2011/02/garlic-germ/> In short, there are mixed teachings as to whether you should remove it. But essentially the germ DOES affect the taste of garlic. Some call it bitter, some call it "more garlicky". Ruhlman suggests that if you're hitting it with heat immediately, then there isn't a point in removing it. If he's doing something that will have the garlic sitting around, then he doesn't. From this what I'd suggest (and what I'm going to try doing from now on) is to ignore it and if you notice a difference in taste, or more importantly find the result objectionable. then take it out next time. Otherwise don't bother as you won't know the difference.
I always remove mine as I too find it affects the taste of the garlic. However, since I started keeping my garlic in the refrigerator, I've noticed that the garlic keeps much longer and rarely develops green germs.
47,611,557
I'm working on an optimization problem that involves minimizing an expensive map operation over a collection of objects. The naive solution would be something like ``` rdd.map(expensive).min() ``` However, the map function returns values that guaranteed to be >= 0. So, if any single result is 0, I can take that as the answer and do not need to compute the rest of the map operations. Is there an idiomatic way to do this using Spark?
2017/12/02
[ "https://Stackoverflow.com/questions/47611557", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3818777/" ]
> > Is there an idiomatic way to do this using Spark? > > > No. If you're concerned with low level optimizations like this one, then Spark is not the best option. It doesn't mean it is completely impossible. If you can for example try something like this: ``` rdd.cache() (min_value, ) = rdd.filter(lambda x: x == 0).take(1) or [rdd.min()] rdd.unpersist() ``` short circuit partitions: ``` def min_part(xs): min_ = None for x in xs: min_ = min(x, min_) if min_ is not None else x if x == 0: return [0] return [min_] in min_ is not None else [] rdd.mapPartitions(min_part).min() ``` Both will usually execute more than required, each giving slightly different performance profile, but can skip evaluating some records. With rare zeros the first one might be better. You can even listen to accumulator updates and use `sc.cancelJobGroup` once 0 is seen. Here is one example of similar approach [Is there a way to stream results to driver without waiting for all partitions to complete execution?](https://stackoverflow.com/q/41810032/8371915)
If "expensive" is **really** expensive, maybe you can write the result of "expensive" to, say, SQL (Or any other storage available to all the workers). Then in the beginning of "expensive" check the number currently stored, if it is zero return zero from "expensive" without performing the expensive part. You can also do this localy for each worker which will save you a lot of time but won't be as "global".
69,853,145
I'm studying pointers in C language with Ted Jensen's "A TUTORIAL ON POINTERS AND ARRAYS IN C" manual. It's a very prickly argument. **Question 1**. I have come to program 3.1 and would like a clarification. This is the program: ``` #include <stdio.h> char strA[80] = "A string to be used for demonstration purposes"; char strB[80]; int main(void) { char *pA; char *pB; puts(strA); pA = strA; puts(pA); pB = strB; putchar('\n'); while(*pA != '\0') { *pB++ = *pA++; } *pB = '\0'; puts(strB); return 0; } ``` Regarding the line `pA = strA;`, the book says "We then [point] the pointer pA at strA. That is, by means of the assignment statement we copy the address of strA [0] into our variable pA", which is what I don't understand. To copy the address of `strA[0]` into our variable pA via the assignment declaration, shouldn't we write `pA = & strA`? **Question 2**. The expression `c = * ++ p;` increases the value of `p` or the address of `p`? Does the indirection operator (`*`) not indicate the value of the pointed variable?
2021/11/05
[ "https://Stackoverflow.com/questions/69853145", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13975322/" ]
> > To copy the address of strA [0] into our variable pA via the assignment declaration, shouldn't we write `pA = & strA`? > > > `&strA` is the address of `strA`. `&strA[0]` is the address of `strA[0]`. These are the “same” in the sense they point to the same place in memory, but they have different types, and the compiler would complain if we wrote `pA = &strA` when the type of `pA` is a pointer to the type of the elements of `strA`. When we write `pA = strA`, the array `strA` is automatically converted to a pointer to its first element, so `pA = strA` is equivalent to `pA = &strA[0]`. > > Question 2: the expression `c = * ++ p;` increases the value of p or the address of p? > > > The C grammar organizes this as `c = *(++p);`, and `++p` increases the value of `p`. If `p` is a pointer, it increases the value of that pointer. The `*` operator uses the increased value. Be careful about speaking of the address of a pointer. The value of the pointer is an address, but you should not say that is the address of the pointer. The pointer is itself an object in memory, and so it has an address in memory where its value is stored. The address where a pointer is stored is different from the address stored in it. The “address of a pointer” is the address where the pointer is stored, not the value of the pointer.
It's simply because strA, which is char array, is a pointer. An array's "value" is actually nothing more than the address of the first element of array. When you assign address of primitive data type(int, char, etc..), you should assign it in the way you described. ``` int x; int *pA; pA = &x; ``` When you assign address of pointer data type(array, etc..), you should assign it without & operator, since the value is in itself the address. ``` int x[10]; int* pA; pA = x; ``` Original code ``` #include <stdio.h> char strA[80] = "A string to be used for demonstration purposes"; char strB[80]; int main(void) { char *pA; /* a pointer to type character */ char *pB; /* another pointer to type character */ puts(strA); /* show string A */ pA = strA; /* point pA at string A */ puts(pA); /* show what pA is pointing to */ pB = strB; /* point pB at string B */ putchar('\n'); /* move down one line on the screen */ while(*pA != '\0') /* line A (see text) */ { *pB++ = *pA++; /* line B (see text) */ } *pB = '\0'; /* line C (see text) */ puts(strB); /* show strB on screen */ return 0; } ```
69,853,145
I'm studying pointers in C language with Ted Jensen's "A TUTORIAL ON POINTERS AND ARRAYS IN C" manual. It's a very prickly argument. **Question 1**. I have come to program 3.1 and would like a clarification. This is the program: ``` #include <stdio.h> char strA[80] = "A string to be used for demonstration purposes"; char strB[80]; int main(void) { char *pA; char *pB; puts(strA); pA = strA; puts(pA); pB = strB; putchar('\n'); while(*pA != '\0') { *pB++ = *pA++; } *pB = '\0'; puts(strB); return 0; } ``` Regarding the line `pA = strA;`, the book says "We then [point] the pointer pA at strA. That is, by means of the assignment statement we copy the address of strA [0] into our variable pA", which is what I don't understand. To copy the address of `strA[0]` into our variable pA via the assignment declaration, shouldn't we write `pA = & strA`? **Question 2**. The expression `c = * ++ p;` increases the value of `p` or the address of `p`? Does the indirection operator (`*`) not indicate the value of the pointed variable?
2021/11/05
[ "https://Stackoverflow.com/questions/69853145", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13975322/" ]
> > To copy the address of strA [0] into our variable pA via the assignment declaration, shouldn't we write `pA = & strA`? > > > `&strA` is the address of `strA`. `&strA[0]` is the address of `strA[0]`. These are the “same” in the sense they point to the same place in memory, but they have different types, and the compiler would complain if we wrote `pA = &strA` when the type of `pA` is a pointer to the type of the elements of `strA`. When we write `pA = strA`, the array `strA` is automatically converted to a pointer to its first element, so `pA = strA` is equivalent to `pA = &strA[0]`. > > Question 2: the expression `c = * ++ p;` increases the value of p or the address of p? > > > The C grammar organizes this as `c = *(++p);`, and `++p` increases the value of `p`. If `p` is a pointer, it increases the value of that pointer. The `*` operator uses the increased value. Be careful about speaking of the address of a pointer. The value of the pointer is an address, but you should not say that is the address of the pointer. The pointer is itself an object in memory, and so it has an address in memory where its value is stored. The address where a pointer is stored is different from the address stored in it. The “address of a pointer” is the address where the pointer is stored, not the value of the pointer.
In C, when you write : ``` char strA[80]; ``` Memory is allocated for your table. This is an example for you to try and visualize what it looks like. | [0] 1st Element | [1] 2nd Element | [2] 3rd Element | [....] .... | [n] nth Element | | --- | --- | --- | --- | --- | | 0000 | 0001 | 0002 | 0003 | n | **strA** is a pointer to the address where your table starts in the memory (0000 in our example), which is the same as the address of its first element **strA[0]**. So when you write ``` pA = strA ``` you are actually copying the first element's address (0000 in our example) to **pA**
69,853,145
I'm studying pointers in C language with Ted Jensen's "A TUTORIAL ON POINTERS AND ARRAYS IN C" manual. It's a very prickly argument. **Question 1**. I have come to program 3.1 and would like a clarification. This is the program: ``` #include <stdio.h> char strA[80] = "A string to be used for demonstration purposes"; char strB[80]; int main(void) { char *pA; char *pB; puts(strA); pA = strA; puts(pA); pB = strB; putchar('\n'); while(*pA != '\0') { *pB++ = *pA++; } *pB = '\0'; puts(strB); return 0; } ``` Regarding the line `pA = strA;`, the book says "We then [point] the pointer pA at strA. That is, by means of the assignment statement we copy the address of strA [0] into our variable pA", which is what I don't understand. To copy the address of `strA[0]` into our variable pA via the assignment declaration, shouldn't we write `pA = & strA`? **Question 2**. The expression `c = * ++ p;` increases the value of `p` or the address of `p`? Does the indirection operator (`*`) not indicate the value of the pointed variable?
2021/11/05
[ "https://Stackoverflow.com/questions/69853145", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13975322/" ]
> > To copy the address of strA [0] into our variable pA via the assignment declaration, shouldn't we write `pA = & strA`? > > > `&strA` is the address of `strA`. `&strA[0]` is the address of `strA[0]`. These are the “same” in the sense they point to the same place in memory, but they have different types, and the compiler would complain if we wrote `pA = &strA` when the type of `pA` is a pointer to the type of the elements of `strA`. When we write `pA = strA`, the array `strA` is automatically converted to a pointer to its first element, so `pA = strA` is equivalent to `pA = &strA[0]`. > > Question 2: the expression `c = * ++ p;` increases the value of p or the address of p? > > > The C grammar organizes this as `c = *(++p);`, and `++p` increases the value of `p`. If `p` is a pointer, it increases the value of that pointer. The `*` operator uses the increased value. Be careful about speaking of the address of a pointer. The value of the pointer is an address, but you should not say that is the address of the pointer. The pointer is itself an object in memory, and so it has an address in memory where its value is stored. The address where a pointer is stored is different from the address stored in it. The “address of a pointer” is the address where the pointer is stored, not the value of the pointer.
> > To copy the address of strA [0] into our variable pA via the assignment declaration, shouldn't we write pA = & strA? > > > Arrays are weird and don't behave like other types. The *expression* `strA` "decays" from type "N-element array of `char`" to "pointer to `char`", and the value of the expression is the address of the first element. This "decay" doesn't happen when the array expression is the operand of the `sizeof` or unary `&` operators, so the expression `&strA` has type "pointer to N-element array of `char`", or `char (*)[N]`, which is not the same as `char *`. The address value is the same (the address of an array is the same as the address of its first element), but the types are different. Assuming the declarations ``` char str[N]; // for some size N char *p; ``` when you write ``` p = str; // char * = char * ``` the *expression* `str` has type "N-element array of `char`"; however, since `str` is not the operand of the `sizeof` or unary `&` operators, it "decays" to type `char *` and evaluates to the address of the first element. It’s equivalent to writing ``` p = &str[0]; // char * = char * ``` There is a reason for this - C was derived from an earlier language named B, and in B array types had a dedicated pointer to the first element - when you declared an array in B like ``` auto a[N]; ``` what you got in memory was ``` +---+ a: | | -------+ +---+ | ... | +---+ | | | a[0] <-+ +---+ | | a[1] +---+ ... ``` and the array subscript operation `a[i]` was *defined* as `*(a + i)` - given the starting address `a`, offset `i` elements from that address and dereference the result. When he was designing C, Ritchie wanted to keep B's array behavior, but he didn't want to keep the explicit pointer that behavior required. When you declare an array in C like ``` int a[N]; ``` what you get in memory is ``` +---+ a: | | a[0] +---+ | | a[1] +---+ ... ``` Instead of setting aside space for an explicit pointer to the first element, the compiler replaces any occurrences of the expression `a` with a pointer to `a[0]`. So `a[i]` is still defined as `*(a + i)`. Unfortunately, this means that arrays lose their "array-ness" under most circumstances and most of the time what you're dealing with is a pointer. > > Question 2: the expression c = \* ++ p; increases the value of p or the address of p? > > > This gets a little complicated. To answer as asked, it increases the *value* of `p` - it sets `p` to point to the next object in a sequence. This is probably better explained with a concrete example. Assume the following declarations: ``` char str[] = "foo"; char *p = str; ``` then the following are true: ``` +---+ str: |'f'| str[0] <--- p +---+ |'o'| str[1] <--- p + 1 +---+ |'o'| str[2] <--- p + 2 +---+ | 0 | str[3] <--- p + 3 +---+ p == &str[0] // char * == char * *p == str[0] == 'f' // char == char == char p + 1 == &str[1] *(p + 1) == str[1] == 'o' p + 2 == &str[2] *(p + 2) == str[2] == 'o' ``` The result of the expression `p + 1` is a pointer to `str[1]`, the result of the expression `p + 2` is a pointer to `str[2]`, etc. `c = *++p;` is roughly equivalent to writing ``` tmp = p + 1; c = *tmp; p = p + 1; ``` with the caveat that the updates to `c` and `p` can happen *in any order* - they may even be evaluated simultaneously (either interleaved or in parallel). In this case, it means we assign the value of `*(p + 1)` (`'o'`) to `c`, and update `p` to point to `str[1]`, leaving us with this: ``` +---+ str: |'f'| str[0] +---+ |'o'| str[1] <--- p +---+ |'o'| str[2] <--- p + 1 +---+ | 0 | str[3] <--- p + 2 +---+ p == &str[1] *p == str[1] == 'o' p + 1 == &str[2] *(p + 1) == str[2] == 'o' p + 2 == &str[3] *(p + 2) == str[3] == 0 ```
57,637,594
I guys, I am new in angular. I created an angular app and in it I have 3 other generated components to test angular navigation. Here is what I need help with, in the "index.html" when I use "[(ngModel)]" in the an input element, it flags no error but if I try to use **"[(ngModel)]"** in any of the 3 created components html file, it gives my error. I have imported "FormsModule" in the app.module.ts. Please I do I make the ngModel property available in my sub html components? It will be appreciated if you answer with examples. Cheers
2019/08/24
[ "https://Stackoverflow.com/questions/57637594", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7408335/" ]
I've been fighting similar problems today (which is how I found your post). To get rid of the libEGL warning run raspi-config and select the "Full KMS" option from Advanced Options->GL Driver (then reboot). That likely won't fix your styling problem though - I'm seeing styling differences between the Pi (my target system) and my Linux Mint development system.
I have a similar problem and running it in the following way will solve it. ``` sudo python3.7 name.py ``` I guess some privilege is needed from the IDE or the current logged in user. Although the colors are still more opaque than in Windows and Ubuntu.
66,110,773
I need help whit my Code (PostgreSQL). I get in my row Result `{{2.0,10}{2.0,10}}` but I want `{{2.0,10}{3.0,20}}`. I don't know where my error is. Result is text `[ ]` its must be a 2D Array This is Table1 | Nummer | Name | Result | | --- | --- | --- | | 01 | Kevin | | This is Table2 | Nummer | Exam | ProfNr | | --- | --- | --- | | 01 | 2.0 | 10 | | 01 | 3.0 | 20 | My Code is ``` update public."Table1" as t1 set "Result" = ARRAY[[t2."Exam", t2."ProfNr"],[t2."Exam",t2."ProfNr"]] from public."Table2" as t2 where t1."Nummer"= 01 and t2."Nummer"=01; ```
2021/02/08
[ "https://Stackoverflow.com/questions/66110773", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15172345/" ]
After your `$mail->send();` function, you could try using the PHP in-built function `header();` So for instance in your case: ``` header('Location: /'); ``` This should redirect to home page after submission, where / is the main root of home page. Some more information on header(): <https://www.php.net/manual/en/function.header.php>
You should handle your `$mail->send()` to handle the success and failed response. Would write the code like this: ``` <?php use PHPMailer\PHPMailer\PHPMailer; if(isset($_POST['name']) && isset($_POST['email'])){ $name = $_POST['name']; $email = $_POST['email']; $subject = $_POST['subject']; $body = $_POST['body']; require_once "PHPMailer/PHPMailer.php"; require_once "PHPMailer/SMTP.php"; require_once "PHPMailer/Exception.php"; $mail = new PHPMailer(); //smtp settings $mail->isSMTP(); $mail->Host = "smtp.gmail.com"; $mail->SMTPAuth = true; $mail->Username = "[email protected]"; $mail->Password = '123'; $mail->Port = 465; $mail->SMTPSecure = "ssl"; //email settings $mail->isHTML(true); $mail->setFrom($email, $name); $mail->addAddress("[email protected]"); $mail->Subject = ("$email ($subject)"); $mail->Body = $body; if($mail->send()){ header('Location: your_url_here.php'); }else{ //do something when email delivery fails. } } ?>``` ```
10,217,558
To explain my problem more easily I will create the following fictional example, illustrating a very basic many-to-many relationship. A **Car** can have many **Parts**, and a **Part** can belong to many **Cars**. **DB SCHEMA:** ``` CAR_TABLE --------- CarId ModelName CAR_PARTS_TABLE --------------- CarId PartId PARTS_TABLE ----------- PartId PartName ``` **CLASSES:** ``` public class Car { public int CarId {get;set;} public string Name {get;set;} public IEnumerable<Part> Parts {get;set;} } public class Part { public int PartId {get;set;} public string Name {get;set} } ``` Using this very simple model I would like to get any cars that have all the parts assigned to them from a list of parts I am searching on. So say I have an array of PartIds: ``` var partIds = new [] { 1, 3, 10}; ``` I want to mimic the following c# code in terms of a database call: ``` var allCars = /* code to retrieve all cars */ var results = new List<Car>(); foreach (var car in allCars) { var containsAllParts = true; foreach (var carPart in car.Parts) { if (false == partIds.Contains(carPart.PartId)) { containsAllParts = false; break; } } if (containsAllParts) { results.Add(car); } } return results; ``` To be clear: I want to get the Cars that have ALL of the Parts specified from the partIds array. I have the following query, which is REALLY inefficient as it creates a subquery for each id within the partIds array and then does an IsIn query on each of their results. I am desperate to find a much more efficient manner to execute this query. ``` Car carAlias = null; Part partAlias = null; var searchCriteria = session.QueryOver<Car>(() => carAlias); foreach (var partId in partIds) { var carsWithPartCriteria = QueryOver.Of<Car>(() => carAlias) .JoinAlias(() => carAlias.Parts, () => partAlias) .Where(() => partAlias.PartId == partId) .Select(Projections.Distinct(Projections.Id())); searchCriteria = searchCriteria .And(Subqueries.WhereProperty(() => carAlias.Id).In(carsWithPartCriteria)); } var results = searchCriteria.List<Car>(); ``` Is there a decent way to execute this sort of query using NHibernate?
2012/04/18
[ "https://Stackoverflow.com/questions/10217558", "https://Stackoverflow.com", "https://Stackoverflow.com/users/350933/" ]
``` Part partAlias=null; Session.QueryOver<Car>().JoinQueryOver(x=>x.Parts,()=>partAlias) .WhereRestrictionOn(()=>partAlias.Id).IsIn(partIds) //partIds should be implement an ICollection .List<Car>(); ``` Hope that helps.
modified version of this [answer](https://stackoverflow.com/a/953461/40822) ``` var cars = session.CreateQuery("SELECT c.id FROM Car c JOIN c.Parts p WHERE p.PartId IN(:parts) GROUP BY c HAVING COUNT(DISTINCT p) = :partsCount") .SetParameterList("parts", partIds) .SetInt32("partsCount", partIds.Count) .List(); ``` AFAIK the `having` clause is only available in HQL. You could modify the select/group by list if you want more columns. Another possible way would be too generate an HQL query that inner joins to each specific part id. I don't think that is possible with ICritiria either as it only lets you join to a property once.
10,217,558
To explain my problem more easily I will create the following fictional example, illustrating a very basic many-to-many relationship. A **Car** can have many **Parts**, and a **Part** can belong to many **Cars**. **DB SCHEMA:** ``` CAR_TABLE --------- CarId ModelName CAR_PARTS_TABLE --------------- CarId PartId PARTS_TABLE ----------- PartId PartName ``` **CLASSES:** ``` public class Car { public int CarId {get;set;} public string Name {get;set;} public IEnumerable<Part> Parts {get;set;} } public class Part { public int PartId {get;set;} public string Name {get;set} } ``` Using this very simple model I would like to get any cars that have all the parts assigned to them from a list of parts I am searching on. So say I have an array of PartIds: ``` var partIds = new [] { 1, 3, 10}; ``` I want to mimic the following c# code in terms of a database call: ``` var allCars = /* code to retrieve all cars */ var results = new List<Car>(); foreach (var car in allCars) { var containsAllParts = true; foreach (var carPart in car.Parts) { if (false == partIds.Contains(carPart.PartId)) { containsAllParts = false; break; } } if (containsAllParts) { results.Add(car); } } return results; ``` To be clear: I want to get the Cars that have ALL of the Parts specified from the partIds array. I have the following query, which is REALLY inefficient as it creates a subquery for each id within the partIds array and then does an IsIn query on each of their results. I am desperate to find a much more efficient manner to execute this query. ``` Car carAlias = null; Part partAlias = null; var searchCriteria = session.QueryOver<Car>(() => carAlias); foreach (var partId in partIds) { var carsWithPartCriteria = QueryOver.Of<Car>(() => carAlias) .JoinAlias(() => carAlias.Parts, () => partAlias) .Where(() => partAlias.PartId == partId) .Select(Projections.Distinct(Projections.Id())); searchCriteria = searchCriteria .And(Subqueries.WhereProperty(() => carAlias.Id).In(carsWithPartCriteria)); } var results = searchCriteria.List<Car>(); ``` Is there a decent way to execute this sort of query using NHibernate?
2012/04/18
[ "https://Stackoverflow.com/questions/10217558", "https://Stackoverflow.com", "https://Stackoverflow.com/users/350933/" ]
This should be exactly what you want... ``` Part part = null; Car car = null; var qoParts = QueryOver.Of<Part>(() => part) .WhereRestrictionOn(x => x.PartId).IsIn(partIds) .JoinQueryOver(x => x.Cars, () => car) .Where(Restrictions.Eq(Projections.Count(() => car.CarId), partIds.Length)) .Select(Projections.Group(() => car.CarId)); ```
``` Part partAlias=null; Session.QueryOver<Car>().JoinQueryOver(x=>x.Parts,()=>partAlias) .WhereRestrictionOn(()=>partAlias.Id).IsIn(partIds) //partIds should be implement an ICollection .List<Car>(); ``` Hope that helps.
10,217,558
To explain my problem more easily I will create the following fictional example, illustrating a very basic many-to-many relationship. A **Car** can have many **Parts**, and a **Part** can belong to many **Cars**. **DB SCHEMA:** ``` CAR_TABLE --------- CarId ModelName CAR_PARTS_TABLE --------------- CarId PartId PARTS_TABLE ----------- PartId PartName ``` **CLASSES:** ``` public class Car { public int CarId {get;set;} public string Name {get;set;} public IEnumerable<Part> Parts {get;set;} } public class Part { public int PartId {get;set;} public string Name {get;set} } ``` Using this very simple model I would like to get any cars that have all the parts assigned to them from a list of parts I am searching on. So say I have an array of PartIds: ``` var partIds = new [] { 1, 3, 10}; ``` I want to mimic the following c# code in terms of a database call: ``` var allCars = /* code to retrieve all cars */ var results = new List<Car>(); foreach (var car in allCars) { var containsAllParts = true; foreach (var carPart in car.Parts) { if (false == partIds.Contains(carPart.PartId)) { containsAllParts = false; break; } } if (containsAllParts) { results.Add(car); } } return results; ``` To be clear: I want to get the Cars that have ALL of the Parts specified from the partIds array. I have the following query, which is REALLY inefficient as it creates a subquery for each id within the partIds array and then does an IsIn query on each of their results. I am desperate to find a much more efficient manner to execute this query. ``` Car carAlias = null; Part partAlias = null; var searchCriteria = session.QueryOver<Car>(() => carAlias); foreach (var partId in partIds) { var carsWithPartCriteria = QueryOver.Of<Car>(() => carAlias) .JoinAlias(() => carAlias.Parts, () => partAlias) .Where(() => partAlias.PartId == partId) .Select(Projections.Distinct(Projections.Id())); searchCriteria = searchCriteria .And(Subqueries.WhereProperty(() => carAlias.Id).In(carsWithPartCriteria)); } var results = searchCriteria.List<Car>(); ``` Is there a decent way to execute this sort of query using NHibernate?
2012/04/18
[ "https://Stackoverflow.com/questions/10217558", "https://Stackoverflow.com", "https://Stackoverflow.com/users/350933/" ]
This should be exactly what you want... ``` Part part = null; Car car = null; var qoParts = QueryOver.Of<Part>(() => part) .WhereRestrictionOn(x => x.PartId).IsIn(partIds) .JoinQueryOver(x => x.Cars, () => car) .Where(Restrictions.Eq(Projections.Count(() => car.CarId), partIds.Length)) .Select(Projections.Group(() => car.CarId)); ```
modified version of this [answer](https://stackoverflow.com/a/953461/40822) ``` var cars = session.CreateQuery("SELECT c.id FROM Car c JOIN c.Parts p WHERE p.PartId IN(:parts) GROUP BY c HAVING COUNT(DISTINCT p) = :partsCount") .SetParameterList("parts", partIds) .SetInt32("partsCount", partIds.Count) .List(); ``` AFAIK the `having` clause is only available in HQL. You could modify the select/group by list if you want more columns. Another possible way would be too generate an HQL query that inner joins to each specific part id. I don't think that is possible with ICritiria either as it only lets you join to a property once.
40,280,440
I've been looking but can't find an answer to this so I'm hoping someone can help. I have two tables Table 1 (audited items) ``` audit_session_id asset_number Audit1 1 Audit1 2 Audit2 3 ``` Table 2 (asset) ``` asset_number location<br> 1 15 2 10 3 15 ``` What I want is a table of assets that appear in Table 2 but not in Table 1 for a given location and audit\_session\_id. What I have is: ``` SELECT a.asset_number FROM auditeditems ai RIGHT JOIN asset a on ai.asset_number = a.asset_number WHERE ai.asset_number IS NULL AND a.location_id=15; ``` However I can't filter on audit\_session\_id as it is NULL. So I get the result: 1,3 when it should just be 1. (assuming I was looking at the audit1 session) I keep thinking this should be straight forward but can't see where I'm going wrong. Thanks in Advance
2016/10/27
[ "https://Stackoverflow.com/questions/40280440", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7079298/" ]
Unfortunately, there is little the SO community can help with if you don't provide even a log trace or a code snippet (doesn't have to be directly executable, but an MWE helps). First, you should use [DCMI `hasPart` term](http://dublincore.org/documents/dcmi-terms/#terms-hasPart) for representing `hasPart` relationship. I recommend that you [check all Model statements](https://jena.apache.org/tutorials/rdf_api.html#ch-Statements) before you save it. After that [make sure you are in a Transaction](https://jena.apache.org/documentation/javadoc/arq/org/apache/jena/query/Dataset.html#isInTransaction--). If this helps you, please update the question properly so that this can become an answer to a *real question*, not just a vague description of the problem.
It proved that extracting the resource from the `Dataset` and using that reference instead (the code was holding a reference to the instance created in the first place) adding the property (hasPart) proved to work as expected. No error reported by the logging framework, and the hasPart-property is in place. The resources affected resides in the default graph of the `Dataset`. *Observation*: using `getResource(uri)` does return the resource, but it seems to be a copy (?) as the instance id:s differ. Thanks berezovskiy for helping out on the details of this.
257,454
I don't know if this can be done in an home environment but I would like to make a powerful system and have that providing a way for all my home computers to connect to having their own profile as if they were logging into their own account on a windows machine. I would prefer a Windows 7 Based OS. Is there such thing? I would think Windows Server 2008 R2 with Hyper V machines associated to each account for logging in? Is that the only concept? Thanks
2011/03/14
[ "https://superuser.com/questions/257454", "https://superuser.com", "https://superuser.com/users/46390/" ]
That sounds like the basic Roaming Profiles facility that all Windows Server editions (certainly since Server 2000) provides. 1. Install a windows server, and set it up as an Active Directory Server. 2. Join the workstations into the Domain you created as part of Step 1. You now have centralised user management and profile storage at your fingertips.
Both [Windows Home Server](http://www.microsoft.com/windows/products/winfamily/windowshomeserver/default.mspx) (new release out soon which is 2008 R2 based) and [Windows Small Business Server 2011](http://www.microsoft.com/oem/en/products/servers/Pages/sbs_overview.aspx) offer features which should help. Home server has the ability to sync accounts from various computers in a Work Group setting for many centralized tasks where as SBS is a single enterprise in a box setup with Active Directory, Exchange, SharePoint and WSUS.
13,348,002
So I need my objects to be able to use functions that are within the main class, so when they are created I want them to get it through their parameters. ``` int main(int argc, char* args[]) { Unit units[3]={{5,5,this},{8,8,this},{12,12,this}}; units[0].init(true); for (int i=1;i<sizeof(units) / sizeof(units[0]);i++) { units[i].init(false); } ``` Where i put "this" it should be the main class, this is how I would do it in java but I am unsure how to do it here. I tried "\*this" and "this" but all I get is an error: Invalid use of 'this' in non-member function. Searching for the error gave me nothing to work with since I am rather unknowing on c++'s class systems. The two first parameters are for the location. The Init commands parameter sets whether they are allies or not. I want the Unit classes to be able to access: ``` int getClosestHostileX(int ask_x,int ask_y,bool team) { return 55; } ``` There is supposed to be more code here later I am just trying to get them to return. I am using Code::Blocks IDE and GNU GCC compiler. TL;DR How do I make my other classes access functions from my main class?
2012/11/12
[ "https://Stackoverflow.com/questions/13348002", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1818669/" ]
In C++, `main` is not a class nor is it part of a class, so `this` doesn't make sense in its context.
c++ isn't like java. You don't need to have all of your methods(or functions as they're called in c++) inside a class. `main` is a function, not a class. there is no `this` Now you can have global variables, or you can put variables/objects on the heap, for other classes to be able to use, but in general, c# doesn't actually have a Main class.
13,348,002
So I need my objects to be able to use functions that are within the main class, so when they are created I want them to get it through their parameters. ``` int main(int argc, char* args[]) { Unit units[3]={{5,5,this},{8,8,this},{12,12,this}}; units[0].init(true); for (int i=1;i<sizeof(units) / sizeof(units[0]);i++) { units[i].init(false); } ``` Where i put "this" it should be the main class, this is how I would do it in java but I am unsure how to do it here. I tried "\*this" and "this" but all I get is an error: Invalid use of 'this' in non-member function. Searching for the error gave me nothing to work with since I am rather unknowing on c++'s class systems. The two first parameters are for the location. The Init commands parameter sets whether they are allies or not. I want the Unit classes to be able to access: ``` int getClosestHostileX(int ask_x,int ask_y,bool team) { return 55; } ``` There is supposed to be more code here later I am just trying to get them to return. I am using Code::Blocks IDE and GNU GCC compiler. TL;DR How do I make my other classes access functions from my main class?
2012/11/12
[ "https://Stackoverflow.com/questions/13348002", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1818669/" ]
You couldn't do that in Java, either. In Java, the entrypoint is a static method and has no associated object instance. The solution is the same -- instantiate your type. ``` int main(int argc, char** argv) { MainClass main_object; // creates an instance Unit units[3]={{5,5,&main_object},{8,8,&main_object},{12,12,&main_object}}; units[0].init(true); for (int i=1;i<sizeof(units) / sizeof(units[0]);i++) { units[i].init(false); } ```
In C++, `main` is not a class nor is it part of a class, so `this` doesn't make sense in its context.
13,348,002
So I need my objects to be able to use functions that are within the main class, so when they are created I want them to get it through their parameters. ``` int main(int argc, char* args[]) { Unit units[3]={{5,5,this},{8,8,this},{12,12,this}}; units[0].init(true); for (int i=1;i<sizeof(units) / sizeof(units[0]);i++) { units[i].init(false); } ``` Where i put "this" it should be the main class, this is how I would do it in java but I am unsure how to do it here. I tried "\*this" and "this" but all I get is an error: Invalid use of 'this' in non-member function. Searching for the error gave me nothing to work with since I am rather unknowing on c++'s class systems. The two first parameters are for the location. The Init commands parameter sets whether they are allies or not. I want the Unit classes to be able to access: ``` int getClosestHostileX(int ask_x,int ask_y,bool team) { return 55; } ``` There is supposed to be more code here later I am just trying to get them to return. I am using Code::Blocks IDE and GNU GCC compiler. TL;DR How do I make my other classes access functions from my main class?
2012/11/12
[ "https://Stackoverflow.com/questions/13348002", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1818669/" ]
You couldn't do that in Java, either. In Java, the entrypoint is a static method and has no associated object instance. The solution is the same -- instantiate your type. ``` int main(int argc, char** argv) { MainClass main_object; // creates an instance Unit units[3]={{5,5,&main_object},{8,8,&main_object},{12,12,&main_object}}; units[0].init(true); for (int i=1;i<sizeof(units) / sizeof(units[0]);i++) { units[i].init(false); } ```
c++ isn't like java. You don't need to have all of your methods(or functions as they're called in c++) inside a class. `main` is a function, not a class. there is no `this` Now you can have global variables, or you can put variables/objects on the heap, for other classes to be able to use, but in general, c# doesn't actually have a Main class.
740
I'm trying to override a view table from within my module. I can't locate what the arguments are suppose to be and in what order (for my hook\_theme func). I copied the theme file from views/themes and did no modifications. Does anyone know what is going wrong, and what should the arguments value be below? My theme configuration is currently: ``` 'views_view_table__opportunities_mentions' => array( 'arguments' => array( 'view' => NULL, 'title' => NULL, 'header' => NULL, 'fields' => null, 'class' => null, 'row_classes' => null, 'rows' => null ), 'template' => 'views-view-table--opportunities-mentions', 'original hook' => 'views_view_table', 'path' => drupal_get_path('module', 'smd') . '/theme', ), ```
2011/03/14
[ "https://drupal.stackexchange.com/questions/740", "https://drupal.stackexchange.com", "https://drupal.stackexchange.com/users/69/" ]
The easiest way to theme views is to edit the particular view in question and scroll down to find the link 'theme information'. This screen will tell you exactly what views theming templates that it is currently using and what templates you can make in your theme to override this output. That essentially all views theming is - overriding the default markup with something to suit you designs. @see <http://www.group42.ca/theming_views_2_the_basics> for an excellent tutorial on views theming **EDIT** If you want full control over the markup produced, *and* for this to be portable across themes, the only option you have is to create a custom module. This custom module could also have themeable components, and could even use a view to perform any heavy SQL (or you could just hand-write the SQL) Take a look at a similiar module to get you started, and have a read through [hook\_theme](http://api.drupal.org/api/drupal/modules--system--system.api.php/function/hook_theme/6)
The theme function you want to override, is a templated theme function. This means that a preprocess function is called, and them the variables are passed to the template. Preprocess functions are a bit different, in that only a single variable is passed to it: an array containing all variables, so the order of the variables are irrelevant. See: * [`template_preprocess_views_view_table`](http://api.lullabot.com/template_preprocess_views_view_table) * [`views-view-table.tpl.php`](http://drupalcode.org/project/views.git/blob_plain/refs/heads/6.x-2.x:/theme/views-view-table.tpl.php)
740
I'm trying to override a view table from within my module. I can't locate what the arguments are suppose to be and in what order (for my hook\_theme func). I copied the theme file from views/themes and did no modifications. Does anyone know what is going wrong, and what should the arguments value be below? My theme configuration is currently: ``` 'views_view_table__opportunities_mentions' => array( 'arguments' => array( 'view' => NULL, 'title' => NULL, 'header' => NULL, 'fields' => null, 'class' => null, 'row_classes' => null, 'rows' => null ), 'template' => 'views-view-table--opportunities-mentions', 'original hook' => 'views_view_table', 'path' => drupal_get_path('module', 'smd') . '/theme', ), ```
2011/03/14
[ "https://drupal.stackexchange.com/questions/740", "https://drupal.stackexchange.com", "https://drupal.stackexchange.com/users/69/" ]
The easiest way to theme views is to edit the particular view in question and scroll down to find the link 'theme information'. This screen will tell you exactly what views theming templates that it is currently using and what templates you can make in your theme to override this output. That essentially all views theming is - overriding the default markup with something to suit you designs. @see <http://www.group42.ca/theming_views_2_the_basics> for an excellent tutorial on views theming **EDIT** If you want full control over the markup produced, *and* for this to be portable across themes, the only option you have is to create a custom module. This custom module could also have themeable components, and could even use a view to perform any heavy SQL (or you could just hand-write the SQL) Take a look at a similiar module to get you started, and have a read through [hook\_theme](http://api.drupal.org/api/drupal/modules--system--system.api.php/function/hook_theme/6)
It's way better to preprocess the view. If you want to override just a particular display, you need to be specific. You must first create a tpl.php file for the view. You can figure out which one you want by looking at the theme information for your particular view. Here is an example: ![enter image description here](https://i.stack.imgur.com/pk1GA.jpg) You then want to find the template suggestions of row style, which is currently 'Table': ![enter image description here](https://i.stack.imgur.com/w7WBJ.jpg) *views-view-table.tpl.php* will override **every** view that has a table style. If you want to be specific to just this view, you're going to want (in this case) *views-view-table--frontpage.tpl.php* - replace 'frontpage' with whatever suggestions your view is giving you. You actually need to create this file in your theme directory. But what do you put in this file? Well, just click that 'Style output' link, and you will be presented with code that you can simply copy and paste right into that file. After saving this file, open up your template.php and create a preprocessor for it. Note that preprocessors *do not work* without the file being present in D6. Here is some stub code, keeping with our example: ``` function [theme-name]_preprocess_views_view_table__frontpage(&$vars) { // manipulate the $vars here ... } ``` $vars is passed by reference so you only have to manipulate the appropriate keys to do what you want.
740
I'm trying to override a view table from within my module. I can't locate what the arguments are suppose to be and in what order (for my hook\_theme func). I copied the theme file from views/themes and did no modifications. Does anyone know what is going wrong, and what should the arguments value be below? My theme configuration is currently: ``` 'views_view_table__opportunities_mentions' => array( 'arguments' => array( 'view' => NULL, 'title' => NULL, 'header' => NULL, 'fields' => null, 'class' => null, 'row_classes' => null, 'rows' => null ), 'template' => 'views-view-table--opportunities-mentions', 'original hook' => 'views_view_table', 'path' => drupal_get_path('module', 'smd') . '/theme', ), ```
2011/03/14
[ "https://drupal.stackexchange.com/questions/740", "https://drupal.stackexchange.com", "https://drupal.stackexchange.com/users/69/" ]
The easiest way to theme views is to edit the particular view in question and scroll down to find the link 'theme information'. This screen will tell you exactly what views theming templates that it is currently using and what templates you can make in your theme to override this output. That essentially all views theming is - overriding the default markup with something to suit you designs. @see <http://www.group42.ca/theming_views_2_the_basics> for an excellent tutorial on views theming **EDIT** If you want full control over the markup produced, *and* for this to be portable across themes, the only option you have is to create a custom module. This custom module could also have themeable components, and could even use a view to perform any heavy SQL (or you could just hand-write the SQL) Take a look at a similiar module to get you started, and have a read through [hook\_theme](http://api.drupal.org/api/drupal/modules--system--system.api.php/function/hook_theme/6)
It actually looks mostly correct to me, I used the same code in my module. I wanted to package my template file with my view in the module. As the site uses the regular bartik theme for admin and I didn't want to edit that theme to add my CSS. What I believe is wrong is the following: ``` 'views_view_table__opportunities_mentions' => array( 'arguments' => array( 'view' => NULL, 'title' => NULL, 'header' => NULL, 'fields' => null, 'class' => null, 'row_classes' => null, 'rows' => null ), 'template' => 'views-view-table--opportunities-mentions', 'base hook' => 'views_view_table', 'path' => drupal_get_path('module', 'smd') . '/theme', ), ``` Note that instead of `original hook`, it should be `base hook`. This is required that view has own preprocess functions to be correctly wired to your tpl. If you don't set that correctly it will pick up your custom tpl anyway, but you'll get all kinds of errors about missing or null variables in the tpl because the preprocess function didn't set any of the variables that the tpl uses.
28,714,622
my project is in **vbnet**. i have a **stored procedure**, and get the results with **linq**. i know how to get it with sql adapter, which is easy in sorting and filtering, but i have to do it with linq. my code is like that. ``` dgv.DataSource = db.Egitek_Gorev_Listesi(LoggedUserID) ``` data is shown in datagridview, but i can not filter,**search** or **order** in it. does anybody know a better way todo it.
2015/02/25
[ "https://Stackoverflow.com/questions/28714622", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3950877/" ]
The corresponding entity for `dbo.AspNetUserLogins` table is `IdentityUserLogin` class. So we just need to declare an appropriate `IDbSet<IdentityUserLogin>` or `DbSet<IdentityUserLogin>` property in the `ApplicationDbContext` class as follows: ``` public class ApplicationDbContext : IdentityDbContext<ApplicationUser> { // ... public IDbSet<IdentityUserLogin> UserLogins { get; set; } // ... } ``` and then query it as usually: ``` using (var dbContext = new ApplicationDbContext()) { var userLogins = dbContext.UserLogins.ToList(); } ```
I know this is old but for anyone looking to do this with asp .Net Core: Add user manager to your controller constructor that you can access below by DI. ``` var user = await _userManager.GetUserAsync(User); var hello = await _userManager.GetLoginsAsync(user); ```
38,286
I know that memorising the whole the Quran is fard kifaya but are there any other fard kifaya acts ?
2017/03/05
[ "https://islam.stackexchange.com/questions/38286", "https://islam.stackexchange.com", "https://islam.stackexchange.com/users/20796/" ]
The most known examples are the funeral prayer (salat al-Janazah beside the janazah -burying itself- and the ghusl of the dead person), jihad, memorizing quran, getting or seeking knowledge, enjoining what is good and forbidding what is evil and ijtihad. What constitutes fard al-kifaya فرض كفاية is that it is an obligation on the Ummah, but if any of them perform this obligation the rest would be exempt from performing it, but if nobody does it the Ummah would be considered as sinning. > > قال الإمام الشافعي رحمه الله : "حق على الناس غسل الميت ، والصلاة عليه ودفنه ، لا يسع عامتهم تركه. وإذا قام به من فيه كفاية أجزأ عنهم ، إن شاء الله تعالى" انتهى من "الأم" (source [islamqa#131270](https://islamqa.info/ar/131270)) > > > Al-Imam a-Shafi'i has written in his al-Umm: "a right people must fulfill is washing the dead, praying on him and burying him, and they can't leave it all of them, if enough people did it those would be rewarded and the rest exempt from it, if Allah wills" > > > But a fard kifaya can easily move from this state to the state of fard 'ayn فرض عين, an obligation which must be performed by anybody (except people who have special conditions). For example if Muslims don't have their own physicians anybody would be asked to learn this science until we would have a capable person, if nobody re-reads the sources and does ijtihad we are all asked to do so until we find at least one capable person. And for jihad it is fard kifaya for jihad to attack the enemy (if this is an allowed option) or help oppressed Muslims in a place far away, but if the enemy is in your country it would be fard 'ayn to fight him! Some relevant posts: [Is ijtihad open in Islam (Sunni view)?](https://islam.stackexchange.com/questions/17371/is-ijtihad-open-in-islam-sunni-view/26101#26101) [Levels of approval/disapproval](https://islam.stackexchange.com/questions/35381/levels-of-approval-disapproval/35385#35385)
example: The five daily prayers for which muslims are individually responsible!
35,121
While leveling in Skyrim I put a perk in a tree, but now I feel like it is wasted, since I've found blowing things up with spells is much more fun than stabbing things with a giant sword. Is there anyway for me to recover the wasted perk? I'm on the PC so I was guessing console commands could help.
2011/11/11
[ "https://gaming.stackexchange.com/questions/35121", "https://gaming.stackexchange.com", "https://gaming.stackexchange.com/users/3015/" ]
If you are on PC, you can use the console to add and remove perks. **Finding a perk id:** help [name of perk] 4 *help Armsman 4* **Removing a perk** player.removeperk [perk id] *player.removeperk 00079342* **Adding a perk** player.addperk [perk id] *player.addperk 00079342* Notes: * You can use the PageUp/PageDown keys to scroll the console. * Use double quotes when searching for a perk with a space: "Steel Smithing" -yx * The [UESP](http://www.uesp.net/wiki/Template:Skills_in_Skyrim) has the perk id for all the skills. -Mark Trapp
You can get the skill up to 100, make it legendary to make the skill 15 again. The perks you dumped into it will be removed and you can reuse them
35,121
While leveling in Skyrim I put a perk in a tree, but now I feel like it is wasted, since I've found blowing things up with spells is much more fun than stabbing things with a giant sword. Is there anyway for me to recover the wasted perk? I'm on the PC so I was guessing console commands could help.
2011/11/11
[ "https://gaming.stackexchange.com/questions/35121", "https://gaming.stackexchange.com", "https://gaming.stackexchange.com/users/3015/" ]
If you are on PC, you can use the console to add and remove perks. **Finding a perk id:** help [name of perk] 4 *help Armsman 4* **Removing a perk** player.removeperk [perk id] *player.removeperk 00079342* **Adding a perk** player.addperk [perk id] *player.addperk 00079342* Notes: * You can use the PageUp/PageDown keys to scroll the console. * Use double quotes when searching for a perk with a space: "Steel Smithing" -yx * The [UESP](http://www.uesp.net/wiki/Template:Skills_in_Skyrim) has the perk id for all the skills. -Mark Trapp
For PC. An easy solution related to all perks, so you can basically recreate your char: This mod will remove all perks and add the right ammount removed as perk points: [Ishs Respec Mod](http://www.nexusmods.com/skyrim/mods/16471/?) If there remain any perks after the above mod being used, use the console to remove them (as explained by [Arkive post](https://gaming.stackexchange.com/a/35140/45976), you can even create a bat file to make it easier later on) and use this mod: [Perk Point Potion](http://www.nexusmods.com/skyrim/mods/10836/?) to get the right ammount of perk points back.
35,121
While leveling in Skyrim I put a perk in a tree, but now I feel like it is wasted, since I've found blowing things up with spells is much more fun than stabbing things with a giant sword. Is there anyway for me to recover the wasted perk? I'm on the PC so I was guessing console commands could help.
2011/11/11
[ "https://gaming.stackexchange.com/questions/35121", "https://gaming.stackexchange.com", "https://gaming.stackexchange.com/users/3015/" ]
There is no way to reset your perks on the Xbox 360 without the Dragonborn DLC, and no way to do it on the PlayStation 3 until Bethesda releases Dragonborn for that console, but you can redo your perks in the PC version of the game by using the [console commands](http://www.uesp.net/wiki/Skyrim:Console): ``` player.removeperk <perk ID> player.addperk <perk ID> ``` Where `<perk ID>` is replaced with the code for the perk you want to change. [The UESP Wiki](http://www.uesp.net/wiki/Template:Skills_in_Skyrim) contains a list of these codes. Careful with these: they have been reports that they will brand you a cheater and prevent you from gaining any achievements, but this is disputed.
For PC. An easy solution related to all perks, so you can basically recreate your char: This mod will remove all perks and add the right ammount removed as perk points: [Ishs Respec Mod](http://www.nexusmods.com/skyrim/mods/16471/?) If there remain any perks after the above mod being used, use the console to remove them (as explained by [Arkive post](https://gaming.stackexchange.com/a/35140/45976), you can even create a bat file to make it easier later on) and use this mod: [Perk Point Potion](http://www.nexusmods.com/skyrim/mods/10836/?) to get the right ammount of perk points back.
35,121
While leveling in Skyrim I put a perk in a tree, but now I feel like it is wasted, since I've found blowing things up with spells is much more fun than stabbing things with a giant sword. Is there anyway for me to recover the wasted perk? I'm on the PC so I was guessing console commands could help.
2011/11/11
[ "https://gaming.stackexchange.com/questions/35121", "https://gaming.stackexchange.com", "https://gaming.stackexchange.com/users/3015/" ]
You can remove perks you currently have by using: > > player.removeperk *perkid* > > > To find out the id of the perk, type this in: > > help "perk name here" 0 > > > This will bring up a list of all items matching your query (hopefully it contains the perk in that list). To add a perk: > > player.addperk *perkid* > > > **Note:** for perks that have multiple levels, you will have to remove all the perks for those skills to clear it out. i.e. one handed has 5 levels, the way skyrim tracks that is to add a perk for each level, so there are 5 different perks for one handed. To redistribute your stats, you can use: > > player.setav *stat value* > > > However this will not persist across saves, to do that use: > > player.modav *stat amount\_to\_modify\_by* > > > That can be used to set all skills and stats.
If you have the Dragonborn DLC, play through the main DLC questline. One of the rewards of completing the [At the Summit of Apocrypha](http://www.uesp.net/wiki/Dragonborn:At_the_Summit_of_Apocrypha) quest is: > > A book that transports you to Hermaeus Mora's realm, and allows you to reset perks at the cost of one Dragon Soul per tree. > > >
35,121
While leveling in Skyrim I put a perk in a tree, but now I feel like it is wasted, since I've found blowing things up with spells is much more fun than stabbing things with a giant sword. Is there anyway for me to recover the wasted perk? I'm on the PC so I was guessing console commands could help.
2011/11/11
[ "https://gaming.stackexchange.com/questions/35121", "https://gaming.stackexchange.com", "https://gaming.stackexchange.com/users/3015/" ]
Alternatively to cheating, there are other options: 1. Get yourself killed, your perk won't be saved. 2. Quit the game abruptly without saving, your perk won't be saved. 3. Although not really fair, you could return to a previous save game.
For PC. An easy solution related to all perks, so you can basically recreate your char: This mod will remove all perks and add the right ammount removed as perk points: [Ishs Respec Mod](http://www.nexusmods.com/skyrim/mods/16471/?) If there remain any perks after the above mod being used, use the console to remove them (as explained by [Arkive post](https://gaming.stackexchange.com/a/35140/45976), you can even create a bat file to make it easier later on) and use this mod: [Perk Point Potion](http://www.nexusmods.com/skyrim/mods/10836/?) to get the right ammount of perk points back.
35,121
While leveling in Skyrim I put a perk in a tree, but now I feel like it is wasted, since I've found blowing things up with spells is much more fun than stabbing things with a giant sword. Is there anyway for me to recover the wasted perk? I'm on the PC so I was guessing console commands could help.
2011/11/11
[ "https://gaming.stackexchange.com/questions/35121", "https://gaming.stackexchange.com", "https://gaming.stackexchange.com/users/3015/" ]
If you are on PC, you can use the console to add and remove perks. **Finding a perk id:** help [name of perk] 4 *help Armsman 4* **Removing a perk** player.removeperk [perk id] *player.removeperk 00079342* **Adding a perk** player.addperk [perk id] *player.addperk 00079342* Notes: * You can use the PageUp/PageDown keys to scroll the console. * Use double quotes when searching for a perk with a space: "Steel Smithing" -yx * The [UESP](http://www.uesp.net/wiki/Template:Skills_in_Skyrim) has the perk id for all the skills. -Mark Trapp
Alternatively to cheating, there are other options: 1. Get yourself killed, your perk won't be saved. 2. Quit the game abruptly without saving, your perk won't be saved. 3. Although not really fair, you could return to a previous save game.
35,121
While leveling in Skyrim I put a perk in a tree, but now I feel like it is wasted, since I've found blowing things up with spells is much more fun than stabbing things with a giant sword. Is there anyway for me to recover the wasted perk? I'm on the PC so I was guessing console commands could help.
2011/11/11
[ "https://gaming.stackexchange.com/questions/35121", "https://gaming.stackexchange.com", "https://gaming.stackexchange.com/users/3015/" ]
You can get the skill up to 100, make it legendary to make the skill 15 again. The perks you dumped into it will be removed and you can reuse them
For PC. An easy solution related to all perks, so you can basically recreate your char: This mod will remove all perks and add the right ammount removed as perk points: [Ishs Respec Mod](http://www.nexusmods.com/skyrim/mods/16471/?) If there remain any perks after the above mod being used, use the console to remove them (as explained by [Arkive post](https://gaming.stackexchange.com/a/35140/45976), you can even create a bat file to make it easier later on) and use this mod: [Perk Point Potion](http://www.nexusmods.com/skyrim/mods/10836/?) to get the right ammount of perk points back.
35,121
While leveling in Skyrim I put a perk in a tree, but now I feel like it is wasted, since I've found blowing things up with spells is much more fun than stabbing things with a giant sword. Is there anyway for me to recover the wasted perk? I'm on the PC so I was guessing console commands could help.
2011/11/11
[ "https://gaming.stackexchange.com/questions/35121", "https://gaming.stackexchange.com", "https://gaming.stackexchange.com/users/3015/" ]
If you have the Dragonborn DLC, play through the main DLC questline. One of the rewards of completing the [At the Summit of Apocrypha](http://www.uesp.net/wiki/Dragonborn:At_the_Summit_of_Apocrypha) quest is: > > A book that transports you to Hermaeus Mora's realm, and allows you to reset perks at the cost of one Dragon Soul per tree. > > >
Alternatively to cheating, there are other options: 1. Get yourself killed, your perk won't be saved. 2. Quit the game abruptly without saving, your perk won't be saved. 3. Although not really fair, you could return to a previous save game.
35,121
While leveling in Skyrim I put a perk in a tree, but now I feel like it is wasted, since I've found blowing things up with spells is much more fun than stabbing things with a giant sword. Is there anyway for me to recover the wasted perk? I'm on the PC so I was guessing console commands could help.
2011/11/11
[ "https://gaming.stackexchange.com/questions/35121", "https://gaming.stackexchange.com", "https://gaming.stackexchange.com/users/3015/" ]
If you have the Dragonborn DLC, play through the main DLC questline. One of the rewards of completing the [At the Summit of Apocrypha](http://www.uesp.net/wiki/Dragonborn:At_the_Summit_of_Apocrypha) quest is: > > A book that transports you to Hermaeus Mora's realm, and allows you to reset perks at the cost of one Dragon Soul per tree. > > >
For PC. An easy solution related to all perks, so you can basically recreate your char: This mod will remove all perks and add the right ammount removed as perk points: [Ishs Respec Mod](http://www.nexusmods.com/skyrim/mods/16471/?) If there remain any perks after the above mod being used, use the console to remove them (as explained by [Arkive post](https://gaming.stackexchange.com/a/35140/45976), you can even create a bat file to make it easier later on) and use this mod: [Perk Point Potion](http://www.nexusmods.com/skyrim/mods/10836/?) to get the right ammount of perk points back.
35,121
While leveling in Skyrim I put a perk in a tree, but now I feel like it is wasted, since I've found blowing things up with spells is much more fun than stabbing things with a giant sword. Is there anyway for me to recover the wasted perk? I'm on the PC so I was guessing console commands could help.
2011/11/11
[ "https://gaming.stackexchange.com/questions/35121", "https://gaming.stackexchange.com", "https://gaming.stackexchange.com/users/3015/" ]
You can remove perks you currently have by using: > > player.removeperk *perkid* > > > To find out the id of the perk, type this in: > > help "perk name here" 0 > > > This will bring up a list of all items matching your query (hopefully it contains the perk in that list). To add a perk: > > player.addperk *perkid* > > > **Note:** for perks that have multiple levels, you will have to remove all the perks for those skills to clear it out. i.e. one handed has 5 levels, the way skyrim tracks that is to add a perk for each level, so there are 5 different perks for one handed. To redistribute your stats, you can use: > > player.setav *stat value* > > > However this will not persist across saves, to do that use: > > player.modav *stat amount\_to\_modify\_by* > > > That can be used to set all skills and stats.
Alternatively to cheating, there are other options: 1. Get yourself killed, your perk won't be saved. 2. Quit the game abruptly without saving, your perk won't be saved. 3. Although not really fair, you could return to a previous save game.
1,086,806
Since I upgraded from Ubuntu 16.04 to 18.04, both Filezilla and Firefox always open in full-screen mode, no matter how I have adjusted them before closing. What can I do to change this annoying behaviour?
2018/10/24
[ "https://askubuntu.com/questions/1086806", "https://askubuntu.com", "https://askubuntu.com/users/885664/" ]
Either: 1. Double-click on the application's titlebar to minimize/maximize the window. 2. Use the GNOME Tweaks tool, and enable the following, and then click the little square icon in the top-right corner of the application's window. [![enter image description here](https://i.stack.imgur.com/nihCZ.png)](https://i.stack.imgur.com/nihCZ.png) **Update #1:** In `terminal`... ``` cd ~/.mozilla/firefox # change to firefox prefs directory ls -al *.default # the one with the newest date is yours cd {.default directory found before} # change to your user directory ls -alt | grep "Oct 25" # note which files changed today ``` one of these files is causing your problem...
Problem with Firefox has been solved by software update. Don't know if it was a Firefox problem or something in Ubuntu. Problem with Filezilla always opening at full-screen continues but I can live with that. Thanks for all your suggestions -- it has been a learning experience for me.
521,702
I am a LaTeX newbie. I am curious to hear your recommendations about the best places to learn it. More precisely, I am going to start writing my doctoral thesis in it. Our school already has a template but I would like to get the basics first before diving into that template. With that, I plan to continue writing my journal articles in LaTeX instead of MS Word (which is, as you may relate, sometimes painfully unfriendly to scholars when it comes to formatting).
2019/12/23
[ "https://tex.stackexchange.com/questions/521702", "https://tex.stackexchange.com", "https://tex.stackexchange.com/users/203832/" ]
My go to is [Wiki](https://en.wikibooks.org/wiki/LaTeX). It literally has everything you need. It is laid out pretty great where you can both learn, and use it as a reference. I use it often. Also, the TeX - LaTeX StackExchange is an excellent place to get answers to specific problems. Once you have an appropriate template, this will give you everything you need to format your thesis. Good luck! Also, don't bog yourself down with the details (in my opinion). Understanding exactly what the LaTeX code is doing is going down a rabbit hole. Just focus on understanding what you need to do what you want.
I suggest that you just start using LaTeX for small projects, perhaps at [sharelatex](https://www.google.com/search?client=ubuntu&channel=fs&q=sharelatex&ie=utf-8&oe=utf-8) or [overleaf](https://www.overleaf.com/). If you're really brand new to it, search online for *latex tutorial*. Once you are underway, learn features as you need them. Ask questions on this site. For a large project like your thesis, check out the [workflow tag](https://tex.stackexchange.com/questions/tagged/workflow). You will find strategies for working on one chapter at a time by setting up a good file structure and naming conventions. @Shinobii is right to warn you not to try to understand too much about LaTeX innards. You will probably never have to read what's in the university thesis template.
521,702
I am a LaTeX newbie. I am curious to hear your recommendations about the best places to learn it. More precisely, I am going to start writing my doctoral thesis in it. Our school already has a template but I would like to get the basics first before diving into that template. With that, I plan to continue writing my journal articles in LaTeX instead of MS Word (which is, as you may relate, sometimes painfully unfriendly to scholars when it comes to formatting).
2019/12/23
[ "https://tex.stackexchange.com/questions/521702", "https://tex.stackexchange.com", "https://tex.stackexchange.com/users/203832/" ]
My go to is [Wiki](https://en.wikibooks.org/wiki/LaTeX). It literally has everything you need. It is laid out pretty great where you can both learn, and use it as a reference. I use it often. Also, the TeX - LaTeX StackExchange is an excellent place to get answers to specific problems. Once you have an appropriate template, this will give you everything you need to format your thesis. Good luck! Also, don't bog yourself down with the details (in my opinion). Understanding exactly what the LaTeX code is doing is going down a rabbit hole. Just focus on understanding what you need to do what you want.
Check out the IITB LaTeX course at edX
521,702
I am a LaTeX newbie. I am curious to hear your recommendations about the best places to learn it. More precisely, I am going to start writing my doctoral thesis in it. Our school already has a template but I would like to get the basics first before diving into that template. With that, I plan to continue writing my journal articles in LaTeX instead of MS Word (which is, as you may relate, sometimes painfully unfriendly to scholars when it comes to formatting).
2019/12/23
[ "https://tex.stackexchange.com/questions/521702", "https://tex.stackexchange.com", "https://tex.stackexchange.com/users/203832/" ]
Little known fact: arXiv is great for this. Look for papers in your field on arXiv, and instead of downloading the pdf, download the source file (changing the file type if needed, so that it will open). Not only will you learn how to make fancy tables, pictures, etc... --- you will also often get to read all the comments that the authors neglected to remove before submitting their paper.
I suggest that you just start using LaTeX for small projects, perhaps at [sharelatex](https://www.google.com/search?client=ubuntu&channel=fs&q=sharelatex&ie=utf-8&oe=utf-8) or [overleaf](https://www.overleaf.com/). If you're really brand new to it, search online for *latex tutorial*. Once you are underway, learn features as you need them. Ask questions on this site. For a large project like your thesis, check out the [workflow tag](https://tex.stackexchange.com/questions/tagged/workflow). You will find strategies for working on one chapter at a time by setting up a good file structure and naming conventions. @Shinobii is right to warn you not to try to understand too much about LaTeX innards. You will probably never have to read what's in the university thesis template.
521,702
I am a LaTeX newbie. I am curious to hear your recommendations about the best places to learn it. More precisely, I am going to start writing my doctoral thesis in it. Our school already has a template but I would like to get the basics first before diving into that template. With that, I plan to continue writing my journal articles in LaTeX instead of MS Word (which is, as you may relate, sometimes painfully unfriendly to scholars when it comes to formatting).
2019/12/23
[ "https://tex.stackexchange.com/questions/521702", "https://tex.stackexchange.com", "https://tex.stackexchange.com/users/203832/" ]
I suggest that you just start using LaTeX for small projects, perhaps at [sharelatex](https://www.google.com/search?client=ubuntu&channel=fs&q=sharelatex&ie=utf-8&oe=utf-8) or [overleaf](https://www.overleaf.com/). If you're really brand new to it, search online for *latex tutorial*. Once you are underway, learn features as you need them. Ask questions on this site. For a large project like your thesis, check out the [workflow tag](https://tex.stackexchange.com/questions/tagged/workflow). You will find strategies for working on one chapter at a time by setting up a good file structure and naming conventions. @Shinobii is right to warn you not to try to understand too much about LaTeX innards. You will probably never have to read what's in the university thesis template.
Check out the IITB LaTeX course at edX
521,702
I am a LaTeX newbie. I am curious to hear your recommendations about the best places to learn it. More precisely, I am going to start writing my doctoral thesis in it. Our school already has a template but I would like to get the basics first before diving into that template. With that, I plan to continue writing my journal articles in LaTeX instead of MS Word (which is, as you may relate, sometimes painfully unfriendly to scholars when it comes to formatting).
2019/12/23
[ "https://tex.stackexchange.com/questions/521702", "https://tex.stackexchange.com", "https://tex.stackexchange.com/users/203832/" ]
Little known fact: arXiv is great for this. Look for papers in your field on arXiv, and instead of downloading the pdf, download the source file (changing the file type if needed, so that it will open). Not only will you learn how to make fancy tables, pictures, etc... --- you will also often get to read all the comments that the authors neglected to remove before submitting their paper.
Check out the IITB LaTeX course at edX
61,197,916
I've got myself a bit confused regarding variables in Python, just looking for a bit of clarification. In the following code, I will pass a global variable into my own Python function which simply takes the value and multiplies it by 2. Very simple. It does not return the variable after. The output from the print function at the end prints 10500 rather than 21000, indicating that the local variable created within the function did not actually edit the global variable that was passed to, but rather used the value as its argument. ``` balance = 10500 def test(balance): balance = balance * 2 test(balance) print(balance) ``` However, in my second piece of code here, when I pass a list/array into a separate function for bubble sorting, it is the actual array that is edited, rather than the function just using the values. ``` def bubble_sort(scores): swapped = True while swapped: swapped = False for i in range(0, len(scores)-1): if scores[i] > scores[i+1]: temp = scores[i] scores[i] = scores[i+1] scores[i+1] = temp swapped = True scores = [60, 50, 60, 58, 54, 54] bubble_sort(scores) print(scores) ``` Now when I print my scores list, it has been sorted. I am confused as to why the top function did not change the global variable that was passed to it, while the second function did? I understand using the global keyword within functions means I am still able to write code that will edit a global variable within my own functions, but maybe I am missing some basic understanding.
2020/04/13
[ "https://Stackoverflow.com/questions/61197916", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9200058/" ]
Thank You Botje! Thank You very much for trying to help me. But I have no time anymore for learning openssl. So I found a great one: **<https://github.com/Thalhammer/jwt-cpp>** from here **jwt.io** It doesn't support the 'scope' field for the jwt-claim, so I just added a method into a class into a header: 'set\_scope(...);'. Ten, 10... Nooo, You just can't feel my pain beacuse of openssl\_from\_devs\_with\_crooked\_hands\_with\_no\_human\_docs. 10 strings of a code and it's done! It has simple sources, so You can find out how to work with ssl from there. If You want to use OpenSSL lib and don't know how it works - **think twice**, may be it's the worst choice of Your life. Good luck!
No need to mark this answer as accepted, yours is by far the easier solution. I'm posting this for future readers to find. For what it's worth, I was able to reproduce the raw hash in the RS256 test case with the following: ``` void die() { for (int err = ERR_get_error(); err != 0; err = ERR_get_error()) { fprintf(stderr, "%s\n", ERR_error_string(err, nullptr)); } exit(1); } int main() { /* md is a SHA-256 digest in this example. */ BIO *pem_BIO = BIO_new_mem_buf(RSA_pem, sizeof(RSA_pem)); EVP_PKEY *signing_key = PEM_read_bio_PrivateKey(pem_BIO, nullptr, nullptr, nullptr); const unsigned char header_payload[] = "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXUyJ9.eyJpc3MiOiJhdXRoMCJ9"; EVP_MD_CTX * MD_ctx = EVP_MD_CTX_new(); bool success = true; success = EVP_DigestSignInit(MD_ctx, nullptr, EVP_get_digestbyname(SN_sha256WithRSAEncryption), nullptr, signing_key); if (!success) die(); unsigned char sigbuf[512]; size_t siglen = sizeof(sigbuf); success = EVP_DigestSign(MD_ctx, sigbuf, &siglen, header_payload, sizeof(header_payload)-1); if (!success) die(); fwrite(sigbuf, 1, siglen, stdout); } ``` The end result still has to be base64-encoded (with the url-safe alphabet), though.
61,197,916
I've got myself a bit confused regarding variables in Python, just looking for a bit of clarification. In the following code, I will pass a global variable into my own Python function which simply takes the value and multiplies it by 2. Very simple. It does not return the variable after. The output from the print function at the end prints 10500 rather than 21000, indicating that the local variable created within the function did not actually edit the global variable that was passed to, but rather used the value as its argument. ``` balance = 10500 def test(balance): balance = balance * 2 test(balance) print(balance) ``` However, in my second piece of code here, when I pass a list/array into a separate function for bubble sorting, it is the actual array that is edited, rather than the function just using the values. ``` def bubble_sort(scores): swapped = True while swapped: swapped = False for i in range(0, len(scores)-1): if scores[i] > scores[i+1]: temp = scores[i] scores[i] = scores[i+1] scores[i+1] = temp swapped = True scores = [60, 50, 60, 58, 54, 54] bubble_sort(scores) print(scores) ``` Now when I print my scores list, it has been sorted. I am confused as to why the top function did not change the global variable that was passed to it, while the second function did? I understand using the global keyword within functions means I am still able to write code that will edit a global variable within my own functions, but maybe I am missing some basic understanding.
2020/04/13
[ "https://Stackoverflow.com/questions/61197916", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9200058/" ]
Thank You Botje! Thank You very much for trying to help me. But I have no time anymore for learning openssl. So I found a great one: **<https://github.com/Thalhammer/jwt-cpp>** from here **jwt.io** It doesn't support the 'scope' field for the jwt-claim, so I just added a method into a class into a header: 'set\_scope(...);'. Ten, 10... Nooo, You just can't feel my pain beacuse of openssl\_from\_devs\_with\_crooked\_hands\_with\_no\_human\_docs. 10 strings of a code and it's done! It has simple sources, so You can find out how to work with ssl from there. If You want to use OpenSSL lib and don't know how it works - **think twice**, may be it's the worst choice of Your life. Good luck!
Just for future people looking this up and struggle how to compute a RS256 (SHA256WithRSA)-Hash in OpenSSL, since I spent about 5 hours researching the error. The [code from Botje](https://stackoverflow.com/a/61224645/7182007) is quite close, but is missing the *Finalize* method (and the destructors). ```cpp #include <OpenSSL/obj_mac.h> #include <OpenSSL/evp.h> #include <OpenSSL/pem.h> #include <OpenSSL/bio.h> bool SHA256WithRSA(const std::string RSAKey, const std::string Data) { struct bio_st* pem_BIO = BIO_new(BIO_s_mem()); if (BIO_write(pem_BIO, RSAKey.data(), RSAKey.size()) != RSAKey.size()) { BIO_free_all(pem_BIO); return false; } struct evp_pkey_st* signing_key = PEM_read_bio_PrivateKey(pem_BIO, nullptr, nullptr, nullptr); if(signing_key == nullptr) { BIO_free_all(pem_BIO); EVP_PKEY_free(signing_key); return false; } std::string ResultBuffer(EVP_PKEY_size(signing_key), '\0'); unsigned int len = 0; struct evp_md_ctx_st * MD_ctx = EVP_MD_CTX_new(); if (!EVP_SignInit(MD_ctx, EVP_get_digestbyname(SN_sha256WithRSAEncryption)) || !EVP_SignUpdate(MD_ctx, Data.data(), Data.size()) || EVP_SignFinal(MD_ctx, (unsigned char*)ResultBuffer.data(), &len, signing_key) == 0) { BIO_free_all(pem_BIO); EVP_PKEY_free(signing_key); EVP_MD_CTX_free(MD_ctx); return false; } ResultBuffer.resize(len); /* Do something with the ResultBuffer */ BIO_free_all(pem_BIO); EVP_PKEY_free(signing_key); EVP_MD_CTX_free(MD_ctx); return true; } ```
61,197,916
I've got myself a bit confused regarding variables in Python, just looking for a bit of clarification. In the following code, I will pass a global variable into my own Python function which simply takes the value and multiplies it by 2. Very simple. It does not return the variable after. The output from the print function at the end prints 10500 rather than 21000, indicating that the local variable created within the function did not actually edit the global variable that was passed to, but rather used the value as its argument. ``` balance = 10500 def test(balance): balance = balance * 2 test(balance) print(balance) ``` However, in my second piece of code here, when I pass a list/array into a separate function for bubble sorting, it is the actual array that is edited, rather than the function just using the values. ``` def bubble_sort(scores): swapped = True while swapped: swapped = False for i in range(0, len(scores)-1): if scores[i] > scores[i+1]: temp = scores[i] scores[i] = scores[i+1] scores[i+1] = temp swapped = True scores = [60, 50, 60, 58, 54, 54] bubble_sort(scores) print(scores) ``` Now when I print my scores list, it has been sorted. I am confused as to why the top function did not change the global variable that was passed to it, while the second function did? I understand using the global keyword within functions means I am still able to write code that will edit a global variable within my own functions, but maybe I am missing some basic understanding.
2020/04/13
[ "https://Stackoverflow.com/questions/61197916", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9200058/" ]
Just for future people looking this up and struggle how to compute a RS256 (SHA256WithRSA)-Hash in OpenSSL, since I spent about 5 hours researching the error. The [code from Botje](https://stackoverflow.com/a/61224645/7182007) is quite close, but is missing the *Finalize* method (and the destructors). ```cpp #include <OpenSSL/obj_mac.h> #include <OpenSSL/evp.h> #include <OpenSSL/pem.h> #include <OpenSSL/bio.h> bool SHA256WithRSA(const std::string RSAKey, const std::string Data) { struct bio_st* pem_BIO = BIO_new(BIO_s_mem()); if (BIO_write(pem_BIO, RSAKey.data(), RSAKey.size()) != RSAKey.size()) { BIO_free_all(pem_BIO); return false; } struct evp_pkey_st* signing_key = PEM_read_bio_PrivateKey(pem_BIO, nullptr, nullptr, nullptr); if(signing_key == nullptr) { BIO_free_all(pem_BIO); EVP_PKEY_free(signing_key); return false; } std::string ResultBuffer(EVP_PKEY_size(signing_key), '\0'); unsigned int len = 0; struct evp_md_ctx_st * MD_ctx = EVP_MD_CTX_new(); if (!EVP_SignInit(MD_ctx, EVP_get_digestbyname(SN_sha256WithRSAEncryption)) || !EVP_SignUpdate(MD_ctx, Data.data(), Data.size()) || EVP_SignFinal(MD_ctx, (unsigned char*)ResultBuffer.data(), &len, signing_key) == 0) { BIO_free_all(pem_BIO); EVP_PKEY_free(signing_key); EVP_MD_CTX_free(MD_ctx); return false; } ResultBuffer.resize(len); /* Do something with the ResultBuffer */ BIO_free_all(pem_BIO); EVP_PKEY_free(signing_key); EVP_MD_CTX_free(MD_ctx); return true; } ```
No need to mark this answer as accepted, yours is by far the easier solution. I'm posting this for future readers to find. For what it's worth, I was able to reproduce the raw hash in the RS256 test case with the following: ``` void die() { for (int err = ERR_get_error(); err != 0; err = ERR_get_error()) { fprintf(stderr, "%s\n", ERR_error_string(err, nullptr)); } exit(1); } int main() { /* md is a SHA-256 digest in this example. */ BIO *pem_BIO = BIO_new_mem_buf(RSA_pem, sizeof(RSA_pem)); EVP_PKEY *signing_key = PEM_read_bio_PrivateKey(pem_BIO, nullptr, nullptr, nullptr); const unsigned char header_payload[] = "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXUyJ9.eyJpc3MiOiJhdXRoMCJ9"; EVP_MD_CTX * MD_ctx = EVP_MD_CTX_new(); bool success = true; success = EVP_DigestSignInit(MD_ctx, nullptr, EVP_get_digestbyname(SN_sha256WithRSAEncryption), nullptr, signing_key); if (!success) die(); unsigned char sigbuf[512]; size_t siglen = sizeof(sigbuf); success = EVP_DigestSign(MD_ctx, sigbuf, &siglen, header_payload, sizeof(header_payload)-1); if (!success) die(); fwrite(sigbuf, 1, siglen, stdout); } ``` The end result still has to be base64-encoded (with the url-safe alphabet), though.
40,671,349
As per the title, I need a string format where ``` sprintf(xxx,5) prints "5" sprintf(xxx,5.1) prints "5.1" sprintf(xxx,15.1234) prints "15.12" ``` That is: no leading zeros, no trailing zeros, maximum of 2 decimals. Is it possible? if not with sprintf, some other way? The use case is to report degrees of freedom which are generally whole numbers, but when corrected, may result in decimals - for which case only I want to add two decimals).
2016/11/18
[ "https://Stackoverflow.com/questions/40671349", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2986596/" ]
Maybe `formatC` is easier for this: ``` formatC(c(5, 5.1, 5.1234), digits = 2, format = "f", drop0trailing = TRUE) #[1] "5" "5.1" "5.12" ```
A solution based on `sprintf` as suggested: ``` sprintf("%.4g", 5) #[1] "5" sprintf("%.4g", 5.1) #[1] "5.1" sprintf("%.4g", 15.1234) #[1] "15.12" ``` Verbose information to `sprintf` can be found e.g. here: <http://www.cplusplus.com/reference/cstdio/printf/> which says: > > g | Use the shortest representation: %e or %f > > > and > > .number | ... For g and G specifiers: This is the maximum number of significant digits to be printed. > > >
28,861,972
This should be quite simple but I didn`t manage to find it. If I am running some batch script in cmd, how do I get process id of the hosting cmd? ``` set currentCmdPid= /* some magic */ echo %currentCmdPid% ``` I have found a lot of solutions that use `tasklist` and name filtering but I believe that this won`t work for me, since there can be launched many instances of cmd. Again, I`d like to have some simple elegant and bullet-proof solution. Thanks.
2015/03/04
[ "https://Stackoverflow.com/questions/28861972", "https://Stackoverflow.com", "https://Stackoverflow.com/users/945343/" ]
Here the topic has been discussed -> <http://www.dostips.com/forum/viewtopic.php?p=38870> Here's my solution: ``` @if (@X)==(@Y) @end /* JScript comment @echo off setlocal for /f "tokens=* delims=" %%v in ('dir /b /s /a:-d /o:-n "%SystemRoot%\Microsoft.NET\Framework\*jsc.exe"') do ( set "jsc=%%v" ) if not exist "%~n0.exe" ( "%jsc%" /nologo /out:"%~n0.exe" "%~dpsfnx0" ) %~n0.exe endlocal & exit /b %errorlevel% */ import System; import System.Diagnostics; import System.ComponentModel; import System.Management; var myId = Process.GetCurrentProcess().Id; var query = String.Format("SELECT ParentProcessId FROM Win32_Process WHERE ProcessId = {0}", myId); var search = new ManagementObjectSearcher("root\\CIMV2", query); var results = search.Get().GetEnumerator(); if (!results.MoveNext()) { Console.WriteLine("Error"); Environment.Exit(-1); } var queryObj = results.Current; var parentId = queryObj["ParentProcessId"]; var parent = Process.GetProcessById(parentId); Console.WriteLine(parent.Id); ```
To get cmd PID, from cmd I run powershell and get parent process Id -- that will be cmd PID. Script gets parent of a parent (since `FOR /F` calls another cmd.exe). ``` FOR /F "tokens=* USEBACKQ" %%F IN (`powershell -c "(gwmi win32_process | ? processid -eq ((gwmi win32_process | ? processid -eq $PID).parentprocessid)).parentprocessid"`) DO ( SET PCT_CleanAfterPID=%%F ) ECHO %PCT_CleanAfterPID% ```
28,861,972
This should be quite simple but I didn`t manage to find it. If I am running some batch script in cmd, how do I get process id of the hosting cmd? ``` set currentCmdPid= /* some magic */ echo %currentCmdPid% ``` I have found a lot of solutions that use `tasklist` and name filtering but I believe that this won`t work for me, since there can be launched many instances of cmd. Again, I`d like to have some simple elegant and bullet-proof solution. Thanks.
2015/03/04
[ "https://Stackoverflow.com/questions/28861972", "https://Stackoverflow.com", "https://Stackoverflow.com/users/945343/" ]
Here is [my pure batch script version](http://www.dostips.com/forum/viewtopic.php?p=38870#p38870) that resulted from the [same DosTips discussion and collaborative effort that npocmaka referenced](http://www.dostips.com/forum/viewtopic.php?p=38870). ``` @echo off :getPID [RtnVar] :: :: Store the Process ID (PID) of the currently running script in environment variable :: RtnVar. If called without any argument, then simply write the PID to stdout. :: setlocal disableDelayedExpansion :getLock set "lock=%temp%\%~nx0.%time::=.%.lock" set "uid=%lock:\=:b%" set "uid=%uid:,=:c%" set "uid=%uid:'=:q%" set "uid=%uid:_=:u%" setlocal enableDelayedExpansion set "uid=!uid:%%=:p!" endlocal & set "uid=%uid%" 2>nul ( 9>"%lock%" ( for /f "skip=1" %%A in ( 'wmic process where "name='cmd.exe' and CommandLine like '%%<%uid%>%%'" get ParentProcessID' ) do for %%B in (%%A) do set "PID=%%B" (call ) ))||goto :getLock del "%lock%" 2>nul endlocal & if "%~1" equ "" (echo(%PID%) else set "%~1=%PID%" exit /b ``` [npocmaka's solution](https://stackoverflow.com/a/28862165/1012053) installs an exe file (compiled JScript) in the same folder as the batch script. On my machine, my pure batch getPID runs 20% faster than npocmaka's exe! This is because the exe first determines its own process PID, which takes significant time, before it uses WMI to determine the desired parent PID. My script generates a unique ID (much faster) which gets incorporated into the WMIC call that determines the desired parent PID. In both solutions, the bulk of the time is spent within WMI where it determines the parent PID of a specific process.
To get cmd PID, from cmd I run powershell and get parent process Id -- that will be cmd PID. Script gets parent of a parent (since `FOR /F` calls another cmd.exe). ``` FOR /F "tokens=* USEBACKQ" %%F IN (`powershell -c "(gwmi win32_process | ? processid -eq ((gwmi win32_process | ? processid -eq $PID).parentprocessid)).parentprocessid"`) DO ( SET PCT_CleanAfterPID=%%F ) ECHO %PCT_CleanAfterPID% ```
3,650,353
Show that $2^n>\frac{(n-1)n}{2}$ without using induction. MY attempt : $$1+2+3+...+(n-2)+(n-1)=\frac{n(n-1)}{2}$$ Since $2^n>n$, $$2^n+2^n+2^n+...+2^n+2^n>\frac{n(n-1)}{2}$$ $$(n-1)2^n>\frac{n(n-1)}{2}$$ SO I'm getting an obvious fact :( How to do it without induction?
2020/04/29
[ "https://math.stackexchange.com/questions/3650353", "https://math.stackexchange.com", "https://math.stackexchange.com/users/280637/" ]
Suppose you have a finite set of $n$ elements. $2^n$ is the number of all possible subsets. $n(n-1)/2$ is the number of subsets of size exactly two, which is strictly less than the number of all possible subsets.
\begin{eqnarray} 2^0 &\geq& 1 \\ 2^1 &\geq& 2 \\ 2^2 &>& 3 \\ &\vdots& \\ 2^{n-1} &>& n-1 \quad \text{for } n>1 \\ \end{eqnarray} If you add everything up, you get (for $n>1$): $$ 2^n -1 = 2^0+2^1+...+2^{n-1} > 1+2+3+...+(n-1) = \frac{n(n-1)}{2} $$ which means that for $n>1$ $$ 2^n > 1+\frac{n(n-1)}{2} > \frac{n(n-1)}{2} $$ We can manually check that this inequality also holds for $n=1$
3,650,353
Show that $2^n>\frac{(n-1)n}{2}$ without using induction. MY attempt : $$1+2+3+...+(n-2)+(n-1)=\frac{n(n-1)}{2}$$ Since $2^n>n$, $$2^n+2^n+2^n+...+2^n+2^n>\frac{n(n-1)}{2}$$ $$(n-1)2^n>\frac{n(n-1)}{2}$$ SO I'm getting an obvious fact :( How to do it without induction?
2020/04/29
[ "https://math.stackexchange.com/questions/3650353", "https://math.stackexchange.com", "https://math.stackexchange.com/users/280637/" ]
Suppose you have a finite set of $n$ elements. $2^n$ is the number of all possible subsets. $n(n-1)/2$ is the number of subsets of size exactly two, which is strictly less than the number of all possible subsets.
If you are allowed to use "well known facts" WKF1: $2^n - 1=\sum\_{k=0}^{n-1} 2^k$. WKF2: $\frac {n(n-1)}2 = \sum\_{k=0}^{n-1} k$ WKF3: $2^k > k$ WKF4: $b\_k > a\_k$ then $\sum\_{k=0}^n b\_k > \sum\_{k=0}^n a\_k$. So ... $2^n> 2^n-1 =\sum\_{k=0}^{n-1} 2^k > \sum\_{k=0}^{n-1} k = \frac {n(n-1)}2$. .... But.... I'm not sure I'd call that a "proof without induction" as the WKFs were taken for granted without proofs and, most likely, to prove them one would have used induction.
3,650,353
Show that $2^n>\frac{(n-1)n}{2}$ without using induction. MY attempt : $$1+2+3+...+(n-2)+(n-1)=\frac{n(n-1)}{2}$$ Since $2^n>n$, $$2^n+2^n+2^n+...+2^n+2^n>\frac{n(n-1)}{2}$$ $$(n-1)2^n>\frac{n(n-1)}{2}$$ SO I'm getting an obvious fact :( How to do it without induction?
2020/04/29
[ "https://math.stackexchange.com/questions/3650353", "https://math.stackexchange.com", "https://math.stackexchange.com/users/280637/" ]
**Hint** For $n \geq 2$ you have: $$2^n=(1+1)^n= \sum\_{k=0}^n \binom{n}{k} > \binom{n}{2}$$
\begin{eqnarray} 2^0 &\geq& 1 \\ 2^1 &\geq& 2 \\ 2^2 &>& 3 \\ &\vdots& \\ 2^{n-1} &>& n-1 \quad \text{for } n>1 \\ \end{eqnarray} If you add everything up, you get (for $n>1$): $$ 2^n -1 = 2^0+2^1+...+2^{n-1} > 1+2+3+...+(n-1) = \frac{n(n-1)}{2} $$ which means that for $n>1$ $$ 2^n > 1+\frac{n(n-1)}{2} > \frac{n(n-1)}{2} $$ We can manually check that this inequality also holds for $n=1$
3,650,353
Show that $2^n>\frac{(n-1)n}{2}$ without using induction. MY attempt : $$1+2+3+...+(n-2)+(n-1)=\frac{n(n-1)}{2}$$ Since $2^n>n$, $$2^n+2^n+2^n+...+2^n+2^n>\frac{n(n-1)}{2}$$ $$(n-1)2^n>\frac{n(n-1)}{2}$$ SO I'm getting an obvious fact :( How to do it without induction?
2020/04/29
[ "https://math.stackexchange.com/questions/3650353", "https://math.stackexchange.com", "https://math.stackexchange.com/users/280637/" ]
\begin{eqnarray} 2^0 &\geq& 1 \\ 2^1 &\geq& 2 \\ 2^2 &>& 3 \\ &\vdots& \\ 2^{n-1} &>& n-1 \quad \text{for } n>1 \\ \end{eqnarray} If you add everything up, you get (for $n>1$): $$ 2^n -1 = 2^0+2^1+...+2^{n-1} > 1+2+3+...+(n-1) = \frac{n(n-1)}{2} $$ which means that for $n>1$ $$ 2^n > 1+\frac{n(n-1)}{2} > \frac{n(n-1)}{2} $$ We can manually check that this inequality also holds for $n=1$
If you are allowed to use "well known facts" WKF1: $2^n - 1=\sum\_{k=0}^{n-1} 2^k$. WKF2: $\frac {n(n-1)}2 = \sum\_{k=0}^{n-1} k$ WKF3: $2^k > k$ WKF4: $b\_k > a\_k$ then $\sum\_{k=0}^n b\_k > \sum\_{k=0}^n a\_k$. So ... $2^n> 2^n-1 =\sum\_{k=0}^{n-1} 2^k > \sum\_{k=0}^{n-1} k = \frac {n(n-1)}2$. .... But.... I'm not sure I'd call that a "proof without induction" as the WKFs were taken for granted without proofs and, most likely, to prove them one would have used induction.
3,650,353
Show that $2^n>\frac{(n-1)n}{2}$ without using induction. MY attempt : $$1+2+3+...+(n-2)+(n-1)=\frac{n(n-1)}{2}$$ Since $2^n>n$, $$2^n+2^n+2^n+...+2^n+2^n>\frac{n(n-1)}{2}$$ $$(n-1)2^n>\frac{n(n-1)}{2}$$ SO I'm getting an obvious fact :( How to do it without induction?
2020/04/29
[ "https://math.stackexchange.com/questions/3650353", "https://math.stackexchange.com", "https://math.stackexchange.com/users/280637/" ]
**Hint** For $n \geq 2$ you have: $$2^n=(1+1)^n= \sum\_{k=0}^n \binom{n}{k} > \binom{n}{2}$$
If you are allowed to use "well known facts" WKF1: $2^n - 1=\sum\_{k=0}^{n-1} 2^k$. WKF2: $\frac {n(n-1)}2 = \sum\_{k=0}^{n-1} k$ WKF3: $2^k > k$ WKF4: $b\_k > a\_k$ then $\sum\_{k=0}^n b\_k > \sum\_{k=0}^n a\_k$. So ... $2^n> 2^n-1 =\sum\_{k=0}^{n-1} 2^k > \sum\_{k=0}^{n-1} k = \frac {n(n-1)}2$. .... But.... I'm not sure I'd call that a "proof without induction" as the WKFs were taken for granted without proofs and, most likely, to prove them one would have used induction.
52,747,847
Write a function named "find\_value" that takes a key-value store as a parameter with strings as keys and integers as values. The function returns a boolean representing true if the value 7 is in the input as a value, false otherwise. (My code below) ``` function find_value(key){ for (var i of Object.values(key)){ if (i == 7){ return true; } else{ return false; } } } ``` When I call with the input `[{'effort': 4, 'doctrine': 8, 'item': 11, 'behavioral': 7, 'occasional': 11}]`, I should get `true`, but I am getting `false` instead. What am I doing wrong?
2018/10/10
[ "https://Stackoverflow.com/questions/52747847", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
Your loops is returning false on your first item, most likely. You should keep the condition and return true statement in the loop, but after the loop you should return false. P.S. You should name your parameter and set a default value for good practice. I renamed it in my example below. ``` function find_value(myObject = {}){ for (var i of Object.values(myObject)){ if (i == 7){ return true; } } return false; } ```
You have 2 problems here: 1. You are passing an array with an object inside. 2. In else you are returning false, so function will test only the first value. BTW it could be done this way: ``` return Object.values(obj).includes(7); ```
52,747,847
Write a function named "find\_value" that takes a key-value store as a parameter with strings as keys and integers as values. The function returns a boolean representing true if the value 7 is in the input as a value, false otherwise. (My code below) ``` function find_value(key){ for (var i of Object.values(key)){ if (i == 7){ return true; } else{ return false; } } } ``` When I call with the input `[{'effort': 4, 'doctrine': 8, 'item': 11, 'behavioral': 7, 'occasional': 11}]`, I should get `true`, but I am getting `false` instead. What am I doing wrong?
2018/10/10
[ "https://Stackoverflow.com/questions/52747847", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
Your loops is returning false on your first item, most likely. You should keep the condition and return true statement in the loop, but after the loop you should return false. P.S. You should name your parameter and set a default value for good practice. I renamed it in my example below. ``` function find_value(myObject = {}){ for (var i of Object.values(myObject)){ if (i == 7){ return true; } } return false; } ```
In order for this to work as expected, you should pass an object into `find_values()`, rather than an array as you are doing. Also, you will want to update the flow of your function, by returning false after loop iteration has completed: ```js function find_value(key){ for (var i of Object.values(key)){ // Only early return if matching value found if (i == 7){ return true; } } // Move return false outside of loop return false; } var object_input = {'effort': 4, 'doctrine': 8, 'item': 11, 'behavioral': 7, 'occasional': 11}; console.log( find_value(object_input) ); ```
52,747,847
Write a function named "find\_value" that takes a key-value store as a parameter with strings as keys and integers as values. The function returns a boolean representing true if the value 7 is in the input as a value, false otherwise. (My code below) ``` function find_value(key){ for (var i of Object.values(key)){ if (i == 7){ return true; } else{ return false; } } } ``` When I call with the input `[{'effort': 4, 'doctrine': 8, 'item': 11, 'behavioral': 7, 'occasional': 11}]`, I should get `true`, but I am getting `false` instead. What am I doing wrong?
2018/10/10
[ "https://Stackoverflow.com/questions/52747847", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
Your loops is returning false on your first item, most likely. You should keep the condition and return true statement in the loop, but after the loop you should return false. P.S. You should name your parameter and set a default value for good practice. I renamed it in my example below. ``` function find_value(myObject = {}){ for (var i of Object.values(myObject)){ if (i == 7){ return true; } } return false; } ```
Try ``` function find_value(key){ for (var i of Object.values(key)){ if (i == 7){ return true; } } } ```
52,747,847
Write a function named "find\_value" that takes a key-value store as a parameter with strings as keys and integers as values. The function returns a boolean representing true if the value 7 is in the input as a value, false otherwise. (My code below) ``` function find_value(key){ for (var i of Object.values(key)){ if (i == 7){ return true; } else{ return false; } } } ``` When I call with the input `[{'effort': 4, 'doctrine': 8, 'item': 11, 'behavioral': 7, 'occasional': 11}]`, I should get `true`, but I am getting `false` instead. What am I doing wrong?
2018/10/10
[ "https://Stackoverflow.com/questions/52747847", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
Your loops is returning false on your first item, most likely. You should keep the condition and return true statement in the loop, but after the loop you should return false. P.S. You should name your parameter and set a default value for good practice. I renamed it in my example below. ``` function find_value(myObject = {}){ for (var i of Object.values(myObject)){ if (i == 7){ return true; } } return false; } ```
Your function automatically returns true or false in the first iteration. The simplest solution that is very beginner-friendly is to set a boolean flag before the loop and check it at the end of the loop Also you were looping through the array and checking for a value when the loop would return you an object with property + value pairs. You want to get the values of those objects and check if it is equal to 7 ```js function find_value(key){ let flag = false; for (let i of key){ console.log(Object.values(i)); if (Object.values(i).indexOf(7) > -1) { flag = true; } } return flag; } console.log(find_value([{'effort': 4, 'doctrine': 8, 'item': 11, 'behavioral': 7, 'occasional': 11}])) ```
13,042,459
I have two tables. One is the "probe" and the other "transcript". Probe table: "probe" ProbeID-------TranscriptID---- ``` 2655 4555555 2600 5454542 2600 4543234 2344 5659595 ``` ...etc Transcript table: "transcript" TranscriptID----Location---- ``` 7896736 chr1 5454542 chr1 ``` ...etc I need to find out how many transcripts per chromosome? AND How many probes per chromosome? ``` SELECT COUNT(*) FROM transcript ``` = '28869' #Above I think gives me the transcripts per chromosome (i.e. location). I need help with answering the second part (and first, if its wrong). I am assuming I need to use the `JOIN` clause. Thank you.
2012/10/24
[ "https://Stackoverflow.com/questions/13042459", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1698774/" ]
I did this exact thing on a client site. I re-used the same product grid across the entire site and it was 100% DRY. I used the dev branch of Stash and used the new embed feature. While regular embeds are always an option that *work*, Stash embeds are more efficient and more powerful. The real difference is how you pass variables, and when the embed is parsed. With stash embeds can be used inside a looping tag, and parse the data just once. (Where as regular embeds get parsed with each iteration of the loop.) Here is a Gist I posted a while back for another user on Twitter. <https://gist.github.com/2950536> Note, the example represents multiple files and code blocks, or I would just post here. IMO, it would make this post hard to follow and read if I posted it here. Essentially it follows a modified template partials approach. More information on template partials. <http://eeinsider.com/blog/ee-podcast-stash-template-partials/> But to more directly answer the question of, "How does one replace embed variables with Stash?". The solution is rather simple and based on core programming concepts of "setters" and "getters".The theory is, if one sets a variable it can be retrieved at any later point in the template. The trick is settings the variables before the getters are parsed. ``` {exp:stash:set} {stash:page_content} {exp:channel:entries channel="your-channel"} {stash:your_var_1}Some value 1{/stash:your_var_1} {stash:your_var_2}Some value 2{/stash:your_var_2} {stash:your_var_3}Some value 3{/stash:your_var_3} {stash:your_var_4}Some value 4{/stash:your_var_4} {stash:embed name="your-template" process="start"} {/exp:channel:entries} {/stash:page_content} {/exp:stash:set} {stash:embed name="header" process="end"} ``` That's where the *process* parameter comes into play. This will allow you to embed your template *before* the entries loop is ran, and to embed the header which would contain the site wrapper and output the page content. Once you get the hang of it, it becomes really powerful and makes your sites so much cleaner.
You can either use embeds or possibly stash depending on what you are trying to pass. <https://github.com/croxton/Stash>
26,932,366
As a previous result of a bad TFS project management, several tasks has been created in the wrong work item. Now I need to move several tasks to different work items. Is there an easy way to do it? So far, I have to edit each task, remove the previos link to primary element and create a new one, but this is taking a lot of my time.
2014/11/14
[ "https://Stackoverflow.com/questions/26932366", "https://Stackoverflow.com", "https://Stackoverflow.com/users/897383/" ]
I suspect that the easiest way to do it would be from Excel. Create a Tree-based query that shows everything, then move the child records in Excel using simple cut and insert cut cells. Excel will then allow you to publish the new structure in one go. If you need to move items up to a higher or lower level, place the Title Field in the column representing the level. [See this little video I captured to show how it is done.](https://www.youtube.com/watch?v=86-8cb4LhS8&hd=1)
MS Project is extremely good with modifying hierarchies of work items. The steps are exactly the same as setting it up in Excel, but project inherently handles parent/child relationships, giving them a drag-and-drop interaction. jessehouwing's Excel answer will be easier if you have never worked with project before. **Updated** jesshouwing's comments are correct. Especially about the shivers.
16,375,500
I'm creating a hibernate app and I'm able to save data to dtb via `hibernate`. Nevertheless I wasn't able to figure out, how to retrieve data from database. Could anybody show me, how to do that in some way, that will be similar to the way, I save data? I've been googling a lot, but everything, I didn't find anything, that would look like my way... E.g. they used a lot of annotations etc. I'm quite new to hibernate, so it's possible, that this is not a good way, how to create hibernate applications. If so, pls write it in a comment. Part of my `UserDAOImpl`: ``` UserDAO user; public UserDAOImpl() { user = new UserDAO(); } public void createUser(int id, String Username, String CreatedBy) { user.setUserId(id); user.setUsername(Username); user.setCreatedBy(CreatedBy); user.setCreatedDate(new Date()); } public void saveUser() { Session session = HibernateUtil.getSessionFactory().openSession(); session.beginTransaction(); session.save(user); // save the data to the database session.getTransaction().commit(); // close the connection session.disconnect(); } public void findUser() { // ???????????? } ``` UserDAO: ``` public class UserDAO implements java.io.Serializable { /** * generated serialVersionUID */ private static final long serialVersionUID = -6440259681541809279L; private int userId; private String username; private String createdBy; private Date createdDate; public UserDAO() { } public UserDAO(int userId, String username, String createdBy, Date createdDate) { this.userId = userId; this.username = username; this.createdBy = createdBy; this.createdDate = createdDate; } public int getUserId() { return this.userId; } public void setUserId(int userId) { this.userId = userId; } public String getUsername() { return this.username; } public void setUsername(String username) { this.username = username; } public String getCreatedBy() { return this.createdBy; } public void setCreatedBy(String createdBy) { this.createdBy = createdBy; } public Date getCreatedDate() { return this.createdDate; } public void setCreatedDate(Date createdDate) { this.createdDate = createdDate; } } ```
2013/05/04
[ "https://Stackoverflow.com/questions/16375500", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1364923/" ]
Assuming the table name is User, here is the sample code to get a User data for an input userId: ``` public User findUserById(int userId) { Session session = HibernateUtil.getSessionFactory().openSession(); String queryString = "from User where userId = :userId"; Query query = session.createQuery(queryString); query.setInteger("userId", userId); Object queryResult = query.uniqueResult(); UserDAO user = (UserDAO)queryResult; } ```
In the end, I've found answer in another poste here, on SO. ``` // finds user by ID public UserDAO findUserById(int userId) { Session session = HibernateUtil.getSessionFactory().openSession(); session = HibernateUtil.getSessionFactory().openSession(); UserDAO userDAO = (UserDAO) session.get(UserDAO.class, userId); session.disconnect(); return userDAO; } ```
56,778,762
I am using SQL Server and in my database I have a date column of type `varchar` and has data like `04042011`. I am trying to write a query that is being used for another program and it is requesting the format in a military format such as `YYYY-MM-DD`. Is there any way to do this on the fly for `HireDate` and `SeparationDate`? ``` SELECT [EmployeeTC_No] AS "Employee TC #" ,[pye_nlast] AS "Name Last" ,[pye_nfirst] AS "Name First" ,[Dept] AS "Department" ,CASE WHEN [pye_status] = 'A' THEN 1 WHEN [pye_status] = 'T' THEN 0 ELSE NULL END AS "Active" ,[HireDate] AS "Hire Date" ,[SeparationDate] AS "Separation Date" FROM [OnBaseWorking].[dbo].[Employees] WHERE EmployeeTC_No != 'Not Assigned' AND LOWER(EmployeeTC_No) = LOWER('@primary') ``` Any help would be greatly appreciated. I only have read rights. So I am hoping I can do this on the fly I know dates should not be data type `varchar` and should be data type date. But I have no control over this and just trying to do what I can.
2019/06/26
[ "https://Stackoverflow.com/questions/56778762", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4106374/" ]
If truly 8 characters. I would stress use try\_convert() in case you have some bogus data. ``` Select try_convert(date,right(HierDate,4)+left(HierDate,4)) From YourTable ``` To Trap EMPTY values. This will return a NULL and not 1900-01-01 ``` Select try_convert(date,nullif(HierDate,'')+left(HierDate,4)) From YourTable ```
Concatenate the string from the [substrings](https://learn.microsoft.com/en-us/sql/t-sql/functions/substring-transact-sql?view=sql-server-2017) that you want. ``` SUBSTRING(YourField, {The position that the year starts}, 4) +'-'+ SUBSTRING(YourField, {The position that the month starts}, 2) +'-'+ SUBSTRING(YourField, {The position that the day starts}, 2) ```
71,815
Most of the work being done at my company is Qt-based C++, and it's all checked into a Subversion repository. Until now, all work on the codebase has been done purely with nano, or perhaps Kate. Being new here, I would like to take advantage of setting up Eclipse -properly- to edit my local copy of the tree. I have the CDT "version" of Eclipse, and the Qt integration, and the Subclipse module. At this point, though, I don't know what to do. Do I "import" the projects into an Eclipse-controlled workspace? Do I edit them in place? Nothing I've tried to do gets Eclipse to recognize that the "project" is a Qt application, so that I can get the integration working.
2008/09/16
[ "https://Stackoverflow.com/questions/71815", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11959/" ]
I have exactly the same situation at work (with CVS instead of subversion and the rest of the team using KDevelop but that's no big deal). Just start a new Qt Gui project using the Qt - Eclipse integration features and then remove all the auto generated files. Now using the "Team" features of eclipse and choose to share your project, enter the path to the repository and you 're good to go.
Second nikolavp - Checkout, and mark the option to use the new project wizard, then select Qt project. I've done this (with ganymede) and it successfully finds everything and builds correctly.
71,815
Most of the work being done at my company is Qt-based C++, and it's all checked into a Subversion repository. Until now, all work on the codebase has been done purely with nano, or perhaps Kate. Being new here, I would like to take advantage of setting up Eclipse -properly- to edit my local copy of the tree. I have the CDT "version" of Eclipse, and the Qt integration, and the Subclipse module. At this point, though, I don't know what to do. Do I "import" the projects into an Eclipse-controlled workspace? Do I edit them in place? Nothing I've tried to do gets Eclipse to recognize that the "project" is a Qt application, so that I can get the integration working.
2008/09/16
[ "https://Stackoverflow.com/questions/71815", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11959/" ]
OK, I've been playing around with this idea, and it has some merit. I can switch to the "SVN Project Exploring" perspective (which I hadn't noticed before), and do a checkout from the head of the sub-project I want. I get a nice SVN-linked copy of the tree in my Eclipse workspace for editing. Eclipse even "understands" the classes, and can do completion on methods and such. However, I still can't get Eclipse to understand that the project is a "QT Gui" project, such that I could view the properties, and control the linking of the various Qt libraries and the like. By extension, it also doesn't understand how to build my project, like it would be able to do if I had created an empty Qt Gui project from scratch. How do I get this part working?
The only way I could get this to work was to check out the project with eclipse and then copy over the .project and .cdtproject files from another Qt-project. Then do a refresh on the project. This is a horrible hack but it gets you started. You might need to define another builder for 'make'.
71,815
Most of the work being done at my company is Qt-based C++, and it's all checked into a Subversion repository. Until now, all work on the codebase has been done purely with nano, or perhaps Kate. Being new here, I would like to take advantage of setting up Eclipse -properly- to edit my local copy of the tree. I have the CDT "version" of Eclipse, and the Qt integration, and the Subclipse module. At this point, though, I don't know what to do. Do I "import" the projects into an Eclipse-controlled workspace? Do I edit them in place? Nothing I've tried to do gets Eclipse to recognize that the "project" is a Qt application, so that I can get the integration working.
2008/09/16
[ "https://Stackoverflow.com/questions/71815", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11959/" ]
I would create a new QT project in eclipse, then switch perspectives to subclipse and simply do a SVN checkout into the new eclipse project. You should be good to go.
OK, I've been playing around with this idea, and it has some merit. I can switch to the "SVN Project Exploring" perspective (which I hadn't noticed before), and do a checkout from the head of the sub-project I want. I get a nice SVN-linked copy of the tree in my Eclipse workspace for editing. Eclipse even "understands" the classes, and can do completion on methods and such. However, I still can't get Eclipse to understand that the project is a "QT Gui" project, such that I could view the properties, and control the linking of the various Qt libraries and the like. By extension, it also doesn't understand how to build my project, like it would be able to do if I had created an empty Qt Gui project from scratch. How do I get this part working?
71,815
Most of the work being done at my company is Qt-based C++, and it's all checked into a Subversion repository. Until now, all work on the codebase has been done purely with nano, or perhaps Kate. Being new here, I would like to take advantage of setting up Eclipse -properly- to edit my local copy of the tree. I have the CDT "version" of Eclipse, and the Qt integration, and the Subclipse module. At this point, though, I don't know what to do. Do I "import" the projects into an Eclipse-controlled workspace? Do I edit them in place? Nothing I've tried to do gets Eclipse to recognize that the "project" is a Qt application, so that I can get the integration working.
2008/09/16
[ "https://Stackoverflow.com/questions/71815", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11959/" ]
I would create a new QT project in eclipse, then switch perspectives to subclipse and simply do a SVN checkout into the new eclipse project. You should be good to go.
Checkout the project. It will ask you some options like if you want to start with a blank project, or want to use the tree to make a new project. Choose the latter and you should be ok :). It seems to work for me with Ganymed and subversive(not sure about subclipse and i don't remember.) :)
71,815
Most of the work being done at my company is Qt-based C++, and it's all checked into a Subversion repository. Until now, all work on the codebase has been done purely with nano, or perhaps Kate. Being new here, I would like to take advantage of setting up Eclipse -properly- to edit my local copy of the tree. I have the CDT "version" of Eclipse, and the Qt integration, and the Subclipse module. At this point, though, I don't know what to do. Do I "import" the projects into an Eclipse-controlled workspace? Do I edit them in place? Nothing I've tried to do gets Eclipse to recognize that the "project" is a Qt application, so that I can get the integration working.
2008/09/16
[ "https://Stackoverflow.com/questions/71815", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11959/" ]
OK, I've been playing around with this idea, and it has some merit. I can switch to the "SVN Project Exploring" perspective (which I hadn't noticed before), and do a checkout from the head of the sub-project I want. I get a nice SVN-linked copy of the tree in my Eclipse workspace for editing. Eclipse even "understands" the classes, and can do completion on methods and such. However, I still can't get Eclipse to understand that the project is a "QT Gui" project, such that I could view the properties, and control the linking of the various Qt libraries and the like. By extension, it also doesn't understand how to build my project, like it would be able to do if I had created an empty Qt Gui project from scratch. How do I get this part working?
My solution: 1. go to the svn-view and add the repository location for your project 2. check out the project some temporary location with svn or any client you like 3. choose 'File->Import...' and say 'Qt->Qt project' 4. browse to the location of the \*.pro file, select and hit the OK-Button 5. you are in the game with an appropriate Qt-project and Subversion Access for that project
71,815
Most of the work being done at my company is Qt-based C++, and it's all checked into a Subversion repository. Until now, all work on the codebase has been done purely with nano, or perhaps Kate. Being new here, I would like to take advantage of setting up Eclipse -properly- to edit my local copy of the tree. I have the CDT "version" of Eclipse, and the Qt integration, and the Subclipse module. At this point, though, I don't know what to do. Do I "import" the projects into an Eclipse-controlled workspace? Do I edit them in place? Nothing I've tried to do gets Eclipse to recognize that the "project" is a Qt application, so that I can get the integration working.
2008/09/16
[ "https://Stackoverflow.com/questions/71815", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11959/" ]
I have exactly the same situation at work (with CVS instead of subversion and the rest of the team using KDevelop but that's no big deal). Just start a new Qt Gui project using the Qt - Eclipse integration features and then remove all the auto generated files. Now using the "Team" features of eclipse and choose to share your project, enter the path to the repository and you 're good to go.
I would say the same as the last one, but instead of the two first steps I would set up the Qt-Eclipse integration: [Qt-Eclipse integration](http://www.qtsoftware.com/developer/eclipse-integration) before looking for the \*.pro file.
71,815
Most of the work being done at my company is Qt-based C++, and it's all checked into a Subversion repository. Until now, all work on the codebase has been done purely with nano, or perhaps Kate. Being new here, I would like to take advantage of setting up Eclipse -properly- to edit my local copy of the tree. I have the CDT "version" of Eclipse, and the Qt integration, and the Subclipse module. At this point, though, I don't know what to do. Do I "import" the projects into an Eclipse-controlled workspace? Do I edit them in place? Nothing I've tried to do gets Eclipse to recognize that the "project" is a Qt application, so that I can get the integration working.
2008/09/16
[ "https://Stackoverflow.com/questions/71815", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11959/" ]
OK, I've been playing around with this idea, and it has some merit. I can switch to the "SVN Project Exploring" perspective (which I hadn't noticed before), and do a checkout from the head of the sub-project I want. I get a nice SVN-linked copy of the tree in my Eclipse workspace for editing. Eclipse even "understands" the classes, and can do completion on methods and such. However, I still can't get Eclipse to understand that the project is a "QT Gui" project, such that I could view the properties, and control the linking of the various Qt libraries and the like. By extension, it also doesn't understand how to build my project, like it would be able to do if I had created an empty Qt Gui project from scratch. How do I get this part working?
I would say the same as the last one, but instead of the two first steps I would set up the Qt-Eclipse integration: [Qt-Eclipse integration](http://www.qtsoftware.com/developer/eclipse-integration) before looking for the \*.pro file.
71,815
Most of the work being done at my company is Qt-based C++, and it's all checked into a Subversion repository. Until now, all work on the codebase has been done purely with nano, or perhaps Kate. Being new here, I would like to take advantage of setting up Eclipse -properly- to edit my local copy of the tree. I have the CDT "version" of Eclipse, and the Qt integration, and the Subclipse module. At this point, though, I don't know what to do. Do I "import" the projects into an Eclipse-controlled workspace? Do I edit them in place? Nothing I've tried to do gets Eclipse to recognize that the "project" is a Qt application, so that I can get the integration working.
2008/09/16
[ "https://Stackoverflow.com/questions/71815", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11959/" ]
OK, I've been playing around with this idea, and it has some merit. I can switch to the "SVN Project Exploring" perspective (which I hadn't noticed before), and do a checkout from the head of the sub-project I want. I get a nice SVN-linked copy of the tree in my Eclipse workspace for editing. Eclipse even "understands" the classes, and can do completion on methods and such. However, I still can't get Eclipse to understand that the project is a "QT Gui" project, such that I could view the properties, and control the linking of the various Qt libraries and the like. By extension, it also doesn't understand how to build my project, like it would be able to do if I had created an empty Qt Gui project from scratch. How do I get this part working?
Checkout the project. It will ask you some options like if you want to start with a blank project, or want to use the tree to make a new project. Choose the latter and you should be ok :). It seems to work for me with Ganymed and subversive(not sure about subclipse and i don't remember.) :)
71,815
Most of the work being done at my company is Qt-based C++, and it's all checked into a Subversion repository. Until now, all work on the codebase has been done purely with nano, or perhaps Kate. Being new here, I would like to take advantage of setting up Eclipse -properly- to edit my local copy of the tree. I have the CDT "version" of Eclipse, and the Qt integration, and the Subclipse module. At this point, though, I don't know what to do. Do I "import" the projects into an Eclipse-controlled workspace? Do I edit them in place? Nothing I've tried to do gets Eclipse to recognize that the "project" is a Qt application, so that I can get the integration working.
2008/09/16
[ "https://Stackoverflow.com/questions/71815", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11959/" ]
OK, I've been playing around with this idea, and it has some merit. I can switch to the "SVN Project Exploring" perspective (which I hadn't noticed before), and do a checkout from the head of the sub-project I want. I get a nice SVN-linked copy of the tree in my Eclipse workspace for editing. Eclipse even "understands" the classes, and can do completion on methods and such. However, I still can't get Eclipse to understand that the project is a "QT Gui" project, such that I could view the properties, and control the linking of the various Qt libraries and the like. By extension, it also doesn't understand how to build my project, like it would be able to do if I had created an empty Qt Gui project from scratch. How do I get this part working?
Second nikolavp - Checkout, and mark the option to use the new project wizard, then select Qt project. I've done this (with ganymede) and it successfully finds everything and builds correctly.
71,815
Most of the work being done at my company is Qt-based C++, and it's all checked into a Subversion repository. Until now, all work on the codebase has been done purely with nano, or perhaps Kate. Being new here, I would like to take advantage of setting up Eclipse -properly- to edit my local copy of the tree. I have the CDT "version" of Eclipse, and the Qt integration, and the Subclipse module. At this point, though, I don't know what to do. Do I "import" the projects into an Eclipse-controlled workspace? Do I edit them in place? Nothing I've tried to do gets Eclipse to recognize that the "project" is a Qt application, so that I can get the integration working.
2008/09/16
[ "https://Stackoverflow.com/questions/71815", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11959/" ]
I would create a new QT project in eclipse, then switch perspectives to subclipse and simply do a SVN checkout into the new eclipse project. You should be good to go.
My solution: 1. go to the svn-view and add the repository location for your project 2. check out the project some temporary location with svn or any client you like 3. choose 'File->Import...' and say 'Qt->Qt project' 4. browse to the location of the \*.pro file, select and hit the OK-Button 5. you are in the game with an appropriate Qt-project and Subversion Access for that project
16,622
What are some real-life exceptions to the PEMDAS rule? I am looking for examples from "real" mathematical language --- conventions that are held in modern mathematics practice, such as those appearing in papers, books, and class notes, that are not covered (or contradicted) by PEMDAS. I am not interested in contrived examples, such as those constructed [to confuse people on Facebook](https://slate.com/technology/2013/03/facebook-math-problem-why-pemdas-doesnt-always-give-a-clear-answer.html). The PEMDAS convention says that order of operations are evaluated as: 1. Parentheses 2. Exponents 3. Multiplication and Division, from left to right 4. Addition and Subtraction, from left to right So far I know of one exception: sometimes the placement of text indicates "implicit" parentheses: text that is a superscript, subscript, or above/below a fraction. * $2^{3 + 5}$ Here, $3 + 5$ is evaluated before the exponentiation * $\frac{3+5}{2}$ Here, $3 + 5$ is evaluated before the division Are there other exceptions?
2019/05/16
[ "https://matheducators.stackexchange.com/questions/16622", "https://matheducators.stackexchange.com", "https://matheducators.stackexchange.com/users/200/" ]
The examples you give aren't exceptions. The parentheses aren't needed because there is no other way to interpret the expressions. In applications in engineering and the physical sciences, variables have units associated with them, and the units often disambiguate the expression without the need for parentheses. For example, if $\omega$ has units of radians per second, and $t$ has units of seconds, then $\sin\omega t$ has to be interpreted as $\sin(\omega t)$, not as $(\sin\omega) t$, because the sine function requires a unitless input. Omitting the parentheses is preferable in examples like these because it simplifies the appearance of expressions and makes them easier to parse. Similarly, if a force $F$ acts on an object of mass $m$ for a time $t$, then, starting from rest, the object is displaced by $Ft^2/2m$. This can only be interpreted as $(Ft^2)/(2m)$, because otherwise the units wouldn't come out to be units of distance. Examples like this aren't just typewriter usages. Built-up fractions that occur inline in a paragraph of text are awkward typographically: $\frac{Ft^2}{2m}$. They either have to be written very small, which makes them hard to read, or they force the spacing of the lines to be uneven, which looks ugly. These are examples involving physics and units, but more generally, when people read mathematics, they apply their understanding of the content, which could be economics or number theory. People are not computers. Mathematical notation is a human language written for humans to read. Human languages are ambiguous, and that's a good thing. When we don't require all ambiguities to be explicitly resolved, it helps with concision and expressiveness. Besides the meaning, another factor that resolves ambiguities and allows concise and readable notation is that we have certain conventions that we follow, such as the convention that tells us to write $2x$ rather than $x2$. If someone means $(\sin x)(y)$, then they'll write it as $y\sin x$, not $\sin xy$. There is also a convention that if we have a long chain of multiplications and divisions, such as $abcdefgh/ijklm$, we put all the multiplicative factors to the left of the slash, and then it's understood that we mean $abcdefgh/(ijklm)$. We wouldn't write this as $a/ibc/j/kdef/lgh/m$, which would be extremely difficult to read. We wouldn't interpret $abcdefgh/ijklm$ as $(abcdefgh/i)jklm$, because if that had been the intended meaning, it would have been written like $abcdefghjklm/i$.
That's a good question. In addition to PEMDAS there's grouped symbols; they occur under a radical ($\sqrt{~}$, $\sqrt[n]{~}$), in the numerator and denominator of a fraction and in exponents. These grouped symbols are treated as if they are between parenthesis. That means that the expressions $a^{\text{expression}}$, $\sqrt[n]{\text{expression}}$ and $\dfrac{\text{expression}\_1}{\text{expression}\_2}$ mean $a^{(\text{expression})}$, $\sqrt[n]{(\text{expression})}$ and $\dfrac{(\text{expression}\_1)}{(\text{expression}\_2)}$. The horizontal fractional line and the [vinculum](https://en.wikipedia.org/wiki/Vinculum_(symbol)) of the radical act as symbols of grouping. That's why we write $\sqrt{\text{expression}}$ instead of $\sqrt{~}(\text{expression})$ and $\dfrac{\text{expression}\_1}{\text{expression}\_2}$ instead of $(\text{expression}\_1)/(\text{expression}\_2)$. The exponent, written in superscript, is also a grouped symbol, so we write $a^{\text{expression}}$ instead of $a\wedge(\text{expression})$. Other functions use parentheses around the input to avoid ambiguity. The parentheses are sometimes omitted if the input is a monomial. That doesn't have anything to do with units. Thus $\sin 2x$ means $\sin (2x)$ but $\sin a+b$ means $\sin (a)+b$. Personally I prefer to write the parenthesis even around a monomial like $\ln (5x)$. What does $a/bc$ means? Is it $\dfrac{a}{bc}$ or $\dfrac{a}{b}c$ ? We could argue which convention we like but the matter of fact is that different people have different convention and different softwares have different conventions. For example $18/2\times 3$ gives [$27$](https://www.wolframalpha.com/input/?i=18%2F2*3) on wolframalpha but $a/bc$ gives [$3$](https://www.wolframalpha.com/input/?i=a%2Fbc+where+a%3D18+and+b%3D2+and+c%3D3) when $a=18$, $b=2$ and $c=3$. The same software has two conventions for the same expression! That's why I always prefer to write $\dfrac{a}{b}$, $\sqrt{a}$ and $a^b$ instead of $a/b$, $\sqrt{}a$ and $a\wedge b$. They don't cause any ambiguity. The same issue is present with $\sin ab$ which WA interprets as [$b\sin a$](https://www.wolframalpha.com/input/?i=sin2*3) or [$\sin (ab)$](https://www.wolframalpha.com/input/?i=sin+ab+where+a%3D2+and+b%3D3).
16,622
What are some real-life exceptions to the PEMDAS rule? I am looking for examples from "real" mathematical language --- conventions that are held in modern mathematics practice, such as those appearing in papers, books, and class notes, that are not covered (or contradicted) by PEMDAS. I am not interested in contrived examples, such as those constructed [to confuse people on Facebook](https://slate.com/technology/2013/03/facebook-math-problem-why-pemdas-doesnt-always-give-a-clear-answer.html). The PEMDAS convention says that order of operations are evaluated as: 1. Parentheses 2. Exponents 3. Multiplication and Division, from left to right 4. Addition and Subtraction, from left to right So far I know of one exception: sometimes the placement of text indicates "implicit" parentheses: text that is a superscript, subscript, or above/below a fraction. * $2^{3 + 5}$ Here, $3 + 5$ is evaluated before the exponentiation * $\frac{3+5}{2}$ Here, $3 + 5$ is evaluated before the division Are there other exceptions?
2019/05/16
[ "https://matheducators.stackexchange.com/questions/16622", "https://matheducators.stackexchange.com", "https://matheducators.stackexchange.com/users/200/" ]
The examples you give aren't exceptions. The parentheses aren't needed because there is no other way to interpret the expressions. In applications in engineering and the physical sciences, variables have units associated with them, and the units often disambiguate the expression without the need for parentheses. For example, if $\omega$ has units of radians per second, and $t$ has units of seconds, then $\sin\omega t$ has to be interpreted as $\sin(\omega t)$, not as $(\sin\omega) t$, because the sine function requires a unitless input. Omitting the parentheses is preferable in examples like these because it simplifies the appearance of expressions and makes them easier to parse. Similarly, if a force $F$ acts on an object of mass $m$ for a time $t$, then, starting from rest, the object is displaced by $Ft^2/2m$. This can only be interpreted as $(Ft^2)/(2m)$, because otherwise the units wouldn't come out to be units of distance. Examples like this aren't just typewriter usages. Built-up fractions that occur inline in a paragraph of text are awkward typographically: $\frac{Ft^2}{2m}$. They either have to be written very small, which makes them hard to read, or they force the spacing of the lines to be uneven, which looks ugly. These are examples involving physics and units, but more generally, when people read mathematics, they apply their understanding of the content, which could be economics or number theory. People are not computers. Mathematical notation is a human language written for humans to read. Human languages are ambiguous, and that's a good thing. When we don't require all ambiguities to be explicitly resolved, it helps with concision and expressiveness. Besides the meaning, another factor that resolves ambiguities and allows concise and readable notation is that we have certain conventions that we follow, such as the convention that tells us to write $2x$ rather than $x2$. If someone means $(\sin x)(y)$, then they'll write it as $y\sin x$, not $\sin xy$. There is also a convention that if we have a long chain of multiplications and divisions, such as $abcdefgh/ijklm$, we put all the multiplicative factors to the left of the slash, and then it's understood that we mean $abcdefgh/(ijklm)$. We wouldn't write this as $a/ibc/j/kdef/lgh/m$, which would be extremely difficult to read. We wouldn't interpret $abcdefgh/ijklm$ as $(abcdefgh/i)jklm$, because if that had been the intended meaning, it would have been written like $abcdefghjklm/i$.
I would add the following to Paracosmiste's reply: Numerical negation (e.g. the '$-$' sign in in the expression $-x^2$) usually has an order of precedence that is less than that of exponentiation and greater than that of multiplication, division, addition and subtraction in order from right to left. So we have $-x^2=-(x^2)$. And $--x = -(-x))$. And $x+-y= x+(-y)$. When exponentiation is printed using different levels of typeface (e.g. $x^{y^z}$) then they are done in order from right to left. So we have $x^{y^z}=x^{(y^z)}$ If, on the other hand, it is printed using the '^' symbol (or '$\*\*$') as in many programming languages (e.g. $x$^$y$^$z$ or x$\*\*$y$\*\*$z), they are usually done in order from left to right. So we have $x$^$y$^$z = ((x$^$y)$^$z)$
16,622
What are some real-life exceptions to the PEMDAS rule? I am looking for examples from "real" mathematical language --- conventions that are held in modern mathematics practice, such as those appearing in papers, books, and class notes, that are not covered (or contradicted) by PEMDAS. I am not interested in contrived examples, such as those constructed [to confuse people on Facebook](https://slate.com/technology/2013/03/facebook-math-problem-why-pemdas-doesnt-always-give-a-clear-answer.html). The PEMDAS convention says that order of operations are evaluated as: 1. Parentheses 2. Exponents 3. Multiplication and Division, from left to right 4. Addition and Subtraction, from left to right So far I know of one exception: sometimes the placement of text indicates "implicit" parentheses: text that is a superscript, subscript, or above/below a fraction. * $2^{3 + 5}$ Here, $3 + 5$ is evaluated before the exponentiation * $\frac{3+5}{2}$ Here, $3 + 5$ is evaluated before the division Are there other exceptions?
2019/05/16
[ "https://matheducators.stackexchange.com/questions/16622", "https://matheducators.stackexchange.com", "https://matheducators.stackexchange.com/users/200/" ]
The examples you give aren't exceptions. The parentheses aren't needed because there is no other way to interpret the expressions. In applications in engineering and the physical sciences, variables have units associated with them, and the units often disambiguate the expression without the need for parentheses. For example, if $\omega$ has units of radians per second, and $t$ has units of seconds, then $\sin\omega t$ has to be interpreted as $\sin(\omega t)$, not as $(\sin\omega) t$, because the sine function requires a unitless input. Omitting the parentheses is preferable in examples like these because it simplifies the appearance of expressions and makes them easier to parse. Similarly, if a force $F$ acts on an object of mass $m$ for a time $t$, then, starting from rest, the object is displaced by $Ft^2/2m$. This can only be interpreted as $(Ft^2)/(2m)$, because otherwise the units wouldn't come out to be units of distance. Examples like this aren't just typewriter usages. Built-up fractions that occur inline in a paragraph of text are awkward typographically: $\frac{Ft^2}{2m}$. They either have to be written very small, which makes them hard to read, or they force the spacing of the lines to be uneven, which looks ugly. These are examples involving physics and units, but more generally, when people read mathematics, they apply their understanding of the content, which could be economics or number theory. People are not computers. Mathematical notation is a human language written for humans to read. Human languages are ambiguous, and that's a good thing. When we don't require all ambiguities to be explicitly resolved, it helps with concision and expressiveness. Besides the meaning, another factor that resolves ambiguities and allows concise and readable notation is that we have certain conventions that we follow, such as the convention that tells us to write $2x$ rather than $x2$. If someone means $(\sin x)(y)$, then they'll write it as $y\sin x$, not $\sin xy$. There is also a convention that if we have a long chain of multiplications and divisions, such as $abcdefgh/ijklm$, we put all the multiplicative factors to the left of the slash, and then it's understood that we mean $abcdefgh/(ijklm)$. We wouldn't write this as $a/ibc/j/kdef/lgh/m$, which would be extremely difficult to read. We wouldn't interpret $abcdefgh/ijklm$ as $(abcdefgh/i)jklm$, because if that had been the intended meaning, it would have been written like $abcdefghjklm/i$.
Briefly: The thing that you seem to be orbiting around is that some mathematical symbols, in addition to having some primary operation, also have the secondary function of serving as "grouping" symbols. These symbols serve to group certain operations together in the same way that parentheses do, without extra notation. Another way of putting it: parentheses are just one special type of grouping symbol. They do not count as exceptions to the standard precedence syntax. Examples include: * Fraction bars * Radical overbars * Absolute value bars * Superscripts and subscripts
16,622
What are some real-life exceptions to the PEMDAS rule? I am looking for examples from "real" mathematical language --- conventions that are held in modern mathematics practice, such as those appearing in papers, books, and class notes, that are not covered (or contradicted) by PEMDAS. I am not interested in contrived examples, such as those constructed [to confuse people on Facebook](https://slate.com/technology/2013/03/facebook-math-problem-why-pemdas-doesnt-always-give-a-clear-answer.html). The PEMDAS convention says that order of operations are evaluated as: 1. Parentheses 2. Exponents 3. Multiplication and Division, from left to right 4. Addition and Subtraction, from left to right So far I know of one exception: sometimes the placement of text indicates "implicit" parentheses: text that is a superscript, subscript, or above/below a fraction. * $2^{3 + 5}$ Here, $3 + 5$ is evaluated before the exponentiation * $\frac{3+5}{2}$ Here, $3 + 5$ is evaluated before the division Are there other exceptions?
2019/05/16
[ "https://matheducators.stackexchange.com/questions/16622", "https://matheducators.stackexchange.com", "https://matheducators.stackexchange.com/users/200/" ]
That's a good question. In addition to PEMDAS there's grouped symbols; they occur under a radical ($\sqrt{~}$, $\sqrt[n]{~}$), in the numerator and denominator of a fraction and in exponents. These grouped symbols are treated as if they are between parenthesis. That means that the expressions $a^{\text{expression}}$, $\sqrt[n]{\text{expression}}$ and $\dfrac{\text{expression}\_1}{\text{expression}\_2}$ mean $a^{(\text{expression})}$, $\sqrt[n]{(\text{expression})}$ and $\dfrac{(\text{expression}\_1)}{(\text{expression}\_2)}$. The horizontal fractional line and the [vinculum](https://en.wikipedia.org/wiki/Vinculum_(symbol)) of the radical act as symbols of grouping. That's why we write $\sqrt{\text{expression}}$ instead of $\sqrt{~}(\text{expression})$ and $\dfrac{\text{expression}\_1}{\text{expression}\_2}$ instead of $(\text{expression}\_1)/(\text{expression}\_2)$. The exponent, written in superscript, is also a grouped symbol, so we write $a^{\text{expression}}$ instead of $a\wedge(\text{expression})$. Other functions use parentheses around the input to avoid ambiguity. The parentheses are sometimes omitted if the input is a monomial. That doesn't have anything to do with units. Thus $\sin 2x$ means $\sin (2x)$ but $\sin a+b$ means $\sin (a)+b$. Personally I prefer to write the parenthesis even around a monomial like $\ln (5x)$. What does $a/bc$ means? Is it $\dfrac{a}{bc}$ or $\dfrac{a}{b}c$ ? We could argue which convention we like but the matter of fact is that different people have different convention and different softwares have different conventions. For example $18/2\times 3$ gives [$27$](https://www.wolframalpha.com/input/?i=18%2F2*3) on wolframalpha but $a/bc$ gives [$3$](https://www.wolframalpha.com/input/?i=a%2Fbc+where+a%3D18+and+b%3D2+and+c%3D3) when $a=18$, $b=2$ and $c=3$. The same software has two conventions for the same expression! That's why I always prefer to write $\dfrac{a}{b}$, $\sqrt{a}$ and $a^b$ instead of $a/b$, $\sqrt{}a$ and $a\wedge b$. They don't cause any ambiguity. The same issue is present with $\sin ab$ which WA interprets as [$b\sin a$](https://www.wolframalpha.com/input/?i=sin2*3) or [$\sin (ab)$](https://www.wolframalpha.com/input/?i=sin+ab+where+a%3D2+and+b%3D3).
I would add the following to Paracosmiste's reply: Numerical negation (e.g. the '$-$' sign in in the expression $-x^2$) usually has an order of precedence that is less than that of exponentiation and greater than that of multiplication, division, addition and subtraction in order from right to left. So we have $-x^2=-(x^2)$. And $--x = -(-x))$. And $x+-y= x+(-y)$. When exponentiation is printed using different levels of typeface (e.g. $x^{y^z}$) then they are done in order from right to left. So we have $x^{y^z}=x^{(y^z)}$ If, on the other hand, it is printed using the '^' symbol (or '$\*\*$') as in many programming languages (e.g. $x$^$y$^$z$ or x$\*\*$y$\*\*$z), they are usually done in order from left to right. So we have $x$^$y$^$z = ((x$^$y)$^$z)$
16,622
What are some real-life exceptions to the PEMDAS rule? I am looking for examples from "real" mathematical language --- conventions that are held in modern mathematics practice, such as those appearing in papers, books, and class notes, that are not covered (or contradicted) by PEMDAS. I am not interested in contrived examples, such as those constructed [to confuse people on Facebook](https://slate.com/technology/2013/03/facebook-math-problem-why-pemdas-doesnt-always-give-a-clear-answer.html). The PEMDAS convention says that order of operations are evaluated as: 1. Parentheses 2. Exponents 3. Multiplication and Division, from left to right 4. Addition and Subtraction, from left to right So far I know of one exception: sometimes the placement of text indicates "implicit" parentheses: text that is a superscript, subscript, or above/below a fraction. * $2^{3 + 5}$ Here, $3 + 5$ is evaluated before the exponentiation * $\frac{3+5}{2}$ Here, $3 + 5$ is evaluated before the division Are there other exceptions?
2019/05/16
[ "https://matheducators.stackexchange.com/questions/16622", "https://matheducators.stackexchange.com", "https://matheducators.stackexchange.com/users/200/" ]
Briefly: The thing that you seem to be orbiting around is that some mathematical symbols, in addition to having some primary operation, also have the secondary function of serving as "grouping" symbols. These symbols serve to group certain operations together in the same way that parentheses do, without extra notation. Another way of putting it: parentheses are just one special type of grouping symbol. They do not count as exceptions to the standard precedence syntax. Examples include: * Fraction bars * Radical overbars * Absolute value bars * Superscripts and subscripts
I would add the following to Paracosmiste's reply: Numerical negation (e.g. the '$-$' sign in in the expression $-x^2$) usually has an order of precedence that is less than that of exponentiation and greater than that of multiplication, division, addition and subtraction in order from right to left. So we have $-x^2=-(x^2)$. And $--x = -(-x))$. And $x+-y= x+(-y)$. When exponentiation is printed using different levels of typeface (e.g. $x^{y^z}$) then they are done in order from right to left. So we have $x^{y^z}=x^{(y^z)}$ If, on the other hand, it is printed using the '^' symbol (or '$\*\*$') as in many programming languages (e.g. $x$^$y$^$z$ or x$\*\*$y$\*\*$z), they are usually done in order from left to right. So we have $x$^$y$^$z = ((x$^$y)$^$z)$
39,080,703
I have a bootstrap popover element with a form inside. I do a `preventDefault()` when the form is submitted but it doesn't actually prevent the submit. When I don't use the popover and a modal instead it works perfectly. Here is my HTML: ``` <div class="hide" id="popover-content"> <form action="api/check.php" class="checkform" id="requestacallform" method="get" name="requestacallform"> <div class="form-group"> <div class="input-group"> <input class="form-control" id="domein" name="name" placeholder="domein" type="text"> </div> </div><input class="btn btn-blue submit" type="submit" value="Aanmelden"> <p class="response"></p> </form> </div> ``` Here is my JavaScript file where I create the popup (main.js) ``` $('#popover').popover({ html: true, content: function() { return $("#popover-content").html(); } }); ``` And this is where I do my `preventDefault()` in an other JavaScript file ``` $(".checkform").submit(function(e) { e.preventDefault(); var request = $("#domein").val(); $.ajax({ // AJAX content here }); }); ``` Why the `preventDefault()` isn't working?
2016/08/22
[ "https://Stackoverflow.com/questions/39080703", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6730270/" ]
You're trying to append event handler for `.checkform` before adding it to DOM. You need to load second javascript file after loading contents html or append event globaly: ``` $("body").on("submit",".checkform", function(e){ e.preventDefault(); var request = $("#domein").val(); $.ajax({ ... }); ``` You can read more about events binding on dynamic htmls [here](https://stackoverflow.com/questions/1359018/in-jquery-how-to-attach-events-to-dynamic-html-elements)
Try it like this please: ``` $(document).on('submit', '.checkform', function(e){ e.preventDefault(); var request = $("#domein").val(); $.ajax({ ... }); ``` It is possible that the popover isn't loaded on page load and is getting generated just when it is needed so you need the document selector.
39,080,703
I have a bootstrap popover element with a form inside. I do a `preventDefault()` when the form is submitted but it doesn't actually prevent the submit. When I don't use the popover and a modal instead it works perfectly. Here is my HTML: ``` <div class="hide" id="popover-content"> <form action="api/check.php" class="checkform" id="requestacallform" method="get" name="requestacallform"> <div class="form-group"> <div class="input-group"> <input class="form-control" id="domein" name="name" placeholder="domein" type="text"> </div> </div><input class="btn btn-blue submit" type="submit" value="Aanmelden"> <p class="response"></p> </form> </div> ``` Here is my JavaScript file where I create the popup (main.js) ``` $('#popover').popover({ html: true, content: function() { return $("#popover-content").html(); } }); ``` And this is where I do my `preventDefault()` in an other JavaScript file ``` $(".checkform").submit(function(e) { e.preventDefault(); var request = $("#domein").val(); $.ajax({ // AJAX content here }); }); ``` Why the `preventDefault()` isn't working?
2016/08/22
[ "https://Stackoverflow.com/questions/39080703", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6730270/" ]
You're trying to append event handler for `.checkform` before adding it to DOM. You need to load second javascript file after loading contents html or append event globaly: ``` $("body").on("submit",".checkform", function(e){ e.preventDefault(); var request = $("#domein").val(); $.ajax({ ... }); ``` You can read more about events binding on dynamic htmls [here](https://stackoverflow.com/questions/1359018/in-jquery-how-to-attach-events-to-dynamic-html-elements)
Because whenever the popover is opened a new dom fragment is created on the fly you may take advantage on this to attach events or manipulate the html itself like you need. From [bootstrap popover docs](http://getbootstrap.com/javascript/http://getbootstrap.com/javascript/#popovers) you need to listen for this event: > > inserted.bs.popover: This event is fired after the show.bs.popover event when the popover template has been added to the DOM. > > > So, my proposal is to avoid the event delegation and attach the event directly to the correct element: ```js $(function () { // open the popover on click $('#popover').popover({ html: true, content: function () { return $("#popover-content").html(); } }); // when the popover template has been added to the DOM // find the correct element and attach the event handler // because the popover template is removed on close // it's useless to remove the event with .off('submit') $('#popover').on('inserted.bs.popover', function(e){ $(this).next('.popover').find('.checkform').on('submit', function(e){ e.preventDefault(); var request = $("#domein").val(); // do your stuff $('#popover').trigger('click'); }); }); }); ``` ```html <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css"> <script src="https://code.jquery.com/jquery-1.12.1.min.js"></script> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script> <body> <button type="button" class="btn btn-default popover-content" role="button" id="popover"> Click to open Popover </button> <div id="popover-content" class="hidden"> <form action="z.html" id="requestacallform" method="GET" name="requestacallform" class="checkform"> <div class="form-group"> <div class="input-group"> <input id="domein" type="text" class="form-control" placeholder="domein" name="name"/> </div> </div> <input type="submit" value="Aanmelden" class="btn btn-blue submit"/> <p class="response"></p> </form> </div> ```
39,080,703
I have a bootstrap popover element with a form inside. I do a `preventDefault()` when the form is submitted but it doesn't actually prevent the submit. When I don't use the popover and a modal instead it works perfectly. Here is my HTML: ``` <div class="hide" id="popover-content"> <form action="api/check.php" class="checkform" id="requestacallform" method="get" name="requestacallform"> <div class="form-group"> <div class="input-group"> <input class="form-control" id="domein" name="name" placeholder="domein" type="text"> </div> </div><input class="btn btn-blue submit" type="submit" value="Aanmelden"> <p class="response"></p> </form> </div> ``` Here is my JavaScript file where I create the popup (main.js) ``` $('#popover').popover({ html: true, content: function() { return $("#popover-content").html(); } }); ``` And this is where I do my `preventDefault()` in an other JavaScript file ``` $(".checkform").submit(function(e) { e.preventDefault(); var request = $("#domein").val(); $.ajax({ // AJAX content here }); }); ``` Why the `preventDefault()` isn't working?
2016/08/22
[ "https://Stackoverflow.com/questions/39080703", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6730270/" ]
You're trying to append event handler for `.checkform` before adding it to DOM. You need to load second javascript file after loading contents html or append event globaly: ``` $("body").on("submit",".checkform", function(e){ e.preventDefault(); var request = $("#domein").val(); $.ajax({ ... }); ``` You can read more about events binding on dynamic htmls [here](https://stackoverflow.com/questions/1359018/in-jquery-how-to-attach-events-to-dynamic-html-elements)
Thanks for the responses, I was using Meteor and had the same problem. I used @Marcel Wasilewski's response like so... ``` Template.voteContest.onRendered(function() { $(document).on('submit', '.keep-vote', function(event){ // Prevent default browser form submit event.preventDefault(); // Clear all popovers $("[data-toggle='tooltip']").popover('hide'); }); }); ```
39,080,703
I have a bootstrap popover element with a form inside. I do a `preventDefault()` when the form is submitted but it doesn't actually prevent the submit. When I don't use the popover and a modal instead it works perfectly. Here is my HTML: ``` <div class="hide" id="popover-content"> <form action="api/check.php" class="checkform" id="requestacallform" method="get" name="requestacallform"> <div class="form-group"> <div class="input-group"> <input class="form-control" id="domein" name="name" placeholder="domein" type="text"> </div> </div><input class="btn btn-blue submit" type="submit" value="Aanmelden"> <p class="response"></p> </form> </div> ``` Here is my JavaScript file where I create the popup (main.js) ``` $('#popover').popover({ html: true, content: function() { return $("#popover-content").html(); } }); ``` And this is where I do my `preventDefault()` in an other JavaScript file ``` $(".checkform").submit(function(e) { e.preventDefault(); var request = $("#domein").val(); $.ajax({ // AJAX content here }); }); ``` Why the `preventDefault()` isn't working?
2016/08/22
[ "https://Stackoverflow.com/questions/39080703", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6730270/" ]
Try it like this please: ``` $(document).on('submit', '.checkform', function(e){ e.preventDefault(); var request = $("#domein").val(); $.ajax({ ... }); ``` It is possible that the popover isn't loaded on page load and is getting generated just when it is needed so you need the document selector.
Because whenever the popover is opened a new dom fragment is created on the fly you may take advantage on this to attach events or manipulate the html itself like you need. From [bootstrap popover docs](http://getbootstrap.com/javascript/http://getbootstrap.com/javascript/#popovers) you need to listen for this event: > > inserted.bs.popover: This event is fired after the show.bs.popover event when the popover template has been added to the DOM. > > > So, my proposal is to avoid the event delegation and attach the event directly to the correct element: ```js $(function () { // open the popover on click $('#popover').popover({ html: true, content: function () { return $("#popover-content").html(); } }); // when the popover template has been added to the DOM // find the correct element and attach the event handler // because the popover template is removed on close // it's useless to remove the event with .off('submit') $('#popover').on('inserted.bs.popover', function(e){ $(this).next('.popover').find('.checkform').on('submit', function(e){ e.preventDefault(); var request = $("#domein").val(); // do your stuff $('#popover').trigger('click'); }); }); }); ``` ```html <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css"> <script src="https://code.jquery.com/jquery-1.12.1.min.js"></script> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script> <body> <button type="button" class="btn btn-default popover-content" role="button" id="popover"> Click to open Popover </button> <div id="popover-content" class="hidden"> <form action="z.html" id="requestacallform" method="GET" name="requestacallform" class="checkform"> <div class="form-group"> <div class="input-group"> <input id="domein" type="text" class="form-control" placeholder="domein" name="name"/> </div> </div> <input type="submit" value="Aanmelden" class="btn btn-blue submit"/> <p class="response"></p> </form> </div> ```
39,080,703
I have a bootstrap popover element with a form inside. I do a `preventDefault()` when the form is submitted but it doesn't actually prevent the submit. When I don't use the popover and a modal instead it works perfectly. Here is my HTML: ``` <div class="hide" id="popover-content"> <form action="api/check.php" class="checkform" id="requestacallform" method="get" name="requestacallform"> <div class="form-group"> <div class="input-group"> <input class="form-control" id="domein" name="name" placeholder="domein" type="text"> </div> </div><input class="btn btn-blue submit" type="submit" value="Aanmelden"> <p class="response"></p> </form> </div> ``` Here is my JavaScript file where I create the popup (main.js) ``` $('#popover').popover({ html: true, content: function() { return $("#popover-content").html(); } }); ``` And this is where I do my `preventDefault()` in an other JavaScript file ``` $(".checkform").submit(function(e) { e.preventDefault(); var request = $("#domein").val(); $.ajax({ // AJAX content here }); }); ``` Why the `preventDefault()` isn't working?
2016/08/22
[ "https://Stackoverflow.com/questions/39080703", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6730270/" ]
Try it like this please: ``` $(document).on('submit', '.checkform', function(e){ e.preventDefault(); var request = $("#domein").val(); $.ajax({ ... }); ``` It is possible that the popover isn't loaded on page load and is getting generated just when it is needed so you need the document selector.
Thanks for the responses, I was using Meteor and had the same problem. I used @Marcel Wasilewski's response like so... ``` Template.voteContest.onRendered(function() { $(document).on('submit', '.keep-vote', function(event){ // Prevent default browser form submit event.preventDefault(); // Clear all popovers $("[data-toggle='tooltip']").popover('hide'); }); }); ```
21,859,041
Here is what I want to do... I have a bunch of text files that I need to go through and keep only the top 5 lines. If I do `top` then output to a file that is part way there. I need the file name to be the same as it was earlier. Ex.: `file.name` - take top 5 lines (delete everything below line 5), then save file as `file.name`. There are a number of files that this will need to be done on as a batch.
2014/02/18
[ "https://Stackoverflow.com/questions/21859041", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3324211/" ]
You can use `head` to do this. ``` head -n 5 file.name > file.name.tmp && mv file.name.tmp file.name ``` You can structure this as a script to do it for all files, passing `file.name` as an argument in each run later.
The basic syntax, assuming you are working with a file called "file.name", is quite simple ``` head -n5 file.name > temp && cat temp > file.name ``` or ``` cat file.name | head -n5 > temp && cat temp > file.name ``` If you are trying to do this on a lot of files in a path, you should use something like ``` find ./ -type f -printf "%f\n" ``` You can modify the parameters depending on what type of files you want ``` find ./ -name "*.js" -type f -printf "%f\n" ``` You can then iterate through that list, passing each line as an argument into the code above It would probably look something like this (I haven't tested this, but it is similar to another small script I wrote, so hopefully it points you in the right direction) ``` function cutfile { head -n5 "$1" > temp && cat temp > "$1" } find ./ -name "*.js" -type f -printf "%f\n" |\ while read line; do cutfile $line; done ``` EDIT: Changed head...; cat... code based on @fedorqui's recommendations on @mu's code EDIT: Fixed code, added "; done", made code more readable
523,003
I have a text file where column and row number will always vary, and want to remove entire rows from the txt file only if every column within it is equal to either $VAR1 or $VAR2. For example: Lets say $VAR1="X" and $VAR2="N" and I want to remove any row where $VAR1 and $VAR2 makes up the entire column. This would be my input: ``` hajn 32 ahnnd namm 5 543 asfn F X X N X X X N X 5739 dw 32eff Sfff 3 asd 3123 1 ``` And this would be my desired output: ``` hajn 32 ahnnd namm 5 543 asfn F 5739 dw 32eff Sfff 3 asd 3123 1 ``` I can solve this with a loop, but I was wondering if there's a powerful one liner way of doing this, preferably awk.
2019/06/05
[ "https://unix.stackexchange.com/questions/523003", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/170497/" ]
``` $ VAR1=N $ VAR2=X $ awk -v a="$VAR1" -v b="$VAR2" '{ for (i=1; i<=NF; ++i) if ($i != a && $i != b) { print; next } }' file hajn 32 ahnnd namm 5 543 asfn F 5739 dw 32eff Sfff 3 asd 3123 1 ``` Here, we transfer the values `$VAR1` and `$VAR2` into our short `awk` script and its `a` and `b` variables using `-v` on the command line. Inside the `awk` script, we iterate over the fields of each line, and if any field is different from both the `a` and the `b` value, we print the full line and continue with the next line immediately. If no field is different from both `a` and `b`, nothing happens (the line is not printed).
You could grep out the desired results with the right choice of regex. Note: assuming the shell variables have bland chars, meaning those that are not interprettable as regex special. In case this doesn't hold true, then you can enrobe the vars in `\Q...\E` context. ``` $ grep -P "(^|\s)(?!$VAR1(\s|\$))(?!$VAR2(\s|\$))" inp ```
48,305,293
I am using the the jQuery animate function for smooth scrolling inside a div however this function only works properly when you are scrolled at the top. after many console logs on the positions of the tags and hours trying to figure this out i know why this is. this is due to the position of the elements inside the overflow changing when you scroll. the problem is that when you click on one of the tags it will only scroll to the correct position if the div is scrolled to the top, however if the div is anywhere but the top it doesn't do so. for example if you click on the 4th tag and then immediately click on the 3rd it wont go to the correct position when you click on the 3 due to you not being scrolled to the top. i couldn't come up with the correct equation or something to make the div scroll to the correct tag regardless of scroll position. Here is the simple code for the animation the rest is on jsfiddle ``` $('#iddescription').animate({ scrollTop: target.position().top - $('#iddescription').position().top } ``` I did think about doing double animations scrolling to the top first and then scrolling to the correct position but this isn't really what I want. Could somebody help me please without using a plugin just jQuery, here is the code <https://jsfiddle.net/509k8stu/3/> .
2018/01/17
[ "https://Stackoverflow.com/questions/48305293", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8233463/" ]
Animating `scrollTop` to the following position seems to fix the issue: ``` target.offset().top + $('#iddescription').scrollTop() - $('#iddescription').offset().top ``` I would also recommend you abort previous scroll animations using the `.stop()` method. So your full animation method would look something like this: ``` $('#iddescription').stop().animate({ scrollTop: target.offset().top + $('#iddescription').scrollTop() - $('#iddescription').offset().top }, 1000, function() { }); ``` See the result in [this updated fiddle](https://jsfiddle.net/509k8stu/5/)
You need to get the current scroll top and then add the element.position.top() to it like so: ``` // Does a scroll target exist? if (target.length) { // Only prevent default if animation is actually gonna happen event.preventDefault(); var $currScrollTop = $("#iddescription").scrollTop(); $('#iddescription').animate({ scrollTop: $currScrollTop + target.position().top - $('#iddescription').position().top }, 1000, function() { }); } ``` [Here is a fiddle.](https://jsfiddle.net/jchaplin2/509k8stu/4/)
45,731,858
i am running the airflow pipeline but codes looks seems good but actually i'm getting the airflow.exceptions.AirflowException: Cycle detected in DAG. Faulty task: can u please help to resolve this issue
2017/08/17
[ "https://Stackoverflow.com/questions/45731858", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8259305/" ]
This can happen due to duplicate task\_id'a in multiple tasks.
Without the code, it's kind of hard to help you. However, this means that you have a loop in your DAG. Generally, thie error happens when one of your task has a downstream task whose own downstream chain includes it again (A calls B calls C calls D calls A again, for example). That's not permitted by Airflow (and DAGs in general).
51,499,697
I am trying to solve Sherlock and Square problem in Hackerrank [(link)](https://www.hackerrank.com/challenges/sherlock-and-squares/problem) for finding the perfect square within a range of data. 4 test cases passed but i am getting a timeout error for large numbers. Please suggest something to improve its performance My code is as follows: ``` #include<iostream> #include<cmath> using namespace std; int squares(int a, int b) { long double i; long long int count=0; for(i=a;i<=b;i++) { long double b = sqrt(i); if(fmod(b,1)==0.000000) { count++; } } return count; } int main() { int q,i,a,b; cin>>q; for(i=0;i<q;i++) { cin>>a>>b; int result = squares(a, b); cout<<result<<"\n"; } } ```
2018/07/24
[ "https://Stackoverflow.com/questions/51499697", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9256840/" ]
Kindly use div into div as you have 2 divs. one is for background and other one for Heading it will be like ``` <div class="bg"> <div id="heading">Some stuff</div> // All the staff for background will goes here </div> ``` it will work in your case and if you use other divs after this they will not have the background image.
Please first search before ask question [Use a DIV as a background for another element](https://stackoverflow.com/questions/25970787/use-a-div-as-a-background-for-another-element) ```css #wrapper{ position: relative; width: 200px; height: 200px; } .content{ color: #FFFFFF; font-size: 26px; font-weight: bold; text-shadow: -1px -1px 1px #000, 1px 1px 1px #000; position: relative; z-index: 100; } .background{ color: #999999; position: absolute; top: 0; left: 0; z-index: -100; } ```