qid
int64
1
74.7M
question
stringlengths
0
58.3k
date
stringlengths
10
10
metadata
list
response_j
stringlengths
2
48.3k
response_k
stringlengths
2
40.5k
52,543,171
Based on user-selected options, my ComboBox needs to display different content. So i have to throw out the existing Items, and load a new List. Currently i have (and this works) ``` myComboBox.getItems().clear(); myComboBox.getItems().addAll(myList); ``` However I want to chain them: ``` myComboBox.getItems().clear().addAll(myList); ``` or: ``` myComboBox.getItems().clear().getItems().addAll(myList); ``` but I get: void cannot be dereferenced as clear() has already returned void. Is there some way to chain these actions ? It works but it's ugly and i vaguely recall seeing a more elegant solution but cannot remember what it was.
2018/09/27
[ "https://Stackoverflow.com/questions/52543171", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4314250/" ]
If the combo box is from javaFX you can use this: ``` myComboBox.getItems().setAll(<collection>); ``` where is any collection that will replace the existring one (Usually List or ArrayList).
You can also do, ``` myComboBox = new ComboBox(myList); ```
45,525,923
Using Bootstrap, I am trying to get a larger margin space on the left and right of the screen and a thin space between images. Attempted to individually target images and play around with the margin but that changes the image size and since different images has different margin sizes, the images are not even. Attempted to target all the images to have the same margin but the gap is too much which is not what I want is there a way around this? Added images to show what I want and what I currently have. My code as follows: Expected outcome (Large margin left and right, thin margin between images) [![enter image description here](https://i.stack.imgur.com/Iyy7h.jpg)](https://i.stack.imgur.com/Iyy7h.jpg) Current Outcome (No margin left and right, large margin between images) [![enter image description here](https://i.stack.imgur.com/So4kG.jpg)](https://i.stack.imgur.com/So4kG.jpg) HTMl ``` <div class="row"> <div class="row" class="top-img-custom"> <div class="text-center col-md-4"> <img class="img-responsive" src="http://via.placeholder.com/650x512" alt="Smiley face"> </div> <div class="text-center col-md-4"> <img class="img-responsive" src="http://via.placeholder.com/650x512" alt="Smiley face"> </div> <div class="text-center col-md-4"> <img class="img-responsive" src="http://via.placeholder.com/650x512" alt="Smiley face"> </div> </div> </div> ``` CSS ``` .top-img-custom{ margin-left: 20px; margin-right: 20px; } ```
2017/08/05
[ "https://Stackoverflow.com/questions/45525923", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5728508/" ]
To achieve expected result, use below CSS ``` .top-img-custom{ margin-left: 20px; margin-right: 20px; padding-left:20px; padding-right:20px; } .text-center { text-align: center!important; padding: 1px; } img{ width:100%; } ``` <https://codepen.io/nagasai/pen/dzNGqv> And as I mentioned before use both classes in one class-
```css body{ background-color: #f2f2f2!important; } .top-img-custom{ margin:10px 25px!important; } .top-img-custom .text-center{ padding: 0 1px!important; } ``` ```html <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/> <div class="row"> <div class="row top-img-custom" > <div class="text-center col-md-4 col-sm-4 col-xs-4"> <img class="img-responsive" src="https://www.w3schools.com/html/pic_mountain.jpg" alt="Smiley face"> </div> <div class="text-center col-md-4 col-sm-4 col-xs-4"> <img class="img-responsive" src="https://www.w3schools.com/html/pic_mountain.jpg" alt="Smiley face"> </div> <div class="text-center col-md-4 col-sm-4 col-xs-4"> <img class="img-responsive" src="https://www.w3schools.com/html/pic_mountain.jpg" alt="Smiley face"> </div> </div> </div> ```
45,525,923
Using Bootstrap, I am trying to get a larger margin space on the left and right of the screen and a thin space between images. Attempted to individually target images and play around with the margin but that changes the image size and since different images has different margin sizes, the images are not even. Attempted to target all the images to have the same margin but the gap is too much which is not what I want is there a way around this? Added images to show what I want and what I currently have. My code as follows: Expected outcome (Large margin left and right, thin margin between images) [![enter image description here](https://i.stack.imgur.com/Iyy7h.jpg)](https://i.stack.imgur.com/Iyy7h.jpg) Current Outcome (No margin left and right, large margin between images) [![enter image description here](https://i.stack.imgur.com/So4kG.jpg)](https://i.stack.imgur.com/So4kG.jpg) HTMl ``` <div class="row"> <div class="row" class="top-img-custom"> <div class="text-center col-md-4"> <img class="img-responsive" src="http://via.placeholder.com/650x512" alt="Smiley face"> </div> <div class="text-center col-md-4"> <img class="img-responsive" src="http://via.placeholder.com/650x512" alt="Smiley face"> </div> <div class="text-center col-md-4"> <img class="img-responsive" src="http://via.placeholder.com/650x512" alt="Smiley face"> </div> </div> </div> ``` CSS ``` .top-img-custom{ margin-left: 20px; margin-right: 20px; } ```
2017/08/05
[ "https://Stackoverflow.com/questions/45525923", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5728508/" ]
```css body{ background-color: #f2f2f2!important; } .top-img-custom{ margin:10px 25px!important; } .top-img-custom .text-center{ padding: 0 1px!important; } ``` ```html <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/> <div class="row"> <div class="row top-img-custom" > <div class="text-center col-md-4 col-sm-4 col-xs-4"> <img class="img-responsive" src="https://www.w3schools.com/html/pic_mountain.jpg" alt="Smiley face"> </div> <div class="text-center col-md-4 col-sm-4 col-xs-4"> <img class="img-responsive" src="https://www.w3schools.com/html/pic_mountain.jpg" alt="Smiley face"> </div> <div class="text-center col-md-4 col-sm-4 col-xs-4"> <img class="img-responsive" src="https://www.w3schools.com/html/pic_mountain.jpg" alt="Smiley face"> </div> </div> </div> ```
This behaviour won't come totally easy to the bootstrap grid system - it is pretty much designed for 15px padding in each of its `col-` classes, and a negative margin on the containing `row` classes to compensate at the edges. Messing with those, it is pretty easy to get some accidental element wrapping or horizontal scrollbars. My approach might be to leave the `row` and `col-` classes alone to size themselves, but give the contents of your `col-` classes a negative margin to fill more of the space. And you would have to be tricky if you didn't want this on the edge elements. This css should work: ``` .top-image-custom .img-responsive { margin-left: -12px; margin-right: -12px; } ``` If you don't want this on the edge elements then using some `:first-of-type` and `:last-of-type` selectors may help, or assign new classes in your html to differentiate.
45,525,923
Using Bootstrap, I am trying to get a larger margin space on the left and right of the screen and a thin space between images. Attempted to individually target images and play around with the margin but that changes the image size and since different images has different margin sizes, the images are not even. Attempted to target all the images to have the same margin but the gap is too much which is not what I want is there a way around this? Added images to show what I want and what I currently have. My code as follows: Expected outcome (Large margin left and right, thin margin between images) [![enter image description here](https://i.stack.imgur.com/Iyy7h.jpg)](https://i.stack.imgur.com/Iyy7h.jpg) Current Outcome (No margin left and right, large margin between images) [![enter image description here](https://i.stack.imgur.com/So4kG.jpg)](https://i.stack.imgur.com/So4kG.jpg) HTMl ``` <div class="row"> <div class="row" class="top-img-custom"> <div class="text-center col-md-4"> <img class="img-responsive" src="http://via.placeholder.com/650x512" alt="Smiley face"> </div> <div class="text-center col-md-4"> <img class="img-responsive" src="http://via.placeholder.com/650x512" alt="Smiley face"> </div> <div class="text-center col-md-4"> <img class="img-responsive" src="http://via.placeholder.com/650x512" alt="Smiley face"> </div> </div> </div> ``` CSS ``` .top-img-custom{ margin-left: 20px; margin-right: 20px; } ```
2017/08/05
[ "https://Stackoverflow.com/questions/45525923", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5728508/" ]
To achieve expected result, use below CSS ``` .top-img-custom{ margin-left: 20px; margin-right: 20px; padding-left:20px; padding-right:20px; } .text-center { text-align: center!important; padding: 1px; } img{ width:100%; } ``` <https://codepen.io/nagasai/pen/dzNGqv> And as I mentioned before use both classes in one class-
This behaviour won't come totally easy to the bootstrap grid system - it is pretty much designed for 15px padding in each of its `col-` classes, and a negative margin on the containing `row` classes to compensate at the edges. Messing with those, it is pretty easy to get some accidental element wrapping or horizontal scrollbars. My approach might be to leave the `row` and `col-` classes alone to size themselves, but give the contents of your `col-` classes a negative margin to fill more of the space. And you would have to be tricky if you didn't want this on the edge elements. This css should work: ``` .top-image-custom .img-responsive { margin-left: -12px; margin-right: -12px; } ``` If you don't want this on the edge elements then using some `:first-of-type` and `:last-of-type` selectors may help, or assign new classes in your html to differentiate.
65,876,057
I have been trying to scrape dynamic content (Restaurant Title, Rating, Type of Restaurant) from Doordash and It is not just one website that I am trying to scrape, but rather multiple websites, probably around 100 - 1000 pages on a single domain on Doordash. I got a 'single scrape" to work, however, when I used the code below, it gave me a long error ``` def ScrapeDoorDash(df): for i in df: url = df[i] print(url) driver = webdriver.Chrome(ChromeDriverManager().install()) driver.get(url) restaurantname = driver.find_element_by_xpath('//*[@id="root"]/div/div[1]/div[2]/div/div[1]/header/div[2]/h1').text rating = driver.find_element_by_xpath('//*[@id="root"]/div/div[1]/div[2]/div/div[1]/header/div[2]/div[1]/div[3]/div/span[1]').text #estauranttype = driver.find_element_by_xpath('//*[@id="root"]/div/div[1]/div[2]/div/div[1]/header/div[2]/div[1]/div[1]/span').text #Store into / print Out print (restaurantname, rating, restauranttype) ``` The XPath is already correct, but I noticed Selenium opens chrome every time to let it finish loading before scraping content. And on the code I provided above, I noticed the error already popped up before the first page finished loading. Is there a way to implement some code to "pause the for loop" to let it load and scrape first before moving onto the next item in the "URL dataframe"? Please use the below to create the URL dataframe ``` url = ["https://www.doordash.com/store/popeyes-toronto-254846/en-CA", "https://www.doordash.com/store/sunset-grill-toronto-211003/en-CA"] ``` url = pd.DataFrame(data) URL The error message is below(it is much longer). It says no such element, however, I tried it individually when the page was done loading, those elements were found and the right content was scraped. It is just that when I try to scrape multiple pages, it gives me an error. [![enter image description here](https://i.stack.imgur.com/MVBSi.png)](https://i.stack.imgur.com/MVBSi.png) Any help would be appreciated!
2021/01/24
[ "https://Stackoverflow.com/questions/65876057", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5220666/" ]
Try using Volume instead of Bind Mount for the data folder by changing this: ``` - ./db-data:/var/lib/postgresql/data ``` To this: ``` - db-data:/var/lib/postgresql/data ``` And adding this section to the end of the compose file: ``` volumes: db-data: ``` You can read more about bind mounts vs volumes [here](https://docs.docker.com/storage/volumes/)
I found it. The issue is not in docker, but in the compiler. I'm using [ncc](https://github.com/vercel/ncc) and it breaks my postgres client. I opened an issue in their repo with a minimal reproducible example <https://github.com/vercel/ncc/issues/646> Thanks a lot for your help
1,253,523
**Final update** Similar issue has been reported [here](https://github.com/ros-infrastructure/rosinstall_generator/issues/69). Discourse announcement: [Build/CI failures with ros-testing repository enabled?](https://discourse.ros.org/t/build-ci-failures-with-ros-testing-repository-enabled/15006) --- **Update2** Actually, installation of ROS Melodic failed at the end in my case: ``` Errors were encountered while processing: /tmp/apt-dpkg-install-lRVV2P/0767-python-catkin-pkg-modules_0.4.22-1_all.deb /tmp/apt-dpkg-install-lRVV2P/0794-python-rospkg-modules_1.2.8-1_all.deb /tmp/apt-dpkg-install-lRVV2P/0796-python-rosdistro-modules_0.8.2-1_all.deb E: Sub-process /usr/bin/dpkg returned an error code (1) ``` More logs: ``` Selecting previously unselected package python-catkin-pkg-modules. Preparing to unpack .../0767-python-catkin-pkg-modules_0.4.22-1_all.deb ... Unpacking python-catkin-pkg-modules (0.4.22-1) ... dpkg: error processing archive /tmp/apt-dpkg-install-lRVV2P/0767-python-catkin-pkg-modules_0.4.22-1_all.deb (--unpack): trying to overwrite '/usr/lib/python2.7/dist-packages/catkin_pkg/__init__.py', which is also in package python-catkin-pkg 0.3.9-1 ``` ``` Selecting previously unselected package python-rospkg-modules. Preparing to unpack .../0794-python-rospkg-modules_1.2.8-1_all.deb ... Unpacking python-rospkg-modules (1.2.8-1) ... dpkg: error processing archive /tmp/apt-dpkg-install-lRVV2P/0794-python-rospkg-modules_1.2.8-1_all.deb (--unpack): trying to overwrite '/usr/lib/python2.7/dist-packages/rospkg/__init__.py', which is also in package python-rospkg 1.1.4-1 ``` ``` Selecting previously unselected package python-rosdistro-modules. Preparing to unpack .../0796-python-rosdistro-modules_0.8.2-1_all.deb ... Unpacking python-rosdistro-modules (0.8.2-1) ... dpkg: error processing archive /tmp/apt-dpkg-install-lRVV2P/0796-python-rosdistro-modules_0.8.2-1_all.deb (--unpack): trying to overwrite '/usr/lib/python2.7/dist-packages/rosdistro/__init__.py', which is also in package python-rosdistro 0.6.6-1 ``` --- **Update** When faulty: ``` The following packages have unmet dependencies: python-rosinstall-generator : Depends: python-catkin-pkg (>= 0.1.28) but it is not going to be installed Depends: python-pkg-resources but it is not going to be installed Depends: python-rosdistro (>= 0.7.3) but it is not going to be installed Depends: python-rospkg but it is not going to be installed Depends: python-yaml but it is not going to be installed Depends: python2 (< 2.8) but it is not installable Depends: python2 (>= 2.7) but it is not installable Depends: python2:any (>= 2.6.6-7~) but it is not installable E: Unable to correct problems, you have held broken packages. ``` ``` apt-cache policy python-rosinstall-generator python-rosinstall-generator: Installed: (none) Candidate: 0.1.20-1 Version table: 0.1.20-1 500 500 http://packages.ros.org/ros/ubuntu bionic/main amd64 Packages 500 http://packages.ros.org/ros/ubuntu bionic/main i386 Packages 0.1.13-3 500 500 http://archive.ubuntu.com/ubuntu bionic/universe amd64 Packages 500 http://archive.ubuntu.com/ubuntu bionic/universe i386 Packages ``` ``` apt-cache policy python3-rosinstall-generator python3-rosinstall-generator: Installed: (none) Candidate: 0.1.20-1 Version table: 0.1.20-1 500 500 http://packages.ros.org/ros/ubuntu bionic/main amd64 Packages 500 http://packages.ros.org/ros/ubuntu bionic/main i386 Packages 0.1.13-3 500 500 http://archive.ubuntu.com/ubuntu bionic/universe amd64 Packages 500 http://archive.ubuntu.com/ubuntu bionic/universe i386 Packages ``` --- I have some issue to install the following package `python-rosinstall-generator` on Ubuntu 18.04 with `apt`: ``` Some packages could not be installed. This may mean that you have requested an impossible situation or if you are using the unstable distribution that some required packages have not yet been created or been moved out of Incoming. The following information may help to resolve the situation: The following packages have unmet dependencies: python-rosinstall-generator : Depends: python2 (< 2.8) but it is not installable Depends: python2 (>= 2.7) but it is not installable Depends: python2:any (>= 2.6.6-7~) but it is not installable E: Unable to correct problems, you have held broken packages. ``` Since I am using Docker, I have an old image where `python-rosinstall-generator` has been successfully installed with `apt install python-rosinstall-generator`: ``` apt-cache depends python-rosinstall-generator python-rosinstall-generator Depends: python Depends: python Depends: python-catkin-pkg Depends: python-pkg-resources Depends: python-rosdistro Depends: python-rospkg Depends: python-yaml Depends: <python:any> python:i386 python Depends: <python-argparse> libpython2.7-stdlib Conflicts: python3-rosinstall-generator ``` After doing `apt update` in the Docker, it gives now: ``` apt-cache depends python-rosinstall-generator python-rosinstall-generator Depends: python-catkin-pkg Depends: python-pkg-resources Depends: python-rosdistro Depends: python-rospkg Depends: python-yaml Depends: <python2> Depends: <python2> Depends: <python2:any> Depends: <python-argparse> libpython2.7-stdlib Conflicts: python3-rosinstall-generator ``` And `python2` package cannot be installed: ``` apt install python2 Reading package lists... Done Building dependency tree Reading state information... Done Package python2 is not available, but is referred to by another package. This may mean that the package is missing, has been obsoleted, or is only available from another source E: Package 'python2' has no installation candidate ``` It looks like a recent update has broken something, and has introduced a `python2` package dependency. --- **dockerfile** ``` FROM ubuntu:18.04 ENV DEBIAN_FRONTEND=noninteractive RUN apt-get update && apt-get install --yes \ build-essential \ software-properties-common \ pkg-config \ cmake \ g++ RUN add-apt-repository "deb http://archive.ubuntu.com/ubuntu $(lsb_release -sc) main universe restricted multiverse" RUN echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list RUN apt-key adv --keyserver 'hkp://keyserver.ubuntu.com:80' --recv-key C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654 RUN apt-get update && apt-get install --yes python-rosinstall-generator ```
2020/06/25
[ "https://askubuntu.com/questions/1253523", "https://askubuntu.com", "https://askubuntu.com/users/707605/" ]
It looks like that *packages.ros.org* repository provides `python3-rosinstall-generator` package which is not compatible with Ubuntu 18.04 LTS. The container creation using Dockerfile without such repository is successful: ``` FROM ubuntu:18.04 ENV DEBIAN_FRONTEND=noninteractive RUN apt-get update && apt-get install --yes \ build-essential \ software-properties-common \ pkg-config \ cmake \ g++ RUN apt-get update && apt-get install --yes python-rosinstall-generator ``` But installation of `ros-melodic-desktop-full` ends successfully using your original Dockerfile.
One way to go around this issue may be to install it using pip package manager. Since you are using python2 for ROS, just try the following: ``` sudo apt install python-pip sudo pip install -U rosdep rosinstall_generator vcstool rosinstall ``` This has worked for me. I hope this helps.
28,171,901
I have a xml-file that looks like this: ``` <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <ns1:policies xmlns:ns1="http://www.companyname.nl/exchange/policyimport" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <policy> <serialnumber>159</serialnumber> <relationnumber>159</relationnumber> <policynumber>2013000001</policynumber> <soort>2002</soort> <policyStatus>1</policyStatus> <startdate>2001-03-16</startdate> <enddate>2016-03-16</enddate> <label1>0</label1> <label2>100</label2> <btw>true</btw> </policy> <policy> <serialnumber>159</serialnumber> <relationnumber>159</relationnumber> <policynumber>2013000002</policynumber> <soort>2003</soort> <policyStatus>1</policyStatus> <startdate>2001-03-16</startdate> <enddate>2016-03-16</enddate> <label1>0</label1> <label2>100</label2> <btw>false</btw> </policy> </ns1:policies> ``` I would like to extract data from a tag using a bash script, but depending on the contents of another tag. So for instance: If the content of `<btw>` is true, then get the content of `<policynumber>` in that same block (in this case 2013000001). If the content of `<soort>` is 2003 then get the content of `<policynumber>`in that same block(in this case 2013000002). Is that possible in a bash script? I tried to figure it out using xmlstarlet, but I'm a newbie and couldn't get it done. TIA!
2015/01/27
[ "https://Stackoverflow.com/questions/28171901", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4445959/" ]
I solve the problem adding the tags DCM\_BitsAllocated and DCM\_PlanarConfiguration. This are the tags that are missed. I hope that is useful for someone.
At least you should call the function chooseRepresentation, after you have applied the data. ``` **dataset->putAndInsertUint8Array(DCM_PixelData, pSorg, sizeBuffer);** dataset->chooseRepresentation(EXS_JPEGProcess14SV1, &params); ```
22,185,500
I tried following the directions to get Yeoman Ember started from here: <https://github.com/yeoman/generator-ember#usage> ``` npm install -g generator-ember mkdir myemberapp && cd myemberapp yo ember npm install -g grunt-mocha grunt serve A welcome page should appear in your browser. ``` However, Bower errors out withe the following error ``` ..\myemberapp>bower install module.js:340 throw err; ^ Error: Cannot find module 'ansi-styles' at Function.Module._resolveFilename (module.js:338:15) at Function.Module._load (module.js:280:25) at Module.require (module.js:364:17) at require (module.js:380:17) at Object.<anonymous> (C:\Users\Usr\AppData\Roaming\npm\node_modules\bowe r\node_modules\chalk\chalk.js:2:12) at Module._compile (module.js:456:26) at Object.Module._extensions..js (module.js:474:10) at Module.load (module.js:356:32) at Function.Module._load (module.js:312:12) at Module.require (module.js:364:17) ``` Thanks for any leads!
2014/03/04
[ "https://Stackoverflow.com/questions/22185500", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3381250/" ]
Reinstall Bower. It's corrupt as it's missing a dependency.
You can try to install ansi-styles: ``` npm install -g ansi-styles ``` If you just end up having the next dependency missing there is probably something inherently wrong that needs fixed, and someone smarter than me needs to help you.
67,114,026
I'd like to limits API access from one or more domains - in other words I have a set of exposed API endpoints but I only want to respond to specific remote servers. I intend to issue tokens to the servers that I intend to respond to but I want to ensure that I'm really dealing with the right servers in case the tokens become public knowledge. I thought I would be able to use Origin or Referrer from the HTTP headers but perhaps because I'm sitting behind an Nginx front end, those headers don't always seem to be visible. Any suggestions gratefully received.
2021/04/15
[ "https://Stackoverflow.com/questions/67114026", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15650534/" ]
After grouping by 'FamilyID', subset the 'X', 'Y' column where the SubjectID is 4 or 5, check if `any` of the values are equal to 1 and the compound logical expression is joined with OR (`|`) operator ``` library(dplyr) df1 %>% group_by(FamilyID) %>% mutate(Z = +(any(X[SubjectID %in% 4:5] == 1)| any(Y[SubjectID %in% 4:5] == 1))) %>% ungroup ``` -output ``` # A tibble: 13 x 5 # FamilyID SubjectID X Y Z # <int> <int> <int> <int> <int> # 1 1 1 1 1 1 # 2 1 2 2 2 1 # 3 1 4 1 2 1 # 4 2 1 1 1 0 # 5 2 2 2 2 0 # 6 3 1 2 1 1 # 7 3 2 1 1 1 # 8 3 4 2 2 1 # 9 3 5 1 2 1 #10 4 1 2 2 0 #11 4 2 2 2 0 #12 4 4 2 2 0 #13 4 5 2 2 0 ``` --- Or using `base R` ``` df1$Z <- with(df1, +(FamilyID %in% FamilyID[SubjectID %in% 4:5][rowSums(cbind(X, Y)[SubjectID %in% 4:5,] == 1) > 0])) df1$Z #[1] 1 1 1 0 0 1 1 1 1 0 0 0 0 ``` ### data ``` df1 <- structure(list(FamilyID = c(1L, 1L, 1L, 2L, 2L, 3L, 3L, 3L, 3L, 4L, 4L, 4L, 4L), SubjectID = c(1L, 2L, 4L, 1L, 2L, 1L, 2L, 4L, 5L, 1L, 2L, 4L, 5L), X = c(1L, 2L, 1L, 1L, 2L, 2L, 1L, 2L, 1L, 2L, 2L, 2L, 2L), Y = c(1L, 2L, 2L, 1L, 2L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L)), class = "data.frame", row.names = c(NA, -13L)) ```
**Special thanks** to dear @akrun for his helpful suggestions: You can also use the following solution. I used data provided by dear @akrun. ``` library(dplyr) library(purrr) df1 %>% mutate(Z = pmap_dbl(list(SubjectID, X, Y), ~ if_else(..1 %in% c(4, 5) & any(c(..2, ..3) == 1), 1, 0))) %>% group_by(FamilyID) %>% mutate(Z = if_else(any(Z == 1), 1, 0)) # A tibble: 13 x 5 # Groups: FamilyID [4] FamilyID SubjectID X Y Z <int> <int> <int> <int> <dbl> 1 1 1 1 1 1 2 1 2 2 2 1 3 1 4 1 2 1 4 2 1 1 1 0 5 2 2 2 2 0 6 3 1 2 1 1 7 3 2 1 1 1 8 3 4 2 2 1 9 3 5 1 2 1 10 4 1 2 2 0 11 4 2 2 2 0 12 4 4 2 2 0 13 4 5 2 2 0 ```
873
**UPDATE MARCH 24, 2016** After some further thinking, To maintain consistency I decided to go with Winkle-bot for all three images: [![Captcha, 404, and Error Winkle](https://i.stack.imgur.com/P3SfL.png)](https://i.stack.imgur.com/P3SfL.png) *Captcha, 404, and Error Winkle-bots* These will be live with the next production build. --- **UPDATE MARCH 23, 2016** Based on the feedback below, here are three ideas for the error, 404, and captcha images: [![Error](https://i.stack.imgur.com/XxDod.png)](https://i.stack.imgur.com/XxDod.png) **Error:** While I can't change the headline on the page [as suggested in this answer](https://magento.meta.stackexchange.com/a/875/32899), I can place this common Magento error message within the image. [![404](https://i.stack.imgur.com/9Iv2m.png)](https://i.stack.imgur.com/9Iv2m.png) **404:** So the thought here is Magento is an e-commerce platform. This means people buy things. Things are shipped in boxes. Boxes can be stacked. Box stacks could be made to look like numbers with some conveniently placed forklifts. [![Captcha](https://i.stack.imgur.com/8w7dA.png)](https://i.stack.imgur.com/8w7dA.png) **Captcha:** This is a computer sporting [Phil Winkle's hair.](https://magento.meta.stackexchange.com/a/874/32899) --- **ORGINAL:** For those who don't know me: Hello! My name is Joshua and I'm a Senior Product Designer at Stack Overflow. [I've been working on your community site theme.](https://magento.meta.stackexchange.com/questions/817/magento-site-design) (I hope you've been enjoying it.) There is one more thing to finish and I could use some help. On all our Page Not Found (404), Error, and Captcha pages, we customize images for each community. Some examples are: [![Academia' Error Page](https://i.stack.imgur.com/ZnK11.png)](https://i.stack.imgur.com/ZnK11.png) *[Academia's error page](https://academia.stackexchange.com/error) helps communicate that something is currently "off" be tilting the tower in the header.* [![Cryptography's 404 Page](https://i.stack.imgur.com/7iOJW.png)](https://i.stack.imgur.com/7iOJW.png) *[Cryptography's 404 page](https://crypto.stackexchange.com/404) uses a puzzled John Nash (played by Russell Crowe) from "A Beautiful Mind" to show that we're all looking for something.* [![Movies & TV's Captcha Page](https://i.stack.imgur.com/o278U.png)](https://i.stack.imgur.com/o278U.png) *[Movies & TV's captcha page](https://movies.stackexchange.com/captcha) uses HAL 9000 (from "2001: Space Odyssey") to help verify people interacting on the site are humans and not robots.* As you can see in the three examples above, these pages are a way to further express the site's topic—even when things go awry. Typically these are designed when we launch the website, but I struggled to come up with interesting ideas prior to the site launch. And as it isn't a required element, we delayed it hoping the following weeks we would do them. Despite the best intentions though, we still have not done this and the main reason is I'm still stumped on ideas. **So can you help? What ideas for error, page not found, and captcha pages do you have?** Help me create some unique and interesting pages for Magento.
2016/03/22
[ "https://magento.meta.stackexchange.com/questions/873", "https://magento.meta.stackexchange.com", "https://magento.meta.stackexchange.com/users/32899/" ]
I'm not sure yet if this is too cruel but you could replace "Ooops! Something bad happened" with the all too well known phrase ["There has been an error processing your request"](https://www.google.de/search?q=there+has+been+an+error+processing+your+request&source=lnms&tbm=isch&sa=X)
Here is my proposal for the 404 not found page. The idea is based on **famous misspell regarding Magento: Magneto**. Everyone here has probably made the mistake typing too fast on the keyboard. As we all know mistake typing an URL often leads to the 404 page. Thus I would like to see a **designed version of Magneto from X men in the 404 page**. Something like this: [![enter image description here](https://i.stack.imgur.com/1MseT.png)](https://i.stack.imgur.com/1MseT.png) If it was for a 503 page I also would have added the "You shall not pass" phrase as it's the same actor that plays Magneto and Gandalf in the movies. But I guess that would be irrelevant on a 404. Regarding the **captcha page** I was thinking, what about a **"are you human?" phrase with a picture of Phil Winkle's hair** as he seems to have a lot of non human related accounts on the Internet. Maybe too much of a private joke here.
873
**UPDATE MARCH 24, 2016** After some further thinking, To maintain consistency I decided to go with Winkle-bot for all three images: [![Captcha, 404, and Error Winkle](https://i.stack.imgur.com/P3SfL.png)](https://i.stack.imgur.com/P3SfL.png) *Captcha, 404, and Error Winkle-bots* These will be live with the next production build. --- **UPDATE MARCH 23, 2016** Based on the feedback below, here are three ideas for the error, 404, and captcha images: [![Error](https://i.stack.imgur.com/XxDod.png)](https://i.stack.imgur.com/XxDod.png) **Error:** While I can't change the headline on the page [as suggested in this answer](https://magento.meta.stackexchange.com/a/875/32899), I can place this common Magento error message within the image. [![404](https://i.stack.imgur.com/9Iv2m.png)](https://i.stack.imgur.com/9Iv2m.png) **404:** So the thought here is Magento is an e-commerce platform. This means people buy things. Things are shipped in boxes. Boxes can be stacked. Box stacks could be made to look like numbers with some conveniently placed forklifts. [![Captcha](https://i.stack.imgur.com/8w7dA.png)](https://i.stack.imgur.com/8w7dA.png) **Captcha:** This is a computer sporting [Phil Winkle's hair.](https://magento.meta.stackexchange.com/a/874/32899) --- **ORGINAL:** For those who don't know me: Hello! My name is Joshua and I'm a Senior Product Designer at Stack Overflow. [I've been working on your community site theme.](https://magento.meta.stackexchange.com/questions/817/magento-site-design) (I hope you've been enjoying it.) There is one more thing to finish and I could use some help. On all our Page Not Found (404), Error, and Captcha pages, we customize images for each community. Some examples are: [![Academia' Error Page](https://i.stack.imgur.com/ZnK11.png)](https://i.stack.imgur.com/ZnK11.png) *[Academia's error page](https://academia.stackexchange.com/error) helps communicate that something is currently "off" be tilting the tower in the header.* [![Cryptography's 404 Page](https://i.stack.imgur.com/7iOJW.png)](https://i.stack.imgur.com/7iOJW.png) *[Cryptography's 404 page](https://crypto.stackexchange.com/404) uses a puzzled John Nash (played by Russell Crowe) from "A Beautiful Mind" to show that we're all looking for something.* [![Movies & TV's Captcha Page](https://i.stack.imgur.com/o278U.png)](https://i.stack.imgur.com/o278U.png) *[Movies & TV's captcha page](https://movies.stackexchange.com/captcha) uses HAL 9000 (from "2001: Space Odyssey") to help verify people interacting on the site are humans and not robots.* As you can see in the three examples above, these pages are a way to further express the site's topic—even when things go awry. Typically these are designed when we launch the website, but I struggled to come up with interesting ideas prior to the site launch. And as it isn't a required element, we delayed it hoping the following weeks we would do them. Despite the best intentions though, we still have not done this and the main reason is I'm still stumped on ideas. **So can you help? What ideas for error, page not found, and captcha pages do you have?** Help me create some unique and interesting pages for Magento.
2016/03/22
[ "https://magento.meta.stackexchange.com/questions/873", "https://magento.meta.stackexchange.com", "https://magento.meta.stackexchange.com/users/32899/" ]
Here is my proposal for the 404 not found page. The idea is based on **famous misspell regarding Magento: Magneto**. Everyone here has probably made the mistake typing too fast on the keyboard. As we all know mistake typing an URL often leads to the 404 page. Thus I would like to see a **designed version of Magneto from X men in the 404 page**. Something like this: [![enter image description here](https://i.stack.imgur.com/1MseT.png)](https://i.stack.imgur.com/1MseT.png) If it was for a 503 page I also would have added the "You shall not pass" phrase as it's the same actor that plays Magneto and Gandalf in the movies. But I guess that would be irrelevant on a 404. Regarding the **captcha page** I was thinking, what about a **"are you human?" phrase with a picture of Phil Winkle's hair** as he seems to have a lot of non human related accounts on the Internet. Maybe too much of a private joke here.
There are a lot of meme-type things that have been done with my visage, but nothing do freakin' cool as Winkle-bot. Cheers!!
873
**UPDATE MARCH 24, 2016** After some further thinking, To maintain consistency I decided to go with Winkle-bot for all three images: [![Captcha, 404, and Error Winkle](https://i.stack.imgur.com/P3SfL.png)](https://i.stack.imgur.com/P3SfL.png) *Captcha, 404, and Error Winkle-bots* These will be live with the next production build. --- **UPDATE MARCH 23, 2016** Based on the feedback below, here are three ideas for the error, 404, and captcha images: [![Error](https://i.stack.imgur.com/XxDod.png)](https://i.stack.imgur.com/XxDod.png) **Error:** While I can't change the headline on the page [as suggested in this answer](https://magento.meta.stackexchange.com/a/875/32899), I can place this common Magento error message within the image. [![404](https://i.stack.imgur.com/9Iv2m.png)](https://i.stack.imgur.com/9Iv2m.png) **404:** So the thought here is Magento is an e-commerce platform. This means people buy things. Things are shipped in boxes. Boxes can be stacked. Box stacks could be made to look like numbers with some conveniently placed forklifts. [![Captcha](https://i.stack.imgur.com/8w7dA.png)](https://i.stack.imgur.com/8w7dA.png) **Captcha:** This is a computer sporting [Phil Winkle's hair.](https://magento.meta.stackexchange.com/a/874/32899) --- **ORGINAL:** For those who don't know me: Hello! My name is Joshua and I'm a Senior Product Designer at Stack Overflow. [I've been working on your community site theme.](https://magento.meta.stackexchange.com/questions/817/magento-site-design) (I hope you've been enjoying it.) There is one more thing to finish and I could use some help. On all our Page Not Found (404), Error, and Captcha pages, we customize images for each community. Some examples are: [![Academia' Error Page](https://i.stack.imgur.com/ZnK11.png)](https://i.stack.imgur.com/ZnK11.png) *[Academia's error page](https://academia.stackexchange.com/error) helps communicate that something is currently "off" be tilting the tower in the header.* [![Cryptography's 404 Page](https://i.stack.imgur.com/7iOJW.png)](https://i.stack.imgur.com/7iOJW.png) *[Cryptography's 404 page](https://crypto.stackexchange.com/404) uses a puzzled John Nash (played by Russell Crowe) from "A Beautiful Mind" to show that we're all looking for something.* [![Movies & TV's Captcha Page](https://i.stack.imgur.com/o278U.png)](https://i.stack.imgur.com/o278U.png) *[Movies & TV's captcha page](https://movies.stackexchange.com/captcha) uses HAL 9000 (from "2001: Space Odyssey") to help verify people interacting on the site are humans and not robots.* As you can see in the three examples above, these pages are a way to further express the site's topic—even when things go awry. Typically these are designed when we launch the website, but I struggled to come up with interesting ideas prior to the site launch. And as it isn't a required element, we delayed it hoping the following weeks we would do them. Despite the best intentions though, we still have not done this and the main reason is I'm still stumped on ideas. **So can you help? What ideas for error, page not found, and captcha pages do you have?** Help me create some unique and interesting pages for Magento.
2016/03/22
[ "https://magento.meta.stackexchange.com/questions/873", "https://magento.meta.stackexchange.com", "https://magento.meta.stackexchange.com/users/32899/" ]
I'm not sure yet if this is too cruel but you could replace "Ooops! Something bad happened" with the all too well known phrase ["There has been an error processing your request"](https://www.google.de/search?q=there+has+been+an+error+processing+your+request&source=lnms&tbm=isch&sa=X)
There are a lot of meme-type things that have been done with my visage, but nothing do freakin' cool as Winkle-bot. Cheers!!
27,156,353
I was trying to use Microsoft.ApplicationInsights, and I installed the same through nuget. but when I am trying to use ``` _telemetryClient.TrackException(ex, new Dictionary<string, string> { {"Id", id.ToString()} }, null); ``` I am getting an error saying: InstrumentationKey cannot be empty. I have already gone through the [URL](https://github.com/Azure/azure-content/blob/master/articles/app-insights-search-diagnostic-logs.md#i-get-an-error-instrumentation-key-cannot-be-empty) but I can't see any Update menu available for the config file in my VS(Note: I am using VS 2012 Pro). I have also tried updating the config file with the instrumentation key ``` <ComponentID>{Instrumentation Key}</ComponentID> ``` But, that didn't work too. Thanks.
2014/11/26
[ "https://Stackoverflow.com/questions/27156353", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1208503/" ]
I still haven't found any solution in configuration level. However, We can provide the Instrumentation Key while initializing the TelemetryClient object: ``` var telemetryClient = new TelemetryClient(new TelemetryConfiguration() { InstrumentationKey = "Key" }); ``` Please don't hesitate to post an answer how can we provide the Instrumentation key through config. Thanks.
i'm assuming you have added the .11 or later Application Insights SDK. if so add the instrumenation key to your applicationinsights.config file after adding the Application Insights SDK to your project like this: ``` </TelemetryInitializers> <InstrumentationKey>your-guid-goes-ere</InstrumentationKey> </ApplicationInsights> ```
27,156,353
I was trying to use Microsoft.ApplicationInsights, and I installed the same through nuget. but when I am trying to use ``` _telemetryClient.TrackException(ex, new Dictionary<string, string> { {"Id", id.ToString()} }, null); ``` I am getting an error saying: InstrumentationKey cannot be empty. I have already gone through the [URL](https://github.com/Azure/azure-content/blob/master/articles/app-insights-search-diagnostic-logs.md#i-get-an-error-instrumentation-key-cannot-be-empty) but I can't see any Update menu available for the config file in my VS(Note: I am using VS 2012 Pro). I have also tried updating the config file with the instrumentation key ``` <ComponentID>{Instrumentation Key}</ComponentID> ``` But, that didn't work too. Thanks.
2014/11/26
[ "https://Stackoverflow.com/questions/27156353", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1208503/" ]
I still haven't found any solution in configuration level. However, We can provide the Instrumentation Key while initializing the TelemetryClient object: ``` var telemetryClient = new TelemetryClient(new TelemetryConfiguration() { InstrumentationKey = "Key" }); ``` Please don't hesitate to post an answer how can we provide the Instrumentation key through config. Thanks.
Use this below code in your Configuration method. ``` Microsoft.ApplicationInsights.Extensibility.TelemetryConfiguration.Active.InstrumentationKey = key; ```
27,156,353
I was trying to use Microsoft.ApplicationInsights, and I installed the same through nuget. but when I am trying to use ``` _telemetryClient.TrackException(ex, new Dictionary<string, string> { {"Id", id.ToString()} }, null); ``` I am getting an error saying: InstrumentationKey cannot be empty. I have already gone through the [URL](https://github.com/Azure/azure-content/blob/master/articles/app-insights-search-diagnostic-logs.md#i-get-an-error-instrumentation-key-cannot-be-empty) but I can't see any Update menu available for the config file in my VS(Note: I am using VS 2012 Pro). I have also tried updating the config file with the instrumentation key ``` <ComponentID>{Instrumentation Key}</ComponentID> ``` But, that didn't work too. Thanks.
2014/11/26
[ "https://Stackoverflow.com/questions/27156353", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1208503/" ]
I still haven't found any solution in configuration level. However, We can provide the Instrumentation Key while initializing the TelemetryClient object: ``` var telemetryClient = new TelemetryClient(new TelemetryConfiguration() { InstrumentationKey = "Key" }); ``` Please don't hesitate to post an answer how can we provide the Instrumentation key through config. Thanks.
In my case I just needed to add my IP to the Azure Database firewall - the `InstrumentationKey` fails before we get explanatory error about the firewall so it may be confusing.
27,156,353
I was trying to use Microsoft.ApplicationInsights, and I installed the same through nuget. but when I am trying to use ``` _telemetryClient.TrackException(ex, new Dictionary<string, string> { {"Id", id.ToString()} }, null); ``` I am getting an error saying: InstrumentationKey cannot be empty. I have already gone through the [URL](https://github.com/Azure/azure-content/blob/master/articles/app-insights-search-diagnostic-logs.md#i-get-an-error-instrumentation-key-cannot-be-empty) but I can't see any Update menu available for the config file in my VS(Note: I am using VS 2012 Pro). I have also tried updating the config file with the instrumentation key ``` <ComponentID>{Instrumentation Key}</ComponentID> ``` But, that didn't work too. Thanks.
2014/11/26
[ "https://Stackoverflow.com/questions/27156353", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1208503/" ]
Did you download nuget manually or did you get it via UI by adding AppInsights to the project? We have seen this issue when users try to add individual nugget manually. The easiest way to recover is to add full AppInsights support by right click on the project and choosing Update Application Insights - it will ask you to create new AI resource or point to existing AI resource and it will create instrumentation key for you. But you'd need to use VS 2013 in order to have VS integration for Application Insights.
i'm assuming you have added the .11 or later Application Insights SDK. if so add the instrumenation key to your applicationinsights.config file after adding the Application Insights SDK to your project like this: ``` </TelemetryInitializers> <InstrumentationKey>your-guid-goes-ere</InstrumentationKey> </ApplicationInsights> ```
27,156,353
I was trying to use Microsoft.ApplicationInsights, and I installed the same through nuget. but when I am trying to use ``` _telemetryClient.TrackException(ex, new Dictionary<string, string> { {"Id", id.ToString()} }, null); ``` I am getting an error saying: InstrumentationKey cannot be empty. I have already gone through the [URL](https://github.com/Azure/azure-content/blob/master/articles/app-insights-search-diagnostic-logs.md#i-get-an-error-instrumentation-key-cannot-be-empty) but I can't see any Update menu available for the config file in my VS(Note: I am using VS 2012 Pro). I have also tried updating the config file with the instrumentation key ``` <ComponentID>{Instrumentation Key}</ComponentID> ``` But, that didn't work too. Thanks.
2014/11/26
[ "https://Stackoverflow.com/questions/27156353", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1208503/" ]
i'm assuming you have added the .11 or later Application Insights SDK. if so add the instrumenation key to your applicationinsights.config file after adding the Application Insights SDK to your project like this: ``` </TelemetryInitializers> <InstrumentationKey>your-guid-goes-ere</InstrumentationKey> </ApplicationInsights> ```
Use this below code in your Configuration method. ``` Microsoft.ApplicationInsights.Extensibility.TelemetryConfiguration.Active.InstrumentationKey = key; ```
27,156,353
I was trying to use Microsoft.ApplicationInsights, and I installed the same through nuget. but when I am trying to use ``` _telemetryClient.TrackException(ex, new Dictionary<string, string> { {"Id", id.ToString()} }, null); ``` I am getting an error saying: InstrumentationKey cannot be empty. I have already gone through the [URL](https://github.com/Azure/azure-content/blob/master/articles/app-insights-search-diagnostic-logs.md#i-get-an-error-instrumentation-key-cannot-be-empty) but I can't see any Update menu available for the config file in my VS(Note: I am using VS 2012 Pro). I have also tried updating the config file with the instrumentation key ``` <ComponentID>{Instrumentation Key}</ComponentID> ``` But, that didn't work too. Thanks.
2014/11/26
[ "https://Stackoverflow.com/questions/27156353", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1208503/" ]
i'm assuming you have added the .11 or later Application Insights SDK. if so add the instrumenation key to your applicationinsights.config file after adding the Application Insights SDK to your project like this: ``` </TelemetryInitializers> <InstrumentationKey>your-guid-goes-ere</InstrumentationKey> </ApplicationInsights> ```
In my case I just needed to add my IP to the Azure Database firewall - the `InstrumentationKey` fails before we get explanatory error about the firewall so it may be confusing.
27,156,353
I was trying to use Microsoft.ApplicationInsights, and I installed the same through nuget. but when I am trying to use ``` _telemetryClient.TrackException(ex, new Dictionary<string, string> { {"Id", id.ToString()} }, null); ``` I am getting an error saying: InstrumentationKey cannot be empty. I have already gone through the [URL](https://github.com/Azure/azure-content/blob/master/articles/app-insights-search-diagnostic-logs.md#i-get-an-error-instrumentation-key-cannot-be-empty) but I can't see any Update menu available for the config file in my VS(Note: I am using VS 2012 Pro). I have also tried updating the config file with the instrumentation key ``` <ComponentID>{Instrumentation Key}</ComponentID> ``` But, that didn't work too. Thanks.
2014/11/26
[ "https://Stackoverflow.com/questions/27156353", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1208503/" ]
Did you download nuget manually or did you get it via UI by adding AppInsights to the project? We have seen this issue when users try to add individual nugget manually. The easiest way to recover is to add full AppInsights support by right click on the project and choosing Update Application Insights - it will ask you to create new AI resource or point to existing AI resource and it will create instrumentation key for you. But you'd need to use VS 2013 in order to have VS integration for Application Insights.
Use this below code in your Configuration method. ``` Microsoft.ApplicationInsights.Extensibility.TelemetryConfiguration.Active.InstrumentationKey = key; ```
27,156,353
I was trying to use Microsoft.ApplicationInsights, and I installed the same through nuget. but when I am trying to use ``` _telemetryClient.TrackException(ex, new Dictionary<string, string> { {"Id", id.ToString()} }, null); ``` I am getting an error saying: InstrumentationKey cannot be empty. I have already gone through the [URL](https://github.com/Azure/azure-content/blob/master/articles/app-insights-search-diagnostic-logs.md#i-get-an-error-instrumentation-key-cannot-be-empty) but I can't see any Update menu available for the config file in my VS(Note: I am using VS 2012 Pro). I have also tried updating the config file with the instrumentation key ``` <ComponentID>{Instrumentation Key}</ComponentID> ``` But, that didn't work too. Thanks.
2014/11/26
[ "https://Stackoverflow.com/questions/27156353", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1208503/" ]
Did you download nuget manually or did you get it via UI by adding AppInsights to the project? We have seen this issue when users try to add individual nugget manually. The easiest way to recover is to add full AppInsights support by right click on the project and choosing Update Application Insights - it will ask you to create new AI resource or point to existing AI resource and it will create instrumentation key for you. But you'd need to use VS 2013 in order to have VS integration for Application Insights.
In my case I just needed to add my IP to the Azure Database firewall - the `InstrumentationKey` fails before we get explanatory error about the firewall so it may be confusing.
70,728,515
I've been coding a program to write data into a text file and practice data processes in c, and find data from there, every data is stored as lines. There are lines, and data is stored line by line, such as: **student name** *student surname* **student phone etc.** When i take an input of "student name" it starts to print without printing the name itself, prints what comes after it, same happens if i search for surname, only phone will be printed out. ``` #include <stdio.h> #include <stdlib.h> #include <string.h> int main(){ FILE *filePtr; filePtr=fopen("std.txt","r"); char char_input[50]; char string[500]; printf("%s","Please give an input of the phone number\n"); scanf("%s",char_input); while(!feof(filePtr)){ fscanf(filePtr,"%s",string); if(strcmp(string, char_input)== 0){ fgets(string,500,filePtr); puts(string); } } fclose(filePtr); } ``` Text file: ``` Andrew Brooks 865 965 55 ``` Input: ``` Andrew ``` Output: ``` Brooks 865 965 55 ``` Desired output: ``` Andrew Brooks 865 965 55 ```
2022/01/16
[ "https://Stackoverflow.com/questions/70728515", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9560064/" ]
Instead of [incorrectly using `feof()`](http://stackoverflow.com/questions/5431941/why-is-while-feof-file-always-wrong) and `fscanf(filePtr,"%s", ...` to incorrectly read a *line*. Use `fgets()` to read a *line* of the file and convert to a *string*. * Test the return value of `fgets()` to see if input occurred. * Use `strstr()` to look for a matching sub-string within `string`. Example: ``` while (fgets(string, sizeof string, filePtr)) { if (strstr(string, char_input)){ fputs(string, stdout); } } ```
The function `feof` will only tell you whether a previous input operation has already encountered end-of-file. It won't tell you whether you have now reached the end of file, so that the next input operation will fail. That function function is unable to predict whether the next input operation to `fscanf` or `fgets` will fail. Therefore, it should generally not be used as a loop condition. See this question for further information: [Why is “while ( !feof (file) )” always wrong?](https://stackoverflow.com/q/5431941/12149471) In your case, `feof` may return false and the subsequent function call to `fscanf` may return `EOF` due to encountering end-of-file. In that case, your posted code will ignore the return value of `fscanf` and behave as if `fscanf` had succeeded, and your posted code will attempt to process the non-existant input. This is likely to result in a bug. Therefore, instead of using the function `feof` to determine whether the loop should be continued, you should check the return value of the input function. You could rewrite your loop like this: ``` while ( fscanf(filePtr,"%s",string) == 1 ) { if ( strcmp(string, char_input ) == 0 ) { fgets( string, 500, filePtr ); puts( string ); } } ``` This will solve the problem mentioned above of not checking the return value of `fscanf`. However, depending on the exact input, it may also be possible that the function `fgets` will fail due to encountering end-of-file. Therefore, it would be better if your program also checked the return value of the function `fgets`, instead of simply assuming that the function succeeded. Another problem is that the line ``` puts(string); ``` will only print the contents of `string`, which is `" Brooks 865 965 55"`. However, you also want to print `"Andrew"`, which was read by the `fscanf` function call but has been meanwhile overwritten by the `fgets` function call. The simplest solution would be to print it before it gets overwritten. However, this will not work if the user searches for `"Brooks"` instead of `"Andrew"`, because the word `"Andrew"` will already have been discarded in the previous loop iteration. This is because calling `fscanf(filePtr,"%s",string)` in a loop will not read one line of input per loop iteration, but will instead read a single word per loop iteration (which is not very meaningful). Another consequence of reading in the input file word by word using `fscanf(filePtr,"%s",string)` is that your won't be able to find a match for the phone number `"865 965 55"`. This is because your program will first read `"865"` from the input file and determine that this "word" is not identical to the search string. It will then read `"965"` and determine the same thing. It will do the same for `"55"`. The best solution would probably be to redesign your loop so that it always reads exactly one line of input per loop iteration, instead of only one word per loop iteration. After reading in one line of input, you can then parse the line by splitting it into "first name", "last name" and "phone number" using the function [`sscanf`](https://en.cppreference.com/w/c/io/fscanf). ``` #include <stdio.h> #include <stdlib.h> #include <string.h> int main() { FILE *filePtr; char search_string[50]; char line[200]; //open input file filePtr = fopen( "std.txt", "r" ); if ( filePtr == NULL ) { fprintf( stderr, "unable to open input file!\n" ); exit( EXIT_FAILURE ); } //prompt user for input printf( "Please enter search string: " ); //Note that the following code now uses "fgets" instead //of "fscanf", because fscanf will only read a single //word, when using the "%s" format specifier. This means //that it would be unable to read the phone number //"865 965 55" as an input string, because that line //consists of three "words". //read exactly one line of input from user if ( fgets( search_string, sizeof search_string, stdin ) == NULL ) { fprintf( stderr, "input failure!\n" ); exit( EXIT_FAILURE ); } //remove newline character from input line by //replacing it with terminating null character search_string[strcspn(search_string,"\n")] = '\0'; //read exactly one line of input from the input file //per loop iteration while ( fgets( line, sizeof line, filePtr ) != NULL ) { char first_name[50]; char last_name[50]; char phone_number[50]; //attempt to parse input if ( sscanf( line, "%49s %49s %49[^\n]", first_name, last_name, phone_number ) != 3 ) { fprintf( stderr, "WARNING: skipping line due to parse error!\n" ); continue; } //parsing was successful, so we can now search the //3 individual fields for the search string if ( strcmp( search_string, first_name ) == 0 || strcmp( search_string, last_name ) == 0 || strcmp( search_string, phone_number ) == 0 ) { //remove newline character from input line by //replacing it with terminating null character line[strcspn(line,"\n")] = '\0'; //print entire input line of file for user printf( "%s\n", line ); } } //cleanup fclose(filePtr); } ``` This program has the following behavior: ```none Please enter search string: Andrew Andrew Brooks 865 965 55 ``` ```none Please enter search string: Brooks Andrew Brooks 865 965 55 ``` ```none Please enter search string: 865 965 55 Andrew Brooks 865 965 55 ``` Note that the code above is not perfect, as it has the following issues: 1. When using `fgets`, if the input line is too long to fit in the buffer, then the program will not detect this, although it should probably print an error message and quit, in such a situation. 2. If any of the fields "first name", "last name" or "phone number" is larger than 49 characters, the code does prevent a buffer overflow (which would possibly cause your program to crash), but it still doesn't handle this situation properly, for example by checking for such a situation and by printing an appropriate error message. However, for your purposes, the code should probably be sufficient. A more robust program, which fixes these issues, would be the following: ``` #include <stdio.h> #include <stdlib.h> #include <string.h> #include <stdbool.h> //This function will read exactly one line of input using //fgets and verify that the line was not too long for the //input buffer. Note that the buffer size must be two bytes //longer than the actual string length, because there must //be space for the newline character and the terminating //null character. The newline character will be overwritten //with another terminating null character. //On success, it will return true. If not further input is //available due to end-of-file, it will return false. //Otherwise, the function will not return, but will //terminate the program with an error message. bool get_one_line_of_user_input( char *buffer, int buffer_size ) { char *p; if ( fgets( buffer, buffer_size, stdin ) == NULL ) { if ( feof( stdin ) ) { return false; } else { fprintf( stderr, "input error!\n" ); exit( EXIT_FAILURE ); } } p = strchr( buffer, '\n' ); if ( p == NULL ) { //No newline character was found. This could mean //that the line was too long to store in the input //buffer, in which case, the program should quit //with an error message. However, it could also mean //that input has been redirected to come from a //file, and that this file ends with a line without //a line ending. In that case, the missing newline //character can be ignored. if ( !feof( stdin ) ) { fprintf( stderr, "line too long for buffer!\n" ); exit( EXIT_FAILURE ); } } else { //remove newline character *p = '\0'; } return true; } int main() { FILE *filePtr; char search_string[50]; char line[200]; //open input file filePtr = fopen( "std.txt", "r" ); if ( filePtr == NULL ) { fprintf( stderr, "unable to open input file!\n" ); exit( EXIT_FAILURE ); } //prompt user for input printf( "Please enter search string: " ); //read exactly one line of input from user if ( !get_one_line_of_user_input( search_string, sizeof search_string ) ) { fprintf( stderr, "input failure!\n" ); exit( EXIT_FAILURE ); } //read exactly one line of input from the input file //per loop iteration while ( get_one_line_of_user_input( line, sizeof line ) ) { char first_name[50]; char last_name[50]; char phone_number[50]; //attempt to parse input if ( sscanf( line, "%49s %49s %49[^\n]", first_name, last_name, phone_number ) != 3 ) { fprintf( stderr, "WARNING: skipping line due to parse error!\n" ); continue; } //verify that none of the fields was too long if ( strlen( first_name ) == 49 || strlen( last_name ) == 49 || strlen( phone_number ) == 49 ) { //At least one buffer is full, and we have no way //to determine whether the limit was exceeded or whether //we are merely at the limit, so we must assume that //the limit was exceeded. fprintf( stderr, "WARNING: skipping line due to field length " "limit exceeded!\n" ); continue; } //parsing was successful, so we can now search the //3 individual fields for the search string if ( strcmp( search_string, first_name ) == 0 || strcmp( search_string, last_name ) == 0 || strcmp( search_string, phone_number ) == 0 ) { //print entire input line of file for user printf( "%s\n", line ); } } //cleanup fclose(filePtr); } ```
9,840,866
I have a table which is being dynamically populated, each row contains two textfields which can be edited. When the user click the save button, i want to read al those entered values and updated accordingly: ``` echo "<td><input value='".$row[0]."' type='hidden'>$sql1[0]</td><td>$sql1[1]</td> <td><input type='text' id='disc-".$row[0]."' value='".$row[3]."'></td> ``` The `$row[0]` is the ID of that row in the database and `$row[3]` is the value currently stored. What i am trying to achieve is that once the user clicks save, i read the value entered by the user in the textfield based on the ID so that it can be updated. For that have a javascript that selects those elements: ``` for(var i = 0; i < $('#order_basket [id |= "disc"]').length; i++) { alert($('#order_basket [id|="disc"]')??.val()); } ``` Now the length returned is correct but i am trying to read in the id and the value which will be further stored in an array. NOTE: there are more than 1 textfields in the same row, the other textfield has the `id='disc-".$row[0]."'`
2012/03/23
[ "https://Stackoverflow.com/questions/9840866", "https://Stackoverflow.com", "https://Stackoverflow.com/users/325533/" ]
Try this. ``` var values = {}; $('#order_basket input[id^="disc"]').each(function(){ values[this.id] = this.value; }); ``` Now `values` object will contain id/value pair of each of the input elements Note that I am using attribute starts with selector `^=` to find all the input elements Update based on OP's comment. ``` var ids = [], values = []; $('#order_basket input[id^="disc"]').each(function(){ ids.push(this.id); values.push(this.value); }); ```
You can also use class names: ``` <td><input type='text' class="field1" id='disc-".$row[0]."' value='".$row[3]."'></td> ``` You can then query this out using: ``` alert($('.field1').val()) ``` or: ``` alert($('.field1').attr('id') ``` You can check if there's more then one (because class names do not need to be unique) ``` alert($('.field1').length) ``` Then you can loop through the values using a for loop or .each()
67,947,966
I am trying to get all my repositories using the Github v4 API, but I can't find any query named `repositories`. I found a similar way to do so like this: ```js export const query = gql` query repositories() { search(query: "user:userName", type: REPOSITORY, first: 50) { repositoryCount edges { node { ... on Repository { name } } } } } ``` But this is not what I want because I would have to provide the username which I should get through another query (and I do not want to type it by myself) Is there a way to get all my repositories by only using one query? I think it should be easy enough, but I can't find the way.
2021/06/12
[ "https://Stackoverflow.com/questions/67947966", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11148124/" ]
I think pandas is imported only on the scope of function.
You imported pandas in a function which is sent to garbage when function is over. Try importing outside the function
2,143,255
I was wondering if anyone has came up with a way to float html elements, with some content, over .swf without triggering any flash events. In my case the problem is I have flash map, and drop down menu on top of it. I simplified this into the following example: <http://f1vlad.com/etc/d.html> If you mouseover any elements in gray box, you will see that stuff behind it, in a flash file, triggers hover effects.
2010/01/26
[ "https://Stackoverflow.com/questions/2143255", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1689906/" ]
Have you tried adjusting the z-index of the HTML elements with CSS. Try applying this to your HTML element: z-index: 1000; Update: I have placed HTML elements over an .swf and had the area of the flash that is covered by the HTML not respond to click events. Is this essentially the same symptoms you want to correct? try ``` display: block; ```
In Firefox 3.5, your page sort of works. When I mouseout of the floating box and on to Canada it will trigger the mouseover event for Canada. However, if I mouseover the floating box again the SWF doesn't receive the mouseout event so Canada stays highlighted. I assume you want to have Canada receive the mouseout event when this happens? I would use ExternalInterface to have the floating box call methods in the SWF when the mouse enters and leaves the floating box. That way you can simulate the mouseleave event to reset the country highlight and popups, then when the mouse leaves the floating box you can check to see if the mouse is over a country and perform the mouseover event normally.
2,372,297
In firefox 2 I was able to get the path using Browse - I use the path in our project to then write out files to that location. So now that browse does not get the path, does anyone know a way for a user to go to a directory and have the path returned via a web page so I could pass that along to the server for processing? * execCommand does not work in firefox and had limites save type capaility, and entering by hand is not a useable option. Thanks.
2010/03/03
[ "https://Stackoverflow.com/questions/2372297", "https://Stackoverflow.com", "https://Stackoverflow.com/users/285416/" ]
You can convert the dates to Unix timestamp. Randomly pick a timestamp between the two timestamps and convert it back to date.
Transform the dates into 3 ints: d1 = dd, m1 = mm, y1 = yyyy, same with d2, m2, y2 Then, assuming you know how to generate random numbers ( <http://www.cprogramming.com/tutorial/random.html> ), generate a random number between y1 and y2, which will act as the year. Then dd can be generated random between 1 and 28, and mm between 1 and 12. This will limit all of your days to max 28 though. You can generate the month randomly first, then use a table to find out how many days are in each month (if you think about it you don't even need a table, just a way to detect leap years to account for february having 29 days). To generate a random int between a and b, you can use: ``` int random = a + rand() % (b - a + 1); ``` You can extend this to work for dates where y1 = y2 and even m1 = m2 as well with just a few extra conditions
2,372,297
In firefox 2 I was able to get the path using Browse - I use the path in our project to then write out files to that location. So now that browse does not get the path, does anyone know a way for a user to go to a directory and have the path returned via a web page so I could pass that along to the server for processing? * execCommand does not work in firefox and had limites save type capaility, and entering by hand is not a useable option. Thanks.
2010/03/03
[ "https://Stackoverflow.com/questions/2372297", "https://Stackoverflow.com", "https://Stackoverflow.com/users/285416/" ]
You can convert the dates to Unix timestamp. Randomly pick a timestamp between the two timestamps and convert it back to date.
Convert the dates to fixed numbers such as a Julian value (call them J1 and J2). Generate a "random" number from 0 <= N <= J2-j1. Then convert J1+N from Julian back to a date.
2,372,297
In firefox 2 I was able to get the path using Browse - I use the path in our project to then write out files to that location. So now that browse does not get the path, does anyone know a way for a user to go to a directory and have the path returned via a web page so I could pass that along to the server for processing? * execCommand does not work in firefox and had limites save type capaility, and entering by hand is not a useable option. Thanks.
2010/03/03
[ "https://Stackoverflow.com/questions/2372297", "https://Stackoverflow.com", "https://Stackoverflow.com/users/285416/" ]
You can convert the dates to Unix timestamp. Randomly pick a timestamp between the two timestamps and convert it back to date.
Use the types and functions from the standard library time.h: <http://en.wikipedia.org/wiki/Time.h> Convert the string parts to ints, then convert these to time\_t. After calculating your random value in between, go the other way to get your result in a string.
2,372,297
In firefox 2 I was able to get the path using Browse - I use the path in our project to then write out files to that location. So now that browse does not get the path, does anyone know a way for a user to go to a directory and have the path returned via a web page so I could pass that along to the server for processing? * execCommand does not work in firefox and had limites save type capaility, and entering by hand is not a useable option. Thanks.
2010/03/03
[ "https://Stackoverflow.com/questions/2372297", "https://Stackoverflow.com", "https://Stackoverflow.com/users/285416/" ]
Convert the dates to fixed numbers such as a Julian value (call them J1 and J2). Generate a "random" number from 0 <= N <= J2-j1. Then convert J1+N from Julian back to a date.
Transform the dates into 3 ints: d1 = dd, m1 = mm, y1 = yyyy, same with d2, m2, y2 Then, assuming you know how to generate random numbers ( <http://www.cprogramming.com/tutorial/random.html> ), generate a random number between y1 and y2, which will act as the year. Then dd can be generated random between 1 and 28, and mm between 1 and 12. This will limit all of your days to max 28 though. You can generate the month randomly first, then use a table to find out how many days are in each month (if you think about it you don't even need a table, just a way to detect leap years to account for february having 29 days). To generate a random int between a and b, you can use: ``` int random = a + rand() % (b - a + 1); ``` You can extend this to work for dates where y1 = y2 and even m1 = m2 as well with just a few extra conditions
2,372,297
In firefox 2 I was able to get the path using Browse - I use the path in our project to then write out files to that location. So now that browse does not get the path, does anyone know a way for a user to go to a directory and have the path returned via a web page so I could pass that along to the server for processing? * execCommand does not work in firefox and had limites save type capaility, and entering by hand is not a useable option. Thanks.
2010/03/03
[ "https://Stackoverflow.com/questions/2372297", "https://Stackoverflow.com", "https://Stackoverflow.com/users/285416/" ]
Convert the dates to fixed numbers such as a Julian value (call them J1 and J2). Generate a "random" number from 0 <= N <= J2-j1. Then convert J1+N from Julian back to a date.
Use the types and functions from the standard library time.h: <http://en.wikipedia.org/wiki/Time.h> Convert the string parts to ints, then convert these to time\_t. After calculating your random value in between, go the other way to get your result in a string.
36,408,514
I need to make sure each observable is valid and also make sure all the observables are valid together. In my simplified example I have a modelNumber and stockNumber that are each required, but together they must also form a valid partNumber. My attempt gives me this error: "Uncaught Error: Cannot write a value to a ko.computed unless you specify a 'write' option. If you wish to read the current value, don't pass any parameters." What's the problem? <https://jsfiddle.net/yekr2ov2/18/> ``` // enable validation ko.validation.init(); ko.validation.rules['partNumberValid'] = { validator: function(partInfo, otherVal) { return partInfo.modelNumber() + partInfo.stockNumber() == "m1s1"; }, message: 'part number is invalid' }; ko.validation.registerExtenders(); function VM() { var self = this; self.modelNumber = ko.observable().extend({ required: true }); self.stockNumber = ko.observable().extend({ required: true }); self.vinNumber = ko.observable().extend({ required: true }); self.isPartNumberValid = ko.validatedObservable({ modelNumber: self.modelNumber, stockNumber: self.stockNumber, vinNumber: self.vinNumber }).extend({ partNumberValid: true }); self.message = ko.observable(); self.save = function() { if (self.isPartNumberValid.isValid()) { self.message("saved"); } else { debugger; //self.isPartNumberValid.errors.showAllMessages(); self.message("not saved"); } }; } ko.applyBindings(new VM()); ```
2016/04/04
[ "https://Stackoverflow.com/questions/36408514", "https://Stackoverflow.com", "https://Stackoverflow.com/users/251614/" ]
i have modified the code and the following code works fine. ``` ko.validation.init(); ko.validation.rules['partNumberValid'] = { validator: function (partInfo, otherVal) { return partInfo.modelNumber() +''+ partInfo.stockNumber() === "m1s1"; }, message: 'part number is invalid' }; ko.validation.registerExtenders(); function VM() { var self = this; self.modelNumber = ko.observable().extend({required: true}); self.stockNumber = ko.observable().extend({required: true}); self.isPartNumberValid = ko.observable({ modelNumber:self.modelNumber, stockNumber:self.stockNumber }).extend({partNumberValid:true}); self.validateMe = ko.computed(function(){ write:{ var tes = ko.validation.group([self.modelNumber,self.stockNumber,self.isPartNumberValid]); tes.showAllMessages(true); } }); } ko.applyBindings(new VM()); ``` Fiddle :<https://jsfiddle.net/yekr2ov2/7/> i used ko.validation.group to validate observables and computed to validate immediately. you can replace the computed with button click or any other custom function. Let me know if that helps. thank you
I think the answer is you can't extend validation on Knockout Validation's validatedObservable. I think the right answer here is to create an `observable` for each thing or group of things that needs validation and then create a `validatedObservable` to validate all of those `observables`. <https://jsfiddle.net/yekr2ov2/17/> ``` ko.validation.init(); ko.validation.rules['partNumberValid'] = { validator: function(partInfo, otherVal) { return partInfo.modelNumber() + partInfo.stockNumber() === "m1s1"; }, message: 'part number is invalid' }; ko.validation.registerExtenders(); function VM() { var self = this; self.modelNumber = ko.observable().extend({ required: true }); self.stockNumber = ko.observable().extend({ required: true }); self.vinNumber = ko.observable().extend({ required: true }); self.partNumber = ko.observable({ modelNumber: self.modelNumber, stockNumber: self.stockNumber }).extend({ partNumberValid: true }); self.isPartNumberValid = ko.validatedObservable({ modelNumber: self.modelNumber, stockNumber: self.stockNumber, vinNumber: self.vinNumber, partNumber: self.partNumber }); self.message = ko.observable(); self.save = function() { if (self.isPartNumberValid.isValid()) { self.message("saved"); } else { debugger; self.isPartNumberValid.errors.showAllMessages(); self.message("not saved"); } }; } ko.applyBindings(new VM()); ```
15,382,632
For practicing reasons I programmed a little Texas Holdem Game in PHP with some JQuery Animations. Every action (bet, fold, check, raise, call) is submitted via a HTML form to a PHP script. Now unfortunately the user is able to just go back to the first betting round after seeing the whole board and the computer's cards and adjusting his betting structure accordingly by using the back-ubtton of the browser. Is there a practical way for me to prevent this? Thanks, Coffeehouse PS: A buttonscript is for example this: ``` if (isset($_POST['call']) AND $_SESSION['bettingcap'] == 1){ $_SESSION['kapitalspieler'] -= $smallbet; // deduct money from player $_SESSION['pot'] += $smallbet; // add this to the pot $_SESSION['bettingcap'] = 0; // After call go to next street, so cap is 0 $_SESSION['buttonmodus']=1; // I want to show only certain buttons $_SESSION['whichstreet']=$_SESSION['whichstreet']+1; // go to next street $_SESSION['animateagain']='yes'; // show JQuery Animation } ```
2013/03/13
[ "https://Stackoverflow.com/questions/15382632", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2164882/" ]
You need to invalidate the request. That means one request follows after the other. You do this by storing all requests of that user in the game. If a new request is send, it can be only added at the end. You can create the game in memory by initializing it and the pass in all events from all sides until a specific one. This model does allow you to prevent cheating as well as re-playing a game like in a view mode of previous games. * 00 created game ID:#7575 * 01 player joined seat:1; ID:#12 * 02 player joined seat:2; ID:#56 * 03 player joined seat:3; ID:#87 * 04 deck shuffled order:the cards order here. * 05 ... So you keep these events and if a new request is send by a user you can check if it is okay with the current situation or not.
Perhaps something like this will work. ``` <SCRIPT type="text/javascript"> window.history.forward(); function noBack() { window.history.forward(); } </SCRIPT> </HEAD> <BODY onload="noBack();" onpageshow="if (event.persisted) noBack();" onunload=""> ``` From [link](http://viralpatel.net/blogs/disable-back-button-browser-javascript/)
48,857,840
I have three rows return from a table as below: ``` select ID from service ``` Results: ``` ID -- 1 2 3 ``` How can I return output like below: ``` count | IDs -------+---------- 3 | 1,2,3 ```
2018/02/18
[ "https://Stackoverflow.com/questions/48857840", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6728546/" ]
hope this helps ``` select (select Count(*) from service)+' | '+ SELECT STUFF ( ( SELECT ',' + s.FirstName FROM Employee s ORDER BY s.FirstName FOR XML PATH('') ), 1, 1, '' ) AS Employees) ```
If you are going to be work with `stuff()` function then you will no need to `subquery` for count of ids ``` select count(1) count, stuff( (select ','+cast(id as varchar) from table for xml path('')), 1,1,'') Ids from table ```
21,059,703
I want the name of the partition with their total space, used space and free space for the Linux system using java program. I am getting correct value in case of Windows system but in Linux I am getting only one drive information: Here is what I have tried so far. ``` public class DiskSpace { public static void main(String[] args) { FileSystemView fsv = FileSystemView.getFileSystemView(); File[] drives = File.listRoots(); if (drives != null && drives.length > 0) { for (File aDrive : drives) { System.out.println("Drive Letter: " + aDrive); System.out.println("\tType: " + fsv.getSystemTypeDescription(aDrive)); System.out.println("\tTotal space: " + aDrive.getTotalSpace()); System.out.println("\tFree space: " + aDrive.getFreeSpace()); System.out.println(); } } } ```
2014/01/11
[ "https://Stackoverflow.com/questions/21059703", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1460514/" ]
There are no drive letters on Linux. If you want to know which partitions there are, and where they are mounted, read `/proc/mounts`. When you have a mount point (2nd column in /proc/mounts), use `new File(mountpoint).getTotalSpace()` to get the total space.
Linux, Unix, and Unix-like systems have one filesystem with one root within which there may be multiple mount points at which partitions containing Unix filesystems, partial or complete, may be mounted -- non-Unix filesystems may also be mounted with the appropriate software available to handle the transformations necessary, but the unified, single-root filesystem model remains. If the `FileSystemView` class you are using is from the [`javax.swing.filechooser`](http://docs.oracle.com/javase/7/docs/api/javax/swing/filechooser/FileSystemView.html) package, don't expect too much: > > FileSystemView is JFileChooser's gateway to the file system. Since the JDK1.1 File API doesn't allow access to such information as root partitions, file type information, or hidden file bits, this class is designed to intuit as much OS-specific file system information as possible. > > > Java Licensees may want to provide a different implementation of FileSystemView to better handle a given operating system. > > > That second paragraph is key. Java's virtual machine implementation is meant to abstract away the very kind of platform specific things you want in this case. To be successful, you will need to write or find native call wrapper classes for the native system API of each platform you will support. "High-level" abstractions like the `FileSystemView` class are unlikely to be complete or reliable in providing the information you need.
21,059,703
I want the name of the partition with their total space, used space and free space for the Linux system using java program. I am getting correct value in case of Windows system but in Linux I am getting only one drive information: Here is what I have tried so far. ``` public class DiskSpace { public static void main(String[] args) { FileSystemView fsv = FileSystemView.getFileSystemView(); File[] drives = File.listRoots(); if (drives != null && drives.length > 0) { for (File aDrive : drives) { System.out.println("Drive Letter: " + aDrive); System.out.println("\tType: " + fsv.getSystemTypeDescription(aDrive)); System.out.println("\tTotal space: " + aDrive.getTotalSpace()); System.out.println("\tFree space: " + aDrive.getFreeSpace()); System.out.println(); } } } ```
2014/01/11
[ "https://Stackoverflow.com/questions/21059703", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1460514/" ]
There are no drive letters on Linux. If you want to know which partitions there are, and where they are mounted, read `/proc/mounts`. When you have a mount point (2nd column in /proc/mounts), use `new File(mountpoint).getTotalSpace()` to get the total space.
This is a code snippet to display name mounted external media only. ``` String OS = System.getProperty("os.name"); if(OS.equals("Linux")) { String s = ""; Runtime rt = Runtime.getRuntime(); int n=0; Process ps = rt.exec("ls /run/media/Rancho");// Write your UserName, mine is Rancho InputStream in = ps.getInputStream(); while((n = in.read())!=-1) { char ch = (char) n; s+ = ch; } System.out.println(s); } ```
245,645
If I remove a game on my PS4 to save space, will I always have that game, even if it is a PS+ title and can always install it again?
2015/11/28
[ "https://gaming.stackexchange.com/questions/245645", "https://gaming.stackexchange.com", "https://gaming.stackexchange.com/users/74125/" ]
You will get to keep your games. You'll notice that when you get the free PS+ titles, they're added to your account whether you download them or not. Uninstalling games will not remove them from your library, which can be viewed at the far right of the PS4 home screen. i.e. the library is tied to your PSN account, not the console's hard drive. Please note that should you cancel your PS+ subscription at any point, any of the free monthly games you have in your account will be *removed* from your account until you re-subscribe to PS+.
Normally, you can download any game you've downloaded before as often as you want to, free of any additional charge. However, there is one exception to that rule: If the game has ever been pulled out for any reason, you won't be able to download it again until it somehow returns to the PSN. Luckily, the list of games that have been removed entirely is very short (the latest example would be P.T., which is a demo), and you can still use the game until you decide to delete it. As for PS Plus games, they're treated like any other game. Just keep in mind that you won't be able to play those games without a valid PS Plus subscription. If it runs out, you only need to subscribe again in order to play.
245,645
If I remove a game on my PS4 to save space, will I always have that game, even if it is a PS+ title and can always install it again?
2015/11/28
[ "https://gaming.stackexchange.com/questions/245645", "https://gaming.stackexchange.com", "https://gaming.stackexchange.com/users/74125/" ]
You will get to keep your games. You'll notice that when you get the free PS+ titles, they're added to your account whether you download them or not. Uninstalling games will not remove them from your library, which can be viewed at the far right of the PS4 home screen. i.e. the library is tied to your PSN account, not the console's hard drive. Please note that should you cancel your PS+ subscription at any point, any of the free monthly games you have in your account will be *removed* from your account until you re-subscribe to PS+.
PlayStation Plus titles are granted a special ownership status. When you download a free PS+ title, without paying for it, you own it *as part of your PS+ status*. So, if you decide not to pay for PlayStation Plus anymore, then once it expires, you will not be allowed to play that game anymore. However, if you re-subscribe to PlayStation Plus, you will regain access. You don't even have to keep the game downloaded on your machine - redownloading it after resubscribing to PlayStation Plus works fine. Source: I did this after I got my Vita and wanted to try some old games that were cross-play.
245,645
If I remove a game on my PS4 to save space, will I always have that game, even if it is a PS+ title and can always install it again?
2015/11/28
[ "https://gaming.stackexchange.com/questions/245645", "https://gaming.stackexchange.com", "https://gaming.stackexchange.com/users/74125/" ]
Normally, you can download any game you've downloaded before as often as you want to, free of any additional charge. However, there is one exception to that rule: If the game has ever been pulled out for any reason, you won't be able to download it again until it somehow returns to the PSN. Luckily, the list of games that have been removed entirely is very short (the latest example would be P.T., which is a demo), and you can still use the game until you decide to delete it. As for PS Plus games, they're treated like any other game. Just keep in mind that you won't be able to play those games without a valid PS Plus subscription. If it runs out, you only need to subscribe again in order to play.
PlayStation Plus titles are granted a special ownership status. When you download a free PS+ title, without paying for it, you own it *as part of your PS+ status*. So, if you decide not to pay for PlayStation Plus anymore, then once it expires, you will not be allowed to play that game anymore. However, if you re-subscribe to PlayStation Plus, you will regain access. You don't even have to keep the game downloaded on your machine - redownloading it after resubscribing to PlayStation Plus works fine. Source: I did this after I got my Vita and wanted to try some old games that were cross-play.
46,780
I would like to know what are reasons of latency for a HTTP request to load HTML part of a webpage. I think about: * loading webpage with proxy * not having a good web server (apache vs nginx) * having a bad configuration of web server * having a bad internet connexion (bad ping) Any other ideas?
2013/04/01
[ "https://webmasters.stackexchange.com/questions/46780", "https://webmasters.stackexchange.com", "https://webmasters.stackexchange.com/users/20122/" ]
Here are some areas to consider in general, without going into detail: * **Physical configuration/server specs**: + RAM (the more the better) + CPU processor speed, and number of cores for multi-core applications + Drive speed and physical RAID to increase read/write speed (not software RAID used for mirrors and backups) ... * **OS and server configuration**: (This is specific to each web server, but some common ones follow): + Number of simultaneous connections + KeepAlive & KeepAliveTimeout (naming varies) + Caching + Memory allocation + Load balancing (reducing loads across multiple servers) ... * **Network bandwidth and connection speed**: + Run comparisons of sites with different web host companies/ISP's by analyzing ping and traceroutes from different locations (e.g., Pingdom Tools) + Consider the speed of the network connected to your server, and number of hops to your users + Consider if there's redundant Internet connections when bandwidth is exceeded ... * **DNS health and lookup speed**: (Often overlooked) + Run DNS checks to make sure your site can be reached (many are available online for free) + Test DNS response times ... * **Optimize content**: (Numerous techniques) + Compact HTML, CSS, JS, etc... + Compress all data sent to clients (e.g., using gzip) + Compress images and other media ... * **Firewall**: + Prevent scanning and attacks that require your server to work harder * **Block leaching from other sites and servers**: + Lock down application and script access to just your users and domains/hosts + Ban/blacklist abusive IP's ... * **Exploits & Viruses**: (Like desktop computers, servers are vulnerable to viruses and exploits that can slow it down) + Add a well-regarded virus scanner and schedule it during off-peak hours (so as not to slow it down during peak hours) + Keep an eye out for unknown processes in `top`, `Task Manager`, or similar + Watch for unknown files and scripts in directories that take up resources * **Exclude robots and links that shouldn't be indexed** + Use *robots.txt* directives + Add web server configuration rules and/or a security module ... * **Reduce bot & spider crawl frequency** + Use crawl-delay directives in sitemaps + Use search engine webmaster tools to set the crawl rate for your site (e.g., Google's Webmaster Tools "Configuration" settings) ... This is by no means an exhaustive list, but some key areas to think about regarding website speed and latency issues. Search for answers on this site for more details on each individual area.
Not having a good web server is pretty broad since you could have a good web server increasing latency for several reasons such as a peice of hardware that has defected such as a hard drive which is increasing seek time. Also outside influences could be a factor, such as routing issues on networks that you do not have control off, as well as server-side attacks such as a DOS would most certainly increase delays in response time. Finally bad configuration on the server could be increasing latency for one reason or more.
12,785,811
Heres the issue. I have an an ajax function that is just checking if an email that a user inputs is already used. The php script that it uses either sends back "true" or "false" strings depending on the result. When i get the response text back, or the "data" variable in the below function, and see if its == to "true" it never passes and always evaluates to false. > > This is odd, because when I have printed out the data variable on > screen it shows as "true" when it should, but its just not being shown > as equal to "true" in the if statement. No idea what is happening > here. > > > AJAX FUNCTION: ``` function check_email() { var email = document.sign_up_form.email_first.value; document.getElementById("email1").innerHTML = ' <img src="loading.gif" width="15">'; $.ajax({ type: "GET", url: "java_check_email.php", data: "email="+email, success: function(data){ if(data == "true"){ document.getElementById("email1").innerHTML = ' <img src="check.png" width="15">'; document.getElementById("email4").innerHTML = ''; } else { document.getElementById("email1").innerHTML = ' <img src="xmark.png" width="15">'; document.getElementById("email4").innerHTML = 'Email is already in use<br>'; } } }); ``` } UPDATE: PHP script looks like this ``` <?php include('functions.php'); $email = $_GET['email']; $query_check = "removed for obvious reasons..."; $result_check = mysql_query($query_check); if(mysql_num_rows($result_check) == 0){ echo 'true'; } else{ echo 'false'; } ?> ``` Also, after calling console.log(data) when the ajax response is received i got a value of "true" in the js console.....
2012/10/08
[ "https://Stackoverflow.com/questions/12785811", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1703519/" ]
For debugging, try ``` if (data.replace(/\s+/g, '') == "true") { ``` ...my money is on whitespace outside the `<?php ?>` tags. Note that if this solves the problem it should not considered the solution - the real solution is to remove the additional whitespace from the PHP script. The `<` of the opening `<?php` tag should be the very first character in the file. For example: ``` This empty line will be output directly <?php ^^^^ This whitespace will be output directly ``` Note also that the closing `?>` tag is often unnecessary (as it seems to be in this case) and omitting it completely can help avoid problems like this. If you want to return a boolean to JS you should simply echo `1` or `0`, so you can just do this in the receiving Javascript: ``` if (data) { ```
I know this is old but I've had the exact same problem and couldn't fix it. I am realy sure it wasn't a white-space issue but I was able to solve it in a different way. Maybe it's not the best way (I still want to know why it doesnt work in the usual way), but what I did was echo a 0 (for false) and a 1 (for true) Then I parsed the data to an Integer, so my code looks like this: ``` function(data){ var result = parseInt(data); if (result === 1){ $('#loginresult').html('OK'); } else { $('#loginresult').html('NOT OK'); } ``` I hope I can help anyone with this workaround (but a good solution would be better)
8,223,841
Say I have a collection of users and want to implement autocomplete on the usernames of those users. I looked at the mongodb docs and $regex seems to be one way to do this. Is there a better way? By better I mean more performant/better practice.
2011/11/22
[ "https://Stackoverflow.com/questions/8223841", "https://Stackoverflow.com", "https://Stackoverflow.com/users/235771/" ]
As suggested by @Thilo, you can use several ideas including prefixing. The most important thing is to have very quick request (because you want autocomplete to *feel* instaneous). So you have to use query which will use properly indexes. With regexp : use `/^prefix/` (the important thing is the ^ to specify the beginning of line which is mandatory to make the query use index). The range query is good too : `{ $gt : 'jhc', $lt: 'jhd' } }` More complicated but faster : you can store prefix-trees in mongo (aka tries) with entries like : ``` {usrPrefix : "anna", compl : ["annaconda", "annabelle", "annather"]} {usrPrefix : "ann", compl : ["anne", "annaconda", "annabelle", "annather"]} ``` This last solution is very fast (if indexes on compl of course) but not space efficient at all. You know the trade-off you have too choose.
If you are looking for prefixes, you could use a range query (not sure about the exact syntax): ``` db.users.find({'username': { $gt : 'jhc', $lt: 'jhd' } } ) ``` And you want an index on the username field.
8,223,841
Say I have a collection of users and want to implement autocomplete on the usernames of those users. I looked at the mongodb docs and $regex seems to be one way to do this. Is there a better way? By better I mean more performant/better practice.
2011/11/22
[ "https://Stackoverflow.com/questions/8223841", "https://Stackoverflow.com", "https://Stackoverflow.com/users/235771/" ]
We do it using regex and it's fast as long as you have an index and you use /^value/ Be aware you can't use the case insensitive option with an index, so you may want to store a lower case version of your string as another field in your document and use that for the autocomplete. I've done tests with 3 million+ documents and it still appears instantaneous.
If you are looking for prefixes, you could use a range query (not sure about the exact syntax): ``` db.users.find({'username': { $gt : 'jhc', $lt: 'jhd' } } ) ``` And you want an index on the username field.
8,223,841
Say I have a collection of users and want to implement autocomplete on the usernames of those users. I looked at the mongodb docs and $regex seems to be one way to do this. Is there a better way? By better I mean more performant/better practice.
2011/11/22
[ "https://Stackoverflow.com/questions/8223841", "https://Stackoverflow.com", "https://Stackoverflow.com/users/235771/" ]
As suggested by @Thilo, you can use several ideas including prefixing. The most important thing is to have very quick request (because you want autocomplete to *feel* instaneous). So you have to use query which will use properly indexes. With regexp : use `/^prefix/` (the important thing is the ^ to specify the beginning of line which is mandatory to make the query use index). The range query is good too : `{ $gt : 'jhc', $lt: 'jhd' } }` More complicated but faster : you can store prefix-trees in mongo (aka tries) with entries like : ``` {usrPrefix : "anna", compl : ["annaconda", "annabelle", "annather"]} {usrPrefix : "ann", compl : ["anne", "annaconda", "annabelle", "annather"]} ``` This last solution is very fast (if indexes on compl of course) but not space efficient at all. You know the trade-off you have too choose.
We do it using regex and it's fast as long as you have an index and you use /^value/ Be aware you can't use the case insensitive option with an index, so you may want to store a lower case version of your string as another field in your document and use that for the autocomplete. I've done tests with 3 million+ documents and it still appears instantaneous.
14,612,891
Struggling from this issue since 3 days. When i am tested the application in windows (WAMP), everything working fine. But when i am deployed the same in Linux, Billing continue button is not working. When i clicked on “Continue” after entering details, i am seeing in firebug <http://www.domain.com/checkout/onepage/saveBilling/> 200 OK And its staying in the same page ... Then when i checked in apache error\_log, i am seeting below error: [error] File does not exist: /home/docs/public\_html/checkout, referer: <http://www.domain.com/checkout/onepage/> I dont know why its going to /home/docs/public\_html/checkout ??? Am i in right way of debug? Could you please help me to resolve this issue .... Thanks & Regards ecomse
2013/01/30
[ "https://Stackoverflow.com/questions/14612891", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1223669/" ]
When clicking "continue" in the billing address step, the page sends an ajax post request to the`Mage_Checkout_OnepageController::saveBillingAction`. This function is supposed to save the form data into a quote and return a JSON object containing a property "goto\_section", i.e. "goto\_section":"shipping\_method". The success function of the ajax request picks this property up and shows the next step. I suggest you use the firebug debugger to check if `POST /checkout/onepage/saveBilling` returns a valid JSON object with a `goto_section` element. If not - there must be something wrong with the saveBilling function. Use Xdebug and set a breakpoint to the beginning of that function to check if everything is processed properly. Another possible problem source is a third party extension rewriting the checkout routing configuration. Are there any possible suspects in your shop? Try to deactivate them and test if that solves the problem. An example of a valid JSON string returned by the `saveBilling` action: ``` {"goto_section":"shipping_method","update_section":{"name":"shipping-method","html":" <dl class=\"sp-methods\">\r\n <dt>Flat Rate<\/dt>\r\n <dd>\r\n <ul>\r\n <li>\r\n <span class=\"no-display\"><input name=\"shipping_method\" type=\"radio\" value=\"flatrate_flatrate\" id=\"s_method_flatrate_flatrate\" checked=\"checked\" \/><\/span>\r\n <label for=\"s_method_flatrate_flatrate\">Fixed <span class=\"price\">$5.00<\/span> <\/label>\r\n <\/li>\r\n <\/ul>\r\n <\/dd>\r\n <\/dl>\r\n<script type=\"text\/javascript\">\r\n\/\/<![CDATA[\r\n var shippingCodePrice = {'flatrate_flatrate':5};\r\n \r\n $$('input[type=\"radio\"][name=\"shipping_method\"]').each(function(el){\r\n Event.observe(el, 'click', function(){\r\n if (el.checked == true) {\r\n var getShippingCode = el.getValue();\r\n var newPrice = shippingCodePrice[getShippingCode];\r\n if (!lastPrice) {\r\n lastPrice = newPrice;\r\n quoteBaseGrandTotal += newPrice;\r\n }\r\n if (newPrice != lastPrice) {\r\n quoteBaseGrandTotal += (newPrice-lastPrice);\r\n lastPrice = newPrice;\r\n }\r\n checkQuoteBaseGrandTotal = quoteBaseGrandTotal;\r\n return false;\r\n }\r\n });\r\n });\r\n\/\/]]>\r\n<\/script>\r\n"},"allow_sections":["shipping"],"duplicateBillingInfo":"true"} ```
I faced the same problem when I was working locally. There are other shipping methods enabled which were causing this issue. I have disabled DHL, USPS, FedEx and UPS. Now working fine for me. I hope this helps.
39,736,580
The output of both `pactl list sink-inputs` and `pacmd list-sink-inputs` contains a Properties section: ``` Properties: media.name = "ALSA Playback" application.name = "ALSA plug-in [snapclient]" native-protocol.peer = "UNIX socket client" native-protocol.version = "29" application.process.id = "6393" application.process.user = "root" application.process.host = "xxxxxx" application.process.binary = "snapclient" application.language = "C" application.process.machine_id = "8dadf95c2f504864bc0f8b3ab149cbe0" application.process.session_id = "c4" module-stream-restore.id = "sink-input-by-application-name:ALSA plug-in [snapclient]" ``` I am wondering if there is a way to directly look up the index of a sink-input by either the `application.process.id` or `application.process.binary`, without resorting to parsing the many lines of output of the aforementioned commands or writing a separate C program.
2016/09/28
[ "https://Stackoverflow.com/questions/39736580", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6890807/" ]
Some commands also accept the unique name instead of the id, but the ones you are trying to use seem to not be able to do so.. probably because the name is not unique and there could be mulitple matches. You need to parse it yourself. This is what I came up with: ```sh pacmd list-sink-inputs | tr '\n' '\r' | perl -pe 's/.*? *index: ([0-9]+).+?application\.name = "([^\r]+)"\r.+?(?=index:|$)/\2:\1\r/g' | tr '\r' '\n' ``` `perl -pe` is like `sed`, just better. This basically matches `[anything] [index]: [id] [anything] [application.name] = [name] [anything]` and formats the output to something like ```sh "speech-dispatcher":166 "SoX":407 "Clementine":413 ``` Which you then can grep or sed. Maybe you want to adjust `application\.name` to something more suitable to you.
Although it does parse the output and doesn't yet do any matching for the id you may be looking for, this method will provide a way, with some modifications, to get that information by sink id: ``` pactl list sink-inputs | while read -r line ; do #echo "Processing ${line}" echo $line | grep -oP 'Sink Input #\K[^$]' echo $line | grep -oP 'application.process.id = "\K[^"]+' echo $line | grep -oP 'application.process.binary = "\K[^"]+' done ```
39,736,580
The output of both `pactl list sink-inputs` and `pacmd list-sink-inputs` contains a Properties section: ``` Properties: media.name = "ALSA Playback" application.name = "ALSA plug-in [snapclient]" native-protocol.peer = "UNIX socket client" native-protocol.version = "29" application.process.id = "6393" application.process.user = "root" application.process.host = "xxxxxx" application.process.binary = "snapclient" application.language = "C" application.process.machine_id = "8dadf95c2f504864bc0f8b3ab149cbe0" application.process.session_id = "c4" module-stream-restore.id = "sink-input-by-application-name:ALSA plug-in [snapclient]" ``` I am wondering if there is a way to directly look up the index of a sink-input by either the `application.process.id` or `application.process.binary`, without resorting to parsing the many lines of output of the aforementioned commands or writing a separate C program.
2016/09/28
[ "https://Stackoverflow.com/questions/39736580", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6890807/" ]
Although it does parse the output and doesn't yet do any matching for the id you may be looking for, this method will provide a way, with some modifications, to get that information by sink id: ``` pactl list sink-inputs | while read -r line ; do #echo "Processing ${line}" echo $line | grep -oP 'Sink Input #\K[^$]' echo $line | grep -oP 'application.process.id = "\K[^"]+' echo $line | grep -oP 'application.process.binary = "\K[^"]+' done ```
Here's a short solution to OP's question: ``` $ cat pulse-get-sink-input-for-pid #!/bin/bash if [ $# -ne 1 ]; then >&2 echo Need PID; exit 1; fi export pid=$1 pactl list sink-inputs | perl -nle '/Sink Input #(\d+)/ and $si = $1; /application.process.id.*?(\d+)/ and ($1 == $ENV{pid}) and print "$si"' ```
39,736,580
The output of both `pactl list sink-inputs` and `pacmd list-sink-inputs` contains a Properties section: ``` Properties: media.name = "ALSA Playback" application.name = "ALSA plug-in [snapclient]" native-protocol.peer = "UNIX socket client" native-protocol.version = "29" application.process.id = "6393" application.process.user = "root" application.process.host = "xxxxxx" application.process.binary = "snapclient" application.language = "C" application.process.machine_id = "8dadf95c2f504864bc0f8b3ab149cbe0" application.process.session_id = "c4" module-stream-restore.id = "sink-input-by-application-name:ALSA plug-in [snapclient]" ``` I am wondering if there is a way to directly look up the index of a sink-input by either the `application.process.id` or `application.process.binary`, without resorting to parsing the many lines of output of the aforementioned commands or writing a separate C program.
2016/09/28
[ "https://Stackoverflow.com/questions/39736580", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6890807/" ]
Although it does parse the output and doesn't yet do any matching for the id you may be looking for, this method will provide a way, with some modifications, to get that information by sink id: ``` pactl list sink-inputs | while read -r line ; do #echo "Processing ${line}" echo $line | grep -oP 'Sink Input #\K[^$]' echo $line | grep -oP 'application.process.id = "\K[^"]+' echo $line | grep -oP 'application.process.binary = "\K[^"]+' done ```
The very long, easy to understand, maintainable way to do it (using **application.process.binary**) *Result* ``` ffmpeg | 3 firefox-esr | 24 firefox-esr | 58 vlc | 43 ``` *Bash script* ``` str="$(pacmd list-sink-inputs)" list1=$(printf '%s' "$str" | grep 'index: ') list2=$(printf '%s' "$str" | grep 'application.process.binary = "') arr1=() arr2=() while read line; do arr1+=("${line:7}") done <<< "$list1" while read line; do arr2+=("${line:30:-1}") done <<< "$list2" for index in ${!arr1[@]}; do s1="${arr1[index]}" s2="${arr2[index]}" echo "$s2 | $s1" done ``` *Another way to do it* (a bit more obscure) ``` str="$(pacmd list-sink-inputs)" arr1=($(printf '%s' "$str" | grep 'index: ' | rev | cut -d' ' -f 1 | rev)) arr2=($(printf '%s' "$str" | grep 'application.process.binary' | cut -d'"' -f 2)) for index in ${!arr1[@]}; do s1="${arr1[index]}" s2="${arr2[index]}" echo "$s2 | $s1" done ``` And finally, the shortest solution I found : ``` str="$(pacmd list-sink-inputs)" paste -d\| \ <(printf '%s' "$str" | grep 'application.process.binary' | cut -d'"' -f 2) \ <(printf '%s' "$str" | grep 'index: ' | rev | cut -d' ' -f 1 | rev) ```
39,736,580
The output of both `pactl list sink-inputs` and `pacmd list-sink-inputs` contains a Properties section: ``` Properties: media.name = "ALSA Playback" application.name = "ALSA plug-in [snapclient]" native-protocol.peer = "UNIX socket client" native-protocol.version = "29" application.process.id = "6393" application.process.user = "root" application.process.host = "xxxxxx" application.process.binary = "snapclient" application.language = "C" application.process.machine_id = "8dadf95c2f504864bc0f8b3ab149cbe0" application.process.session_id = "c4" module-stream-restore.id = "sink-input-by-application-name:ALSA plug-in [snapclient]" ``` I am wondering if there is a way to directly look up the index of a sink-input by either the `application.process.id` or `application.process.binary`, without resorting to parsing the many lines of output of the aforementioned commands or writing a separate C program.
2016/09/28
[ "https://Stackoverflow.com/questions/39736580", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6890807/" ]
Some commands also accept the unique name instead of the id, but the ones you are trying to use seem to not be able to do so.. probably because the name is not unique and there could be mulitple matches. You need to parse it yourself. This is what I came up with: ```sh pacmd list-sink-inputs | tr '\n' '\r' | perl -pe 's/.*? *index: ([0-9]+).+?application\.name = "([^\r]+)"\r.+?(?=index:|$)/\2:\1\r/g' | tr '\r' '\n' ``` `perl -pe` is like `sed`, just better. This basically matches `[anything] [index]: [id] [anything] [application.name] = [name] [anything]` and formats the output to something like ```sh "speech-dispatcher":166 "SoX":407 "Clementine":413 ``` Which you then can grep or sed. Maybe you want to adjust `application\.name` to something more suitable to you.
Here's a short solution to OP's question: ``` $ cat pulse-get-sink-input-for-pid #!/bin/bash if [ $# -ne 1 ]; then >&2 echo Need PID; exit 1; fi export pid=$1 pactl list sink-inputs | perl -nle '/Sink Input #(\d+)/ and $si = $1; /application.process.id.*?(\d+)/ and ($1 == $ENV{pid}) and print "$si"' ```
39,736,580
The output of both `pactl list sink-inputs` and `pacmd list-sink-inputs` contains a Properties section: ``` Properties: media.name = "ALSA Playback" application.name = "ALSA plug-in [snapclient]" native-protocol.peer = "UNIX socket client" native-protocol.version = "29" application.process.id = "6393" application.process.user = "root" application.process.host = "xxxxxx" application.process.binary = "snapclient" application.language = "C" application.process.machine_id = "8dadf95c2f504864bc0f8b3ab149cbe0" application.process.session_id = "c4" module-stream-restore.id = "sink-input-by-application-name:ALSA plug-in [snapclient]" ``` I am wondering if there is a way to directly look up the index of a sink-input by either the `application.process.id` or `application.process.binary`, without resorting to parsing the many lines of output of the aforementioned commands or writing a separate C program.
2016/09/28
[ "https://Stackoverflow.com/questions/39736580", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6890807/" ]
Some commands also accept the unique name instead of the id, but the ones you are trying to use seem to not be able to do so.. probably because the name is not unique and there could be mulitple matches. You need to parse it yourself. This is what I came up with: ```sh pacmd list-sink-inputs | tr '\n' '\r' | perl -pe 's/.*? *index: ([0-9]+).+?application\.name = "([^\r]+)"\r.+?(?=index:|$)/\2:\1\r/g' | tr '\r' '\n' ``` `perl -pe` is like `sed`, just better. This basically matches `[anything] [index]: [id] [anything] [application.name] = [name] [anything]` and formats the output to something like ```sh "speech-dispatcher":166 "SoX":407 "Clementine":413 ``` Which you then can grep or sed. Maybe you want to adjust `application\.name` to something more suitable to you.
The very long, easy to understand, maintainable way to do it (using **application.process.binary**) *Result* ``` ffmpeg | 3 firefox-esr | 24 firefox-esr | 58 vlc | 43 ``` *Bash script* ``` str="$(pacmd list-sink-inputs)" list1=$(printf '%s' "$str" | grep 'index: ') list2=$(printf '%s' "$str" | grep 'application.process.binary = "') arr1=() arr2=() while read line; do arr1+=("${line:7}") done <<< "$list1" while read line; do arr2+=("${line:30:-1}") done <<< "$list2" for index in ${!arr1[@]}; do s1="${arr1[index]}" s2="${arr2[index]}" echo "$s2 | $s1" done ``` *Another way to do it* (a bit more obscure) ``` str="$(pacmd list-sink-inputs)" arr1=($(printf '%s' "$str" | grep 'index: ' | rev | cut -d' ' -f 1 | rev)) arr2=($(printf '%s' "$str" | grep 'application.process.binary' | cut -d'"' -f 2)) for index in ${!arr1[@]}; do s1="${arr1[index]}" s2="${arr2[index]}" echo "$s2 | $s1" done ``` And finally, the shortest solution I found : ``` str="$(pacmd list-sink-inputs)" paste -d\| \ <(printf '%s' "$str" | grep 'application.process.binary' | cut -d'"' -f 2) \ <(printf '%s' "$str" | grep 'index: ' | rev | cut -d' ' -f 1 | rev) ```
26,341,618
I've got a `DateTimeField` and like to limit it by month/year, i.e. only one entry per month. At the moment i use two extra fields (`month` / `year`) combined with `unique_together = ("month", "year")`, but there is definitly a better solution. ``` class someModel(models.Model): datetime = models.DateTimeField(unique=True) ... class Meta: ordering = ['datetime'] ```
2014/10/13
[ "https://Stackoverflow.com/questions/26341618", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1167012/" ]
You can't really do it "natively" other than the way you're doing it now since when defining a model you're defining DB-level validation, and say MySQL wouldn't support a DATETIME field with a YEAR+MONTH unique constraint. What you can do, however, is add your own validator on the field, but this will require additional overhead on saving/updating the model's instances. I've had troubles with datetime/timestamp values myself before and usually the year+month unique constraint solution is by far the most efficient/transparent even if it results in additional storage (but that's the cheapest element, right?) But if you do decide to go with a single-field unique constraint, see <https://docs.djangoproject.com/en/dev/ref/validators/> - you'll need to add a validator to your field which checks if other objects with that year+month combination exist. Note that this will be very inefficient on a large system as MySQL doesn't support year/month indexes on a DATETIME field either - the value will be passed through a function in a full tablescan and filtered afterwards :(
[Field.unique\_for\_date](https://docs.djangoproject.com/en/dev/ref/models/fields/#django.db.models.Field.unique_for_date) will make instance unique by a certain *field value*. This will limit by month: ``` from django.core.exceptions import ValidationError class SomeModel(models.Model): # Set index to field datetime = models.DateTimeField(db_index=True) def save(self, *args, **kwargs): # If new instance created queryset = SomeModel.objects.filter( datetime__startswith=self.datetime.strftime('%Y-%m-')) # If instance changed if self.id is not None: queryset = queryset.exclude(id=self.id) if queryset.exists(): raise ValidationError('Choose another date') super(SomeModel, self).save(*args, **kwargs) ```
413,597
Even though I've been a developer for awhile I've been lucky enough to have avoided doing much work with XML. So now I've got a project where I've got to interact with some web services, and would like to use some kind of Object-to-XML Mapping solution. The only one I'm aware of is JAXB. Is that the best to go with? Are there any other recommendations? One catch - I'm stuck using Java 1.4, so I can't do anything with annotations.
2009/01/05
[ "https://Stackoverflow.com/questions/413597", "https://Stackoverflow.com", "https://Stackoverflow.com/users/543/" ]
If you're calling a web-service with a WSDL, JAXB is absolutely the best option. Take a look at wsimport, and you're be up and running in 10 minutes. I don't think JAXB 2.0 will be possible on Java 1.4. You may need to use Axis instead: ``` java -cp axis-1.4.jar;commons-logging-1.1.jar;commons-discovery-0.2.jar;jaxrpc-1.1.jar;saaj-1.1.jar;wsdl4j-1.4.jar;activation-1.1.jar;mail-1.4.jar org.apache.axis.wsdl.WSDL2Java http://someurl?WSDL ``` This will generate similar stubs to JAXB. If you don't have a WSDL or XSD, you can always [generate one](http://bitkickers.blogspot.com/2008/12/using-jaxb-without-schema.html).
There's [XStream](http://xstream.codehaus.org/). I seem to remember I used that ages ago, and it was fine. Can't say I have enough experience to recommend it for or against, but it's worth checking out just as an alternative.
413,597
Even though I've been a developer for awhile I've been lucky enough to have avoided doing much work with XML. So now I've got a project where I've got to interact with some web services, and would like to use some kind of Object-to-XML Mapping solution. The only one I'm aware of is JAXB. Is that the best to go with? Are there any other recommendations? One catch - I'm stuck using Java 1.4, so I can't do anything with annotations.
2009/01/05
[ "https://Stackoverflow.com/questions/413597", "https://Stackoverflow.com", "https://Stackoverflow.com/users/543/" ]
**JAXB is the best choice:** * [Public API included in Java SE 6](http://download.oracle.com/javase/6/docs/api/javax/xml/bind/package-summary.html) * Binding layer for JAX-WS (Web Services) * Binding layer for JAX-RS (Rest) * [Can preserve XML Infoset](http://bdoughan.blogspot.com/2010/09/jaxb-xml-infoset-preservation.html) * Multiple implementations: [Metro](http://jaxb.java.net/), [MOXy](http://www.eclipse.org/eclipselink/moxy.php), [JaxMe](http://ws.apache.org/jaxme/), etc **[EclipseLink JAXB (MOXy)](http://www.eclipse.org/eclipselink/moxy.php) is the best implementation:** MOXy is a JAXB implementation with Extensions MOXy has an external configuration file (based on JAXB annotations with extensions): * <http://bdoughan.blogspot.com/2010/12/extending-jaxb-representing-annotations.html> * <http://wiki.eclipse.org/EclipseLink/Examples/MOXy/EclipseLink-OXM.XML> Has XPath based mapping, for deep mapping: * <http://bdoughan.blogspot.com/2010/07/xpath-based-mapping.html> * <http://bdoughan.blogspot.com/2011/03/map-to-element-based-on-attribute-value.html> * <http://bdoughan.blogspot.com/2010/09/xpath-based-mapping-geocode-example.html> Designed to handle ORM mapped objects, including support for bidirectional relationships: * <http://wiki.eclipse.org/EclipseLink/Examples/MOXy/JPA> * <http://bdoughan.blogspot.com/2010/07/jpa-entities-to-xml-bidirectional.html>
There's [XStream](http://xstream.codehaus.org/). I seem to remember I used that ages ago, and it was fine. Can't say I have enough experience to recommend it for or against, but it's worth checking out just as an alternative.
413,597
Even though I've been a developer for awhile I've been lucky enough to have avoided doing much work with XML. So now I've got a project where I've got to interact with some web services, and would like to use some kind of Object-to-XML Mapping solution. The only one I'm aware of is JAXB. Is that the best to go with? Are there any other recommendations? One catch - I'm stuck using Java 1.4, so I can't do anything with annotations.
2009/01/05
[ "https://Stackoverflow.com/questions/413597", "https://Stackoverflow.com", "https://Stackoverflow.com/users/543/" ]
If you're calling a web-service with a WSDL, JAXB is absolutely the best option. Take a look at wsimport, and you're be up and running in 10 minutes. I don't think JAXB 2.0 will be possible on Java 1.4. You may need to use Axis instead: ``` java -cp axis-1.4.jar;commons-logging-1.1.jar;commons-discovery-0.2.jar;jaxrpc-1.1.jar;saaj-1.1.jar;wsdl4j-1.4.jar;activation-1.1.jar;mail-1.4.jar org.apache.axis.wsdl.WSDL2Java http://someurl?WSDL ``` This will generate similar stubs to JAXB. If you don't have a WSDL or XSD, you can always [generate one](http://bitkickers.blogspot.com/2008/12/using-jaxb-without-schema.html).
JIBX - known for performance JAXB2 - Ease of use Castor - Ease of use others - XMLBean, Xstream
413,597
Even though I've been a developer for awhile I've been lucky enough to have avoided doing much work with XML. So now I've got a project where I've got to interact with some web services, and would like to use some kind of Object-to-XML Mapping solution. The only one I'm aware of is JAXB. Is that the best to go with? Are there any other recommendations? One catch - I'm stuck using Java 1.4, so I can't do anything with annotations.
2009/01/05
[ "https://Stackoverflow.com/questions/413597", "https://Stackoverflow.com", "https://Stackoverflow.com/users/543/" ]
If you're calling a web-service with a WSDL, JAXB is absolutely the best option. Take a look at wsimport, and you're be up and running in 10 minutes. I don't think JAXB 2.0 will be possible on Java 1.4. You may need to use Axis instead: ``` java -cp axis-1.4.jar;commons-logging-1.1.jar;commons-discovery-0.2.jar;jaxrpc-1.1.jar;saaj-1.1.jar;wsdl4j-1.4.jar;activation-1.1.jar;mail-1.4.jar org.apache.axis.wsdl.WSDL2Java http://someurl?WSDL ``` This will generate similar stubs to JAXB. If you don't have a WSDL or XSD, you can always [generate one](http://bitkickers.blogspot.com/2008/12/using-jaxb-without-schema.html).
**JAXB is the best choice:** * [Public API included in Java SE 6](http://download.oracle.com/javase/6/docs/api/javax/xml/bind/package-summary.html) * Binding layer for JAX-WS (Web Services) * Binding layer for JAX-RS (Rest) * [Can preserve XML Infoset](http://bdoughan.blogspot.com/2010/09/jaxb-xml-infoset-preservation.html) * Multiple implementations: [Metro](http://jaxb.java.net/), [MOXy](http://www.eclipse.org/eclipselink/moxy.php), [JaxMe](http://ws.apache.org/jaxme/), etc **[EclipseLink JAXB (MOXy)](http://www.eclipse.org/eclipselink/moxy.php) is the best implementation:** MOXy is a JAXB implementation with Extensions MOXy has an external configuration file (based on JAXB annotations with extensions): * <http://bdoughan.blogspot.com/2010/12/extending-jaxb-representing-annotations.html> * <http://wiki.eclipse.org/EclipseLink/Examples/MOXy/EclipseLink-OXM.XML> Has XPath based mapping, for deep mapping: * <http://bdoughan.blogspot.com/2010/07/xpath-based-mapping.html> * <http://bdoughan.blogspot.com/2011/03/map-to-element-based-on-attribute-value.html> * <http://bdoughan.blogspot.com/2010/09/xpath-based-mapping-geocode-example.html> Designed to handle ORM mapped objects, including support for bidirectional relationships: * <http://wiki.eclipse.org/EclipseLink/Examples/MOXy/JPA> * <http://bdoughan.blogspot.com/2010/07/jpa-entities-to-xml-bidirectional.html>
413,597
Even though I've been a developer for awhile I've been lucky enough to have avoided doing much work with XML. So now I've got a project where I've got to interact with some web services, and would like to use some kind of Object-to-XML Mapping solution. The only one I'm aware of is JAXB. Is that the best to go with? Are there any other recommendations? One catch - I'm stuck using Java 1.4, so I can't do anything with annotations.
2009/01/05
[ "https://Stackoverflow.com/questions/413597", "https://Stackoverflow.com", "https://Stackoverflow.com/users/543/" ]
**JAXB is the best choice:** * [Public API included in Java SE 6](http://download.oracle.com/javase/6/docs/api/javax/xml/bind/package-summary.html) * Binding layer for JAX-WS (Web Services) * Binding layer for JAX-RS (Rest) * [Can preserve XML Infoset](http://bdoughan.blogspot.com/2010/09/jaxb-xml-infoset-preservation.html) * Multiple implementations: [Metro](http://jaxb.java.net/), [MOXy](http://www.eclipse.org/eclipselink/moxy.php), [JaxMe](http://ws.apache.org/jaxme/), etc **[EclipseLink JAXB (MOXy)](http://www.eclipse.org/eclipselink/moxy.php) is the best implementation:** MOXy is a JAXB implementation with Extensions MOXy has an external configuration file (based on JAXB annotations with extensions): * <http://bdoughan.blogspot.com/2010/12/extending-jaxb-representing-annotations.html> * <http://wiki.eclipse.org/EclipseLink/Examples/MOXy/EclipseLink-OXM.XML> Has XPath based mapping, for deep mapping: * <http://bdoughan.blogspot.com/2010/07/xpath-based-mapping.html> * <http://bdoughan.blogspot.com/2011/03/map-to-element-based-on-attribute-value.html> * <http://bdoughan.blogspot.com/2010/09/xpath-based-mapping-geocode-example.html> Designed to handle ORM mapped objects, including support for bidirectional relationships: * <http://wiki.eclipse.org/EclipseLink/Examples/MOXy/JPA> * <http://bdoughan.blogspot.com/2010/07/jpa-entities-to-xml-bidirectional.html>
JIBX - known for performance JAXB2 - Ease of use Castor - Ease of use others - XMLBean, Xstream
29,434,734
I am trying to delete 38 lines of text after coming across a certain phrase in a .txt file in Python, while still printing the rest of the text. The code I currently have is ``` with open('text_file.txt','r') as f: lines = f.readlines() for line in lines: if "certain_phrase" in line: for num in range(38): del line else: print(line,end='') ``` However, I keep getting the following error: ``` Traceback (most recent call last): File "C:\<location of file>\python_program.py", line 6, in <module> del line NameError: name 'line' is not defined ``` Does anyone have any suggestions or clues as to why it does not recognize "line" once I've put it inside the for loop below? Additionally, is there a better way to execute this kind of program?
2015/04/03
[ "https://Stackoverflow.com/questions/29434734", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4739392/" ]
You would need to remove from the list, you cannot `del` the line, the easiest way is to write to a temp file and copy after if you want to modify the file, if you just want to print ignoring the 38 line replace write with print: ``` with open('in.txt','r') as f,open('temp.txt','w') as temp: for line in f: if "phrase" in line: for i in range(38): next(f) # skip 38 lines else: temp.write(line) ``` Then use shutil to move the file: ``` import shutil shutil.move("temp.txt","in.txt") ``` You can also use a [NamedTemporaryFile](https://docs.python.org/2/library/tempfile.html#tempfile.NamedTemporaryFile): ``` from tempfile import NamedTemporaryFile with open('file.txt','r') as f, NamedTemporaryFile(dir=".",delete=False) as temp: for line in f: if "phrase" in line: for i in range(38): next(f) else: temp.write(line) import shutil shutil.move(temp.name,"file.txt") ``` The only potential problem I see is if the phrase is in one of the 38 ignored lines and you should also remove the next 38 lines from there. ``` To ignore until a second phrase, keep looping in the inner loop until you find the second phrase then break: with open('in.txt','r') as f, NamedTemporaryFile(dir=".", delete=False) as temp: for line in f: if "phrase" in line: for _line in f: if "phrase2" in _line: break else: temp.write(line) ```
`del line` actually deletes the variable `line`, meaning that when you try to do that a second time, it doesn't work, because `line` isn't defined anymore. You can loop over indices to find the line, break, then delete the next 38 lines: ``` with open('text_file.txt','r') as f: lines = f.readlines() for i in range(len(lines)): if "certain_phrase" in lines[i]: break else: print(line,end='') for num in range(38): del lines[i] ```
29,434,734
I am trying to delete 38 lines of text after coming across a certain phrase in a .txt file in Python, while still printing the rest of the text. The code I currently have is ``` with open('text_file.txt','r') as f: lines = f.readlines() for line in lines: if "certain_phrase" in line: for num in range(38): del line else: print(line,end='') ``` However, I keep getting the following error: ``` Traceback (most recent call last): File "C:\<location of file>\python_program.py", line 6, in <module> del line NameError: name 'line' is not defined ``` Does anyone have any suggestions or clues as to why it does not recognize "line" once I've put it inside the for loop below? Additionally, is there a better way to execute this kind of program?
2015/04/03
[ "https://Stackoverflow.com/questions/29434734", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4739392/" ]
Instead of trying to delete lines from a file, write a new file based on the old one. The following uses `__next__()` to skip over `line`s yielded by the generator. ``` with open('text_file.txt','r') as f, open('text_file_mod.txt', 'w') as w: for line in f: w.write(line) if "certain_phrase" in line: for num in range(38): # skip 38 lines next(f) ``` If you're doing this from the interactive interpreter, you can prevent it from spitting out returned values by saving the results of `next(f)` and `w.write(line)` to variables.
`del line` actually deletes the variable `line`, meaning that when you try to do that a second time, it doesn't work, because `line` isn't defined anymore. You can loop over indices to find the line, break, then delete the next 38 lines: ``` with open('text_file.txt','r') as f: lines = f.readlines() for i in range(len(lines)): if "certain_phrase" in lines[i]: break else: print(line,end='') for num in range(38): del lines[i] ```
29,434,734
I am trying to delete 38 lines of text after coming across a certain phrase in a .txt file in Python, while still printing the rest of the text. The code I currently have is ``` with open('text_file.txt','r') as f: lines = f.readlines() for line in lines: if "certain_phrase" in line: for num in range(38): del line else: print(line,end='') ``` However, I keep getting the following error: ``` Traceback (most recent call last): File "C:\<location of file>\python_program.py", line 6, in <module> del line NameError: name 'line' is not defined ``` Does anyone have any suggestions or clues as to why it does not recognize "line" once I've put it inside the for loop below? Additionally, is there a better way to execute this kind of program?
2015/04/03
[ "https://Stackoverflow.com/questions/29434734", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4739392/" ]
You would need to remove from the list, you cannot `del` the line, the easiest way is to write to a temp file and copy after if you want to modify the file, if you just want to print ignoring the 38 line replace write with print: ``` with open('in.txt','r') as f,open('temp.txt','w') as temp: for line in f: if "phrase" in line: for i in range(38): next(f) # skip 38 lines else: temp.write(line) ``` Then use shutil to move the file: ``` import shutil shutil.move("temp.txt","in.txt") ``` You can also use a [NamedTemporaryFile](https://docs.python.org/2/library/tempfile.html#tempfile.NamedTemporaryFile): ``` from tempfile import NamedTemporaryFile with open('file.txt','r') as f, NamedTemporaryFile(dir=".",delete=False) as temp: for line in f: if "phrase" in line: for i in range(38): next(f) else: temp.write(line) import shutil shutil.move(temp.name,"file.txt") ``` The only potential problem I see is if the phrase is in one of the 38 ignored lines and you should also remove the next 38 lines from there. ``` To ignore until a second phrase, keep looping in the inner loop until you find the second phrase then break: with open('in.txt','r') as f, NamedTemporaryFile(dir=".", delete=False) as temp: for line in f: if "phrase" in line: for _line in f: if "phrase2" in _line: break else: temp.write(line) ```
``` with open('temp.txt','r') as fin: for line in fin: print(line,end="") #you want to print the phrase, right? if "certain_phrase" in line: for _ in range(38): next(line) ```
29,434,734
I am trying to delete 38 lines of text after coming across a certain phrase in a .txt file in Python, while still printing the rest of the text. The code I currently have is ``` with open('text_file.txt','r') as f: lines = f.readlines() for line in lines: if "certain_phrase" in line: for num in range(38): del line else: print(line,end='') ``` However, I keep getting the following error: ``` Traceback (most recent call last): File "C:\<location of file>\python_program.py", line 6, in <module> del line NameError: name 'line' is not defined ``` Does anyone have any suggestions or clues as to why it does not recognize "line" once I've put it inside the for loop below? Additionally, is there a better way to execute this kind of program?
2015/04/03
[ "https://Stackoverflow.com/questions/29434734", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4739392/" ]
You would need to remove from the list, you cannot `del` the line, the easiest way is to write to a temp file and copy after if you want to modify the file, if you just want to print ignoring the 38 line replace write with print: ``` with open('in.txt','r') as f,open('temp.txt','w') as temp: for line in f: if "phrase" in line: for i in range(38): next(f) # skip 38 lines else: temp.write(line) ``` Then use shutil to move the file: ``` import shutil shutil.move("temp.txt","in.txt") ``` You can also use a [NamedTemporaryFile](https://docs.python.org/2/library/tempfile.html#tempfile.NamedTemporaryFile): ``` from tempfile import NamedTemporaryFile with open('file.txt','r') as f, NamedTemporaryFile(dir=".",delete=False) as temp: for line in f: if "phrase" in line: for i in range(38): next(f) else: temp.write(line) import shutil shutil.move(temp.name,"file.txt") ``` The only potential problem I see is if the phrase is in one of the 38 ignored lines and you should also remove the next 38 lines from there. ``` To ignore until a second phrase, keep looping in the inner loop until you find the second phrase then break: with open('in.txt','r') as f, NamedTemporaryFile(dir=".", delete=False) as temp: for line in f: if "phrase" in line: for _line in f: if "phrase2" in _line: break else: temp.write(line) ```
Instead of trying to delete lines from a file, write a new file based on the old one. The following uses `__next__()` to skip over `line`s yielded by the generator. ``` with open('text_file.txt','r') as f, open('text_file_mod.txt', 'w') as w: for line in f: w.write(line) if "certain_phrase" in line: for num in range(38): # skip 38 lines next(f) ``` If you're doing this from the interactive interpreter, you can prevent it from spitting out returned values by saving the results of `next(f)` and `w.write(line)` to variables.
29,434,734
I am trying to delete 38 lines of text after coming across a certain phrase in a .txt file in Python, while still printing the rest of the text. The code I currently have is ``` with open('text_file.txt','r') as f: lines = f.readlines() for line in lines: if "certain_phrase" in line: for num in range(38): del line else: print(line,end='') ``` However, I keep getting the following error: ``` Traceback (most recent call last): File "C:\<location of file>\python_program.py", line 6, in <module> del line NameError: name 'line' is not defined ``` Does anyone have any suggestions or clues as to why it does not recognize "line" once I've put it inside the for loop below? Additionally, is there a better way to execute this kind of program?
2015/04/03
[ "https://Stackoverflow.com/questions/29434734", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4739392/" ]
Instead of trying to delete lines from a file, write a new file based on the old one. The following uses `__next__()` to skip over `line`s yielded by the generator. ``` with open('text_file.txt','r') as f, open('text_file_mod.txt', 'w') as w: for line in f: w.write(line) if "certain_phrase" in line: for num in range(38): # skip 38 lines next(f) ``` If you're doing this from the interactive interpreter, you can prevent it from spitting out returned values by saving the results of `next(f)` and `w.write(line)` to variables.
``` with open('temp.txt','r') as fin: for line in fin: print(line,end="") #you want to print the phrase, right? if "certain_phrase" in line: for _ in range(38): next(line) ```
22,451,333
I have some test code asserting duplicate `User`s cannot be created through my `UserRepository`. User.cs: ``` public class User { public int Id { get; set; } public string AccountAlias { get; set; } public string DisplayName { get; set; } public string Email { get; set; } public bool IsActive { get; set; } } ``` UserRepository.cs: ``` public class UserRepository { public virtual async Task<User> CreateAsync(User entity) { if (entity == null) { throw new ArgumentNullException("entity"); } if (await GetDuplicateAsync(entity) != null) { throw new InvalidOperationException("This user already exists"); } return Create(entity); } public async Task<User> GetDuplicateAsync(User user) { if (user == null) { throw new ArgumentNullException("user"); } return await (from u in Users where u.AccountAlias == user.AccountAlias && u.Id != user.Id && u.IsActive select u).FirstOrDefaultAsync(); } } ``` UserRepositoryTests.cs: ``` public sealed class UserRepositoryTests : IDisposable { public UserRepositoryTests() { UserRepository = new UserRepository(new FooEntities()); // DbContext // from EF } private UserRepository UserRepository { get; set; } [Fact] public void DuplicateUserCannotBeCreated() { var testUser = new User // This test user already exists in database { Id = 0, AccountAlias = "domain\\foo", DisplayName = "Foo", Email = "foo@bar.com", IsActive = true }; Assert.Throws<InvalidOperationException>(async () => await UserRepository.CreateAsync(testUser)); } public void Dispose() { if (UserRepository != null) { UserRepository.Dispose(); } } } ``` When I run this unit test, `Xunit.Sdk.ThrowsException` is thrown (i.e. my `InvalidOperationException` was **not** thrown): > > Assert.Throws() Failure > Expected: System.InvalidOperationException > Actual: (No exception was thrown) > > > From the debugger, `GetDuplicateAsync()` was evaluated but when the LINQ query was executed, the result was never returned and thus no exception was thrown. Can anyone help?
2014/03/17
[ "https://Stackoverflow.com/questions/22451333", "https://Stackoverflow.com", "https://Stackoverflow.com/users/465056/" ]
xUnit's `Assert.Throws` (at least on version 1.9.2) is not async-aware. This was fixed in version 2, which now has an [`Assert.ThrowsAsync`](http://xunit.codeplex.com/SourceControl/latest#src/xunit.assert/Asserts/ExceptionAsserts.cs) method. So, you can either upgrade to xUnit 2 or create your own method to get it working: ``` public async static Task<T> ThrowsAsync<T>(Func<Task> testCode) where T : Exception { try { await testCode(); Assert.Throws<T>(() => { }); // Use xUnit's default behavior. } catch (T exception) { return exception; } return null; } await ThrowsAsync<InvalidOperationException>(async () => await UserRepository.CreateAsync(testUser)); ``` From [Haacked's gist](https://gist.github.com/Haacked/4616366).
This works for me: ``` Assert.Throws<AbpValidationException>(() => _personAppService.CreatePersonAsync(new CreatePersonInput { Name = null })); ``` Just don't use async/await.
22,451,333
I have some test code asserting duplicate `User`s cannot be created through my `UserRepository`. User.cs: ``` public class User { public int Id { get; set; } public string AccountAlias { get; set; } public string DisplayName { get; set; } public string Email { get; set; } public bool IsActive { get; set; } } ``` UserRepository.cs: ``` public class UserRepository { public virtual async Task<User> CreateAsync(User entity) { if (entity == null) { throw new ArgumentNullException("entity"); } if (await GetDuplicateAsync(entity) != null) { throw new InvalidOperationException("This user already exists"); } return Create(entity); } public async Task<User> GetDuplicateAsync(User user) { if (user == null) { throw new ArgumentNullException("user"); } return await (from u in Users where u.AccountAlias == user.AccountAlias && u.Id != user.Id && u.IsActive select u).FirstOrDefaultAsync(); } } ``` UserRepositoryTests.cs: ``` public sealed class UserRepositoryTests : IDisposable { public UserRepositoryTests() { UserRepository = new UserRepository(new FooEntities()); // DbContext // from EF } private UserRepository UserRepository { get; set; } [Fact] public void DuplicateUserCannotBeCreated() { var testUser = new User // This test user already exists in database { Id = 0, AccountAlias = "domain\\foo", DisplayName = "Foo", Email = "foo@bar.com", IsActive = true }; Assert.Throws<InvalidOperationException>(async () => await UserRepository.CreateAsync(testUser)); } public void Dispose() { if (UserRepository != null) { UserRepository.Dispose(); } } } ``` When I run this unit test, `Xunit.Sdk.ThrowsException` is thrown (i.e. my `InvalidOperationException` was **not** thrown): > > Assert.Throws() Failure > Expected: System.InvalidOperationException > Actual: (No exception was thrown) > > > From the debugger, `GetDuplicateAsync()` was evaluated but when the LINQ query was executed, the result was never returned and thus no exception was thrown. Can anyone help?
2014/03/17
[ "https://Stackoverflow.com/questions/22451333", "https://Stackoverflow.com", "https://Stackoverflow.com/users/465056/" ]
xUnit's `Assert.Throws` (at least on version 1.9.2) is not async-aware. This was fixed in version 2, which now has an [`Assert.ThrowsAsync`](http://xunit.codeplex.com/SourceControl/latest#src/xunit.assert/Asserts/ExceptionAsserts.cs) method. So, you can either upgrade to xUnit 2 or create your own method to get it working: ``` public async static Task<T> ThrowsAsync<T>(Func<Task> testCode) where T : Exception { try { await testCode(); Assert.Throws<T>(() => { }); // Use xUnit's default behavior. } catch (T exception) { return exception; } return null; } await ThrowsAsync<InvalidOperationException>(async () => await UserRepository.CreateAsync(testUser)); ``` From [Haacked's gist](https://gist.github.com/Haacked/4616366).
XUnit now handle Assert.ThrowAsync by default
22,451,333
I have some test code asserting duplicate `User`s cannot be created through my `UserRepository`. User.cs: ``` public class User { public int Id { get; set; } public string AccountAlias { get; set; } public string DisplayName { get; set; } public string Email { get; set; } public bool IsActive { get; set; } } ``` UserRepository.cs: ``` public class UserRepository { public virtual async Task<User> CreateAsync(User entity) { if (entity == null) { throw new ArgumentNullException("entity"); } if (await GetDuplicateAsync(entity) != null) { throw new InvalidOperationException("This user already exists"); } return Create(entity); } public async Task<User> GetDuplicateAsync(User user) { if (user == null) { throw new ArgumentNullException("user"); } return await (from u in Users where u.AccountAlias == user.AccountAlias && u.Id != user.Id && u.IsActive select u).FirstOrDefaultAsync(); } } ``` UserRepositoryTests.cs: ``` public sealed class UserRepositoryTests : IDisposable { public UserRepositoryTests() { UserRepository = new UserRepository(new FooEntities()); // DbContext // from EF } private UserRepository UserRepository { get; set; } [Fact] public void DuplicateUserCannotBeCreated() { var testUser = new User // This test user already exists in database { Id = 0, AccountAlias = "domain\\foo", DisplayName = "Foo", Email = "foo@bar.com", IsActive = true }; Assert.Throws<InvalidOperationException>(async () => await UserRepository.CreateAsync(testUser)); } public void Dispose() { if (UserRepository != null) { UserRepository.Dispose(); } } } ``` When I run this unit test, `Xunit.Sdk.ThrowsException` is thrown (i.e. my `InvalidOperationException` was **not** thrown): > > Assert.Throws() Failure > Expected: System.InvalidOperationException > Actual: (No exception was thrown) > > > From the debugger, `GetDuplicateAsync()` was evaluated but when the LINQ query was executed, the result was never returned and thus no exception was thrown. Can anyone help?
2014/03/17
[ "https://Stackoverflow.com/questions/22451333", "https://Stackoverflow.com", "https://Stackoverflow.com/users/465056/" ]
XUnit now handle Assert.ThrowAsync by default
This works for me: ``` Assert.Throws<AbpValidationException>(() => _personAppService.CreatePersonAsync(new CreatePersonInput { Name = null })); ``` Just don't use async/await.
35,146
I am most familiar with 4e D&D, but might be playing in a 3.5 game starting in a couple months and I need to nail down a character. I have been drawn to the idea of a swarm druid in 4e rules and wondered if there is anything like that in 3.5? Top uses I like about the swarm are not locked into attacks, but more just the over all feel of the character being kinda sneaky and creepy. I like the though of being able to send one or two insects from my swarm out to do reconnaissance (I think that's possible in the rules). Other than that I like the thought of the insect swarm engulfing my opponents and "eating them alive" and I am also inclined to utilize the controller aspects of the class. The character I have created as a possibility is a loner from the jungles who always seems like his mind is always preoccupied by a hundred different thoughts, he is very fidgety and if you catch a glance of him out of the corner of your eyes he might look like he has bugs crawling around under his skin. So if there is anything like that in 3.5 for druids, or any other class I would really like to know. Other info that might be helpful is I plan on playing an elf or half elf, probably neutral aligned(tho willing to explore other alignments), and probably starting at level 1. (Just guessing about the level as the GM is going to be new to GMing)
2014/03/19
[ "https://rpg.stackexchange.com/questions/35146", "https://rpg.stackexchange.com", "https://rpg.stackexchange.com/users/10263/" ]
Homebrew ======== This is not official material; I’m making it up. For what it’s worth, I’m fairly good at it (won several 3.5 homebrew competitions; did freelance work for Legend and Pathfinder, each a 3.5-spinoff; wrote a [“book” about it](https://rpg.stackexchange.com/a/18269/4563) as a question answer), but don’t mistake this for official material. You’ll have to ask your DM about it. I would love to hear feedback on it, whether or not you use it. If you do, I’d really love to know how it plays. Ultimately, this variant of the druid has one major advantage and one major disadvantage, with respect to the regular druid. The advantage is that the swarms the swarm druid calls are inherently expendable; you can call up a new quite quickly relative to training a new animal companion. This means you can scout dangerous areas more easily. The disadvantage is in the swarms themselves: you have far fewer options for calling a swarm or adopting a swarm shape than a druid does for bonding an animal companion or assuming a wild shape. Swarm Druid variant =================== The swarm druid is a [variant class](http://www.d20srd.org/srd/variant/classes/variantCharacterClasses.htm) option for the [druid](http://www.d20srd.org/srd/classes/druid.htm); except as noted here, the class is identical to the druid in every way. You cannot multiclass between swarm druid and regular druid, or any other druid variant, but you may take advantage of [alternative class features](http://www.d20srd.org/srd/variant/classes/classFeatureVariants.htm) that replace those class features that the swarm druid does have. | Level | BAB | Fort | Ref | Will | Special | | --- | --- | --- | --- | --- | --- | | 1st | +0 | +2 | +0 | +2 | Call swarm, eusociality, swarm trainer | | 2nd | +1 | +3 | +0 | +3 | Hivemind | | 3rd | +2 | +3 | +1 | +3 | Resist the swarm | | 5th | +3 | +4 | +1 | +4 | Swarm shape (1/day) | | 8th | +6/+1 | +6 | +2 | +6 | Call swarm (across planes) | | 11th | +8/+3 | +7 | +3 | +7 | Swarm shape (two swarms) | | 12th | +9/+4 | +8 | +4 | +8 | Swarm shape (fey, plant, ooze swarms) | | 15th | +11/+6/+1 | +9 | +5 | +9 | Swarm shape (three swarms), timeless body | | 16th | +11/+6/+1 | +9 | +5 | +9 | Swarm shape (elemental swarms 1/day) | | 18th | +13/+8/+3 | +11 | +6 | +11 | Swarm shape (6/day, elemental swarms 2/day) | | 20th | +15/+10/+5 | +12 | +6 | +12 | Swarm shape (any type swarms, 3/day) | Spells ------ As a regular druid, except with the addition of the following spells: 1. *Buzzing bee,SC cause fear, deathwatch, ebon eyes,SC nerveskitter,SC spirit wormSC* 2. *Darkness, death knell, scare, web* 3. *Chain of eyes,SC deeper darkness, gaseous form, spider poison,SC stinking cloud, tremorsenseSC* 4. *Fear* 5. *Cloudkill, crawling darkness,SC plague of rats,SC prying eyes* 6. *Fire spiders,SC spider plagueSC* 7. *Brain spiderSC* 8. *Greater prying eyes* 9. *Otyugh swarmSC* Spells marked *SC* are from *Spell Compendium*. Bonus Languages --------------- As a swarm druid, you still learn druidic as a free language and are still barred from teaching it to non-druids. However, instead of adding Sylvan as a bonus language, you add Undercommon, the language of dark places, and perhaps more importantly, the drow. Even if you are not a drow, the drow’s long history of working with vermin and swarms means it is important for many swarm druids to be able to interact with them. If you do learn Undercommon (whether as a bonus language or not), you count as a drow for the sake of meeting the prerequisites of feats or prestige classes that have to do with vermin or swarms, and drow treat you as they would other drow (which is not that well, but as far as it goes). Call Swarm (Ex) --------------- You may call together a swarm almost anywhere; even desolate deserts usually have spiders and scorpions hidden under the sands. The swarm’s members are called from the immediate surroundings. In the rare cases where there are not sufficient options in the immediate area, you may draw them from great distances, though this makes the call take longer. Calling the swarm is a full-round action. Provided the environment you are in would be able to provide sufficient creatures for the swarm in a square mile centered on you, the swarm is fully gathered by the end of your calling, as eligible creatures tend to be drawn to you before you even call. If this area would not have sufficient creatures, consider an area with a 1½ mile radius; if this would be sufficient, the swarm has gathered by the start of your next turn. For every additional mile in the radius before enough creatures may be found, it takes another round for the swarm to form, always becoming available at the start of your turn. You do not need to continue calling while the swarm is forming. The called swarm remains together and with you for as long as you wish it to. You do not need to concentrate on its continued existence. It disperses either when you tell it to or when the swarm creature dies. You may order a swarm to disperse but follow you, out of sight, so that you may call it again without worrying about whether there are enough creatures in the area. The DM may determine that there are some places the swarm cannot go or barriers it cannot cross, or at least cannot go without coming out of the woodwork and reforming as a swarm. If this happens, you are aware of it. If you leave a swarm or tell it to go away, the individual creatures will gradually return from where they came. You cannot tell a group of swarm-capable creatures to remain in an area as you leave, unless you leave it as a cohesive swarm. You may only have one swarm at a time. A swarm you have disbanded but continue to have with you counts as this swarm. Calling a new swarm causes the previous one to gradually disperse and return from where it came. See **Swarm Druid’s Called Swarm**, below, for more details on the swarm itself. Beginning at 8th level, you may call swarms from any distance, even from other planes. This is a supernatural action that takes 1 round to complete; at the end of the action, your called swarm is ready, no matter where you are. This is a Conjuration (Calling) effect. This feature replaces the druid’s regular animal companion class feature. Any feature that augments or improves your animal companion may improve your called swarm. Any other class that grants an animal companion that stacks with druid levels may instead stack with your swarm druid levels for your called swarm. If you choose to forgo this option and gain an animal companion instead, swarm druid levels do not count towards it, and you cannot change this choice for that class once made. Eusociality (Ex) ---------------- You can improve the attitude of any swarm. This functions just like a Diplomacy check made to improve the attitude of a person. You roll 1d20 and add your class level and your Charisma modifier to determine the check result. A swarm of creatures used to life within humanoid civilization (“indoor” species of ants, cockroaches, spiders, and so on) usually have a starting attitude of indifferent, while species in the wilderness usually start as unfriendly. To make this check, you and the swarm must be able to study each other, which for many swarms requires sharing the swarm’s space. In such cases, you roll your check upon entering the swarm (or the swarm covering you), and if it is successful, the swarm will not attack you. You may also make this check to improve the attitude of vermin without the swarm subtype, but do so at a −4 penalty. Additionally, you are immune to the Distraction special attack of any creature with the swarm subtype. This is true even of swarms that you do not improve the attitude of. This class feature replaces wild empathy. Any feature that augments or improves wild empathy may improve eusociality. Any other class that grants wild empathy that stacks with druid levels may instead stack with your swarm druid levels for eusociality. If you choose to forgo this option and gain wild empathy instead, swarm druid levels do not count towards it, and you cannot change this choice for that class once made. This class feature counts as the Verminfriend feat (*Drow of the Underdark*) for the purposes of prerequisites. You may still take that feat if you meet its requirements. Swarm Trainer (Ex) ------------------ You may train mindless swarms, as well as swarms with Intelligence scores of 1 or 2, by using the Handle Animal skill, even if the swarm is not composed of animals. More intelligent swarms must be interacted with using the usual social skills, or eusociality, not Handle Animal. Mindless swarms are considered to have Intelligence 1 for the purposes of training them and their ability, once trained, to execute tricks and other commands. They are still considered mindless for all other purposes, including affecting them with mind-affecting magic. This class feature replaces nature sense. It also counts as the Vermin Trainer feat (*Drow of the Underdark*) for prerequisites. You may still take Vermin Trainer as a feat if you meet its requirements. Hivemind (Su) ------------- Beginning at 2nd level, any swarm you share a space with reports information back to you. Generally speaking, the information is what the swarm collectively sees, smells, hears, and feels. This is not the same as actually experiencing those sensations yourself (but see the **Sensory Feedback** feature that swarms called by high-level swarm druids get), but it is sufficient to pin-point creatures you cannot sense yourself that share a space with the same swarm you do. Resist the Swarm (Ex) --------------------- At 4th level, you gain a +4 bonus on all saving throws made against the special attacks and special qualities of swarms. This feature replaces the resist nature’s lore class feature that a regular druid receives. Swarm Shape (Su) ---------------- At 5th level, you gain the ability to turn yourself into a swarm once per day. This feature otherwise functions exactly as does a regular druid’s wild shape, which it replaces, except that instead of turning into an animal, you turn into an animal or vermin with the swarm subtype. Swarm shape may be used in place of wild shape for prerequisites, and daily uses of swarm shape count as daily uses of wild shape and may be expended in much the same way for wild feats and the like. Feats and features that modify wild shape may modify swarm shape. Class levels that stack with druid levels for wild shape instead stack with swarm druid levels for swarm shape. If a class grants wild shape to those that don’t have it, you may either gain wild shape and the levels don’t stack, or else choose to stack those levels with swarm druid levels for swarm shape. This choice, once made, cannot be changed for that class. Like the regular druid, you more daily uses of this ability at 6th, 7th, 10th, 14th, and 18th level, as noted in [Table: The Druid](http://www.d20srd.org/srd/classes/druid.htm#tableTheDruid). At 8th, 11th, and 15th level, you gain the ability to shape yourself into two, three, and four swarms at the same time. All swarms must be adjacent to each other and either include or be adjacent to the space you occupied before assuming the shape. When you shape into multiple swarms, divide your HP evenly among them; when you return to your own shape, add the remaining HP totals to determine your remaining HP. You die only if all swarms you are shaped in die. This replaces the druid’s ability to turn into larger and smaller creatures. At 12th level, you add the fey, plant, and ooze types to the list of creature types you can turn into with swarm shape. The chosen creature must still have the swarm subtype and meet all criteria for wild shape aside from type and subtype. This replaces the druid’s ability to wild shape into plant forms. At 16th level, you can use swarm shape to turn into swarms with the elemental type, once per day. This daily elemental swarm shape is in addition to your normal swarm shape usage. In addition to the normal effects of wild shape, you gain all the elemental swarm’s extraordinary, supernatural, and spell-like abilities. You also gain the elemental swarm’s feats for as long as you maintain the wild shape, but you retain your own creature type. This replaces the druid’s ability to wild shape into elemental forms. At 18th and 20th levels, you can assume the form of an elemental swarm another time each day. At 20th level, you can turn into a swarm of any type by using a use of the elemental swarm shape feature, gaining all special attacks and qualities as you would with elemental swarms. This replaces the druid’s ability to wild shape into huge elementals. Swarm Druid’s Called Swarm ========================== The swarm that you may call as a swarm druid is different from a normal swarm in many ways, as described below. Training your called swarm -------------------------- You may train the swarm you call using Handle Animal, as if it were an animal with Intelligence 2. As you gain more swarm druid levels, the swarm may also learn bonus tricks; see below. Each time you call a swarm, it comes trained in the same tricks as the previous swarm, though each trick must be taught in its entirety to a single swarm. Thus your called swarm can be trained, even though the swarm itself is composed of entirely different creatures each time you call it. Called swarm bonuses -------------------- Use the base statistics for a creature of the called swarm’s kind, but make the following changes. | Class Level | Bonus HD | DC Adj. | Space | Bonus Tricks | Special | | --- | --- | --- | --- | --- | --- | | 1st – 2nd | +0 | +1 | +0 | +1 | Link, share spells | | 3rd – 5th | +2 | +2 | +0 | +2 | Evasion | | 6th – 8th | +4 | +3 | +5 | +3 | | | 9th – 11th | +6 | +4 | +5 | +4 | Sensory feedback | | 12th – 14th | +8 | +5 | +10 | +5 | | | 15th – 17th | +10 | +6 | +10 | +6 | Improved Evasion | | 18th – 20th | +12 | +7 | +15 | +7 | | ### Class Level Your swarm druid level. Your class level stacks with levels of any other classes that are entitled to an animal companion or to call a swarm for the purpose of determining the companion’s abilities and the alternative lists available to the character. ### Bonus HD Extra racial hit dice as appropriate to the swarm’s type. For most swarms, this means Animal or Vermin hit dice, which are both d8s that get +¾ BAB and 2+Int skill points per level. Animals get good Fortitude and Reflex saves, while Vermin only get good Fortitude saves. ### DC Adj. The number noted here is added to the saving throw DC of any special attacks or qualities, poisons, and so on that the called swarm has. ### Space The swarm’s space increases by the number noted here. As usual with swarms, this space is far more malleable than a typical creature’s. ### Bonus Tricks The value given in this column is the total number of “bonus” tricks that the swarm knows in addition to any that you might choose to teach it (see the **Training the swarm**, above). These bonus tricks don’t require any training time or Handle Animal checks, and they don’t count against the normal limit of tricks known by the swarm. The druid selects these bonus tricks each time he calls a swarm, but they cannot be changed for that swarm thereafter. ### Link (Ex) You can handle your called swarm as a free action, or push it as a move action, even if you don’t have any ranks in the Handle Animal skill. You gain a +4 circumstance bonus on all eusociality checks and Handle Animal checks made regarding a called swarm. ### Share Spells (Ex) At your option, you may have any spell (but not any spell-like ability) you cast upon yourself also affect your called swarm. You must be within the swarm’s space at the time of casting to receive the benefit. Additionally, you may cast a spell with a target of “You” on your called swarm (as long as the swarm is covering you) instead of on yourself. You and your called swarm can share spells even if the spells normally do not affect creatures of the swarm’s type. ### Evasion (Ex) If a called swarm is subjected to an attack that normally allows a Reflex saving throw for half damage, it takes no damage if it makes a successful saving throw. ### Sensory Feedback (Su) You are automatically aware of anything your called swarm can sense, at a distance of up to a mile. All checks made to use these senses, however, are made at the swarm’s bonus, not your own, which may make it difficult to understand what it is that the swarm is seeing or hearing. Touch, however, is often far more effective. When your called swarm is sharing a space with a creature or object, you know exactly where that creature is, how it is moving, its texture, and so on, even if the creature is invisible and silent. Incorporeal or ethereal creatures, however, are typically not felt. ### Improved Evasion (Ex) When subjected to an attack that normally allows a Reflex saving throw for half damage, a called swarm takes no damage if it makes a successful saving throw and only half damage if the saving throw fails. Called Swarm Options -------------------- You cannot necessarily call together just any swarm, even if the creatures to make up the swarm are available. ### Basic options As a 1st-level swarm druid, you may call the following swarms together: * [Bat swarm](http://www.d20srd.org/srd/monsters/swarm.htm#batSwarm) * Demonet swarm (*Monster Manual IV*) * Leech swarm1 (*Stormwrack*) * [Rat swarm](http://www.d20srd.org/srd/monsters/swarm.htm#ratSwarm) * [Spider swarm](http://www.d20srd.org/srd/monsters/swarm.htm#ratSwarm) * Wasp swarm (*Fiend Folio*) * Minor swarm2 ### Alternative Swarms If you are a swarm druid of sufficiently high level, you may call swarms from one of the following lists, applying the indicated adjustment to your swarm druid level (in parentheses) for purposes of determining the swarm’s characteristics and abilities. **4th level or Higher (Level −3)** * Cranium rat swarm, lesser pack (*Fiend Folio*) * [Locust swarm](http://www.d20srd.org/srd/monsters/swarm.htm#locustSwarm) * Tomb spider broodswarm (*Monster Manual IV*) * Viper swarm (*Fiend Folio*) **7th level or Higher (Level −6)** * [Centipede swarm](http://www.d20srd.org/srd/monsters/swarm.htm#centipedeSwarm) * Bone rat swarm (*Libris Mortis*) * Piranha swarm1 (*Stormwrack*) * Rylkspawn swarm (*Monster Manual V*) **10th level or Higher (Level −9)** * Broodswarm (*Fiendish Codex I*) * Corpse rat swarm (*Libris Mortis*) * Ephemeral swarm (*Monster Manual III*) * Jellyfish swarm1 (*Stormwrack*) * Pest swarm (*Cityscape*) * Plague ant swarm (*Fiend Folio*) * Rapture locust swarm (*Fiend Folio*) * Scorpion swarm (*Sandstorm*) * Swamp strider swarm (*Monster Manual III*) **13th level or Higher (Level −12)** * Cranium rat swarm, average pack (*Fiend Folio*) * Death scarab swarm (*Sandstorm*) * Dread bloom swarm (*Monster Manual III*) * Bloodmote cloud swarm (*Libris Mortis*) * Mageripper swarm (*Monster Manual IV*) * Needletooth swarm (*Monster Manual III*) **16th level or Higher (Level −15)** * Bloodfiend locust swarm (*Fiend Folio*) * Cinder swarm (*Monster Manual II*) * [Hellwasp swarm](http://www.d20srd.org/srd/monsters/swarm.htm#hellwaspSwarm) * Shimmering swarm (*Monster Manual III*) * Brood keeper larva swarm (*Monster Manual III*) 1 Can only be called into an aquatic environment. 2 New monster presented below Minor Swarm =========== * **Size/Type:** Dimuntive Vermin (swarm) * **Hit Dice:** 2d8 (9 hp) * **Speed:** 25 ft. (see text) * **Attack:** Swarm (1d4) * **Space/Reach:** 10 ft./0 ft. * **Special Attacks:** Distraction * **Special Qualities:** Immune to weapon damage, swarm traits, vermin traits * **Saves:** Fort +3, Ref +0, Will +0 * **Abilities:** Str —, Dex 10, Con 10, Int —, Wis 10, Cha 10 * **Skills:** Listen +6, Spot +6 * **Feats:** Alertness A “minor swarm” is a swarm of creatures that is not particularly threatening. Usually composed of non-poisonous, non-diseased arachnids, insects, and small mammals, they could conceivably also be a flock of small birds or a school of small fish. The point is, even *en masse* they’re not particularly dangerous. A minor swarm is only called when in an environment that absolutely does not have anything scarier; they are a default option just to make call swarm (almost) always get you *something*. They can be used for scouting or distraction purposes. The speed of a minor swarm is always 25 ft., but it may be climbing, flying, land-based, or swimming depending on the creature. Distraction (Ex) ---------------- Any living creature that begins its turn with a swarm in its space must succeed on a DC 10 Fortitude save or be nauseated for 1 round. The save DC is Constitution-based.
If controlling and summoning swarms is insufficient, and you want, instead, to *become* a swarm, here're some options. **Master of Flies Prestige Class** It's not a good class by any measure (e.g. uninteresting, difficult to optimize, doesn't perform level-appropriate tasks), but the prestige class master of flies (*SS* 80-3) permits a creature to take the form of a swarm 1/day starting at the prestige class's second level. That makes this ability available at about character level 7 or 6 *via* shenanigans. **House Rules** There is but a single parenthetical reference that prevents the [entomanothrope template](http://www.wizards.com/default.asp?x=dnd/re/20040621a) creating wereswarms, so the DM can, with minimal textual alterations, house rule into existence wereswarms . Alternately, the template necropolitan (*LM* 114-5) combined with the template swarm-shifter (*LM* 123-7) lets you do precisely what you want, but your character ends up sort of undead and there's no Level Adjustment for the swarm-shifter template; that is, the template's unavailable to PCs unless the DM's house rules allow it. You'll be *at least* 1-2 levels behind the rest of the party (unless they're playing kooky stuff, too), but grabbing those permits an at-will swarm form.
35,146
I am most familiar with 4e D&D, but might be playing in a 3.5 game starting in a couple months and I need to nail down a character. I have been drawn to the idea of a swarm druid in 4e rules and wondered if there is anything like that in 3.5? Top uses I like about the swarm are not locked into attacks, but more just the over all feel of the character being kinda sneaky and creepy. I like the though of being able to send one or two insects from my swarm out to do reconnaissance (I think that's possible in the rules). Other than that I like the thought of the insect swarm engulfing my opponents and "eating them alive" and I am also inclined to utilize the controller aspects of the class. The character I have created as a possibility is a loner from the jungles who always seems like his mind is always preoccupied by a hundred different thoughts, he is very fidgety and if you catch a glance of him out of the corner of your eyes he might look like he has bugs crawling around under his skin. So if there is anything like that in 3.5 for druids, or any other class I would really like to know. Other info that might be helpful is I plan on playing an elf or half elf, probably neutral aligned(tho willing to explore other alignments), and probably starting at level 1. (Just guessing about the level as the GM is going to be new to GMing)
2014/03/19
[ "https://rpg.stackexchange.com/questions/35146", "https://rpg.stackexchange.com", "https://rpg.stackexchange.com/users/10263/" ]
The closest thing I know in D&D 3.5e is the [Vermin Lord](http://dndtools.eu/classes/vermin-lord/) from the Book of Vile Darkness. > > The vermin lord offers itself as a host for all manner of parasitic organisms. > > > With abilities like; Swarm Armor, Spew Vermin, and Hivemind. Otherwise you also have the [Animal Lord](http://dndtools.eu/classes/animal-lord/): > > Each animal lord forms a bond with one group of animals. Apelords, > bearlords, birdlords, catlords, horselords, sharklords, snakelords, > and wolflords all exist. Animals in his selected group accept an animal > lord as a kindred soul and a leader. They offer him their support, and > he watches over them in turn. > > > Who is able to summon many of his chosen group, and gain benefits similar to that group for himself. And the [Tamer of Beasts](http://dndtools.eu/classes/tamer-of-beasts/): > > Through magic and his overwhelming concern for his charges, the tamer > of beasts can make them tougher and more intelligent. > > > Who is able to have many HD of animal companions. And connect through them with powerful group abilities. Both from Masters of the Wild.
Some non-druid options, just for completeness: ### Were-Murder-of-Crows The lycanthrope template has the following requirement for the animal base: > > This animal can be any predator, scavenger, or omnivore whose size is within one size category of the base creature’s size (Small, Medium, or Large for a Medium base creature). > > > Because it requires the Animal type, this eliminates the overwhelming majority of swarms. The [entomanothrope template](http://www.wizards.com/default.asp?x=dnd/re/20040621a) allows Vermin type creatures, which most swarms are, but specifically bars Vermin with the Swarm subtype. Lycanthrope doesn’t do that. Enter *Tome of Magic* and its Murder of Crows creature: a Tiny Animal (Swarm), *just* large enough for Small lycanthropes. Crows are omnivorous, and the murder itself is a Tiny creature even though the individual crows are much too small for lycanthrope for most player characters. This is not an option at level one, since an afflicted lycanthrope has the RHD of his animal form and LA +2, so you have to be at least 7th level in order to actually *be* a were-murder-of-claws (4 Animal RHD, LA +2, mandatory single class level, presumably druid here). Ultimately, this would be a *very* poor 7th-level character: you do not get the swarm subtype until you go into full animal form, since hybrid form does not get subtypes, and the murder of crows is a CR 2 creature. The +2 Wisdom you get is nice, but not worth nearly as many levels as this is costing. The natural armor and damage reduction are meh, the racial hit dice are downright bad, and so on. Scent and Low-light Vision are extremely minor. In short, you’ll have low HP, low BAB, *very* low skills, with little to show for it. You do get to fly while in hybrid form, which is sort of nice, but not amazing. You can certainly get it far cheaper than this. The one fairly unique thing is the ability to turn into a (very weak) swarm at-will. This isn’t good for very much since you cannot cast spells in this form. ### Warlock Warlocks get *dark discorporation*... at 16th level. And it mostly amounts to a self-nerf, since they can’t *do* much of anything while in swarm form. Just mentioning that it exists. They also get *summon swarm* at-will, which is actually available at 1st level and actually quite good at that level, though it wanes in effectiveness pretty quickly.
35,146
I am most familiar with 4e D&D, but might be playing in a 3.5 game starting in a couple months and I need to nail down a character. I have been drawn to the idea of a swarm druid in 4e rules and wondered if there is anything like that in 3.5? Top uses I like about the swarm are not locked into attacks, but more just the over all feel of the character being kinda sneaky and creepy. I like the though of being able to send one or two insects from my swarm out to do reconnaissance (I think that's possible in the rules). Other than that I like the thought of the insect swarm engulfing my opponents and "eating them alive" and I am also inclined to utilize the controller aspects of the class. The character I have created as a possibility is a loner from the jungles who always seems like his mind is always preoccupied by a hundred different thoughts, he is very fidgety and if you catch a glance of him out of the corner of your eyes he might look like he has bugs crawling around under his skin. So if there is anything like that in 3.5 for druids, or any other class I would really like to know. Other info that might be helpful is I plan on playing an elf or half elf, probably neutral aligned(tho willing to explore other alignments), and probably starting at level 1. (Just guessing about the level as the GM is going to be new to GMing)
2014/03/19
[ "https://rpg.stackexchange.com/questions/35146", "https://rpg.stackexchange.com", "https://rpg.stackexchange.com/users/10263/" ]
The closest thing I know in D&D 3.5e is the [Vermin Lord](http://dndtools.eu/classes/vermin-lord/) from the Book of Vile Darkness. > > The vermin lord offers itself as a host for all manner of parasitic organisms. > > > With abilities like; Swarm Armor, Spew Vermin, and Hivemind. Otherwise you also have the [Animal Lord](http://dndtools.eu/classes/animal-lord/): > > Each animal lord forms a bond with one group of animals. Apelords, > bearlords, birdlords, catlords, horselords, sharklords, snakelords, > and wolflords all exist. Animals in his selected group accept an animal > lord as a kindred soul and a leader. They offer him their support, and > he watches over them in turn. > > > Who is able to summon many of his chosen group, and gain benefits similar to that group for himself. And the [Tamer of Beasts](http://dndtools.eu/classes/tamer-of-beasts/): > > Through magic and his overwhelming concern for his charges, the tamer > of beasts can make them tougher and more intelligent. > > > Who is able to have many HD of animal companions. And connect through them with powerful group abilities. Both from Masters of the Wild.
You can also use [this ACF](https://web.archive.org/web/20161101150402/http://archive.wizards.com/default.asp?x=dnd/re/20040705a) to swap your animal companion for a vermin companion. At level 7 and higher, you can pick up a centipede or locust swarm. It's not much, but it's something. Maybe ask the DM if you can pick up more exotic swarms at higher levels.
35,146
I am most familiar with 4e D&D, but might be playing in a 3.5 game starting in a couple months and I need to nail down a character. I have been drawn to the idea of a swarm druid in 4e rules and wondered if there is anything like that in 3.5? Top uses I like about the swarm are not locked into attacks, but more just the over all feel of the character being kinda sneaky and creepy. I like the though of being able to send one or two insects from my swarm out to do reconnaissance (I think that's possible in the rules). Other than that I like the thought of the insect swarm engulfing my opponents and "eating them alive" and I am also inclined to utilize the controller aspects of the class. The character I have created as a possibility is a loner from the jungles who always seems like his mind is always preoccupied by a hundred different thoughts, he is very fidgety and if you catch a glance of him out of the corner of your eyes he might look like he has bugs crawling around under his skin. So if there is anything like that in 3.5 for druids, or any other class I would really like to know. Other info that might be helpful is I plan on playing an elf or half elf, probably neutral aligned(tho willing to explore other alignments), and probably starting at level 1. (Just guessing about the level as the GM is going to be new to GMing)
2014/03/19
[ "https://rpg.stackexchange.com/questions/35146", "https://rpg.stackexchange.com", "https://rpg.stackexchange.com/users/10263/" ]
Homebrew ======== This is not official material; I’m making it up. For what it’s worth, I’m fairly good at it (won several 3.5 homebrew competitions; did freelance work for Legend and Pathfinder, each a 3.5-spinoff; wrote a [“book” about it](https://rpg.stackexchange.com/a/18269/4563) as a question answer), but don’t mistake this for official material. You’ll have to ask your DM about it. I would love to hear feedback on it, whether or not you use it. If you do, I’d really love to know how it plays. Ultimately, this variant of the druid has one major advantage and one major disadvantage, with respect to the regular druid. The advantage is that the swarms the swarm druid calls are inherently expendable; you can call up a new quite quickly relative to training a new animal companion. This means you can scout dangerous areas more easily. The disadvantage is in the swarms themselves: you have far fewer options for calling a swarm or adopting a swarm shape than a druid does for bonding an animal companion or assuming a wild shape. Swarm Druid variant =================== The swarm druid is a [variant class](http://www.d20srd.org/srd/variant/classes/variantCharacterClasses.htm) option for the [druid](http://www.d20srd.org/srd/classes/druid.htm); except as noted here, the class is identical to the druid in every way. You cannot multiclass between swarm druid and regular druid, or any other druid variant, but you may take advantage of [alternative class features](http://www.d20srd.org/srd/variant/classes/classFeatureVariants.htm) that replace those class features that the swarm druid does have. | Level | BAB | Fort | Ref | Will | Special | | --- | --- | --- | --- | --- | --- | | 1st | +0 | +2 | +0 | +2 | Call swarm, eusociality, swarm trainer | | 2nd | +1 | +3 | +0 | +3 | Hivemind | | 3rd | +2 | +3 | +1 | +3 | Resist the swarm | | 5th | +3 | +4 | +1 | +4 | Swarm shape (1/day) | | 8th | +6/+1 | +6 | +2 | +6 | Call swarm (across planes) | | 11th | +8/+3 | +7 | +3 | +7 | Swarm shape (two swarms) | | 12th | +9/+4 | +8 | +4 | +8 | Swarm shape (fey, plant, ooze swarms) | | 15th | +11/+6/+1 | +9 | +5 | +9 | Swarm shape (three swarms), timeless body | | 16th | +11/+6/+1 | +9 | +5 | +9 | Swarm shape (elemental swarms 1/day) | | 18th | +13/+8/+3 | +11 | +6 | +11 | Swarm shape (6/day, elemental swarms 2/day) | | 20th | +15/+10/+5 | +12 | +6 | +12 | Swarm shape (any type swarms, 3/day) | Spells ------ As a regular druid, except with the addition of the following spells: 1. *Buzzing bee,SC cause fear, deathwatch, ebon eyes,SC nerveskitter,SC spirit wormSC* 2. *Darkness, death knell, scare, web* 3. *Chain of eyes,SC deeper darkness, gaseous form, spider poison,SC stinking cloud, tremorsenseSC* 4. *Fear* 5. *Cloudkill, crawling darkness,SC plague of rats,SC prying eyes* 6. *Fire spiders,SC spider plagueSC* 7. *Brain spiderSC* 8. *Greater prying eyes* 9. *Otyugh swarmSC* Spells marked *SC* are from *Spell Compendium*. Bonus Languages --------------- As a swarm druid, you still learn druidic as a free language and are still barred from teaching it to non-druids. However, instead of adding Sylvan as a bonus language, you add Undercommon, the language of dark places, and perhaps more importantly, the drow. Even if you are not a drow, the drow’s long history of working with vermin and swarms means it is important for many swarm druids to be able to interact with them. If you do learn Undercommon (whether as a bonus language or not), you count as a drow for the sake of meeting the prerequisites of feats or prestige classes that have to do with vermin or swarms, and drow treat you as they would other drow (which is not that well, but as far as it goes). Call Swarm (Ex) --------------- You may call together a swarm almost anywhere; even desolate deserts usually have spiders and scorpions hidden under the sands. The swarm’s members are called from the immediate surroundings. In the rare cases where there are not sufficient options in the immediate area, you may draw them from great distances, though this makes the call take longer. Calling the swarm is a full-round action. Provided the environment you are in would be able to provide sufficient creatures for the swarm in a square mile centered on you, the swarm is fully gathered by the end of your calling, as eligible creatures tend to be drawn to you before you even call. If this area would not have sufficient creatures, consider an area with a 1½ mile radius; if this would be sufficient, the swarm has gathered by the start of your next turn. For every additional mile in the radius before enough creatures may be found, it takes another round for the swarm to form, always becoming available at the start of your turn. You do not need to continue calling while the swarm is forming. The called swarm remains together and with you for as long as you wish it to. You do not need to concentrate on its continued existence. It disperses either when you tell it to or when the swarm creature dies. You may order a swarm to disperse but follow you, out of sight, so that you may call it again without worrying about whether there are enough creatures in the area. The DM may determine that there are some places the swarm cannot go or barriers it cannot cross, or at least cannot go without coming out of the woodwork and reforming as a swarm. If this happens, you are aware of it. If you leave a swarm or tell it to go away, the individual creatures will gradually return from where they came. You cannot tell a group of swarm-capable creatures to remain in an area as you leave, unless you leave it as a cohesive swarm. You may only have one swarm at a time. A swarm you have disbanded but continue to have with you counts as this swarm. Calling a new swarm causes the previous one to gradually disperse and return from where it came. See **Swarm Druid’s Called Swarm**, below, for more details on the swarm itself. Beginning at 8th level, you may call swarms from any distance, even from other planes. This is a supernatural action that takes 1 round to complete; at the end of the action, your called swarm is ready, no matter where you are. This is a Conjuration (Calling) effect. This feature replaces the druid’s regular animal companion class feature. Any feature that augments or improves your animal companion may improve your called swarm. Any other class that grants an animal companion that stacks with druid levels may instead stack with your swarm druid levels for your called swarm. If you choose to forgo this option and gain an animal companion instead, swarm druid levels do not count towards it, and you cannot change this choice for that class once made. Eusociality (Ex) ---------------- You can improve the attitude of any swarm. This functions just like a Diplomacy check made to improve the attitude of a person. You roll 1d20 and add your class level and your Charisma modifier to determine the check result. A swarm of creatures used to life within humanoid civilization (“indoor” species of ants, cockroaches, spiders, and so on) usually have a starting attitude of indifferent, while species in the wilderness usually start as unfriendly. To make this check, you and the swarm must be able to study each other, which for many swarms requires sharing the swarm’s space. In such cases, you roll your check upon entering the swarm (or the swarm covering you), and if it is successful, the swarm will not attack you. You may also make this check to improve the attitude of vermin without the swarm subtype, but do so at a −4 penalty. Additionally, you are immune to the Distraction special attack of any creature with the swarm subtype. This is true even of swarms that you do not improve the attitude of. This class feature replaces wild empathy. Any feature that augments or improves wild empathy may improve eusociality. Any other class that grants wild empathy that stacks with druid levels may instead stack with your swarm druid levels for eusociality. If you choose to forgo this option and gain wild empathy instead, swarm druid levels do not count towards it, and you cannot change this choice for that class once made. This class feature counts as the Verminfriend feat (*Drow of the Underdark*) for the purposes of prerequisites. You may still take that feat if you meet its requirements. Swarm Trainer (Ex) ------------------ You may train mindless swarms, as well as swarms with Intelligence scores of 1 or 2, by using the Handle Animal skill, even if the swarm is not composed of animals. More intelligent swarms must be interacted with using the usual social skills, or eusociality, not Handle Animal. Mindless swarms are considered to have Intelligence 1 for the purposes of training them and their ability, once trained, to execute tricks and other commands. They are still considered mindless for all other purposes, including affecting them with mind-affecting magic. This class feature replaces nature sense. It also counts as the Vermin Trainer feat (*Drow of the Underdark*) for prerequisites. You may still take Vermin Trainer as a feat if you meet its requirements. Hivemind (Su) ------------- Beginning at 2nd level, any swarm you share a space with reports information back to you. Generally speaking, the information is what the swarm collectively sees, smells, hears, and feels. This is not the same as actually experiencing those sensations yourself (but see the **Sensory Feedback** feature that swarms called by high-level swarm druids get), but it is sufficient to pin-point creatures you cannot sense yourself that share a space with the same swarm you do. Resist the Swarm (Ex) --------------------- At 4th level, you gain a +4 bonus on all saving throws made against the special attacks and special qualities of swarms. This feature replaces the resist nature’s lore class feature that a regular druid receives. Swarm Shape (Su) ---------------- At 5th level, you gain the ability to turn yourself into a swarm once per day. This feature otherwise functions exactly as does a regular druid’s wild shape, which it replaces, except that instead of turning into an animal, you turn into an animal or vermin with the swarm subtype. Swarm shape may be used in place of wild shape for prerequisites, and daily uses of swarm shape count as daily uses of wild shape and may be expended in much the same way for wild feats and the like. Feats and features that modify wild shape may modify swarm shape. Class levels that stack with druid levels for wild shape instead stack with swarm druid levels for swarm shape. If a class grants wild shape to those that don’t have it, you may either gain wild shape and the levels don’t stack, or else choose to stack those levels with swarm druid levels for swarm shape. This choice, once made, cannot be changed for that class. Like the regular druid, you more daily uses of this ability at 6th, 7th, 10th, 14th, and 18th level, as noted in [Table: The Druid](http://www.d20srd.org/srd/classes/druid.htm#tableTheDruid). At 8th, 11th, and 15th level, you gain the ability to shape yourself into two, three, and four swarms at the same time. All swarms must be adjacent to each other and either include or be adjacent to the space you occupied before assuming the shape. When you shape into multiple swarms, divide your HP evenly among them; when you return to your own shape, add the remaining HP totals to determine your remaining HP. You die only if all swarms you are shaped in die. This replaces the druid’s ability to turn into larger and smaller creatures. At 12th level, you add the fey, plant, and ooze types to the list of creature types you can turn into with swarm shape. The chosen creature must still have the swarm subtype and meet all criteria for wild shape aside from type and subtype. This replaces the druid’s ability to wild shape into plant forms. At 16th level, you can use swarm shape to turn into swarms with the elemental type, once per day. This daily elemental swarm shape is in addition to your normal swarm shape usage. In addition to the normal effects of wild shape, you gain all the elemental swarm’s extraordinary, supernatural, and spell-like abilities. You also gain the elemental swarm’s feats for as long as you maintain the wild shape, but you retain your own creature type. This replaces the druid’s ability to wild shape into elemental forms. At 18th and 20th levels, you can assume the form of an elemental swarm another time each day. At 20th level, you can turn into a swarm of any type by using a use of the elemental swarm shape feature, gaining all special attacks and qualities as you would with elemental swarms. This replaces the druid’s ability to wild shape into huge elementals. Swarm Druid’s Called Swarm ========================== The swarm that you may call as a swarm druid is different from a normal swarm in many ways, as described below. Training your called swarm -------------------------- You may train the swarm you call using Handle Animal, as if it were an animal with Intelligence 2. As you gain more swarm druid levels, the swarm may also learn bonus tricks; see below. Each time you call a swarm, it comes trained in the same tricks as the previous swarm, though each trick must be taught in its entirety to a single swarm. Thus your called swarm can be trained, even though the swarm itself is composed of entirely different creatures each time you call it. Called swarm bonuses -------------------- Use the base statistics for a creature of the called swarm’s kind, but make the following changes. | Class Level | Bonus HD | DC Adj. | Space | Bonus Tricks | Special | | --- | --- | --- | --- | --- | --- | | 1st – 2nd | +0 | +1 | +0 | +1 | Link, share spells | | 3rd – 5th | +2 | +2 | +0 | +2 | Evasion | | 6th – 8th | +4 | +3 | +5 | +3 | | | 9th – 11th | +6 | +4 | +5 | +4 | Sensory feedback | | 12th – 14th | +8 | +5 | +10 | +5 | | | 15th – 17th | +10 | +6 | +10 | +6 | Improved Evasion | | 18th – 20th | +12 | +7 | +15 | +7 | | ### Class Level Your swarm druid level. Your class level stacks with levels of any other classes that are entitled to an animal companion or to call a swarm for the purpose of determining the companion’s abilities and the alternative lists available to the character. ### Bonus HD Extra racial hit dice as appropriate to the swarm’s type. For most swarms, this means Animal or Vermin hit dice, which are both d8s that get +¾ BAB and 2+Int skill points per level. Animals get good Fortitude and Reflex saves, while Vermin only get good Fortitude saves. ### DC Adj. The number noted here is added to the saving throw DC of any special attacks or qualities, poisons, and so on that the called swarm has. ### Space The swarm’s space increases by the number noted here. As usual with swarms, this space is far more malleable than a typical creature’s. ### Bonus Tricks The value given in this column is the total number of “bonus” tricks that the swarm knows in addition to any that you might choose to teach it (see the **Training the swarm**, above). These bonus tricks don’t require any training time or Handle Animal checks, and they don’t count against the normal limit of tricks known by the swarm. The druid selects these bonus tricks each time he calls a swarm, but they cannot be changed for that swarm thereafter. ### Link (Ex) You can handle your called swarm as a free action, or push it as a move action, even if you don’t have any ranks in the Handle Animal skill. You gain a +4 circumstance bonus on all eusociality checks and Handle Animal checks made regarding a called swarm. ### Share Spells (Ex) At your option, you may have any spell (but not any spell-like ability) you cast upon yourself also affect your called swarm. You must be within the swarm’s space at the time of casting to receive the benefit. Additionally, you may cast a spell with a target of “You” on your called swarm (as long as the swarm is covering you) instead of on yourself. You and your called swarm can share spells even if the spells normally do not affect creatures of the swarm’s type. ### Evasion (Ex) If a called swarm is subjected to an attack that normally allows a Reflex saving throw for half damage, it takes no damage if it makes a successful saving throw. ### Sensory Feedback (Su) You are automatically aware of anything your called swarm can sense, at a distance of up to a mile. All checks made to use these senses, however, are made at the swarm’s bonus, not your own, which may make it difficult to understand what it is that the swarm is seeing or hearing. Touch, however, is often far more effective. When your called swarm is sharing a space with a creature or object, you know exactly where that creature is, how it is moving, its texture, and so on, even if the creature is invisible and silent. Incorporeal or ethereal creatures, however, are typically not felt. ### Improved Evasion (Ex) When subjected to an attack that normally allows a Reflex saving throw for half damage, a called swarm takes no damage if it makes a successful saving throw and only half damage if the saving throw fails. Called Swarm Options -------------------- You cannot necessarily call together just any swarm, even if the creatures to make up the swarm are available. ### Basic options As a 1st-level swarm druid, you may call the following swarms together: * [Bat swarm](http://www.d20srd.org/srd/monsters/swarm.htm#batSwarm) * Demonet swarm (*Monster Manual IV*) * Leech swarm1 (*Stormwrack*) * [Rat swarm](http://www.d20srd.org/srd/monsters/swarm.htm#ratSwarm) * [Spider swarm](http://www.d20srd.org/srd/monsters/swarm.htm#ratSwarm) * Wasp swarm (*Fiend Folio*) * Minor swarm2 ### Alternative Swarms If you are a swarm druid of sufficiently high level, you may call swarms from one of the following lists, applying the indicated adjustment to your swarm druid level (in parentheses) for purposes of determining the swarm’s characteristics and abilities. **4th level or Higher (Level −3)** * Cranium rat swarm, lesser pack (*Fiend Folio*) * [Locust swarm](http://www.d20srd.org/srd/monsters/swarm.htm#locustSwarm) * Tomb spider broodswarm (*Monster Manual IV*) * Viper swarm (*Fiend Folio*) **7th level or Higher (Level −6)** * [Centipede swarm](http://www.d20srd.org/srd/monsters/swarm.htm#centipedeSwarm) * Bone rat swarm (*Libris Mortis*) * Piranha swarm1 (*Stormwrack*) * Rylkspawn swarm (*Monster Manual V*) **10th level or Higher (Level −9)** * Broodswarm (*Fiendish Codex I*) * Corpse rat swarm (*Libris Mortis*) * Ephemeral swarm (*Monster Manual III*) * Jellyfish swarm1 (*Stormwrack*) * Pest swarm (*Cityscape*) * Plague ant swarm (*Fiend Folio*) * Rapture locust swarm (*Fiend Folio*) * Scorpion swarm (*Sandstorm*) * Swamp strider swarm (*Monster Manual III*) **13th level or Higher (Level −12)** * Cranium rat swarm, average pack (*Fiend Folio*) * Death scarab swarm (*Sandstorm*) * Dread bloom swarm (*Monster Manual III*) * Bloodmote cloud swarm (*Libris Mortis*) * Mageripper swarm (*Monster Manual IV*) * Needletooth swarm (*Monster Manual III*) **16th level or Higher (Level −15)** * Bloodfiend locust swarm (*Fiend Folio*) * Cinder swarm (*Monster Manual II*) * [Hellwasp swarm](http://www.d20srd.org/srd/monsters/swarm.htm#hellwaspSwarm) * Shimmering swarm (*Monster Manual III*) * Brood keeper larva swarm (*Monster Manual III*) 1 Can only be called into an aquatic environment. 2 New monster presented below Minor Swarm =========== * **Size/Type:** Dimuntive Vermin (swarm) * **Hit Dice:** 2d8 (9 hp) * **Speed:** 25 ft. (see text) * **Attack:** Swarm (1d4) * **Space/Reach:** 10 ft./0 ft. * **Special Attacks:** Distraction * **Special Qualities:** Immune to weapon damage, swarm traits, vermin traits * **Saves:** Fort +3, Ref +0, Will +0 * **Abilities:** Str —, Dex 10, Con 10, Int —, Wis 10, Cha 10 * **Skills:** Listen +6, Spot +6 * **Feats:** Alertness A “minor swarm” is a swarm of creatures that is not particularly threatening. Usually composed of non-poisonous, non-diseased arachnids, insects, and small mammals, they could conceivably also be a flock of small birds or a school of small fish. The point is, even *en masse* they’re not particularly dangerous. A minor swarm is only called when in an environment that absolutely does not have anything scarier; they are a default option just to make call swarm (almost) always get you *something*. They can be used for scouting or distraction purposes. The speed of a minor swarm is always 25 ft., but it may be climbing, flying, land-based, or swimming depending on the creature. Distraction (Ex) ---------------- Any living creature that begins its turn with a swarm in its space must succeed on a DC 10 Fortitude save or be nauseated for 1 round. The save DC is Constitution-based.
**Yes, but not at early levels, though you can start planning for it now with the character-defining feat "Child of Winter"** There are no clear parallels to "turning into a swarm from level 1 as just this thing, y'know?" that the swarm druids can do. On the other hand, you might be able to pull off a [Skitter](http://parahumans.wordpress.com/category/stories-arcs-1-10/arc-1-gestation/1-01/) without too much trouble. As you're not a drow, many of the "oooh, spiders!" options are not available to you. (Check out [this thread](http://forum.rpg.net/showthread.php?342283-D-amp-D-3-5-A-Vermin-Based-Druid) for discussion reference) You'll be focusing on the Child of Winter from ebberon. > > You can use any druid spell that normally targets animals against vermin as well. A mindless vermin is considered to have an Intelligence score of 2 when dealing with you and can be charmed, calmed, or targeted by wild empathy or similar abilities. In addition, you can use your summon nature's ally spells to summon vermin. > > > You'll want to then progress into Vermin Keeper at 5th level, just to round things out. While there's some overlap in abilities, it's a natural progression and doesn't suck. For scouting, you'll want things like Chain of Eyes (though that comes quite late for a druid) or Spider Hand (1st level, creates a small spider you can see through) and may want to dip into binder for Malphas's bird's eye viewing. (Normally this is absolutely horrible advice, as dropping caster levels for anything at all is bloody stupid... but it *is* fun. If you *only* want bird's eye viewing, consider dropping a few feats into Bind Vestige and Practiced Binder. It doesn't cost you caster levels, and having a respawnable bird-scout can certainly be worth 2 feats in the right campaign. Reduce Animal will get that bird into *very* tiny spaces (and consider asking the DM to refluff it to some sort of flying roach (ew)) and may help the party remain competitive with the druid. the druid/2 spell summon swarm is *good* but not the only thing you're going to be spamming, especially as you can spontaneously summon spider swarms at the same level due to the child of winter feat.) As a summoner-druid, there is a clear and protected niche for you in the party. Make sure to read the [Druid Handbook](http://www.minmaxboards.com/index.php?topic=940.0). Consider instead [City-Shape](https://www.wizards.com/default.asp?x=dnd/we/20070228a) to the Vermin Lord PrC. Between City-Shape and the extended feats from Child of Winter, much of the Vermin Lord PrC can be achieved more quickly for less cost, leaving your mid levels open for more campaign-appropriate PrCs. Note [this post](http://www.minmaxboards.com/index.php?topic=940.0;msg=23929) for giving up normal wild shape, you are paying a high price for flavour.
35,146
I am most familiar with 4e D&D, but might be playing in a 3.5 game starting in a couple months and I need to nail down a character. I have been drawn to the idea of a swarm druid in 4e rules and wondered if there is anything like that in 3.5? Top uses I like about the swarm are not locked into attacks, but more just the over all feel of the character being kinda sneaky and creepy. I like the though of being able to send one or two insects from my swarm out to do reconnaissance (I think that's possible in the rules). Other than that I like the thought of the insect swarm engulfing my opponents and "eating them alive" and I am also inclined to utilize the controller aspects of the class. The character I have created as a possibility is a loner from the jungles who always seems like his mind is always preoccupied by a hundred different thoughts, he is very fidgety and if you catch a glance of him out of the corner of your eyes he might look like he has bugs crawling around under his skin. So if there is anything like that in 3.5 for druids, or any other class I would really like to know. Other info that might be helpful is I plan on playing an elf or half elf, probably neutral aligned(tho willing to explore other alignments), and probably starting at level 1. (Just guessing about the level as the GM is going to be new to GMing)
2014/03/19
[ "https://rpg.stackexchange.com/questions/35146", "https://rpg.stackexchange.com", "https://rpg.stackexchange.com/users/10263/" ]
**Yes, but not at early levels, though you can start planning for it now with the character-defining feat "Child of Winter"** There are no clear parallels to "turning into a swarm from level 1 as just this thing, y'know?" that the swarm druids can do. On the other hand, you might be able to pull off a [Skitter](http://parahumans.wordpress.com/category/stories-arcs-1-10/arc-1-gestation/1-01/) without too much trouble. As you're not a drow, many of the "oooh, spiders!" options are not available to you. (Check out [this thread](http://forum.rpg.net/showthread.php?342283-D-amp-D-3-5-A-Vermin-Based-Druid) for discussion reference) You'll be focusing on the Child of Winter from ebberon. > > You can use any druid spell that normally targets animals against vermin as well. A mindless vermin is considered to have an Intelligence score of 2 when dealing with you and can be charmed, calmed, or targeted by wild empathy or similar abilities. In addition, you can use your summon nature's ally spells to summon vermin. > > > You'll want to then progress into Vermin Keeper at 5th level, just to round things out. While there's some overlap in abilities, it's a natural progression and doesn't suck. For scouting, you'll want things like Chain of Eyes (though that comes quite late for a druid) or Spider Hand (1st level, creates a small spider you can see through) and may want to dip into binder for Malphas's bird's eye viewing. (Normally this is absolutely horrible advice, as dropping caster levels for anything at all is bloody stupid... but it *is* fun. If you *only* want bird's eye viewing, consider dropping a few feats into Bind Vestige and Practiced Binder. It doesn't cost you caster levels, and having a respawnable bird-scout can certainly be worth 2 feats in the right campaign. Reduce Animal will get that bird into *very* tiny spaces (and consider asking the DM to refluff it to some sort of flying roach (ew)) and may help the party remain competitive with the druid. the druid/2 spell summon swarm is *good* but not the only thing you're going to be spamming, especially as you can spontaneously summon spider swarms at the same level due to the child of winter feat.) As a summoner-druid, there is a clear and protected niche for you in the party. Make sure to read the [Druid Handbook](http://www.minmaxboards.com/index.php?topic=940.0). Consider instead [City-Shape](https://www.wizards.com/default.asp?x=dnd/we/20070228a) to the Vermin Lord PrC. Between City-Shape and the extended feats from Child of Winter, much of the Vermin Lord PrC can be achieved more quickly for less cost, leaving your mid levels open for more campaign-appropriate PrCs. Note [this post](http://www.minmaxboards.com/index.php?topic=940.0;msg=23929) for giving up normal wild shape, you are paying a high price for flavour.
Some non-druid options, just for completeness: ### Were-Murder-of-Crows The lycanthrope template has the following requirement for the animal base: > > This animal can be any predator, scavenger, or omnivore whose size is within one size category of the base creature’s size (Small, Medium, or Large for a Medium base creature). > > > Because it requires the Animal type, this eliminates the overwhelming majority of swarms. The [entomanothrope template](http://www.wizards.com/default.asp?x=dnd/re/20040621a) allows Vermin type creatures, which most swarms are, but specifically bars Vermin with the Swarm subtype. Lycanthrope doesn’t do that. Enter *Tome of Magic* and its Murder of Crows creature: a Tiny Animal (Swarm), *just* large enough for Small lycanthropes. Crows are omnivorous, and the murder itself is a Tiny creature even though the individual crows are much too small for lycanthrope for most player characters. This is not an option at level one, since an afflicted lycanthrope has the RHD of his animal form and LA +2, so you have to be at least 7th level in order to actually *be* a were-murder-of-claws (4 Animal RHD, LA +2, mandatory single class level, presumably druid here). Ultimately, this would be a *very* poor 7th-level character: you do not get the swarm subtype until you go into full animal form, since hybrid form does not get subtypes, and the murder of crows is a CR 2 creature. The +2 Wisdom you get is nice, but not worth nearly as many levels as this is costing. The natural armor and damage reduction are meh, the racial hit dice are downright bad, and so on. Scent and Low-light Vision are extremely minor. In short, you’ll have low HP, low BAB, *very* low skills, with little to show for it. You do get to fly while in hybrid form, which is sort of nice, but not amazing. You can certainly get it far cheaper than this. The one fairly unique thing is the ability to turn into a (very weak) swarm at-will. This isn’t good for very much since you cannot cast spells in this form. ### Warlock Warlocks get *dark discorporation*... at 16th level. And it mostly amounts to a self-nerf, since they can’t *do* much of anything while in swarm form. Just mentioning that it exists. They also get *summon swarm* at-will, which is actually available at 1st level and actually quite good at that level, though it wanes in effectiveness pretty quickly.
35,146
I am most familiar with 4e D&D, but might be playing in a 3.5 game starting in a couple months and I need to nail down a character. I have been drawn to the idea of a swarm druid in 4e rules and wondered if there is anything like that in 3.5? Top uses I like about the swarm are not locked into attacks, but more just the over all feel of the character being kinda sneaky and creepy. I like the though of being able to send one or two insects from my swarm out to do reconnaissance (I think that's possible in the rules). Other than that I like the thought of the insect swarm engulfing my opponents and "eating them alive" and I am also inclined to utilize the controller aspects of the class. The character I have created as a possibility is a loner from the jungles who always seems like his mind is always preoccupied by a hundred different thoughts, he is very fidgety and if you catch a glance of him out of the corner of your eyes he might look like he has bugs crawling around under his skin. So if there is anything like that in 3.5 for druids, or any other class I would really like to know. Other info that might be helpful is I plan on playing an elf or half elf, probably neutral aligned(tho willing to explore other alignments), and probably starting at level 1. (Just guessing about the level as the GM is going to be new to GMing)
2014/03/19
[ "https://rpg.stackexchange.com/questions/35146", "https://rpg.stackexchange.com", "https://rpg.stackexchange.com/users/10263/" ]
Homebrew ======== This is not official material; I’m making it up. For what it’s worth, I’m fairly good at it (won several 3.5 homebrew competitions; did freelance work for Legend and Pathfinder, each a 3.5-spinoff; wrote a [“book” about it](https://rpg.stackexchange.com/a/18269/4563) as a question answer), but don’t mistake this for official material. You’ll have to ask your DM about it. I would love to hear feedback on it, whether or not you use it. If you do, I’d really love to know how it plays. Ultimately, this variant of the druid has one major advantage and one major disadvantage, with respect to the regular druid. The advantage is that the swarms the swarm druid calls are inherently expendable; you can call up a new quite quickly relative to training a new animal companion. This means you can scout dangerous areas more easily. The disadvantage is in the swarms themselves: you have far fewer options for calling a swarm or adopting a swarm shape than a druid does for bonding an animal companion or assuming a wild shape. Swarm Druid variant =================== The swarm druid is a [variant class](http://www.d20srd.org/srd/variant/classes/variantCharacterClasses.htm) option for the [druid](http://www.d20srd.org/srd/classes/druid.htm); except as noted here, the class is identical to the druid in every way. You cannot multiclass between swarm druid and regular druid, or any other druid variant, but you may take advantage of [alternative class features](http://www.d20srd.org/srd/variant/classes/classFeatureVariants.htm) that replace those class features that the swarm druid does have. | Level | BAB | Fort | Ref | Will | Special | | --- | --- | --- | --- | --- | --- | | 1st | +0 | +2 | +0 | +2 | Call swarm, eusociality, swarm trainer | | 2nd | +1 | +3 | +0 | +3 | Hivemind | | 3rd | +2 | +3 | +1 | +3 | Resist the swarm | | 5th | +3 | +4 | +1 | +4 | Swarm shape (1/day) | | 8th | +6/+1 | +6 | +2 | +6 | Call swarm (across planes) | | 11th | +8/+3 | +7 | +3 | +7 | Swarm shape (two swarms) | | 12th | +9/+4 | +8 | +4 | +8 | Swarm shape (fey, plant, ooze swarms) | | 15th | +11/+6/+1 | +9 | +5 | +9 | Swarm shape (three swarms), timeless body | | 16th | +11/+6/+1 | +9 | +5 | +9 | Swarm shape (elemental swarms 1/day) | | 18th | +13/+8/+3 | +11 | +6 | +11 | Swarm shape (6/day, elemental swarms 2/day) | | 20th | +15/+10/+5 | +12 | +6 | +12 | Swarm shape (any type swarms, 3/day) | Spells ------ As a regular druid, except with the addition of the following spells: 1. *Buzzing bee,SC cause fear, deathwatch, ebon eyes,SC nerveskitter,SC spirit wormSC* 2. *Darkness, death knell, scare, web* 3. *Chain of eyes,SC deeper darkness, gaseous form, spider poison,SC stinking cloud, tremorsenseSC* 4. *Fear* 5. *Cloudkill, crawling darkness,SC plague of rats,SC prying eyes* 6. *Fire spiders,SC spider plagueSC* 7. *Brain spiderSC* 8. *Greater prying eyes* 9. *Otyugh swarmSC* Spells marked *SC* are from *Spell Compendium*. Bonus Languages --------------- As a swarm druid, you still learn druidic as a free language and are still barred from teaching it to non-druids. However, instead of adding Sylvan as a bonus language, you add Undercommon, the language of dark places, and perhaps more importantly, the drow. Even if you are not a drow, the drow’s long history of working with vermin and swarms means it is important for many swarm druids to be able to interact with them. If you do learn Undercommon (whether as a bonus language or not), you count as a drow for the sake of meeting the prerequisites of feats or prestige classes that have to do with vermin or swarms, and drow treat you as they would other drow (which is not that well, but as far as it goes). Call Swarm (Ex) --------------- You may call together a swarm almost anywhere; even desolate deserts usually have spiders and scorpions hidden under the sands. The swarm’s members are called from the immediate surroundings. In the rare cases where there are not sufficient options in the immediate area, you may draw them from great distances, though this makes the call take longer. Calling the swarm is a full-round action. Provided the environment you are in would be able to provide sufficient creatures for the swarm in a square mile centered on you, the swarm is fully gathered by the end of your calling, as eligible creatures tend to be drawn to you before you even call. If this area would not have sufficient creatures, consider an area with a 1½ mile radius; if this would be sufficient, the swarm has gathered by the start of your next turn. For every additional mile in the radius before enough creatures may be found, it takes another round for the swarm to form, always becoming available at the start of your turn. You do not need to continue calling while the swarm is forming. The called swarm remains together and with you for as long as you wish it to. You do not need to concentrate on its continued existence. It disperses either when you tell it to or when the swarm creature dies. You may order a swarm to disperse but follow you, out of sight, so that you may call it again without worrying about whether there are enough creatures in the area. The DM may determine that there are some places the swarm cannot go or barriers it cannot cross, or at least cannot go without coming out of the woodwork and reforming as a swarm. If this happens, you are aware of it. If you leave a swarm or tell it to go away, the individual creatures will gradually return from where they came. You cannot tell a group of swarm-capable creatures to remain in an area as you leave, unless you leave it as a cohesive swarm. You may only have one swarm at a time. A swarm you have disbanded but continue to have with you counts as this swarm. Calling a new swarm causes the previous one to gradually disperse and return from where it came. See **Swarm Druid’s Called Swarm**, below, for more details on the swarm itself. Beginning at 8th level, you may call swarms from any distance, even from other planes. This is a supernatural action that takes 1 round to complete; at the end of the action, your called swarm is ready, no matter where you are. This is a Conjuration (Calling) effect. This feature replaces the druid’s regular animal companion class feature. Any feature that augments or improves your animal companion may improve your called swarm. Any other class that grants an animal companion that stacks with druid levels may instead stack with your swarm druid levels for your called swarm. If you choose to forgo this option and gain an animal companion instead, swarm druid levels do not count towards it, and you cannot change this choice for that class once made. Eusociality (Ex) ---------------- You can improve the attitude of any swarm. This functions just like a Diplomacy check made to improve the attitude of a person. You roll 1d20 and add your class level and your Charisma modifier to determine the check result. A swarm of creatures used to life within humanoid civilization (“indoor” species of ants, cockroaches, spiders, and so on) usually have a starting attitude of indifferent, while species in the wilderness usually start as unfriendly. To make this check, you and the swarm must be able to study each other, which for many swarms requires sharing the swarm’s space. In such cases, you roll your check upon entering the swarm (or the swarm covering you), and if it is successful, the swarm will not attack you. You may also make this check to improve the attitude of vermin without the swarm subtype, but do so at a −4 penalty. Additionally, you are immune to the Distraction special attack of any creature with the swarm subtype. This is true even of swarms that you do not improve the attitude of. This class feature replaces wild empathy. Any feature that augments or improves wild empathy may improve eusociality. Any other class that grants wild empathy that stacks with druid levels may instead stack with your swarm druid levels for eusociality. If you choose to forgo this option and gain wild empathy instead, swarm druid levels do not count towards it, and you cannot change this choice for that class once made. This class feature counts as the Verminfriend feat (*Drow of the Underdark*) for the purposes of prerequisites. You may still take that feat if you meet its requirements. Swarm Trainer (Ex) ------------------ You may train mindless swarms, as well as swarms with Intelligence scores of 1 or 2, by using the Handle Animal skill, even if the swarm is not composed of animals. More intelligent swarms must be interacted with using the usual social skills, or eusociality, not Handle Animal. Mindless swarms are considered to have Intelligence 1 for the purposes of training them and their ability, once trained, to execute tricks and other commands. They are still considered mindless for all other purposes, including affecting them with mind-affecting magic. This class feature replaces nature sense. It also counts as the Vermin Trainer feat (*Drow of the Underdark*) for prerequisites. You may still take Vermin Trainer as a feat if you meet its requirements. Hivemind (Su) ------------- Beginning at 2nd level, any swarm you share a space with reports information back to you. Generally speaking, the information is what the swarm collectively sees, smells, hears, and feels. This is not the same as actually experiencing those sensations yourself (but see the **Sensory Feedback** feature that swarms called by high-level swarm druids get), but it is sufficient to pin-point creatures you cannot sense yourself that share a space with the same swarm you do. Resist the Swarm (Ex) --------------------- At 4th level, you gain a +4 bonus on all saving throws made against the special attacks and special qualities of swarms. This feature replaces the resist nature’s lore class feature that a regular druid receives. Swarm Shape (Su) ---------------- At 5th level, you gain the ability to turn yourself into a swarm once per day. This feature otherwise functions exactly as does a regular druid’s wild shape, which it replaces, except that instead of turning into an animal, you turn into an animal or vermin with the swarm subtype. Swarm shape may be used in place of wild shape for prerequisites, and daily uses of swarm shape count as daily uses of wild shape and may be expended in much the same way for wild feats and the like. Feats and features that modify wild shape may modify swarm shape. Class levels that stack with druid levels for wild shape instead stack with swarm druid levels for swarm shape. If a class grants wild shape to those that don’t have it, you may either gain wild shape and the levels don’t stack, or else choose to stack those levels with swarm druid levels for swarm shape. This choice, once made, cannot be changed for that class. Like the regular druid, you more daily uses of this ability at 6th, 7th, 10th, 14th, and 18th level, as noted in [Table: The Druid](http://www.d20srd.org/srd/classes/druid.htm#tableTheDruid). At 8th, 11th, and 15th level, you gain the ability to shape yourself into two, three, and four swarms at the same time. All swarms must be adjacent to each other and either include or be adjacent to the space you occupied before assuming the shape. When you shape into multiple swarms, divide your HP evenly among them; when you return to your own shape, add the remaining HP totals to determine your remaining HP. You die only if all swarms you are shaped in die. This replaces the druid’s ability to turn into larger and smaller creatures. At 12th level, you add the fey, plant, and ooze types to the list of creature types you can turn into with swarm shape. The chosen creature must still have the swarm subtype and meet all criteria for wild shape aside from type and subtype. This replaces the druid’s ability to wild shape into plant forms. At 16th level, you can use swarm shape to turn into swarms with the elemental type, once per day. This daily elemental swarm shape is in addition to your normal swarm shape usage. In addition to the normal effects of wild shape, you gain all the elemental swarm’s extraordinary, supernatural, and spell-like abilities. You also gain the elemental swarm’s feats for as long as you maintain the wild shape, but you retain your own creature type. This replaces the druid’s ability to wild shape into elemental forms. At 18th and 20th levels, you can assume the form of an elemental swarm another time each day. At 20th level, you can turn into a swarm of any type by using a use of the elemental swarm shape feature, gaining all special attacks and qualities as you would with elemental swarms. This replaces the druid’s ability to wild shape into huge elementals. Swarm Druid’s Called Swarm ========================== The swarm that you may call as a swarm druid is different from a normal swarm in many ways, as described below. Training your called swarm -------------------------- You may train the swarm you call using Handle Animal, as if it were an animal with Intelligence 2. As you gain more swarm druid levels, the swarm may also learn bonus tricks; see below. Each time you call a swarm, it comes trained in the same tricks as the previous swarm, though each trick must be taught in its entirety to a single swarm. Thus your called swarm can be trained, even though the swarm itself is composed of entirely different creatures each time you call it. Called swarm bonuses -------------------- Use the base statistics for a creature of the called swarm’s kind, but make the following changes. | Class Level | Bonus HD | DC Adj. | Space | Bonus Tricks | Special | | --- | --- | --- | --- | --- | --- | | 1st – 2nd | +0 | +1 | +0 | +1 | Link, share spells | | 3rd – 5th | +2 | +2 | +0 | +2 | Evasion | | 6th – 8th | +4 | +3 | +5 | +3 | | | 9th – 11th | +6 | +4 | +5 | +4 | Sensory feedback | | 12th – 14th | +8 | +5 | +10 | +5 | | | 15th – 17th | +10 | +6 | +10 | +6 | Improved Evasion | | 18th – 20th | +12 | +7 | +15 | +7 | | ### Class Level Your swarm druid level. Your class level stacks with levels of any other classes that are entitled to an animal companion or to call a swarm for the purpose of determining the companion’s abilities and the alternative lists available to the character. ### Bonus HD Extra racial hit dice as appropriate to the swarm’s type. For most swarms, this means Animal or Vermin hit dice, which are both d8s that get +¾ BAB and 2+Int skill points per level. Animals get good Fortitude and Reflex saves, while Vermin only get good Fortitude saves. ### DC Adj. The number noted here is added to the saving throw DC of any special attacks or qualities, poisons, and so on that the called swarm has. ### Space The swarm’s space increases by the number noted here. As usual with swarms, this space is far more malleable than a typical creature’s. ### Bonus Tricks The value given in this column is the total number of “bonus” tricks that the swarm knows in addition to any that you might choose to teach it (see the **Training the swarm**, above). These bonus tricks don’t require any training time or Handle Animal checks, and they don’t count against the normal limit of tricks known by the swarm. The druid selects these bonus tricks each time he calls a swarm, but they cannot be changed for that swarm thereafter. ### Link (Ex) You can handle your called swarm as a free action, or push it as a move action, even if you don’t have any ranks in the Handle Animal skill. You gain a +4 circumstance bonus on all eusociality checks and Handle Animal checks made regarding a called swarm. ### Share Spells (Ex) At your option, you may have any spell (but not any spell-like ability) you cast upon yourself also affect your called swarm. You must be within the swarm’s space at the time of casting to receive the benefit. Additionally, you may cast a spell with a target of “You” on your called swarm (as long as the swarm is covering you) instead of on yourself. You and your called swarm can share spells even if the spells normally do not affect creatures of the swarm’s type. ### Evasion (Ex) If a called swarm is subjected to an attack that normally allows a Reflex saving throw for half damage, it takes no damage if it makes a successful saving throw. ### Sensory Feedback (Su) You are automatically aware of anything your called swarm can sense, at a distance of up to a mile. All checks made to use these senses, however, are made at the swarm’s bonus, not your own, which may make it difficult to understand what it is that the swarm is seeing or hearing. Touch, however, is often far more effective. When your called swarm is sharing a space with a creature or object, you know exactly where that creature is, how it is moving, its texture, and so on, even if the creature is invisible and silent. Incorporeal or ethereal creatures, however, are typically not felt. ### Improved Evasion (Ex) When subjected to an attack that normally allows a Reflex saving throw for half damage, a called swarm takes no damage if it makes a successful saving throw and only half damage if the saving throw fails. Called Swarm Options -------------------- You cannot necessarily call together just any swarm, even if the creatures to make up the swarm are available. ### Basic options As a 1st-level swarm druid, you may call the following swarms together: * [Bat swarm](http://www.d20srd.org/srd/monsters/swarm.htm#batSwarm) * Demonet swarm (*Monster Manual IV*) * Leech swarm1 (*Stormwrack*) * [Rat swarm](http://www.d20srd.org/srd/monsters/swarm.htm#ratSwarm) * [Spider swarm](http://www.d20srd.org/srd/monsters/swarm.htm#ratSwarm) * Wasp swarm (*Fiend Folio*) * Minor swarm2 ### Alternative Swarms If you are a swarm druid of sufficiently high level, you may call swarms from one of the following lists, applying the indicated adjustment to your swarm druid level (in parentheses) for purposes of determining the swarm’s characteristics and abilities. **4th level or Higher (Level −3)** * Cranium rat swarm, lesser pack (*Fiend Folio*) * [Locust swarm](http://www.d20srd.org/srd/monsters/swarm.htm#locustSwarm) * Tomb spider broodswarm (*Monster Manual IV*) * Viper swarm (*Fiend Folio*) **7th level or Higher (Level −6)** * [Centipede swarm](http://www.d20srd.org/srd/monsters/swarm.htm#centipedeSwarm) * Bone rat swarm (*Libris Mortis*) * Piranha swarm1 (*Stormwrack*) * Rylkspawn swarm (*Monster Manual V*) **10th level or Higher (Level −9)** * Broodswarm (*Fiendish Codex I*) * Corpse rat swarm (*Libris Mortis*) * Ephemeral swarm (*Monster Manual III*) * Jellyfish swarm1 (*Stormwrack*) * Pest swarm (*Cityscape*) * Plague ant swarm (*Fiend Folio*) * Rapture locust swarm (*Fiend Folio*) * Scorpion swarm (*Sandstorm*) * Swamp strider swarm (*Monster Manual III*) **13th level or Higher (Level −12)** * Cranium rat swarm, average pack (*Fiend Folio*) * Death scarab swarm (*Sandstorm*) * Dread bloom swarm (*Monster Manual III*) * Bloodmote cloud swarm (*Libris Mortis*) * Mageripper swarm (*Monster Manual IV*) * Needletooth swarm (*Monster Manual III*) **16th level or Higher (Level −15)** * Bloodfiend locust swarm (*Fiend Folio*) * Cinder swarm (*Monster Manual II*) * [Hellwasp swarm](http://www.d20srd.org/srd/monsters/swarm.htm#hellwaspSwarm) * Shimmering swarm (*Monster Manual III*) * Brood keeper larva swarm (*Monster Manual III*) 1 Can only be called into an aquatic environment. 2 New monster presented below Minor Swarm =========== * **Size/Type:** Dimuntive Vermin (swarm) * **Hit Dice:** 2d8 (9 hp) * **Speed:** 25 ft. (see text) * **Attack:** Swarm (1d4) * **Space/Reach:** 10 ft./0 ft. * **Special Attacks:** Distraction * **Special Qualities:** Immune to weapon damage, swarm traits, vermin traits * **Saves:** Fort +3, Ref +0, Will +0 * **Abilities:** Str —, Dex 10, Con 10, Int —, Wis 10, Cha 10 * **Skills:** Listen +6, Spot +6 * **Feats:** Alertness A “minor swarm” is a swarm of creatures that is not particularly threatening. Usually composed of non-poisonous, non-diseased arachnids, insects, and small mammals, they could conceivably also be a flock of small birds or a school of small fish. The point is, even *en masse* they’re not particularly dangerous. A minor swarm is only called when in an environment that absolutely does not have anything scarier; they are a default option just to make call swarm (almost) always get you *something*. They can be used for scouting or distraction purposes. The speed of a minor swarm is always 25 ft., but it may be climbing, flying, land-based, or swimming depending on the creature. Distraction (Ex) ---------------- Any living creature that begins its turn with a swarm in its space must succeed on a DC 10 Fortitude save or be nauseated for 1 round. The save DC is Constitution-based.
The closest thing I know in D&D 3.5e is the [Vermin Lord](http://dndtools.eu/classes/vermin-lord/) from the Book of Vile Darkness. > > The vermin lord offers itself as a host for all manner of parasitic organisms. > > > With abilities like; Swarm Armor, Spew Vermin, and Hivemind. Otherwise you also have the [Animal Lord](http://dndtools.eu/classes/animal-lord/): > > Each animal lord forms a bond with one group of animals. Apelords, > bearlords, birdlords, catlords, horselords, sharklords, snakelords, > and wolflords all exist. Animals in his selected group accept an animal > lord as a kindred soul and a leader. They offer him their support, and > he watches over them in turn. > > > Who is able to summon many of his chosen group, and gain benefits similar to that group for himself. And the [Tamer of Beasts](http://dndtools.eu/classes/tamer-of-beasts/): > > Through magic and his overwhelming concern for his charges, the tamer > of beasts can make them tougher and more intelligent. > > > Who is able to have many HD of animal companions. And connect through them with powerful group abilities. Both from Masters of the Wild.
35,146
I am most familiar with 4e D&D, but might be playing in a 3.5 game starting in a couple months and I need to nail down a character. I have been drawn to the idea of a swarm druid in 4e rules and wondered if there is anything like that in 3.5? Top uses I like about the swarm are not locked into attacks, but more just the over all feel of the character being kinda sneaky and creepy. I like the though of being able to send one or two insects from my swarm out to do reconnaissance (I think that's possible in the rules). Other than that I like the thought of the insect swarm engulfing my opponents and "eating them alive" and I am also inclined to utilize the controller aspects of the class. The character I have created as a possibility is a loner from the jungles who always seems like his mind is always preoccupied by a hundred different thoughts, he is very fidgety and if you catch a glance of him out of the corner of your eyes he might look like he has bugs crawling around under his skin. So if there is anything like that in 3.5 for druids, or any other class I would really like to know. Other info that might be helpful is I plan on playing an elf or half elf, probably neutral aligned(tho willing to explore other alignments), and probably starting at level 1. (Just guessing about the level as the GM is going to be new to GMing)
2014/03/19
[ "https://rpg.stackexchange.com/questions/35146", "https://rpg.stackexchange.com", "https://rpg.stackexchange.com/users/10263/" ]
**Yes, but not at early levels, though you can start planning for it now with the character-defining feat "Child of Winter"** There are no clear parallels to "turning into a swarm from level 1 as just this thing, y'know?" that the swarm druids can do. On the other hand, you might be able to pull off a [Skitter](http://parahumans.wordpress.com/category/stories-arcs-1-10/arc-1-gestation/1-01/) without too much trouble. As you're not a drow, many of the "oooh, spiders!" options are not available to you. (Check out [this thread](http://forum.rpg.net/showthread.php?342283-D-amp-D-3-5-A-Vermin-Based-Druid) for discussion reference) You'll be focusing on the Child of Winter from ebberon. > > You can use any druid spell that normally targets animals against vermin as well. A mindless vermin is considered to have an Intelligence score of 2 when dealing with you and can be charmed, calmed, or targeted by wild empathy or similar abilities. In addition, you can use your summon nature's ally spells to summon vermin. > > > You'll want to then progress into Vermin Keeper at 5th level, just to round things out. While there's some overlap in abilities, it's a natural progression and doesn't suck. For scouting, you'll want things like Chain of Eyes (though that comes quite late for a druid) or Spider Hand (1st level, creates a small spider you can see through) and may want to dip into binder for Malphas's bird's eye viewing. (Normally this is absolutely horrible advice, as dropping caster levels for anything at all is bloody stupid... but it *is* fun. If you *only* want bird's eye viewing, consider dropping a few feats into Bind Vestige and Practiced Binder. It doesn't cost you caster levels, and having a respawnable bird-scout can certainly be worth 2 feats in the right campaign. Reduce Animal will get that bird into *very* tiny spaces (and consider asking the DM to refluff it to some sort of flying roach (ew)) and may help the party remain competitive with the druid. the druid/2 spell summon swarm is *good* but not the only thing you're going to be spamming, especially as you can spontaneously summon spider swarms at the same level due to the child of winter feat.) As a summoner-druid, there is a clear and protected niche for you in the party. Make sure to read the [Druid Handbook](http://www.minmaxboards.com/index.php?topic=940.0). Consider instead [City-Shape](https://www.wizards.com/default.asp?x=dnd/we/20070228a) to the Vermin Lord PrC. Between City-Shape and the extended feats from Child of Winter, much of the Vermin Lord PrC can be achieved more quickly for less cost, leaving your mid levels open for more campaign-appropriate PrCs. Note [this post](http://www.minmaxboards.com/index.php?topic=940.0;msg=23929) for giving up normal wild shape, you are paying a high price for flavour.
You can also use [this ACF](https://web.archive.org/web/20161101150402/http://archive.wizards.com/default.asp?x=dnd/re/20040705a) to swap your animal companion for a vermin companion. At level 7 and higher, you can pick up a centipede or locust swarm. It's not much, but it's something. Maybe ask the DM if you can pick up more exotic swarms at higher levels.
35,146
I am most familiar with 4e D&D, but might be playing in a 3.5 game starting in a couple months and I need to nail down a character. I have been drawn to the idea of a swarm druid in 4e rules and wondered if there is anything like that in 3.5? Top uses I like about the swarm are not locked into attacks, but more just the over all feel of the character being kinda sneaky and creepy. I like the though of being able to send one or two insects from my swarm out to do reconnaissance (I think that's possible in the rules). Other than that I like the thought of the insect swarm engulfing my opponents and "eating them alive" and I am also inclined to utilize the controller aspects of the class. The character I have created as a possibility is a loner from the jungles who always seems like his mind is always preoccupied by a hundred different thoughts, he is very fidgety and if you catch a glance of him out of the corner of your eyes he might look like he has bugs crawling around under his skin. So if there is anything like that in 3.5 for druids, or any other class I would really like to know. Other info that might be helpful is I plan on playing an elf or half elf, probably neutral aligned(tho willing to explore other alignments), and probably starting at level 1. (Just guessing about the level as the GM is going to be new to GMing)
2014/03/19
[ "https://rpg.stackexchange.com/questions/35146", "https://rpg.stackexchange.com", "https://rpg.stackexchange.com/users/10263/" ]
Homebrew ======== This is not official material; I’m making it up. For what it’s worth, I’m fairly good at it (won several 3.5 homebrew competitions; did freelance work for Legend and Pathfinder, each a 3.5-spinoff; wrote a [“book” about it](https://rpg.stackexchange.com/a/18269/4563) as a question answer), but don’t mistake this for official material. You’ll have to ask your DM about it. I would love to hear feedback on it, whether or not you use it. If you do, I’d really love to know how it plays. Ultimately, this variant of the druid has one major advantage and one major disadvantage, with respect to the regular druid. The advantage is that the swarms the swarm druid calls are inherently expendable; you can call up a new quite quickly relative to training a new animal companion. This means you can scout dangerous areas more easily. The disadvantage is in the swarms themselves: you have far fewer options for calling a swarm or adopting a swarm shape than a druid does for bonding an animal companion or assuming a wild shape. Swarm Druid variant =================== The swarm druid is a [variant class](http://www.d20srd.org/srd/variant/classes/variantCharacterClasses.htm) option for the [druid](http://www.d20srd.org/srd/classes/druid.htm); except as noted here, the class is identical to the druid in every way. You cannot multiclass between swarm druid and regular druid, or any other druid variant, but you may take advantage of [alternative class features](http://www.d20srd.org/srd/variant/classes/classFeatureVariants.htm) that replace those class features that the swarm druid does have. | Level | BAB | Fort | Ref | Will | Special | | --- | --- | --- | --- | --- | --- | | 1st | +0 | +2 | +0 | +2 | Call swarm, eusociality, swarm trainer | | 2nd | +1 | +3 | +0 | +3 | Hivemind | | 3rd | +2 | +3 | +1 | +3 | Resist the swarm | | 5th | +3 | +4 | +1 | +4 | Swarm shape (1/day) | | 8th | +6/+1 | +6 | +2 | +6 | Call swarm (across planes) | | 11th | +8/+3 | +7 | +3 | +7 | Swarm shape (two swarms) | | 12th | +9/+4 | +8 | +4 | +8 | Swarm shape (fey, plant, ooze swarms) | | 15th | +11/+6/+1 | +9 | +5 | +9 | Swarm shape (three swarms), timeless body | | 16th | +11/+6/+1 | +9 | +5 | +9 | Swarm shape (elemental swarms 1/day) | | 18th | +13/+8/+3 | +11 | +6 | +11 | Swarm shape (6/day, elemental swarms 2/day) | | 20th | +15/+10/+5 | +12 | +6 | +12 | Swarm shape (any type swarms, 3/day) | Spells ------ As a regular druid, except with the addition of the following spells: 1. *Buzzing bee,SC cause fear, deathwatch, ebon eyes,SC nerveskitter,SC spirit wormSC* 2. *Darkness, death knell, scare, web* 3. *Chain of eyes,SC deeper darkness, gaseous form, spider poison,SC stinking cloud, tremorsenseSC* 4. *Fear* 5. *Cloudkill, crawling darkness,SC plague of rats,SC prying eyes* 6. *Fire spiders,SC spider plagueSC* 7. *Brain spiderSC* 8. *Greater prying eyes* 9. *Otyugh swarmSC* Spells marked *SC* are from *Spell Compendium*. Bonus Languages --------------- As a swarm druid, you still learn druidic as a free language and are still barred from teaching it to non-druids. However, instead of adding Sylvan as a bonus language, you add Undercommon, the language of dark places, and perhaps more importantly, the drow. Even if you are not a drow, the drow’s long history of working with vermin and swarms means it is important for many swarm druids to be able to interact with them. If you do learn Undercommon (whether as a bonus language or not), you count as a drow for the sake of meeting the prerequisites of feats or prestige classes that have to do with vermin or swarms, and drow treat you as they would other drow (which is not that well, but as far as it goes). Call Swarm (Ex) --------------- You may call together a swarm almost anywhere; even desolate deserts usually have spiders and scorpions hidden under the sands. The swarm’s members are called from the immediate surroundings. In the rare cases where there are not sufficient options in the immediate area, you may draw them from great distances, though this makes the call take longer. Calling the swarm is a full-round action. Provided the environment you are in would be able to provide sufficient creatures for the swarm in a square mile centered on you, the swarm is fully gathered by the end of your calling, as eligible creatures tend to be drawn to you before you even call. If this area would not have sufficient creatures, consider an area with a 1½ mile radius; if this would be sufficient, the swarm has gathered by the start of your next turn. For every additional mile in the radius before enough creatures may be found, it takes another round for the swarm to form, always becoming available at the start of your turn. You do not need to continue calling while the swarm is forming. The called swarm remains together and with you for as long as you wish it to. You do not need to concentrate on its continued existence. It disperses either when you tell it to or when the swarm creature dies. You may order a swarm to disperse but follow you, out of sight, so that you may call it again without worrying about whether there are enough creatures in the area. The DM may determine that there are some places the swarm cannot go or barriers it cannot cross, or at least cannot go without coming out of the woodwork and reforming as a swarm. If this happens, you are aware of it. If you leave a swarm or tell it to go away, the individual creatures will gradually return from where they came. You cannot tell a group of swarm-capable creatures to remain in an area as you leave, unless you leave it as a cohesive swarm. You may only have one swarm at a time. A swarm you have disbanded but continue to have with you counts as this swarm. Calling a new swarm causes the previous one to gradually disperse and return from where it came. See **Swarm Druid’s Called Swarm**, below, for more details on the swarm itself. Beginning at 8th level, you may call swarms from any distance, even from other planes. This is a supernatural action that takes 1 round to complete; at the end of the action, your called swarm is ready, no matter where you are. This is a Conjuration (Calling) effect. This feature replaces the druid’s regular animal companion class feature. Any feature that augments or improves your animal companion may improve your called swarm. Any other class that grants an animal companion that stacks with druid levels may instead stack with your swarm druid levels for your called swarm. If you choose to forgo this option and gain an animal companion instead, swarm druid levels do not count towards it, and you cannot change this choice for that class once made. Eusociality (Ex) ---------------- You can improve the attitude of any swarm. This functions just like a Diplomacy check made to improve the attitude of a person. You roll 1d20 and add your class level and your Charisma modifier to determine the check result. A swarm of creatures used to life within humanoid civilization (“indoor” species of ants, cockroaches, spiders, and so on) usually have a starting attitude of indifferent, while species in the wilderness usually start as unfriendly. To make this check, you and the swarm must be able to study each other, which for many swarms requires sharing the swarm’s space. In such cases, you roll your check upon entering the swarm (or the swarm covering you), and if it is successful, the swarm will not attack you. You may also make this check to improve the attitude of vermin without the swarm subtype, but do so at a −4 penalty. Additionally, you are immune to the Distraction special attack of any creature with the swarm subtype. This is true even of swarms that you do not improve the attitude of. This class feature replaces wild empathy. Any feature that augments or improves wild empathy may improve eusociality. Any other class that grants wild empathy that stacks with druid levels may instead stack with your swarm druid levels for eusociality. If you choose to forgo this option and gain wild empathy instead, swarm druid levels do not count towards it, and you cannot change this choice for that class once made. This class feature counts as the Verminfriend feat (*Drow of the Underdark*) for the purposes of prerequisites. You may still take that feat if you meet its requirements. Swarm Trainer (Ex) ------------------ You may train mindless swarms, as well as swarms with Intelligence scores of 1 or 2, by using the Handle Animal skill, even if the swarm is not composed of animals. More intelligent swarms must be interacted with using the usual social skills, or eusociality, not Handle Animal. Mindless swarms are considered to have Intelligence 1 for the purposes of training them and their ability, once trained, to execute tricks and other commands. They are still considered mindless for all other purposes, including affecting them with mind-affecting magic. This class feature replaces nature sense. It also counts as the Vermin Trainer feat (*Drow of the Underdark*) for prerequisites. You may still take Vermin Trainer as a feat if you meet its requirements. Hivemind (Su) ------------- Beginning at 2nd level, any swarm you share a space with reports information back to you. Generally speaking, the information is what the swarm collectively sees, smells, hears, and feels. This is not the same as actually experiencing those sensations yourself (but see the **Sensory Feedback** feature that swarms called by high-level swarm druids get), but it is sufficient to pin-point creatures you cannot sense yourself that share a space with the same swarm you do. Resist the Swarm (Ex) --------------------- At 4th level, you gain a +4 bonus on all saving throws made against the special attacks and special qualities of swarms. This feature replaces the resist nature’s lore class feature that a regular druid receives. Swarm Shape (Su) ---------------- At 5th level, you gain the ability to turn yourself into a swarm once per day. This feature otherwise functions exactly as does a regular druid’s wild shape, which it replaces, except that instead of turning into an animal, you turn into an animal or vermin with the swarm subtype. Swarm shape may be used in place of wild shape for prerequisites, and daily uses of swarm shape count as daily uses of wild shape and may be expended in much the same way for wild feats and the like. Feats and features that modify wild shape may modify swarm shape. Class levels that stack with druid levels for wild shape instead stack with swarm druid levels for swarm shape. If a class grants wild shape to those that don’t have it, you may either gain wild shape and the levels don’t stack, or else choose to stack those levels with swarm druid levels for swarm shape. This choice, once made, cannot be changed for that class. Like the regular druid, you more daily uses of this ability at 6th, 7th, 10th, 14th, and 18th level, as noted in [Table: The Druid](http://www.d20srd.org/srd/classes/druid.htm#tableTheDruid). At 8th, 11th, and 15th level, you gain the ability to shape yourself into two, three, and four swarms at the same time. All swarms must be adjacent to each other and either include or be adjacent to the space you occupied before assuming the shape. When you shape into multiple swarms, divide your HP evenly among them; when you return to your own shape, add the remaining HP totals to determine your remaining HP. You die only if all swarms you are shaped in die. This replaces the druid’s ability to turn into larger and smaller creatures. At 12th level, you add the fey, plant, and ooze types to the list of creature types you can turn into with swarm shape. The chosen creature must still have the swarm subtype and meet all criteria for wild shape aside from type and subtype. This replaces the druid’s ability to wild shape into plant forms. At 16th level, you can use swarm shape to turn into swarms with the elemental type, once per day. This daily elemental swarm shape is in addition to your normal swarm shape usage. In addition to the normal effects of wild shape, you gain all the elemental swarm’s extraordinary, supernatural, and spell-like abilities. You also gain the elemental swarm’s feats for as long as you maintain the wild shape, but you retain your own creature type. This replaces the druid’s ability to wild shape into elemental forms. At 18th and 20th levels, you can assume the form of an elemental swarm another time each day. At 20th level, you can turn into a swarm of any type by using a use of the elemental swarm shape feature, gaining all special attacks and qualities as you would with elemental swarms. This replaces the druid’s ability to wild shape into huge elementals. Swarm Druid’s Called Swarm ========================== The swarm that you may call as a swarm druid is different from a normal swarm in many ways, as described below. Training your called swarm -------------------------- You may train the swarm you call using Handle Animal, as if it were an animal with Intelligence 2. As you gain more swarm druid levels, the swarm may also learn bonus tricks; see below. Each time you call a swarm, it comes trained in the same tricks as the previous swarm, though each trick must be taught in its entirety to a single swarm. Thus your called swarm can be trained, even though the swarm itself is composed of entirely different creatures each time you call it. Called swarm bonuses -------------------- Use the base statistics for a creature of the called swarm’s kind, but make the following changes. | Class Level | Bonus HD | DC Adj. | Space | Bonus Tricks | Special | | --- | --- | --- | --- | --- | --- | | 1st – 2nd | +0 | +1 | +0 | +1 | Link, share spells | | 3rd – 5th | +2 | +2 | +0 | +2 | Evasion | | 6th – 8th | +4 | +3 | +5 | +3 | | | 9th – 11th | +6 | +4 | +5 | +4 | Sensory feedback | | 12th – 14th | +8 | +5 | +10 | +5 | | | 15th – 17th | +10 | +6 | +10 | +6 | Improved Evasion | | 18th – 20th | +12 | +7 | +15 | +7 | | ### Class Level Your swarm druid level. Your class level stacks with levels of any other classes that are entitled to an animal companion or to call a swarm for the purpose of determining the companion’s abilities and the alternative lists available to the character. ### Bonus HD Extra racial hit dice as appropriate to the swarm’s type. For most swarms, this means Animal or Vermin hit dice, which are both d8s that get +¾ BAB and 2+Int skill points per level. Animals get good Fortitude and Reflex saves, while Vermin only get good Fortitude saves. ### DC Adj. The number noted here is added to the saving throw DC of any special attacks or qualities, poisons, and so on that the called swarm has. ### Space The swarm’s space increases by the number noted here. As usual with swarms, this space is far more malleable than a typical creature’s. ### Bonus Tricks The value given in this column is the total number of “bonus” tricks that the swarm knows in addition to any that you might choose to teach it (see the **Training the swarm**, above). These bonus tricks don’t require any training time or Handle Animal checks, and they don’t count against the normal limit of tricks known by the swarm. The druid selects these bonus tricks each time he calls a swarm, but they cannot be changed for that swarm thereafter. ### Link (Ex) You can handle your called swarm as a free action, or push it as a move action, even if you don’t have any ranks in the Handle Animal skill. You gain a +4 circumstance bonus on all eusociality checks and Handle Animal checks made regarding a called swarm. ### Share Spells (Ex) At your option, you may have any spell (but not any spell-like ability) you cast upon yourself also affect your called swarm. You must be within the swarm’s space at the time of casting to receive the benefit. Additionally, you may cast a spell with a target of “You” on your called swarm (as long as the swarm is covering you) instead of on yourself. You and your called swarm can share spells even if the spells normally do not affect creatures of the swarm’s type. ### Evasion (Ex) If a called swarm is subjected to an attack that normally allows a Reflex saving throw for half damage, it takes no damage if it makes a successful saving throw. ### Sensory Feedback (Su) You are automatically aware of anything your called swarm can sense, at a distance of up to a mile. All checks made to use these senses, however, are made at the swarm’s bonus, not your own, which may make it difficult to understand what it is that the swarm is seeing or hearing. Touch, however, is often far more effective. When your called swarm is sharing a space with a creature or object, you know exactly where that creature is, how it is moving, its texture, and so on, even if the creature is invisible and silent. Incorporeal or ethereal creatures, however, are typically not felt. ### Improved Evasion (Ex) When subjected to an attack that normally allows a Reflex saving throw for half damage, a called swarm takes no damage if it makes a successful saving throw and only half damage if the saving throw fails. Called Swarm Options -------------------- You cannot necessarily call together just any swarm, even if the creatures to make up the swarm are available. ### Basic options As a 1st-level swarm druid, you may call the following swarms together: * [Bat swarm](http://www.d20srd.org/srd/monsters/swarm.htm#batSwarm) * Demonet swarm (*Monster Manual IV*) * Leech swarm1 (*Stormwrack*) * [Rat swarm](http://www.d20srd.org/srd/monsters/swarm.htm#ratSwarm) * [Spider swarm](http://www.d20srd.org/srd/monsters/swarm.htm#ratSwarm) * Wasp swarm (*Fiend Folio*) * Minor swarm2 ### Alternative Swarms If you are a swarm druid of sufficiently high level, you may call swarms from one of the following lists, applying the indicated adjustment to your swarm druid level (in parentheses) for purposes of determining the swarm’s characteristics and abilities. **4th level or Higher (Level −3)** * Cranium rat swarm, lesser pack (*Fiend Folio*) * [Locust swarm](http://www.d20srd.org/srd/monsters/swarm.htm#locustSwarm) * Tomb spider broodswarm (*Monster Manual IV*) * Viper swarm (*Fiend Folio*) **7th level or Higher (Level −6)** * [Centipede swarm](http://www.d20srd.org/srd/monsters/swarm.htm#centipedeSwarm) * Bone rat swarm (*Libris Mortis*) * Piranha swarm1 (*Stormwrack*) * Rylkspawn swarm (*Monster Manual V*) **10th level or Higher (Level −9)** * Broodswarm (*Fiendish Codex I*) * Corpse rat swarm (*Libris Mortis*) * Ephemeral swarm (*Monster Manual III*) * Jellyfish swarm1 (*Stormwrack*) * Pest swarm (*Cityscape*) * Plague ant swarm (*Fiend Folio*) * Rapture locust swarm (*Fiend Folio*) * Scorpion swarm (*Sandstorm*) * Swamp strider swarm (*Monster Manual III*) **13th level or Higher (Level −12)** * Cranium rat swarm, average pack (*Fiend Folio*) * Death scarab swarm (*Sandstorm*) * Dread bloom swarm (*Monster Manual III*) * Bloodmote cloud swarm (*Libris Mortis*) * Mageripper swarm (*Monster Manual IV*) * Needletooth swarm (*Monster Manual III*) **16th level or Higher (Level −15)** * Bloodfiend locust swarm (*Fiend Folio*) * Cinder swarm (*Monster Manual II*) * [Hellwasp swarm](http://www.d20srd.org/srd/monsters/swarm.htm#hellwaspSwarm) * Shimmering swarm (*Monster Manual III*) * Brood keeper larva swarm (*Monster Manual III*) 1 Can only be called into an aquatic environment. 2 New monster presented below Minor Swarm =========== * **Size/Type:** Dimuntive Vermin (swarm) * **Hit Dice:** 2d8 (9 hp) * **Speed:** 25 ft. (see text) * **Attack:** Swarm (1d4) * **Space/Reach:** 10 ft./0 ft. * **Special Attacks:** Distraction * **Special Qualities:** Immune to weapon damage, swarm traits, vermin traits * **Saves:** Fort +3, Ref +0, Will +0 * **Abilities:** Str —, Dex 10, Con 10, Int —, Wis 10, Cha 10 * **Skills:** Listen +6, Spot +6 * **Feats:** Alertness A “minor swarm” is a swarm of creatures that is not particularly threatening. Usually composed of non-poisonous, non-diseased arachnids, insects, and small mammals, they could conceivably also be a flock of small birds or a school of small fish. The point is, even *en masse* they’re not particularly dangerous. A minor swarm is only called when in an environment that absolutely does not have anything scarier; they are a default option just to make call swarm (almost) always get you *something*. They can be used for scouting or distraction purposes. The speed of a minor swarm is always 25 ft., but it may be climbing, flying, land-based, or swimming depending on the creature. Distraction (Ex) ---------------- Any living creature that begins its turn with a swarm in its space must succeed on a DC 10 Fortitude save or be nauseated for 1 round. The save DC is Constitution-based.
You can also use [this ACF](https://web.archive.org/web/20161101150402/http://archive.wizards.com/default.asp?x=dnd/re/20040705a) to swap your animal companion for a vermin companion. At level 7 and higher, you can pick up a centipede or locust swarm. It's not much, but it's something. Maybe ask the DM if you can pick up more exotic swarms at higher levels.
35,146
I am most familiar with 4e D&D, but might be playing in a 3.5 game starting in a couple months and I need to nail down a character. I have been drawn to the idea of a swarm druid in 4e rules and wondered if there is anything like that in 3.5? Top uses I like about the swarm are not locked into attacks, but more just the over all feel of the character being kinda sneaky and creepy. I like the though of being able to send one or two insects from my swarm out to do reconnaissance (I think that's possible in the rules). Other than that I like the thought of the insect swarm engulfing my opponents and "eating them alive" and I am also inclined to utilize the controller aspects of the class. The character I have created as a possibility is a loner from the jungles who always seems like his mind is always preoccupied by a hundred different thoughts, he is very fidgety and if you catch a glance of him out of the corner of your eyes he might look like he has bugs crawling around under his skin. So if there is anything like that in 3.5 for druids, or any other class I would really like to know. Other info that might be helpful is I plan on playing an elf or half elf, probably neutral aligned(tho willing to explore other alignments), and probably starting at level 1. (Just guessing about the level as the GM is going to be new to GMing)
2014/03/19
[ "https://rpg.stackexchange.com/questions/35146", "https://rpg.stackexchange.com", "https://rpg.stackexchange.com/users/10263/" ]
**Yes, but not at early levels, though you can start planning for it now with the character-defining feat "Child of Winter"** There are no clear parallels to "turning into a swarm from level 1 as just this thing, y'know?" that the swarm druids can do. On the other hand, you might be able to pull off a [Skitter](http://parahumans.wordpress.com/category/stories-arcs-1-10/arc-1-gestation/1-01/) without too much trouble. As you're not a drow, many of the "oooh, spiders!" options are not available to you. (Check out [this thread](http://forum.rpg.net/showthread.php?342283-D-amp-D-3-5-A-Vermin-Based-Druid) for discussion reference) You'll be focusing on the Child of Winter from ebberon. > > You can use any druid spell that normally targets animals against vermin as well. A mindless vermin is considered to have an Intelligence score of 2 when dealing with you and can be charmed, calmed, or targeted by wild empathy or similar abilities. In addition, you can use your summon nature's ally spells to summon vermin. > > > You'll want to then progress into Vermin Keeper at 5th level, just to round things out. While there's some overlap in abilities, it's a natural progression and doesn't suck. For scouting, you'll want things like Chain of Eyes (though that comes quite late for a druid) or Spider Hand (1st level, creates a small spider you can see through) and may want to dip into binder for Malphas's bird's eye viewing. (Normally this is absolutely horrible advice, as dropping caster levels for anything at all is bloody stupid... but it *is* fun. If you *only* want bird's eye viewing, consider dropping a few feats into Bind Vestige and Practiced Binder. It doesn't cost you caster levels, and having a respawnable bird-scout can certainly be worth 2 feats in the right campaign. Reduce Animal will get that bird into *very* tiny spaces (and consider asking the DM to refluff it to some sort of flying roach (ew)) and may help the party remain competitive with the druid. the druid/2 spell summon swarm is *good* but not the only thing you're going to be spamming, especially as you can spontaneously summon spider swarms at the same level due to the child of winter feat.) As a summoner-druid, there is a clear and protected niche for you in the party. Make sure to read the [Druid Handbook](http://www.minmaxboards.com/index.php?topic=940.0). Consider instead [City-Shape](https://www.wizards.com/default.asp?x=dnd/we/20070228a) to the Vermin Lord PrC. Between City-Shape and the extended feats from Child of Winter, much of the Vermin Lord PrC can be achieved more quickly for less cost, leaving your mid levels open for more campaign-appropriate PrCs. Note [this post](http://www.minmaxboards.com/index.php?topic=940.0;msg=23929) for giving up normal wild shape, you are paying a high price for flavour.
If controlling and summoning swarms is insufficient, and you want, instead, to *become* a swarm, here're some options. **Master of Flies Prestige Class** It's not a good class by any measure (e.g. uninteresting, difficult to optimize, doesn't perform level-appropriate tasks), but the prestige class master of flies (*SS* 80-3) permits a creature to take the form of a swarm 1/day starting at the prestige class's second level. That makes this ability available at about character level 7 or 6 *via* shenanigans. **House Rules** There is but a single parenthetical reference that prevents the [entomanothrope template](http://www.wizards.com/default.asp?x=dnd/re/20040621a) creating wereswarms, so the DM can, with minimal textual alterations, house rule into existence wereswarms . Alternately, the template necropolitan (*LM* 114-5) combined with the template swarm-shifter (*LM* 123-7) lets you do precisely what you want, but your character ends up sort of undead and there's no Level Adjustment for the swarm-shifter template; that is, the template's unavailable to PCs unless the DM's house rules allow it. You'll be *at least* 1-2 levels behind the rest of the party (unless they're playing kooky stuff, too), but grabbing those permits an at-will swarm form.
35,146
I am most familiar with 4e D&D, but might be playing in a 3.5 game starting in a couple months and I need to nail down a character. I have been drawn to the idea of a swarm druid in 4e rules and wondered if there is anything like that in 3.5? Top uses I like about the swarm are not locked into attacks, but more just the over all feel of the character being kinda sneaky and creepy. I like the though of being able to send one or two insects from my swarm out to do reconnaissance (I think that's possible in the rules). Other than that I like the thought of the insect swarm engulfing my opponents and "eating them alive" and I am also inclined to utilize the controller aspects of the class. The character I have created as a possibility is a loner from the jungles who always seems like his mind is always preoccupied by a hundred different thoughts, he is very fidgety and if you catch a glance of him out of the corner of your eyes he might look like he has bugs crawling around under his skin. So if there is anything like that in 3.5 for druids, or any other class I would really like to know. Other info that might be helpful is I plan on playing an elf or half elf, probably neutral aligned(tho willing to explore other alignments), and probably starting at level 1. (Just guessing about the level as the GM is going to be new to GMing)
2014/03/19
[ "https://rpg.stackexchange.com/questions/35146", "https://rpg.stackexchange.com", "https://rpg.stackexchange.com/users/10263/" ]
Homebrew ======== This is not official material; I’m making it up. For what it’s worth, I’m fairly good at it (won several 3.5 homebrew competitions; did freelance work for Legend and Pathfinder, each a 3.5-spinoff; wrote a [“book” about it](https://rpg.stackexchange.com/a/18269/4563) as a question answer), but don’t mistake this for official material. You’ll have to ask your DM about it. I would love to hear feedback on it, whether or not you use it. If you do, I’d really love to know how it plays. Ultimately, this variant of the druid has one major advantage and one major disadvantage, with respect to the regular druid. The advantage is that the swarms the swarm druid calls are inherently expendable; you can call up a new quite quickly relative to training a new animal companion. This means you can scout dangerous areas more easily. The disadvantage is in the swarms themselves: you have far fewer options for calling a swarm or adopting a swarm shape than a druid does for bonding an animal companion or assuming a wild shape. Swarm Druid variant =================== The swarm druid is a [variant class](http://www.d20srd.org/srd/variant/classes/variantCharacterClasses.htm) option for the [druid](http://www.d20srd.org/srd/classes/druid.htm); except as noted here, the class is identical to the druid in every way. You cannot multiclass between swarm druid and regular druid, or any other druid variant, but you may take advantage of [alternative class features](http://www.d20srd.org/srd/variant/classes/classFeatureVariants.htm) that replace those class features that the swarm druid does have. | Level | BAB | Fort | Ref | Will | Special | | --- | --- | --- | --- | --- | --- | | 1st | +0 | +2 | +0 | +2 | Call swarm, eusociality, swarm trainer | | 2nd | +1 | +3 | +0 | +3 | Hivemind | | 3rd | +2 | +3 | +1 | +3 | Resist the swarm | | 5th | +3 | +4 | +1 | +4 | Swarm shape (1/day) | | 8th | +6/+1 | +6 | +2 | +6 | Call swarm (across planes) | | 11th | +8/+3 | +7 | +3 | +7 | Swarm shape (two swarms) | | 12th | +9/+4 | +8 | +4 | +8 | Swarm shape (fey, plant, ooze swarms) | | 15th | +11/+6/+1 | +9 | +5 | +9 | Swarm shape (three swarms), timeless body | | 16th | +11/+6/+1 | +9 | +5 | +9 | Swarm shape (elemental swarms 1/day) | | 18th | +13/+8/+3 | +11 | +6 | +11 | Swarm shape (6/day, elemental swarms 2/day) | | 20th | +15/+10/+5 | +12 | +6 | +12 | Swarm shape (any type swarms, 3/day) | Spells ------ As a regular druid, except with the addition of the following spells: 1. *Buzzing bee,SC cause fear, deathwatch, ebon eyes,SC nerveskitter,SC spirit wormSC* 2. *Darkness, death knell, scare, web* 3. *Chain of eyes,SC deeper darkness, gaseous form, spider poison,SC stinking cloud, tremorsenseSC* 4. *Fear* 5. *Cloudkill, crawling darkness,SC plague of rats,SC prying eyes* 6. *Fire spiders,SC spider plagueSC* 7. *Brain spiderSC* 8. *Greater prying eyes* 9. *Otyugh swarmSC* Spells marked *SC* are from *Spell Compendium*. Bonus Languages --------------- As a swarm druid, you still learn druidic as a free language and are still barred from teaching it to non-druids. However, instead of adding Sylvan as a bonus language, you add Undercommon, the language of dark places, and perhaps more importantly, the drow. Even if you are not a drow, the drow’s long history of working with vermin and swarms means it is important for many swarm druids to be able to interact with them. If you do learn Undercommon (whether as a bonus language or not), you count as a drow for the sake of meeting the prerequisites of feats or prestige classes that have to do with vermin or swarms, and drow treat you as they would other drow (which is not that well, but as far as it goes). Call Swarm (Ex) --------------- You may call together a swarm almost anywhere; even desolate deserts usually have spiders and scorpions hidden under the sands. The swarm’s members are called from the immediate surroundings. In the rare cases where there are not sufficient options in the immediate area, you may draw them from great distances, though this makes the call take longer. Calling the swarm is a full-round action. Provided the environment you are in would be able to provide sufficient creatures for the swarm in a square mile centered on you, the swarm is fully gathered by the end of your calling, as eligible creatures tend to be drawn to you before you even call. If this area would not have sufficient creatures, consider an area with a 1½ mile radius; if this would be sufficient, the swarm has gathered by the start of your next turn. For every additional mile in the radius before enough creatures may be found, it takes another round for the swarm to form, always becoming available at the start of your turn. You do not need to continue calling while the swarm is forming. The called swarm remains together and with you for as long as you wish it to. You do not need to concentrate on its continued existence. It disperses either when you tell it to or when the swarm creature dies. You may order a swarm to disperse but follow you, out of sight, so that you may call it again without worrying about whether there are enough creatures in the area. The DM may determine that there are some places the swarm cannot go or barriers it cannot cross, or at least cannot go without coming out of the woodwork and reforming as a swarm. If this happens, you are aware of it. If you leave a swarm or tell it to go away, the individual creatures will gradually return from where they came. You cannot tell a group of swarm-capable creatures to remain in an area as you leave, unless you leave it as a cohesive swarm. You may only have one swarm at a time. A swarm you have disbanded but continue to have with you counts as this swarm. Calling a new swarm causes the previous one to gradually disperse and return from where it came. See **Swarm Druid’s Called Swarm**, below, for more details on the swarm itself. Beginning at 8th level, you may call swarms from any distance, even from other planes. This is a supernatural action that takes 1 round to complete; at the end of the action, your called swarm is ready, no matter where you are. This is a Conjuration (Calling) effect. This feature replaces the druid’s regular animal companion class feature. Any feature that augments or improves your animal companion may improve your called swarm. Any other class that grants an animal companion that stacks with druid levels may instead stack with your swarm druid levels for your called swarm. If you choose to forgo this option and gain an animal companion instead, swarm druid levels do not count towards it, and you cannot change this choice for that class once made. Eusociality (Ex) ---------------- You can improve the attitude of any swarm. This functions just like a Diplomacy check made to improve the attitude of a person. You roll 1d20 and add your class level and your Charisma modifier to determine the check result. A swarm of creatures used to life within humanoid civilization (“indoor” species of ants, cockroaches, spiders, and so on) usually have a starting attitude of indifferent, while species in the wilderness usually start as unfriendly. To make this check, you and the swarm must be able to study each other, which for many swarms requires sharing the swarm’s space. In such cases, you roll your check upon entering the swarm (or the swarm covering you), and if it is successful, the swarm will not attack you. You may also make this check to improve the attitude of vermin without the swarm subtype, but do so at a −4 penalty. Additionally, you are immune to the Distraction special attack of any creature with the swarm subtype. This is true even of swarms that you do not improve the attitude of. This class feature replaces wild empathy. Any feature that augments or improves wild empathy may improve eusociality. Any other class that grants wild empathy that stacks with druid levels may instead stack with your swarm druid levels for eusociality. If you choose to forgo this option and gain wild empathy instead, swarm druid levels do not count towards it, and you cannot change this choice for that class once made. This class feature counts as the Verminfriend feat (*Drow of the Underdark*) for the purposes of prerequisites. You may still take that feat if you meet its requirements. Swarm Trainer (Ex) ------------------ You may train mindless swarms, as well as swarms with Intelligence scores of 1 or 2, by using the Handle Animal skill, even if the swarm is not composed of animals. More intelligent swarms must be interacted with using the usual social skills, or eusociality, not Handle Animal. Mindless swarms are considered to have Intelligence 1 for the purposes of training them and their ability, once trained, to execute tricks and other commands. They are still considered mindless for all other purposes, including affecting them with mind-affecting magic. This class feature replaces nature sense. It also counts as the Vermin Trainer feat (*Drow of the Underdark*) for prerequisites. You may still take Vermin Trainer as a feat if you meet its requirements. Hivemind (Su) ------------- Beginning at 2nd level, any swarm you share a space with reports information back to you. Generally speaking, the information is what the swarm collectively sees, smells, hears, and feels. This is not the same as actually experiencing those sensations yourself (but see the **Sensory Feedback** feature that swarms called by high-level swarm druids get), but it is sufficient to pin-point creatures you cannot sense yourself that share a space with the same swarm you do. Resist the Swarm (Ex) --------------------- At 4th level, you gain a +4 bonus on all saving throws made against the special attacks and special qualities of swarms. This feature replaces the resist nature’s lore class feature that a regular druid receives. Swarm Shape (Su) ---------------- At 5th level, you gain the ability to turn yourself into a swarm once per day. This feature otherwise functions exactly as does a regular druid’s wild shape, which it replaces, except that instead of turning into an animal, you turn into an animal or vermin with the swarm subtype. Swarm shape may be used in place of wild shape for prerequisites, and daily uses of swarm shape count as daily uses of wild shape and may be expended in much the same way for wild feats and the like. Feats and features that modify wild shape may modify swarm shape. Class levels that stack with druid levels for wild shape instead stack with swarm druid levels for swarm shape. If a class grants wild shape to those that don’t have it, you may either gain wild shape and the levels don’t stack, or else choose to stack those levels with swarm druid levels for swarm shape. This choice, once made, cannot be changed for that class. Like the regular druid, you more daily uses of this ability at 6th, 7th, 10th, 14th, and 18th level, as noted in [Table: The Druid](http://www.d20srd.org/srd/classes/druid.htm#tableTheDruid). At 8th, 11th, and 15th level, you gain the ability to shape yourself into two, three, and four swarms at the same time. All swarms must be adjacent to each other and either include or be adjacent to the space you occupied before assuming the shape. When you shape into multiple swarms, divide your HP evenly among them; when you return to your own shape, add the remaining HP totals to determine your remaining HP. You die only if all swarms you are shaped in die. This replaces the druid’s ability to turn into larger and smaller creatures. At 12th level, you add the fey, plant, and ooze types to the list of creature types you can turn into with swarm shape. The chosen creature must still have the swarm subtype and meet all criteria for wild shape aside from type and subtype. This replaces the druid’s ability to wild shape into plant forms. At 16th level, you can use swarm shape to turn into swarms with the elemental type, once per day. This daily elemental swarm shape is in addition to your normal swarm shape usage. In addition to the normal effects of wild shape, you gain all the elemental swarm’s extraordinary, supernatural, and spell-like abilities. You also gain the elemental swarm’s feats for as long as you maintain the wild shape, but you retain your own creature type. This replaces the druid’s ability to wild shape into elemental forms. At 18th and 20th levels, you can assume the form of an elemental swarm another time each day. At 20th level, you can turn into a swarm of any type by using a use of the elemental swarm shape feature, gaining all special attacks and qualities as you would with elemental swarms. This replaces the druid’s ability to wild shape into huge elementals. Swarm Druid’s Called Swarm ========================== The swarm that you may call as a swarm druid is different from a normal swarm in many ways, as described below. Training your called swarm -------------------------- You may train the swarm you call using Handle Animal, as if it were an animal with Intelligence 2. As you gain more swarm druid levels, the swarm may also learn bonus tricks; see below. Each time you call a swarm, it comes trained in the same tricks as the previous swarm, though each trick must be taught in its entirety to a single swarm. Thus your called swarm can be trained, even though the swarm itself is composed of entirely different creatures each time you call it. Called swarm bonuses -------------------- Use the base statistics for a creature of the called swarm’s kind, but make the following changes. | Class Level | Bonus HD | DC Adj. | Space | Bonus Tricks | Special | | --- | --- | --- | --- | --- | --- | | 1st – 2nd | +0 | +1 | +0 | +1 | Link, share spells | | 3rd – 5th | +2 | +2 | +0 | +2 | Evasion | | 6th – 8th | +4 | +3 | +5 | +3 | | | 9th – 11th | +6 | +4 | +5 | +4 | Sensory feedback | | 12th – 14th | +8 | +5 | +10 | +5 | | | 15th – 17th | +10 | +6 | +10 | +6 | Improved Evasion | | 18th – 20th | +12 | +7 | +15 | +7 | | ### Class Level Your swarm druid level. Your class level stacks with levels of any other classes that are entitled to an animal companion or to call a swarm for the purpose of determining the companion’s abilities and the alternative lists available to the character. ### Bonus HD Extra racial hit dice as appropriate to the swarm’s type. For most swarms, this means Animal or Vermin hit dice, which are both d8s that get +¾ BAB and 2+Int skill points per level. Animals get good Fortitude and Reflex saves, while Vermin only get good Fortitude saves. ### DC Adj. The number noted here is added to the saving throw DC of any special attacks or qualities, poisons, and so on that the called swarm has. ### Space The swarm’s space increases by the number noted here. As usual with swarms, this space is far more malleable than a typical creature’s. ### Bonus Tricks The value given in this column is the total number of “bonus” tricks that the swarm knows in addition to any that you might choose to teach it (see the **Training the swarm**, above). These bonus tricks don’t require any training time or Handle Animal checks, and they don’t count against the normal limit of tricks known by the swarm. The druid selects these bonus tricks each time he calls a swarm, but they cannot be changed for that swarm thereafter. ### Link (Ex) You can handle your called swarm as a free action, or push it as a move action, even if you don’t have any ranks in the Handle Animal skill. You gain a +4 circumstance bonus on all eusociality checks and Handle Animal checks made regarding a called swarm. ### Share Spells (Ex) At your option, you may have any spell (but not any spell-like ability) you cast upon yourself also affect your called swarm. You must be within the swarm’s space at the time of casting to receive the benefit. Additionally, you may cast a spell with a target of “You” on your called swarm (as long as the swarm is covering you) instead of on yourself. You and your called swarm can share spells even if the spells normally do not affect creatures of the swarm’s type. ### Evasion (Ex) If a called swarm is subjected to an attack that normally allows a Reflex saving throw for half damage, it takes no damage if it makes a successful saving throw. ### Sensory Feedback (Su) You are automatically aware of anything your called swarm can sense, at a distance of up to a mile. All checks made to use these senses, however, are made at the swarm’s bonus, not your own, which may make it difficult to understand what it is that the swarm is seeing or hearing. Touch, however, is often far more effective. When your called swarm is sharing a space with a creature or object, you know exactly where that creature is, how it is moving, its texture, and so on, even if the creature is invisible and silent. Incorporeal or ethereal creatures, however, are typically not felt. ### Improved Evasion (Ex) When subjected to an attack that normally allows a Reflex saving throw for half damage, a called swarm takes no damage if it makes a successful saving throw and only half damage if the saving throw fails. Called Swarm Options -------------------- You cannot necessarily call together just any swarm, even if the creatures to make up the swarm are available. ### Basic options As a 1st-level swarm druid, you may call the following swarms together: * [Bat swarm](http://www.d20srd.org/srd/monsters/swarm.htm#batSwarm) * Demonet swarm (*Monster Manual IV*) * Leech swarm1 (*Stormwrack*) * [Rat swarm](http://www.d20srd.org/srd/monsters/swarm.htm#ratSwarm) * [Spider swarm](http://www.d20srd.org/srd/monsters/swarm.htm#ratSwarm) * Wasp swarm (*Fiend Folio*) * Minor swarm2 ### Alternative Swarms If you are a swarm druid of sufficiently high level, you may call swarms from one of the following lists, applying the indicated adjustment to your swarm druid level (in parentheses) for purposes of determining the swarm’s characteristics and abilities. **4th level or Higher (Level −3)** * Cranium rat swarm, lesser pack (*Fiend Folio*) * [Locust swarm](http://www.d20srd.org/srd/monsters/swarm.htm#locustSwarm) * Tomb spider broodswarm (*Monster Manual IV*) * Viper swarm (*Fiend Folio*) **7th level or Higher (Level −6)** * [Centipede swarm](http://www.d20srd.org/srd/monsters/swarm.htm#centipedeSwarm) * Bone rat swarm (*Libris Mortis*) * Piranha swarm1 (*Stormwrack*) * Rylkspawn swarm (*Monster Manual V*) **10th level or Higher (Level −9)** * Broodswarm (*Fiendish Codex I*) * Corpse rat swarm (*Libris Mortis*) * Ephemeral swarm (*Monster Manual III*) * Jellyfish swarm1 (*Stormwrack*) * Pest swarm (*Cityscape*) * Plague ant swarm (*Fiend Folio*) * Rapture locust swarm (*Fiend Folio*) * Scorpion swarm (*Sandstorm*) * Swamp strider swarm (*Monster Manual III*) **13th level or Higher (Level −12)** * Cranium rat swarm, average pack (*Fiend Folio*) * Death scarab swarm (*Sandstorm*) * Dread bloom swarm (*Monster Manual III*) * Bloodmote cloud swarm (*Libris Mortis*) * Mageripper swarm (*Monster Manual IV*) * Needletooth swarm (*Monster Manual III*) **16th level or Higher (Level −15)** * Bloodfiend locust swarm (*Fiend Folio*) * Cinder swarm (*Monster Manual II*) * [Hellwasp swarm](http://www.d20srd.org/srd/monsters/swarm.htm#hellwaspSwarm) * Shimmering swarm (*Monster Manual III*) * Brood keeper larva swarm (*Monster Manual III*) 1 Can only be called into an aquatic environment. 2 New monster presented below Minor Swarm =========== * **Size/Type:** Dimuntive Vermin (swarm) * **Hit Dice:** 2d8 (9 hp) * **Speed:** 25 ft. (see text) * **Attack:** Swarm (1d4) * **Space/Reach:** 10 ft./0 ft. * **Special Attacks:** Distraction * **Special Qualities:** Immune to weapon damage, swarm traits, vermin traits * **Saves:** Fort +3, Ref +0, Will +0 * **Abilities:** Str —, Dex 10, Con 10, Int —, Wis 10, Cha 10 * **Skills:** Listen +6, Spot +6 * **Feats:** Alertness A “minor swarm” is a swarm of creatures that is not particularly threatening. Usually composed of non-poisonous, non-diseased arachnids, insects, and small mammals, they could conceivably also be a flock of small birds or a school of small fish. The point is, even *en masse* they’re not particularly dangerous. A minor swarm is only called when in an environment that absolutely does not have anything scarier; they are a default option just to make call swarm (almost) always get you *something*. They can be used for scouting or distraction purposes. The speed of a minor swarm is always 25 ft., but it may be climbing, flying, land-based, or swimming depending on the creature. Distraction (Ex) ---------------- Any living creature that begins its turn with a swarm in its space must succeed on a DC 10 Fortitude save or be nauseated for 1 round. The save DC is Constitution-based.
Some non-druid options, just for completeness: ### Were-Murder-of-Crows The lycanthrope template has the following requirement for the animal base: > > This animal can be any predator, scavenger, or omnivore whose size is within one size category of the base creature’s size (Small, Medium, or Large for a Medium base creature). > > > Because it requires the Animal type, this eliminates the overwhelming majority of swarms. The [entomanothrope template](http://www.wizards.com/default.asp?x=dnd/re/20040621a) allows Vermin type creatures, which most swarms are, but specifically bars Vermin with the Swarm subtype. Lycanthrope doesn’t do that. Enter *Tome of Magic* and its Murder of Crows creature: a Tiny Animal (Swarm), *just* large enough for Small lycanthropes. Crows are omnivorous, and the murder itself is a Tiny creature even though the individual crows are much too small for lycanthrope for most player characters. This is not an option at level one, since an afflicted lycanthrope has the RHD of his animal form and LA +2, so you have to be at least 7th level in order to actually *be* a were-murder-of-claws (4 Animal RHD, LA +2, mandatory single class level, presumably druid here). Ultimately, this would be a *very* poor 7th-level character: you do not get the swarm subtype until you go into full animal form, since hybrid form does not get subtypes, and the murder of crows is a CR 2 creature. The +2 Wisdom you get is nice, but not worth nearly as many levels as this is costing. The natural armor and damage reduction are meh, the racial hit dice are downright bad, and so on. Scent and Low-light Vision are extremely minor. In short, you’ll have low HP, low BAB, *very* low skills, with little to show for it. You do get to fly while in hybrid form, which is sort of nice, but not amazing. You can certainly get it far cheaper than this. The one fairly unique thing is the ability to turn into a (very weak) swarm at-will. This isn’t good for very much since you cannot cast spells in this form. ### Warlock Warlocks get *dark discorporation*... at 16th level. And it mostly amounts to a self-nerf, since they can’t *do* much of anything while in swarm form. Just mentioning that it exists. They also get *summon swarm* at-will, which is actually available at 1st level and actually quite good at that level, though it wanes in effectiveness pretty quickly.
14,572,851
Is there someway to turn the row of a gridview into a hyperlink so that when a user opens it in a new tab for example, it goes to that link? Right now I am using a LinkButton and when the user opens it in a new tab, it doesn't know where to go. I figured the .aspx code would look something like: ``` <asp:TemplateField> <ItemTemplate> <Hyperlink ID="hyperlink" runat="server" ForeColor="red" HtmlEncode="false" navigationURL="testUrl.aspx" </ItemTemplate> </asp:TemplateField> ``` The only thing is, our URLs are set up in the C# code behind as a query string, so I'm not sure how to pass that into the navigationURL section. I'm guessing there's something I can do on the page\_load with the query string to redirect to the page I need, but this is my first time working with query strings so I'm a little confused. Thanks!
2013/01/28
[ "https://Stackoverflow.com/questions/14572851", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1355120/" ]
``` <asp:TemplateField> <ItemTemplate> <asp:HyperLink ID="HyperLink1" runat="server" NavigateUrl='<%#String.Format("~/controller.aspx?routeID1={0}&routeID2={1}", Eval("routeid1"), Eval("routeid2"))%>'></asp:HyperLink> </ItemTemplate> </asp:TemplateField> ``` **routeid1 and routeid2 are passed as query strings to the controller of that page.**
What I did recently is modified my class to have a readonly property that constructs the A tag for me. This way I have control over what gets displayed; just text or a link. ``` <ItemTemplate> <asp:Label ID="ColumnItem_Title" runat="server" Text='<%# Bind("DownloadATag") %>'> </asp:Label> </ItemTemplate> ``` The code behind just binds an instance of the class to the gridview. You can bind the gridview whenever, on load on postback event, etc. ``` Dim docs As DocViewList = GetViewList() GridViewDocuments.DataSource = docs GridViewDocuments.DataBind() ``` In the above code, the DocViewList, instantiated as docs, is a list of a class that has all the properties that are needed to fill my GridView, which is named GridViewDocuments here. Once you set the DataSource of your GridView, you can bind any of the source's properties to an item.
14,572,851
Is there someway to turn the row of a gridview into a hyperlink so that when a user opens it in a new tab for example, it goes to that link? Right now I am using a LinkButton and when the user opens it in a new tab, it doesn't know where to go. I figured the .aspx code would look something like: ``` <asp:TemplateField> <ItemTemplate> <Hyperlink ID="hyperlink" runat="server" ForeColor="red" HtmlEncode="false" navigationURL="testUrl.aspx" </ItemTemplate> </asp:TemplateField> ``` The only thing is, our URLs are set up in the C# code behind as a query string, so I'm not sure how to pass that into the navigationURL section. I'm guessing there's something I can do on the page\_load with the query string to redirect to the page I need, but this is my first time working with query strings so I'm a little confused. Thanks!
2013/01/28
[ "https://Stackoverflow.com/questions/14572851", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1355120/" ]
``` <asp:TemplateField> <ItemTemplate> <asp:HyperLink ID="HyperLink1" runat="server" NavigateUrl='<%#String.Format("~/controller.aspx?routeID1={0}&routeID2={1}", Eval("routeid1"), Eval("routeid2"))%>'></asp:HyperLink> </ItemTemplate> </asp:TemplateField> ``` **routeid1 and routeid2 are passed as query strings to the controller of that page.**
Something like: `<asp:LinkButton ID="LinkButton_Title" runat="server" target="_blank" PostBackUrl='<%# Eval(Request.QueryString["title"]) %>'` or binding them from the RowCreated event: ``` protected void GridView_OnRowCreated(Object sender, GridViewRowEventArgs e) { if(e.Row.RowType == DataControlRowType.DataRow) { (e.Row.FindControl("LinkButton_Title") as LinkButton).PostBackUrl = Request.QueryString["title"])) } } ```
32,830,496
Below is the PHP code to retrieve data: ``` <?php $sql = $myquery; $result = $conn->query($sql); $QueryArray = array(); if ($result->num_rows > 0) { // output data of each row while($row = $result->fetch_assoc()) { $QueryArray[] = Array($row["Column1"], $row["Column2"], $row["Column3"]); } } else { } ?> ``` And on the HTML side: ``` <textarea style="width:100%; height:50%; resize:none; rows="5" cols="40"> <?php $output = implode("\n" , $QueryArray); echo $output; ?> </textarea> ``` However the below query prints: ``` Array Array Array Array ..etc ``` Not sure where code is going wrong.
2015/09/28
[ "https://Stackoverflow.com/questions/32830496", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5174952/" ]
As you can see `$QueryArray` is an array of arrays ``` $QueryArray[] = Array($row["Column1"], $row["Column2"], $row["Column3"]); ``` You can access the `$queryArray` elements (array), in a foreach loop. Than use implode to print what you want. ``` <textarea style="width:100%; height:50%; resize:none; rows="5" cols="40"> <?php $output = ''; foreach($array in $QueryArray) { $output .= implode("\n" , $array); } echo $output; ?> </textarea> ``` I hope it helps
In your code $QueryArray is a array of array. if your field count are know, simply you can: ``` <?php $sql = $myquery; $result = $conn->query($sql); if ($result->num_rows > 0) { while($row = $result->fetch_assoc()) { $QueryArray[] = $row["Column1"]; $QueryArray[] = $row["Column2"]; $QueryArray[] = $row["Column3"]; } } else {} ?> ```
32,830,496
Below is the PHP code to retrieve data: ``` <?php $sql = $myquery; $result = $conn->query($sql); $QueryArray = array(); if ($result->num_rows > 0) { // output data of each row while($row = $result->fetch_assoc()) { $QueryArray[] = Array($row["Column1"], $row["Column2"], $row["Column3"]); } } else { } ?> ``` And on the HTML side: ``` <textarea style="width:100%; height:50%; resize:none; rows="5" cols="40"> <?php $output = implode("\n" , $QueryArray); echo $output; ?> </textarea> ``` However the below query prints: ``` Array Array Array Array ..etc ``` Not sure where code is going wrong.
2015/09/28
[ "https://Stackoverflow.com/questions/32830496", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5174952/" ]
As you can see `$QueryArray` is an array of arrays ``` $QueryArray[] = Array($row["Column1"], $row["Column2"], $row["Column3"]); ``` You can access the `$queryArray` elements (array), in a foreach loop. Than use implode to print what you want. ``` <textarea style="width:100%; height:50%; resize:none; rows="5" cols="40"> <?php $output = ''; foreach($array in $QueryArray) { $output .= implode("\n" , $array); } echo $output; ?> </textarea> ``` I hope it helps
This is an old question but someone might need the answer. ``` echo "<pre>"; print_r($QueryArray); echo "</pre>"; ```
5,435,758
Having: ``` @interface MyClass : NSObject { NSString *name; // retained and synthesized NSString *address; // retained and synthesized } ``` I'm creating an array: ``` NSMutableArray *myArray; // retained and synthesized ``` Filling it with several MyClass objects: ``` MyClass *kat = [MyClass new]; kat.name = @"somestring"; kat.address = @"someotherstring" [myArray addObject:kat]; [kat release]; ``` How can I get object at some index? The code below keeps giving me null but it should illustrate what I need.. ``` MyClass *obj = (MyClass*)[myArray objectAtIndex:5]; NSLog(@"Selected: %@", obj.address); // = null :( ``` Is it something wrong with casting or I'm forgetting about something?
2011/03/25
[ "https://Stackoverflow.com/questions/5435758", "https://Stackoverflow.com", "https://Stackoverflow.com/users/475861/" ]
``` MyClass *obj = (MyClass*)[myArray objectAtIndex:5]; NSLog(@"Selected: %@", obj.address); // = null :( ``` If that code is printing `(null)`, it *cannot* be because the array is empty or `objectAtIndex:` failed. `objectAtIndex:` will throw a range exception if you try to access an index beyond the count of objects in the array and an array cannot contain "holes" or nil references. The only way that code will run without incident is if: * `myArray` is nil; you didn't allocate and/or assign an array instance to `myArray`. * `obj.address` returns nil; you didn't correctly initialize the instance (which it appears you did).
It's not enough to just declare myArray in an @property/@synthesize pair. You need myArray to be non-nil as well. You need to add `myArray = [[NSMutableArray alloc] init];` somewhere above your `[addObject:]`call. Additionally, since you've declared the "myArray" variable as retain, if you set another (non-nil) array to myArray through `self.myArray = otherArray` myArray will be non-nil and retained and ready to accept objects. Also, if you allocate myArray, don't forget to release it in your class's dealloc method.
93,510
In [this video at 7:04](https://youtu.be/okz0jI7FN9c?t=424) we see the following view of a VC-25 (an aircraft frequently known as "Air Force One"): [![Two VC-25 engines seen from the rear](https://i.stack.imgur.com/ttCEf.png)](https://i.stack.imgur.com/ttCEf.png) What are the two shiny, gold-coloured structures above and to the rear of the engine exhaust?
2022/06/09
[ "https://aviation.stackexchange.com/questions/93510", "https://aviation.stackexchange.com", "https://aviation.stackexchange.com/users/16923/" ]
According to a [comment on the video from Jamie Lancaster](https://www.youtube.com/watch?v=okz0jI7FN9c&lc=Ugx8YW2LXwNhAZnB_RZ4AaABAg): > > Behind the engines under the wing are the 2 IRCM (Infrared Counter Measure) Jammers - for Air to Air or Ground to Air Missile Defense. > > > In the comments below, [GremlinWranger suggests](https://aviation.stackexchange.com/questions/93510/what-are-the-reflective-structures-above-and-to-the-rear-of-the-engines-on-a-vc#comment256963_93511) that it's likely a descendant of the [Common Infrared Countermeasures Program](https://en.wikipedia.org/wiki/Common_Infrared_Countermeasures_program) based on the appearance of the [ALQ-144](https://en.wikipedia.org/wiki/AN/ALQ-144), which does indeed have similar mirrored panels. A bit of further searching turns up [this blog entry](https://blog.daum.net/wonhanglee/15861485) which claims to show pictures of the AN/ALQ-157 which is even more similar looking, particularly in its four-facet design with hemispherical coverage. (That page also has a reduced-size German poster explaining "Air Force One," by which they mean the V-25, but the relationship of that to anything else in the article is never explained.) [![AN/ALQ-157](https://i.stack.imgur.com/svqd4.png)](https://i.stack.imgur.com/svqd4.png)
[![enter image description here](https://i.stack.imgur.com/nHlw0.jpg)](https://i.stack.imgur.com/nHlw0.jpg)AN/ALQ-204 Matador <https://cryptome.org/eyeball/af1-ircm/af1-ircm.htm> It is a decendant of AN/ALQ-144 and similarly is designed to defeat first gen MANPADS
15,800,319
My app is running fine for months. Today it starts to give error on "Exceeded maximum allocated IDs" with datastore put. Is this something new with appengine quota and limitation? <http://gochild2009.appspot.com>
2013/04/04
[ "https://Stackoverflow.com/questions/15800319", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2158677/" ]
bottom-up merge sort: ``` 25, 64, 22, 46, 20, 65, 90, 66, 48, 98 -> merge groups-of-1 -> 25, 64, 22, 46, 20, 65, 66, 90, 48, 98 -> merge groups-of-2 -> 22, 25, 46, 64, 20, 65, 66, 90, 48, 98 -> merge groups-of-4 -> 20, 22, 25, 46, 64, 65, 66, 90, 48, 98 -> merge groups-of-8 -> 20, 22, 25, 46, 48, 64, 65, 66, 90, 98 result ```
You can find some nice pictures of MergeSort (and others) on [Wikipedia](http://en.wikipedia.org/wiki/Mergesort).
15,800,319
My app is running fine for months. Today it starts to give error on "Exceeded maximum allocated IDs" with datastore put. Is this something new with appengine quota and limitation? <http://gochild2009.appspot.com>
2013/04/04
[ "https://Stackoverflow.com/questions/15800319", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2158677/" ]
Take a look at this image found from wikipedia. Numbers are different but it's a good example of what the data would look like in each recursive call. <http://en.wikipedia.org/wiki/File:Merge_sort_algorithm_diagram.svg>
You can find some nice pictures of MergeSort (and others) on [Wikipedia](http://en.wikipedia.org/wiki/Mergesort).
56,563,952
I'm trying to build my first calculator app with android studio, I'm familiar with Java but not with UIs and XML files. I do not understand why I have margins around the buttons that I have created. I tried to set the layout\_margin to 0 but it did not work. ``` <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" android:weightSum="18" tools:context=".MainActivity"> <TextView android:id="@+id/displayTextView" android:layout_width="match_parent" android:layout_height="0dp" android:textSize="30dp" android:layout_margin="10dp" android:layout_weight="1" android:gravity="left" android:background="@drawable/border" /> <TextView android:id="@+id/finalResultTextView" android:layout_width="match_parent" android:layout_height="0dp" android:textSize="40dp" android:layout_margin="10dp" android:layout_weight="2" android:background="@drawable/border" android:gravity="center" /> <LinearLayout android:layout_width="match_parent" android:layout_height="0dp" android:orientation="horizontal" android:layout_weight="3" android:weightSum="5" > <Button android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1" android:text="C" android:autoSizeTextType="uniform" android:autoSizeMaxTextSize="60dp" /> <Button android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1" android:text="\u232b" android:autoSizeTextType="uniform" android:autoSizeMaxTextSize="60dp" /> <Button android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1" android:text="%" android:autoSizeTextType="uniform" android:autoSizeMaxTextSize="60dp" /> <Button android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1" android:autoSizeMaxTextSize="60dp" android:autoSizeTextType="uniform" android:text="{" /> <Button android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1" android:text="}" android:autoSizeTextType="uniform" android:autoSizeMaxTextSize="60dp" /> </LinearLayout> <LinearLayout android:layout_width="match_parent" android:layout_height="0dp" android:orientation="horizontal" android:layout_weight="3" android:weightSum="5" > <Button android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1" android:text="7" android:autoSizeTextType="uniform" android:autoSizeMaxTextSize="60dp" /> <Button android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1" android:autoSizeMaxTextSize="60dp" android:autoSizeTextType="uniform" android:text="8" /> <Button android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1" android:text="9" android:autoSizeTextType="uniform" android:autoSizeMaxTextSize="60dp" /> <Button android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1" android:text="(" android:autoSizeTextType="uniform" android:autoSizeMaxTextSize="60dp" /> <Button android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1" android:text=")" android:autoSizeTextType="uniform" android:autoSizeMaxTextSize="60dp" /> </LinearLayout> <LinearLayout android:layout_width="match_parent" android:layout_height="0dp" android:orientation="horizontal" android:layout_weight="3" android:weightSum="5" > <Button android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1" android:text="4" android:autoSizeTextType="uniform" android:autoSizeMaxTextSize="60dp" /> <Button android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1" android:text="5" android:autoSizeTextType="uniform" android:autoSizeMaxTextSize="60dp" /> <Button android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1" android:text="6" android:autoSizeTextType="uniform" android:autoSizeMaxTextSize="60dp" /> <Button android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1" android:text="/" android:autoSizeTextType="uniform" android:autoSizeMaxTextSize="60dp" /> <Button android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1" android:text="*" android:autoSizeTextType="uniform" android:autoSizeMaxTextSize="60dp" /> </LinearLayout> <LinearLayout android:layout_width="match_parent" android:layout_height="0dp" android:orientation="horizontal" android:layout_weight="3" android:weightSum="5" > <Button android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1" android:text="1" android:autoSizeTextType="uniform" android:autoSizeMaxTextSize="60dp" /> <Button android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1" android:text="2" android:autoSizeTextType="uniform" android:autoSizeMaxTextSize="60dp" /> <Button android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1" android:text="3" android:autoSizeTextType="uniform" android:autoSizeMaxTextSize="60dp" /> <Button android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1" android:text="-" android:autoSizeTextType="uniform" android:autoSizeMaxTextSize="60dp" /> <Button android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1" android:text="+" android:autoSizeTextType="uniform" android:autoSizeMaxTextSize="60dp" /> </LinearLayout> <LinearLayout android:layout_width="match_parent" android:layout_height="0dp" android:orientation="horizontal" android:layout_weight="3" android:weightSum="5" > <Button android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1" android:text="." android:autoSizeTextType="uniform" android:autoSizeMaxTextSize="60dp" /> <Button android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1" android:text="0" android:autoSizeTextType="uniform" android:autoSizeMaxTextSize="60dp" /> <Button android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="3" android:text="=" android:autoSizeTextType="uniform" android:autoSizeMaxTextSize="100dp" /> /> </LinearLayout> </LinearLayout> ``` Even after I set the layout\_margin to "0dp" I'm still getting margin around each button. Here is the screenshot: [![You can see at the blueprint that each button have a margin around it](https://i.stack.imgur.com/12eCr.png)](https://i.stack.imgur.com/12eCr.png)
2019/06/12
[ "https://Stackoverflow.com/questions/56563952", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9937744/" ]
> > The document “Main.storyboard” requires at least Xcode 11.0. This > version does not support iOS 13.0 system colors. Open this document > with at least Xcode 11.0. > > > solved open the storyboard as source code and first delete the lines: ``` <capability name = "iOS 13.0 system colors" minToolsVersion = "11.0" /> ``` and everything where there is ``` cocoaTouchSystemColor ``` And then in the Interface builder to restore the desired colors. thnx for Russian Stack Overflow <https://ru.stackoverflow.com/a/992148/322338>
In my case I had to delete this line: ``` <capability name="collection view cell content view" minToolsVersion="11.0"/> ``` And then replace all appearances of **collectionViewCellContentView** with **view**.
30,579,616
i'm searching for something like this for days and i couldn't find anything. My knowledge of Javascript is very limited so i'm here to ask you guys to help me out. Basically i need a PHP script which read a huge log .txt file in real time (Without page refresh) which is constantly updated. But it should read only latest lines which has been written to the file since i open up my .php page. This means that if i refresh my page it must starts from the beginning to load new lines. I got this now (**catchlogs.php**): ``` $f = fopen("test.txt", 'r'); $maxLineLength = 1000; $linesToRead = 1; fseek($f, -$maxLineLength*$linesToRead, SEEK_END); $res = array(); while (($buffer = fgets($f, $maxLineLength)) !== false) { $res[] = $buffer; } $content = array_slice($res, -$linesToRead); for($i = 0; $i < $linesToRead; $i++) { echo $content[$i]."<br>"; } ``` And this (**logreader.php**): ``` <script type="text/javascript"> var auto_refresh = setInterval( (function () { $("#logreader").load("catchlogs.php"); }), 1000); </script> <div id="logreader"></div> ``` This load the latest 10 lines but slice them every second. I don't need a limited amout of lines, i need a script that starts to load lines from the last one until i refresh the page (or close it or whatever). Thank you!
2015/06/01
[ "https://Stackoverflow.com/questions/30579616", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4718346/" ]
Here is your script, tested by me. **catchlogs.php** ``` define("LOG_FILE", "test.txt"); /* function to count lines from a file */ function count_line_numbers($file){ $linecount = 0; $handle = fopen($file, "r"); while(!feof($handle)){ $line = fgets($handle); $linecount++; } fclose($handle); // return results return $linecount; } /* show all lines from line */ function logs_started_by_line($file, $xline = 0){ $currline = 0; $handle = fopen($file, "r"); while(!feof($handle)){ $line = fgets($handle, 2000); if($xline <= $currline) echo $line."<br>"; $currline++; } fclose($handle); } session_start(); if(isset($_GET['do'])){ $_SESSION['start'] = -1; } if( ! isset($_SESSION['start']) || $_SESSION['start'] == -1 ){ $_SESSION['start'] = count_line_numbers(LOG_FILE); } logs_started_by_line( LOG_FILE, $_SESSION['start'] ); ``` **logreader.php** ``` <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script> <script type="text/javascript"> $(function(){ $("#logreader").load("catchlogs.php?do=refresh"); var auto_refresh = setInterval( (function () { $("#logreader").load("catchlogs.php"); }), 1000); }); </script> <div id="logreader"></div> ``` **test.txt** ``` line 1 new log something.. ```
The most flawless solution - use Node-Webkit and listen for `tail -f /path/to/log`.
18,623,876
This function is incorrect and won't compile: ``` checkIsZero :: (Num a) => a -> String checkIsZero a = if a == 0 then "Zero" else "Not zero" ``` This doesn't work because of the comparison between a `Num` and `0` in the expression `a == 0`. Changing `Num` to `Integral` makes this a valid function. What is this wicked sorcery that doesn't let me compare my numbers to `0`?!
2013/09/04
[ "https://Stackoverflow.com/questions/18623876", "https://Stackoverflow.com", "https://Stackoverflow.com/users/446554/" ]
`Num` requires instances to implement `+`, `*`, `abs`, `signum`, and `fromInteger`. Note that `==` isn't on the list! It's instances of the `Eq` typeclass that must implement `==`. So, the `Num` constraint is not sufficient - you need an `Eq` constraint too. The following will compile. ``` checkIsZero :: (Eq a, Num a) => a -> String checkIsZero a | a == 0 = "Zero" | otherwise = "Not zero" ``` `Integral` works because something which is an instance of `Integral` must itself be an instance of `Ord`, which in turn must be an instance of `Eq`. You can check all this stuff by using [hoogle](http://www.haskell.org/hoogle/) and digging into the source.
The reason for not requiring an `Eq` instance to define a `Num` instance is that it would rule out useful instances like ``` instance Num b => Num (a -> b) where f + g = \x -> f x + g x f - g = \x -> f x - g x f * x = \x -> f x * g x abs f = \x -> abs (f x) signum f = \x -> signum (f x) fromInteger = const . fromInteger ``` because you can't write an `Eq` instance for a function.
18,623,876
This function is incorrect and won't compile: ``` checkIsZero :: (Num a) => a -> String checkIsZero a = if a == 0 then "Zero" else "Not zero" ``` This doesn't work because of the comparison between a `Num` and `0` in the expression `a == 0`. Changing `Num` to `Integral` makes this a valid function. What is this wicked sorcery that doesn't let me compare my numbers to `0`?!
2013/09/04
[ "https://Stackoverflow.com/questions/18623876", "https://Stackoverflow.com", "https://Stackoverflow.com/users/446554/" ]
`Num` requires instances to implement `+`, `*`, `abs`, `signum`, and `fromInteger`. Note that `==` isn't on the list! It's instances of the `Eq` typeclass that must implement `==`. So, the `Num` constraint is not sufficient - you need an `Eq` constraint too. The following will compile. ``` checkIsZero :: (Eq a, Num a) => a -> String checkIsZero a | a == 0 = "Zero" | otherwise = "Not zero" ``` `Integral` works because something which is an instance of `Integral` must itself be an instance of `Ord`, which in turn must be an instance of `Eq`. You can check all this stuff by using [hoogle](http://www.haskell.org/hoogle/) and digging into the source.
If data is an instance of `Num a`, it is not a grantee , that this data is an instance of `Eq a`. `Integer` (and `Int`, `Double`) has both instances: `instance Num Integer` and `instance Eq Integer`, and program is valid `Integral` is defined as ``` class (Real a, Enum a)=> Integral a where ... class (Num a, Ord a)=> Real a where ... class Eq a => Ord a where ... ~= class (Num a, Eq a, Enum a)=> Integral a where ... --means ```
18,623,876
This function is incorrect and won't compile: ``` checkIsZero :: (Num a) => a -> String checkIsZero a = if a == 0 then "Zero" else "Not zero" ``` This doesn't work because of the comparison between a `Num` and `0` in the expression `a == 0`. Changing `Num` to `Integral` makes this a valid function. What is this wicked sorcery that doesn't let me compare my numbers to `0`?!
2013/09/04
[ "https://Stackoverflow.com/questions/18623876", "https://Stackoverflow.com", "https://Stackoverflow.com/users/446554/" ]
The reason for not requiring an `Eq` instance to define a `Num` instance is that it would rule out useful instances like ``` instance Num b => Num (a -> b) where f + g = \x -> f x + g x f - g = \x -> f x - g x f * x = \x -> f x * g x abs f = \x -> abs (f x) signum f = \x -> signum (f x) fromInteger = const . fromInteger ``` because you can't write an `Eq` instance for a function.
If data is an instance of `Num a`, it is not a grantee , that this data is an instance of `Eq a`. `Integer` (and `Int`, `Double`) has both instances: `instance Num Integer` and `instance Eq Integer`, and program is valid `Integral` is defined as ``` class (Real a, Enum a)=> Integral a where ... class (Num a, Ord a)=> Real a where ... class Eq a => Ord a where ... ~= class (Num a, Eq a, Enum a)=> Integral a where ... --means ```
41,479,466
I have two inputs, where user types `width` and `height` of a product (let's say in mm). So min price is $250 until `width=50` and `height=20`. Then I want to increase total price by $25 every time width OR height edited by 10mm. So total should be $275 if `w=60 and h=20` (or `w=50/h=30`); $300 - when `w=60 and h=30`... Now with my poor jquery knowledge I made this monster <https://jsfiddle.net/fkqotzzb/> ```js var basePrice = 250; var priceForSm = 50; var price300 = basePrice + priceForSm; var price450 = price300 + (priceForSm * 3); var price700 = price450 + (priceForSm * 5); var price950 = price700 + (priceForSm * 5); $("#stwidth, #stheight").keyup(function () { var stwidth = parseInt($("#stwidth").val(), 10); var stheight = parseInt($("#stheight").val(), 10); if (stwidth > 113) { $("#stwidth").val("113"); } if (stheight > 62) { $("#stheight").val("62"); } if (stwidth >= 50 && stheight >= 20 || stwidth >= 110 && stheight >= 10) { $(".stamp-full-price span").html(basePrice); } if (stwidth >= 30 && stheight >= 60 || stwidth == 80 && stheight == 20 || stwidth >= 60 && stheight >= 30 || stwidth >= 40 && stheight >= 40) { $(".stamp-full-price span").html(price300); } if (stwidth >= 110 && stheight >= 20 || stwidth >= 110 && stheight == 30 || stwidth >= 70 && stheight >= 30 || stwidth >= 60 && stheight >= 40 || stwidth >= 50 && stheight >= 50 || stwidth >= 40 && stheight >= 60) { $(".stamp-full-price span").html(price450); } if (stwidth >= 110 && stheight >= 40 || stwidth >= 110 && stheight >= 50 || stwidth >= 90 && stheight >= 40 || stwidth >= 80 && stheight >= 50 || stwidth >= 60 && stheight >= 60) { $(".stamp-full-price span").html(price700); } if (stwidth >= 100 && stheight >= 60 || stwidth >= 111 && stheight >= 50) { $(".stamp-full-price span").html(price950); } }); ``` ```html <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <input type="text" name="stwidth" id="stwidth" value="50" class="form-control input-xs" maxlength="3"> x <input type="text" name="stheight" id="stheight" value="20" class="form-control input-xs" maxlength="2"> мм <div class="stamp-full-price"> Total: <span>250</span> </div> ``` Here prices and sizes set manually, but I don't want to set them so, it could be nice to control price by `width` and `height` separately. It also doesn't cover all the sizes an cases, so I can't predict what price could be shown in specific situation, and it's really monster :). I also have some another options next after sizes in form of radios and checkboxes. So how to get value of a total price after sizes defined to add a price of radio/checkbox?
2017/01/05
[ "https://Stackoverflow.com/questions/41479466", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4428360/" ]
Technical facts based answer: having the loop in your shell script means that you keep constantly **starting** new JVM processes. That will put a higher load on your system compared to having a loop within the Java program you are executing. In other words: you start one JVM session, it does something; it goes down; the next starts ... forever. Probably Linux is doing a lot of things behind the cover that reduce the cost of doing so (for example by actually keeping things in memory); but still: you are constantly starting processes to end them soon thereafter. If you really intend to run your code for an "infinite" time; than you definitely want to avoid wasting resources in any form. That on the other hand, can give a (weak) argument for keeping the loop on the script side: when you put your loop into your java code, and your java code is actually buggy (memory leaks for example); then the memory consumption of that one JVM could keep growing forever (until reaching its limit; and then you might see a lot of garbage collection). Meaning: when you know that your Java code is in a bad shape; and that running it in the **same** JVM over longer periods of time causes problems; then of course: starting and stopping the JVM has some benefits. But of course - in that case, you have some bigger problem anyway. If your java application has such problems, then you better identify their root cause and fix them; instead of constantly starting/stopping your JVM to circumvent these issues.
How about using 'watch' command if you didn't care the interval? You may type watch {your command} Then your command will refresh by 2 seconds, if you want to change the interval, you may type watch -n 5 {your command} Then the interval is 5 seconds, that's convininent if you are monitoring some output value. To quit that you may use CTRL+C.
27,453
We currently have a central AC unit and oil furnace. The AC is broken and the furnace is old, so we are thinking of replacing both sometime in the next year. We are considering replacing the AC with a heat pump and the oil furnace with a gas furnace in the hopes that the gas company will bring a line down our street from the main road sometime before the furnace needs to be replaced. From my understanding, the heat pump could also be used to heat the house up to a certain point in the winter. I don't know a whole lot about heat pumps, so I'm wondering how effective a heat pump would be at cooling and heating the house (currently just the first floor, about 800 sq ft, and basement), both in terms of cost effectiveness and actual comfort level of the house. Should a pump be able to cool our house on 100+ degree days to, say, 70-75 degrees? Will it be able to get our house warm enough in the winter in a reasonable amount of time? I'm told the units will somehow be set so that the furnace kicks in automatically when needed, but I'm wondering how that is actually determined. I don't want to be sitting in a cold house for hours waiting for the furnace to realize the heat pump isn't going to do the job. I've also heard the pump is cheaper for heating, but I am wondering about the specifics. How much cheaper would a heat pump be to run? Both run on electricity to some extent, but does the heat pump use more electricity to warm the house than the furnace, and, if so, is it enough to make up for the cost difference? Any other pros/cons I should be thinking about?
2013/05/01
[ "https://diy.stackexchange.com/questions/27453", "https://diy.stackexchange.com", "https://diy.stackexchange.com/users/12790/" ]
You don't have to worry about a heat pump being inadequate for cooling tasks, they are available in a large range of sizes. For really large buildings, they can be ganged together. 800 sf is a walk in the park for residential sized units. I don't know the specifics of what determines when the backup furnace kicks in. IIRC, it is the combination of a lower thermostat set point and the outside temperature. It kicks on when the pump is not keeping up or it's too cold for it to run efficiently. I can assure you you will not be sitting for hours waiting for backup heat. No customer would sit still for such a system. While it is true that heat pump heat is free, you are just paying to move it around, if you've had heat wave cooling bills before, you know moving heat around is far from cheap. Only a careful analysis of the various options, considering both operational and installation costs, as well as life cycle replacement, can you make a proper decision about which system is most cost effective. The correct solution will vary by small changes in energy costs and climate. In cold climates, a ground heat source system should at least be considered because it will reduce or eliminate the need for backup heat. If you are concerned about your carbon footprint, do not forget most electricity generated in the US is by burning fossil fuels. Your footprint from using a heat pump will vary greatly depending on where your local power is coming from. Heat pumps make a lot of sense for many people, especially if they are investing in cooling equipment anyway. But everyone's situation is unique, so the best solution can be arrived at only after careful rational analysis of all the factors.
We had a heat pump in Pennsylvania , 1 hour north of Philadelphia, used for heating and cooling. We now , after 25 years in that home we built, have gas forced air and a central AC unit. There is no comparison. The gas heat is cheaper, stays I the room, and feels warmer. I was always cold with the heat pump, even when it kicked on to residence heat . The heat pump only provides cheap heat until you get to temps of below 32 and then it becomes less efficient and more expensive. If you can get gas heat, by all means do it. We had oil in our first home, summer /winter hock up and even that was better than the heat pump in Pennsylvania. South of Philadelphia , with milder winter temps is better for heat pumps no matter what he contractors and electric companies tell you.
27,453
We currently have a central AC unit and oil furnace. The AC is broken and the furnace is old, so we are thinking of replacing both sometime in the next year. We are considering replacing the AC with a heat pump and the oil furnace with a gas furnace in the hopes that the gas company will bring a line down our street from the main road sometime before the furnace needs to be replaced. From my understanding, the heat pump could also be used to heat the house up to a certain point in the winter. I don't know a whole lot about heat pumps, so I'm wondering how effective a heat pump would be at cooling and heating the house (currently just the first floor, about 800 sq ft, and basement), both in terms of cost effectiveness and actual comfort level of the house. Should a pump be able to cool our house on 100+ degree days to, say, 70-75 degrees? Will it be able to get our house warm enough in the winter in a reasonable amount of time? I'm told the units will somehow be set so that the furnace kicks in automatically when needed, but I'm wondering how that is actually determined. I don't want to be sitting in a cold house for hours waiting for the furnace to realize the heat pump isn't going to do the job. I've also heard the pump is cheaper for heating, but I am wondering about the specifics. How much cheaper would a heat pump be to run? Both run on electricity to some extent, but does the heat pump use more electricity to warm the house than the furnace, and, if so, is it enough to make up for the cost difference? Any other pros/cons I should be thinking about?
2013/05/01
[ "https://diy.stackexchange.com/questions/27453", "https://diy.stackexchange.com", "https://diy.stackexchange.com/users/12790/" ]
You don't have to worry about a heat pump being inadequate for cooling tasks, they are available in a large range of sizes. For really large buildings, they can be ganged together. 800 sf is a walk in the park for residential sized units. I don't know the specifics of what determines when the backup furnace kicks in. IIRC, it is the combination of a lower thermostat set point and the outside temperature. It kicks on when the pump is not keeping up or it's too cold for it to run efficiently. I can assure you you will not be sitting for hours waiting for backup heat. No customer would sit still for such a system. While it is true that heat pump heat is free, you are just paying to move it around, if you've had heat wave cooling bills before, you know moving heat around is far from cheap. Only a careful analysis of the various options, considering both operational and installation costs, as well as life cycle replacement, can you make a proper decision about which system is most cost effective. The correct solution will vary by small changes in energy costs and climate. In cold climates, a ground heat source system should at least be considered because it will reduce or eliminate the need for backup heat. If you are concerned about your carbon footprint, do not forget most electricity generated in the US is by burning fossil fuels. Your footprint from using a heat pump will vary greatly depending on where your local power is coming from. Heat pumps make a lot of sense for many people, especially if they are investing in cooling equipment anyway. But everyone's situation is unique, so the best solution can be arrived at only after careful rational analysis of all the factors.
How well the heat pump warms the house depends on the capacity of the heat pump and how well insulated the house is. Heat pumps definitely act a lot slower than furnaces, the temperature just kind of creeps up. In fact, in my house in New Hampshire, the temperature actually gets *lower* when the heat pump comes on because it starts blowing cold air around for 10 minutes. The way backup heat works in my house is that if the temperature gets 5-degrees lower than the thermostat, then the furnace comes on. Once the temperature gets to be about freezing, the heat pump is more annoying than helpful. During the fall and spring when the temperature is in the 50s and 60s, the heat pump is very useful because otherwise the furnace would be coming on and off all the time. As far as efficiency is concerned, it is definitely cheaper to run the heat pump when the temperature is above 45 degrees. Also, a heat pump is a lot cheaper than an air conditioner. Of course, with some $15,000 heat pump it can take a long time to justify that even if you are saving $100 a month.
27,453
We currently have a central AC unit and oil furnace. The AC is broken and the furnace is old, so we are thinking of replacing both sometime in the next year. We are considering replacing the AC with a heat pump and the oil furnace with a gas furnace in the hopes that the gas company will bring a line down our street from the main road sometime before the furnace needs to be replaced. From my understanding, the heat pump could also be used to heat the house up to a certain point in the winter. I don't know a whole lot about heat pumps, so I'm wondering how effective a heat pump would be at cooling and heating the house (currently just the first floor, about 800 sq ft, and basement), both in terms of cost effectiveness and actual comfort level of the house. Should a pump be able to cool our house on 100+ degree days to, say, 70-75 degrees? Will it be able to get our house warm enough in the winter in a reasonable amount of time? I'm told the units will somehow be set so that the furnace kicks in automatically when needed, but I'm wondering how that is actually determined. I don't want to be sitting in a cold house for hours waiting for the furnace to realize the heat pump isn't going to do the job. I've also heard the pump is cheaper for heating, but I am wondering about the specifics. How much cheaper would a heat pump be to run? Both run on electricity to some extent, but does the heat pump use more electricity to warm the house than the furnace, and, if so, is it enough to make up for the cost difference? Any other pros/cons I should be thinking about?
2013/05/01
[ "https://diy.stackexchange.com/questions/27453", "https://diy.stackexchange.com", "https://diy.stackexchange.com/users/12790/" ]
Heat pumps are quite common in Central Oregon where summer daytime highs are often over 100°F and nights below 25°F. I have been in many a heat pump rental house in winter at below 10°F in a wide range of efficiencies from below eight to over 20 SEER. They work fine. For units with a SEER of over 14 or so, the backup heat does not kick in (except for defrost cycles) in cold, dry weather and the thing pumps a lot of heat into the house with air register temperatures over 110°F. These are all air source units—there is no groundwater in the desert. Natural gas is available and cheap, but about half of the owners choose heat pumps, the remainder choosing central air plus a gas furnace. The recent trend seems to be favoring heat pumps more. A close friend had a ground source heat pump installed in his Willamette Valley home (temperate, moist climate). It was beautifully quiet, compact, and tremendously efficient. When I asked if he would do it again, he said "No. The expense of excavation would not pay for itself in his lifetime." (He was about 32 at the time). For a level lot in nice sandy loam with the water table about 6 feet deep and good water flow from 2 feet deep and below, it cost $45,000 twenty years ago just to install the ground loops. I can't imagine what it would cost now. > > I'm told the units will somehow be set so that the furnace kicks in automatically when needed, but I'm wondering how that is actually determined. > > > I have owned two heat pump systems (okay three: one was an upgrade replacing another). Backup or emergency heat (same physical thing) is activated under any of several conditions: 1. During defrost cycles—which only occur during system "heat" operation. The heat pump outdoor fan is turned off, the system reverses to cooling mode to melt frost and ice built up on the outdoor unit. To keep from blowing cold air indoors at a time heat is expected, the backup heat is turned on to remove the chill. My most stupid heat pump, a 1980s relic, used a timer which ran a defrost cycle for 4 minutes out of every 45 minutes (of system "on" time) whether it was needed or not. The other two systems were much smarter and learned under what conditions defrosting might be needed, would engage defrosting every hour or two, somehow detect if it wasn't needed and return to heating within a minute. Otherwise the defrost cycle could run up to 3 or 4 minutes. 2. When the thermostat (which are necessarily specialized for heat pumps) is switched into emergency heat mode. You would do this if you did not want to run the heat pump because a tree fell on it or something. 3. When a simpler thermostat's setpoint is more than 4°F above the current room temperature, or when a smart thermostat determines that the heat pump is not going to get the temperature to the setpoint anytime soon. > > I've also heard the pump is cheaper for heating, but I am wondering about the specifics. How much cheaper would a heat pump be to run? Both run on electricity to some extent, but does the heat pump use more electricity to warm the house than the furnace, and, if so, is it enough to make up for the cost difference? > > > Yes, a heat pump uses more electricity than a furnace, which only blows air inside. A heat pump blows around air outside *and* inside, plus it runs a hefty refrigeration compressor. The [seasonal energy efficiency ratio (SEER)](https://en.wikipedia.org/wiki/Seasonal_energy_efficiency_ratio) is a measure of how much heat is moved compared to how much energy was input to move the heat. An electric furnace or electric baseboard heater would have a SEER very close to 3.8. A new window air conditioner is now required (in the U.S.) to be at least 8.0, and for an Energy Star rating, at least 14.0. Ratings of 10–12 were recently common in low end heat pumps, but the required minimum is 13.0 since 2005. As the rating increases, so does the purchase price. My Portland, Oregon, condo came with an electric furnace. When it was installed in the 1970s, electricity cost 2.2 cents per kilowatt hour; today's price is $0.07–0.11 depending on the power company. During a particularly cold winter storm c. 2004, my electric bill made it to $300 per month, mostly due to some compromised windward windows—normal winter electricity ran $50–70. I replaced the electric furnace with an 18 SEER heat pump costing $7,000; a 15 or 16 SEER version was $5,000 IIRC. Afterward, my electric bill was $45 in normal winter weather and up to $60 in severe cold, most of which was probably to run a bank of five computers 24x7. While the economics may not make perfect sense, I am sure the more "normal" electric rates which most areas have would easily make the break-even point plenty soon enough. I am really happy with having a heatpump. I would consider doing a ground source if there were a cheap way to bury the tubing, but otherwise the air source is just fine.
We had a heat pump in Pennsylvania , 1 hour north of Philadelphia, used for heating and cooling. We now , after 25 years in that home we built, have gas forced air and a central AC unit. There is no comparison. The gas heat is cheaper, stays I the room, and feels warmer. I was always cold with the heat pump, even when it kicked on to residence heat . The heat pump only provides cheap heat until you get to temps of below 32 and then it becomes less efficient and more expensive. If you can get gas heat, by all means do it. We had oil in our first home, summer /winter hock up and even that was better than the heat pump in Pennsylvania. South of Philadelphia , with milder winter temps is better for heat pumps no matter what he contractors and electric companies tell you.
27,453
We currently have a central AC unit and oil furnace. The AC is broken and the furnace is old, so we are thinking of replacing both sometime in the next year. We are considering replacing the AC with a heat pump and the oil furnace with a gas furnace in the hopes that the gas company will bring a line down our street from the main road sometime before the furnace needs to be replaced. From my understanding, the heat pump could also be used to heat the house up to a certain point in the winter. I don't know a whole lot about heat pumps, so I'm wondering how effective a heat pump would be at cooling and heating the house (currently just the first floor, about 800 sq ft, and basement), both in terms of cost effectiveness and actual comfort level of the house. Should a pump be able to cool our house on 100+ degree days to, say, 70-75 degrees? Will it be able to get our house warm enough in the winter in a reasonable amount of time? I'm told the units will somehow be set so that the furnace kicks in automatically when needed, but I'm wondering how that is actually determined. I don't want to be sitting in a cold house for hours waiting for the furnace to realize the heat pump isn't going to do the job. I've also heard the pump is cheaper for heating, but I am wondering about the specifics. How much cheaper would a heat pump be to run? Both run on electricity to some extent, but does the heat pump use more electricity to warm the house than the furnace, and, if so, is it enough to make up for the cost difference? Any other pros/cons I should be thinking about?
2013/05/01
[ "https://diy.stackexchange.com/questions/27453", "https://diy.stackexchange.com", "https://diy.stackexchange.com/users/12790/" ]
Heat pumps are quite common in Central Oregon where summer daytime highs are often over 100°F and nights below 25°F. I have been in many a heat pump rental house in winter at below 10°F in a wide range of efficiencies from below eight to over 20 SEER. They work fine. For units with a SEER of over 14 or so, the backup heat does not kick in (except for defrost cycles) in cold, dry weather and the thing pumps a lot of heat into the house with air register temperatures over 110°F. These are all air source units—there is no groundwater in the desert. Natural gas is available and cheap, but about half of the owners choose heat pumps, the remainder choosing central air plus a gas furnace. The recent trend seems to be favoring heat pumps more. A close friend had a ground source heat pump installed in his Willamette Valley home (temperate, moist climate). It was beautifully quiet, compact, and tremendously efficient. When I asked if he would do it again, he said "No. The expense of excavation would not pay for itself in his lifetime." (He was about 32 at the time). For a level lot in nice sandy loam with the water table about 6 feet deep and good water flow from 2 feet deep and below, it cost $45,000 twenty years ago just to install the ground loops. I can't imagine what it would cost now. > > I'm told the units will somehow be set so that the furnace kicks in automatically when needed, but I'm wondering how that is actually determined. > > > I have owned two heat pump systems (okay three: one was an upgrade replacing another). Backup or emergency heat (same physical thing) is activated under any of several conditions: 1. During defrost cycles—which only occur during system "heat" operation. The heat pump outdoor fan is turned off, the system reverses to cooling mode to melt frost and ice built up on the outdoor unit. To keep from blowing cold air indoors at a time heat is expected, the backup heat is turned on to remove the chill. My most stupid heat pump, a 1980s relic, used a timer which ran a defrost cycle for 4 minutes out of every 45 minutes (of system "on" time) whether it was needed or not. The other two systems were much smarter and learned under what conditions defrosting might be needed, would engage defrosting every hour or two, somehow detect if it wasn't needed and return to heating within a minute. Otherwise the defrost cycle could run up to 3 or 4 minutes. 2. When the thermostat (which are necessarily specialized for heat pumps) is switched into emergency heat mode. You would do this if you did not want to run the heat pump because a tree fell on it or something. 3. When a simpler thermostat's setpoint is more than 4°F above the current room temperature, or when a smart thermostat determines that the heat pump is not going to get the temperature to the setpoint anytime soon. > > I've also heard the pump is cheaper for heating, but I am wondering about the specifics. How much cheaper would a heat pump be to run? Both run on electricity to some extent, but does the heat pump use more electricity to warm the house than the furnace, and, if so, is it enough to make up for the cost difference? > > > Yes, a heat pump uses more electricity than a furnace, which only blows air inside. A heat pump blows around air outside *and* inside, plus it runs a hefty refrigeration compressor. The [seasonal energy efficiency ratio (SEER)](https://en.wikipedia.org/wiki/Seasonal_energy_efficiency_ratio) is a measure of how much heat is moved compared to how much energy was input to move the heat. An electric furnace or electric baseboard heater would have a SEER very close to 3.8. A new window air conditioner is now required (in the U.S.) to be at least 8.0, and for an Energy Star rating, at least 14.0. Ratings of 10–12 were recently common in low end heat pumps, but the required minimum is 13.0 since 2005. As the rating increases, so does the purchase price. My Portland, Oregon, condo came with an electric furnace. When it was installed in the 1970s, electricity cost 2.2 cents per kilowatt hour; today's price is $0.07–0.11 depending on the power company. During a particularly cold winter storm c. 2004, my electric bill made it to $300 per month, mostly due to some compromised windward windows—normal winter electricity ran $50–70. I replaced the electric furnace with an 18 SEER heat pump costing $7,000; a 15 or 16 SEER version was $5,000 IIRC. Afterward, my electric bill was $45 in normal winter weather and up to $60 in severe cold, most of which was probably to run a bank of five computers 24x7. While the economics may not make perfect sense, I am sure the more "normal" electric rates which most areas have would easily make the break-even point plenty soon enough. I am really happy with having a heatpump. I would consider doing a ground source if there were a cheap way to bury the tubing, but otherwise the air source is just fine.
How well the heat pump warms the house depends on the capacity of the heat pump and how well insulated the house is. Heat pumps definitely act a lot slower than furnaces, the temperature just kind of creeps up. In fact, in my house in New Hampshire, the temperature actually gets *lower* when the heat pump comes on because it starts blowing cold air around for 10 minutes. The way backup heat works in my house is that if the temperature gets 5-degrees lower than the thermostat, then the furnace comes on. Once the temperature gets to be about freezing, the heat pump is more annoying than helpful. During the fall and spring when the temperature is in the 50s and 60s, the heat pump is very useful because otherwise the furnace would be coming on and off all the time. As far as efficiency is concerned, it is definitely cheaper to run the heat pump when the temperature is above 45 degrees. Also, a heat pump is a lot cheaper than an air conditioner. Of course, with some $15,000 heat pump it can take a long time to justify that even if you are saving $100 a month.
612,722
I'm using the following groovy code to search a file for a string, an account number. The file I'm reading is about 30MB and contains 80,000-120,000 lines. Is there a more efficient way to find a record in a file that contains the given AcctNum? I'm a novice, so I don't know which area to investigate, the `toList()` or the for-loop. Thanks! ``` AcctNum = 1234567890 if (testfile.exists()) { lines = testfile.readLines() words = lines.toList() for (word in words) { if (word.contains(AcctNum)) { done = true; match = 'YES' ; break } chunks += 1 if (done) { break } } } ```
2009/03/04
[ "https://Stackoverflow.com/questions/612722", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
Sad to say, I don't even have Groovy installed on my current laptop - but I wouldn't expect you to have to call `toList()` at all. I'd also hope you could express the condition in a closure, but I'll have to refer to Groovy in Action to check... Having said that, do you really need it split into lines? Could you just read the whole thing using `getText()` and then just use a single call to `contains()`? EDIT: Okay, if you need to find the actual line containing the record, you do need to call `readLines()` but I don't think you need to call `toList()` afterwards. You should be able to just use: ``` for (line in lines) { if (line.contains(AcctNum)) { // Grab the results you need here break; } } ```
I should have explained it better, if I find a record with the AcctNum, I extract out other information on the record...so I thought I needed to split the file into multiple lines.
612,722
I'm using the following groovy code to search a file for a string, an account number. The file I'm reading is about 30MB and contains 80,000-120,000 lines. Is there a more efficient way to find a record in a file that contains the given AcctNum? I'm a novice, so I don't know which area to investigate, the `toList()` or the for-loop. Thanks! ``` AcctNum = 1234567890 if (testfile.exists()) { lines = testfile.readLines() words = lines.toList() for (word in words) { if (word.contains(AcctNum)) { done = true; match = 'YES' ; break } chunks += 1 if (done) { break } } } ```
2009/03/04
[ "https://Stackoverflow.com/questions/612722", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
Sad to say, I don't even have Groovy installed on my current laptop - but I wouldn't expect you to have to call `toList()` at all. I'd also hope you could express the condition in a closure, but I'll have to refer to Groovy in Action to check... Having said that, do you really need it split into lines? Could you just read the whole thing using `getText()` and then just use a single call to `contains()`? EDIT: Okay, if you need to find the actual line containing the record, you do need to call `readLines()` but I don't think you need to call `toList()` afterwards. You should be able to just use: ``` for (line in lines) { if (line.contains(AcctNum)) { // Grab the results you need here break; } } ```
When you say *efficient* you usually have to decide which direction you mean: whether it should run quickly, or use as few resources (memory, ...) as possible. Often both lie on opposite sites and you have to pick a trade-off. If you want to search memory-friendly I'd suggest reading the file line-by-line instead of reading it at once which I suspect it does (I would be wrong there, but in other languages something like readLines reads the whole file into an array of strings). If you want it to run quickly I'd suggest, as already mentioned, reading in the whole file at once and looking for the given pattern. Instead of just checking with contains you could use indexOf to get the position and then read the record as needed from that position.
612,722
I'm using the following groovy code to search a file for a string, an account number. The file I'm reading is about 30MB and contains 80,000-120,000 lines. Is there a more efficient way to find a record in a file that contains the given AcctNum? I'm a novice, so I don't know which area to investigate, the `toList()` or the for-loop. Thanks! ``` AcctNum = 1234567890 if (testfile.exists()) { lines = testfile.readLines() words = lines.toList() for (word in words) { if (word.contains(AcctNum)) { done = true; match = 'YES' ; break } chunks += 1 if (done) { break } } } ```
2009/03/04
[ "https://Stackoverflow.com/questions/612722", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
Sad to say, I don't even have Groovy installed on my current laptop - but I wouldn't expect you to have to call `toList()` at all. I'd also hope you could express the condition in a closure, but I'll have to refer to Groovy in Action to check... Having said that, do you really need it split into lines? Could you just read the whole thing using `getText()` and then just use a single call to `contains()`? EDIT: Okay, if you need to find the actual line containing the record, you do need to call `readLines()` but I don't think you need to call `toList()` afterwards. You should be able to just use: ``` for (line in lines) { if (line.contains(AcctNum)) { // Grab the results you need here break; } } ```
if you control the format of the file you are reading, the solution is to add in an index. In fact, this is how databases are able to locate records so quickly. But for 30MB of data, i think a modern computer with a decent harddrive should do the trick, instead of over complicating the program.
612,722
I'm using the following groovy code to search a file for a string, an account number. The file I'm reading is about 30MB and contains 80,000-120,000 lines. Is there a more efficient way to find a record in a file that contains the given AcctNum? I'm a novice, so I don't know which area to investigate, the `toList()` or the for-loop. Thanks! ``` AcctNum = 1234567890 if (testfile.exists()) { lines = testfile.readLines() words = lines.toList() for (word in words) { if (word.contains(AcctNum)) { done = true; match = 'YES' ; break } chunks += 1 if (done) { break } } } ```
2009/03/04
[ "https://Stackoverflow.com/questions/612722", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
When you say *efficient* you usually have to decide which direction you mean: whether it should run quickly, or use as few resources (memory, ...) as possible. Often both lie on opposite sites and you have to pick a trade-off. If you want to search memory-friendly I'd suggest reading the file line-by-line instead of reading it at once which I suspect it does (I would be wrong there, but in other languages something like readLines reads the whole file into an array of strings). If you want it to run quickly I'd suggest, as already mentioned, reading in the whole file at once and looking for the given pattern. Instead of just checking with contains you could use indexOf to get the position and then read the record as needed from that position.
I should have explained it better, if I find a record with the AcctNum, I extract out other information on the record...so I thought I needed to split the file into multiple lines.
612,722
I'm using the following groovy code to search a file for a string, an account number. The file I'm reading is about 30MB and contains 80,000-120,000 lines. Is there a more efficient way to find a record in a file that contains the given AcctNum? I'm a novice, so I don't know which area to investigate, the `toList()` or the for-loop. Thanks! ``` AcctNum = 1234567890 if (testfile.exists()) { lines = testfile.readLines() words = lines.toList() for (word in words) { if (word.contains(AcctNum)) { done = true; match = 'YES' ; break } chunks += 1 if (done) { break } } } ```
2009/03/04
[ "https://Stackoverflow.com/questions/612722", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
When you say *efficient* you usually have to decide which direction you mean: whether it should run quickly, or use as few resources (memory, ...) as possible. Often both lie on opposite sites and you have to pick a trade-off. If you want to search memory-friendly I'd suggest reading the file line-by-line instead of reading it at once which I suspect it does (I would be wrong there, but in other languages something like readLines reads the whole file into an array of strings). If you want it to run quickly I'd suggest, as already mentioned, reading in the whole file at once and looking for the given pattern. Instead of just checking with contains you could use indexOf to get the position and then read the record as needed from that position.
if you control the format of the file you are reading, the solution is to add in an index. In fact, this is how databases are able to locate records so quickly. But for 30MB of data, i think a modern computer with a decent harddrive should do the trick, instead of over complicating the program.
14,466,591
I tried some stuff I found in past questions but unfortunately it hasn't helped. I think the reason may be it is deeply buried in CSS classes and I'm just inexperienced and not targeting it accurately, despite my attempts to use Chrome's inspect element to find exactly where it is. This is the code I have: ``` .multilanguage-widget.readmore ul.display-posts-listing li.listing-item a.current { font-weight: bold !important; } ``` and this is the page example I'm trying to do it on [here](http://lumistaging.designiscasual.com/biometrics/). See the list of Capabilities to the right side. Please help, I've been struggling with this for quite a while now and all my attempts have been failing.
2013/01/22
[ "https://Stackoverflow.com/questions/14466591", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2001526/" ]
If you are aiming for an exclusion regex according to the Schema Central parser requirement, you are almost there. The first half, excluding percent signs not followed by two hexadecimal digits is best solved using a *negative look-ahead assertion*; the second half is fine, though you can ditch the last repeat indicator without affecting your results: ``` (%(?![0-9A-F]{2})|#.*#) ``` Compile your regex with case independence (`i` flag) and you are good to go. Recommended reading: the Python Standard Library’s [chapter on Regular Expression Operation Syntax](http://docs.python.org/2/library/re.html#regular-expression-syntax).
I recently had to do this without a negative lookahead, and the following seems to work: `(%.?[^0-9A-Fa-f]|#.*#)`
7,426,844
I've been building a nested query editor in knockoutjs and added animations to it using the beforeRemove and afterAdd options on a template in foreach mode. It works just fine on the first level of nesting, but not when manipulating filters in a child filter group. Am I doing something wrong, or is this a bug in KnockoutJS? Is afterAdd and beforeRemove not supported for nested templates? If so, is there a workaround? Here is [my jsfiddle of the problem](http://jsfiddle.net/daedalus28/98GwD/). Also, is there a way to change the animation behaviour based on what is being added/removed? I'd like to have different animations for adding/removing filter groups then adding/removing filters themselves.
2011/09/15
[ "https://Stackoverflow.com/questions/7426844", "https://Stackoverflow.com", "https://Stackoverflow.com/users/609641/" ]
You are running into the issue described in this [post](http://www.knockmeout.net/2011/03/are-your-templates-working-overtime.html). Basically, your inner template depends on $data.filters and ends up re-rendering the entire template whenever an item is added. So, your animation is not happening, because the entire list is getting re-rendered from scratch each time. Here is the sample with a small amount of re-factoring in the template to push the "if" logic into the template binding: <http://jsfiddle.net/rniemeyer/UkGTF/> Also, if you start using [1.3beta](http://blog.stevensanderson.com/2011/08/31/knockout-1-3-0-beta-available/) with native templates, then you can use `if`, `with`, and `foreach` control-flow bindings to simplify this further.
I figured out the second part of the question myself. For the benefit of anyone who may have landed here from google: I switched the afterAdd and beforeRemove functions to be explicitly declared (and out of the markup), and then did some checks on the elem element with jQuery to figure out whether it's a filter or filter group, applying different animations appropriately. Here is the [final fiddle](http://jsfiddle.net/daedalus28/vpjhZ/)
15,009,022
I was reading this <http://msdn.microsoft.com/en-us/library/87d83y5b(v=vs.80).aspx> but I am wondering, what is the difference between or benefit of using interfaces as opposed to simply creating a class with properties and adding it to your class via "`using MyClass.cs`?" It seems like either way you have to instantiate the method or property class... Thanks for your advice.
2013/02/21
[ "https://Stackoverflow.com/questions/15009022", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1477388/" ]
An interface is *not* so you can use the interface's objects. It's, rather, so that you *must* **create** those objects.
Several different classes may all implement the same interface and thus share a specific set of characteristics. E.g. all types that implement the `IEnumerable` interface may be enumerated without having anything else in common. Interfaces allows less restrictive way for types to support specific features.
15,009,022
I was reading this <http://msdn.microsoft.com/en-us/library/87d83y5b(v=vs.80).aspx> but I am wondering, what is the difference between or benefit of using interfaces as opposed to simply creating a class with properties and adding it to your class via "`using MyClass.cs`?" It seems like either way you have to instantiate the method or property class... Thanks for your advice.
2013/02/21
[ "https://Stackoverflow.com/questions/15009022", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1477388/" ]
Several different classes may all implement the same interface and thus share a specific set of characteristics. E.g. all types that implement the `IEnumerable` interface may be enumerated without having anything else in common. Interfaces allows less restrictive way for types to support specific features.
I don't see how the two are even similar. An interface defines how your code is used by clients. The using keyword (which should be followed by a namespace name rather than a file name) simply lets you use objects in that namespace without prefixing them with the entire namespace each time. A more common question is what is the difference between implementing an interface and deriving from a class. Maybe that is what you were trying to ask. That question has been covered pretty extensively elsewhere.
15,009,022
I was reading this <http://msdn.microsoft.com/en-us/library/87d83y5b(v=vs.80).aspx> but I am wondering, what is the difference between or benefit of using interfaces as opposed to simply creating a class with properties and adding it to your class via "`using MyClass.cs`?" It seems like either way you have to instantiate the method or property class... Thanks for your advice.
2013/02/21
[ "https://Stackoverflow.com/questions/15009022", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1477388/" ]
Several different classes may all implement the same interface and thus share a specific set of characteristics. E.g. all types that implement the `IEnumerable` interface may be enumerated without having anything else in common. Interfaces allows less restrictive way for types to support specific features.
Interface only contains the signature of your logic. It must be implemented fully in your child class. We use "using" clause when we want to include namespace which is different then the namespace of your project, but if your class or interface is in the same namespace you don't need to use "using" clause. You can inherit your child class with interfaces and make your code more flexible. An example of it would be: ``` public interface IClown { string FunnyThingIHave { get; } void Honk(); } public class TallGuy : IClown { public string FunnyThingIHave { get { return "big shoes"; } } public void Honk() { MessageBox.Show("Honk honk!"); } } public class Joker:IClown { public string FunnyThingIHave { get {return "I have a clown car"} } public void Honk() { MessageBox.Show("Honk Bonk"); } } public class FunnyClowns { Joker joker = new Joker(); TallGuy tguy = new TallGuy(); string WhichFunnyThingIWant(IClown clownType) { clownType.Honk(); } } ``` Now what this is doing is defining a clown interface and then defining two child classes for it then a third class can dynamically call the clowntype object of IClown. This is a simple example but this kind of logic can be applied in many other situations. That is where interfaces can be really helpful. I hope this helps..