qid
int64
1
74.7M
question
stringlengths
15
58.3k
date
stringlengths
10
10
metadata
list
response_j
stringlengths
4
30.2k
response_k
stringlengths
11
36.5k
226,599
So I have xml that looks like this: ```html <todo-list> <id type="integer">#{id}</id> <name>#{name}</name> <description>#{description}</description> <project-id type="integer">#{project_id}</project-id> <milestone-id type="integer">#{milestone_id}</milestone-id> <position type="integer">#{position}</position> <!-- if user can see private lists --> <private type="boolean">#{private}</private> <!-- if the account supports time tracking --> <tracked type="boolean">#{tracked}</tracked> <!-- if todo-items are included in the response --> <todo-items type="array"> <todo-item> ... </todo-item> <todo-item> ... </todo-item> ... </todo-items> </todo-list> ``` How would I go about using .NET's serialization library to deserialize this into C# objects? Currently I'm using reflection and I map between the xml and my objects using the naming conventions.
2008/10/22
[ "https://Stackoverflow.com/questions/226599", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9401/" ]
Boils down to using xsd.exe from tools in VS: ``` xsd.exe "%xsdFile%" /c /out:"%outDirectory%" /l:"%language%" ``` Then load it with reader and deserializer: ``` public GeneratedClassFromXSD GetObjectFromXML() { var settings = new XmlReaderSettings(); var obj = new GeneratedClassFromXSD(); var reader = XmlReader.Create(urlToService, settings); var serializer = new System.Xml.Serialization.XmlSerializer(typeof(GeneratedClassFromXSD)); obj = (GeneratedClassFromXSD)serializer.Deserialize(reader); reader.Close(); return obj; } ```
Checkout <http://xsd2code.codeplex.com/> Xsd2Code is a CSharp or Visual Basic Business Entity class Generator from XSD schema.
226,599
So I have xml that looks like this: ```html <todo-list> <id type="integer">#{id}</id> <name>#{name}</name> <description>#{description}</description> <project-id type="integer">#{project_id}</project-id> <milestone-id type="integer">#{milestone_id}</milestone-id> <position type="integer">#{position}</position> <!-- if user can see private lists --> <private type="boolean">#{private}</private> <!-- if the account supports time tracking --> <tracked type="boolean">#{tracked}</tracked> <!-- if todo-items are included in the response --> <todo-items type="array"> <todo-item> ... </todo-item> <todo-item> ... </todo-item> ... </todo-items> </todo-list> ``` How would I go about using .NET's serialization library to deserialize this into C# objects? Currently I'm using reflection and I map between the xml and my objects using the naming conventions.
2008/10/22
[ "https://Stackoverflow.com/questions/226599", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9401/" ]
Deserialize any object, as long as the type `T` is marked Serializable: ``` function T Deserialize<T>(string serializedResults) { var serializer = new XmlSerializer(typeof(T)); using (var stringReader = new StringReader(serializedResults)) return (T)serializer.Deserialize(stringReader); } ```
Checkout <http://xsd2code.codeplex.com/> Xsd2Code is a CSharp or Visual Basic Business Entity class Generator from XSD schema.
226,599
So I have xml that looks like this: ```html <todo-list> <id type="integer">#{id}</id> <name>#{name}</name> <description>#{description}</description> <project-id type="integer">#{project_id}</project-id> <milestone-id type="integer">#{milestone_id}</milestone-id> <position type="integer">#{position}</position> <!-- if user can see private lists --> <private type="boolean">#{private}</private> <!-- if the account supports time tracking --> <tracked type="boolean">#{tracked}</tracked> <!-- if todo-items are included in the response --> <todo-items type="array"> <todo-item> ... </todo-item> <todo-item> ... </todo-item> ... </todo-items> </todo-list> ``` How would I go about using .NET's serialization library to deserialize this into C# objects? Currently I'm using reflection and I map between the xml and my objects using the naming conventions.
2008/10/22
[ "https://Stackoverflow.com/questions/226599", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9401/" ]
Create a class for each element that has a property for each element and a List or Array of objects (use the created one) for each child element. Then call System.Xml.Serialization.XmlSerializer.Deserialize on the string and cast the result as your object. Use the System.Xml.Serialization attributes to make adjustments, like to map the element to your ToDoList class, use the XmlElement("todo-list") attribute. A shourtcut is to load your XML into Visual Studio, click the "Infer Schema" button and run "xsd.exe /c schema.xsd" to generate the classes. xsd.exe is in the tools folder. Then go through the generated code and make adjustments, such as changing shorts to ints where appropriate.
Boils down to using xsd.exe from tools in VS: ``` xsd.exe "%xsdFile%" /c /out:"%outDirectory%" /l:"%language%" ``` Then load it with reader and deserializer: ``` public GeneratedClassFromXSD GetObjectFromXML() { var settings = new XmlReaderSettings(); var obj = new GeneratedClassFromXSD(); var reader = XmlReader.Create(urlToService, settings); var serializer = new System.Xml.Serialization.XmlSerializer(typeof(GeneratedClassFromXSD)); obj = (GeneratedClassFromXSD)serializer.Deserialize(reader); reader.Close(); return obj; } ```
226,599
So I have xml that looks like this: ```html <todo-list> <id type="integer">#{id}</id> <name>#{name}</name> <description>#{description}</description> <project-id type="integer">#{project_id}</project-id> <milestone-id type="integer">#{milestone_id}</milestone-id> <position type="integer">#{position}</position> <!-- if user can see private lists --> <private type="boolean">#{private}</private> <!-- if the account supports time tracking --> <tracked type="boolean">#{tracked}</tracked> <!-- if todo-items are included in the response --> <todo-items type="array"> <todo-item> ... </todo-item> <todo-item> ... </todo-item> ... </todo-items> </todo-list> ``` How would I go about using .NET's serialization library to deserialize this into C# objects? Currently I'm using reflection and I map between the xml and my objects using the naming conventions.
2008/10/22
[ "https://Stackoverflow.com/questions/226599", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9401/" ]
Boils down to using xsd.exe from tools in VS: ``` xsd.exe "%xsdFile%" /c /out:"%outDirectory%" /l:"%language%" ``` Then load it with reader and deserializer: ``` public GeneratedClassFromXSD GetObjectFromXML() { var settings = new XmlReaderSettings(); var obj = new GeneratedClassFromXSD(); var reader = XmlReader.Create(urlToService, settings); var serializer = new System.Xml.Serialization.XmlSerializer(typeof(GeneratedClassFromXSD)); obj = (GeneratedClassFromXSD)serializer.Deserialize(reader); reader.Close(); return obj; } ```
i had the same questions few years back that how abt mapping xml to C# classes or creating C# classes which are mapped to our XMLs, jst like we do in entity Framework (we map tables to C# classes). I created a framework finally, which can create C# classes out of your XML and these classes can be used to read/write your xml. Have a [look](http://www.stepupframeworks.com/Home/products/xml-object-mapping-xom/)
226,599
So I have xml that looks like this: ```html <todo-list> <id type="integer">#{id}</id> <name>#{name}</name> <description>#{description}</description> <project-id type="integer">#{project_id}</project-id> <milestone-id type="integer">#{milestone_id}</milestone-id> <position type="integer">#{position}</position> <!-- if user can see private lists --> <private type="boolean">#{private}</private> <!-- if the account supports time tracking --> <tracked type="boolean">#{tracked}</tracked> <!-- if todo-items are included in the response --> <todo-items type="array"> <todo-item> ... </todo-item> <todo-item> ... </todo-item> ... </todo-items> </todo-list> ``` How would I go about using .NET's serialization library to deserialize this into C# objects? Currently I'm using reflection and I map between the xml and my objects using the naming conventions.
2008/10/22
[ "https://Stackoverflow.com/questions/226599", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9401/" ]
Create a class for each element that has a property for each element and a List or Array of objects (use the created one) for each child element. Then call System.Xml.Serialization.XmlSerializer.Deserialize on the string and cast the result as your object. Use the System.Xml.Serialization attributes to make adjustments, like to map the element to your ToDoList class, use the XmlElement("todo-list") attribute. A shourtcut is to load your XML into Visual Studio, click the "Infer Schema" button and run "xsd.exe /c schema.xsd" to generate the classes. xsd.exe is in the tools folder. Then go through the generated code and make adjustments, such as changing shorts to ints where appropriate.
Checkout <http://xsd2code.codeplex.com/> Xsd2Code is a CSharp or Visual Basic Business Entity class Generator from XSD schema.
226,599
So I have xml that looks like this: ```html <todo-list> <id type="integer">#{id}</id> <name>#{name}</name> <description>#{description}</description> <project-id type="integer">#{project_id}</project-id> <milestone-id type="integer">#{milestone_id}</milestone-id> <position type="integer">#{position}</position> <!-- if user can see private lists --> <private type="boolean">#{private}</private> <!-- if the account supports time tracking --> <tracked type="boolean">#{tracked}</tracked> <!-- if todo-items are included in the response --> <todo-items type="array"> <todo-item> ... </todo-item> <todo-item> ... </todo-item> ... </todo-items> </todo-list> ``` How would I go about using .NET's serialization library to deserialize this into C# objects? Currently I'm using reflection and I map between the xml and my objects using the naming conventions.
2008/10/22
[ "https://Stackoverflow.com/questions/226599", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9401/" ]
Create a class for each element that has a property for each element and a List or Array of objects (use the created one) for each child element. Then call System.Xml.Serialization.XmlSerializer.Deserialize on the string and cast the result as your object. Use the System.Xml.Serialization attributes to make adjustments, like to map the element to your ToDoList class, use the XmlElement("todo-list") attribute. A shourtcut is to load your XML into Visual Studio, click the "Infer Schema" button and run "xsd.exe /c schema.xsd" to generate the classes. xsd.exe is in the tools folder. Then go through the generated code and make adjustments, such as changing shorts to ints where appropriate.
Well, you'd have to have classes in your assembly that match, roughly, the XML (property called Private, a collection property called ToDo, etc). The problem is that **the XML has elements that are invalid for class names**. So you'd have to implement IXmlSerializable in these classes to control how they are serialized to and from XML. You might be able to get away with using some of the xml serialization specific attributes as well, but that depends on your xml's schema. That's a step above using reflection, but it might not be exactly what you're hoping for.
55,390,770
I am trying to write a simple express/node.js app that responds to GET requests using data found in a csv file. I would like to read this csv file to generate a javascript object (essentially a key-value mapping), and then make that generated map available for the HTTP request handling logic in the controller. I wrote a module that reads the csv files and exports the desired objects, but I'm not sure how to ensure: 1. This operation completes and the objects actually exist before HTTP requests are handled 2. The file operation is performed only a single time when the server starts up and not once per request incurring massive overhead How can I organize my code to meet these goals in the context of an express app? This is how I am processing the CSV file: ``` var myMap = {}; fs.createReadStream('filename.csv') .pipe(csv()) .on('data', (row) => { // Build javascript object myMap[row['key']] = row['value']; }) .on('end', () => { console.log('Done.'); }); // Does this work? module.exports = myMap; ```
2019/03/28
[ "https://Stackoverflow.com/questions/55390770", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11270096/" ]
How about ensuring http object listens after the file is loaded into memory: ```js // server.js var myMap = {}; function readCsv(cb){ fs.createReadStream('filename.csv') .pipe(csv()) .on('data', (row) => { // Build javascript object myMap[row['key']] = row['value']; }) .on('end', () => { console.log('Done.'); cb(); }); } var app = express(); exports = Object.freeze({ server: http.createServer(app) init(){ readCsv(() => { this.server.listen(80) }) } }) ``` Something like that. You can also utilize Promise ```js // server.js var myMap = {}; function readCsv(){ return new Promise((resolve, reject) => { fs.createReadStream('filename.csv') .pipe(csv()) .on('data', (row) => { // Build javascript object myMap[row['key']] = row['value']; }) .on('end', () => { console.log('Done.'); resolve(); }) .on('error', reject) }) } var app = express(); exports = Object.freeze({ server: http.createServer(app) init(){ return readCsv().then(() => { this.server.listen(80) }) } }) ```
In order to meet both of your goals, you can include the code in the app.js file. App.js only runs when the express server starts. It doesn't reload on page refresh. You can run app.listen after the readstream ends. ``` var myMap = {}; fs.createReadStream('filename.csv') .pipe(csv()) .on('data', (row) => { // Build javascript object myMap[row['key']] = row['value']; }) .on('end', () => { app.listen(port, () => console.log(`Example app listening on port ${port}!`)); }); ``` However, since I don't think you're going to have a lot of data, it's better to use a synchronous (blocking) methods, for both the csv parser and file reader. This just makes it easier to understand. I use [csv-parse](https://csv.js.org/parse/api/#sync-api) below. ``` const express = require('express') const fs = require('fs') const parse = require('csv-parse/lib/sync') const app = express() const port = 3000 /* In this example assume myMap will be / ` / "key_1","key_2" / "value 1","value 2" / ` */ var myMap = fs.readFileSync('sample.csv', 'utf8'); /* parsing the csv will return: / [Object {key_1: "value 1", key_2: "value 2"}] */ const records = parse(myMap, { columns: true, skip_empty_lines: true }) app.get('/', (req, res) => res.send('Hello World!' + records[0].key_1)) app.listen(port, () => console.log(`Example app listening on port ${port}!`)) ``` [test it on runkit](https://runkit.com/pooya-raz/check-if-object-is-empty-before-running-app-listen)
55,390,770
I am trying to write a simple express/node.js app that responds to GET requests using data found in a csv file. I would like to read this csv file to generate a javascript object (essentially a key-value mapping), and then make that generated map available for the HTTP request handling logic in the controller. I wrote a module that reads the csv files and exports the desired objects, but I'm not sure how to ensure: 1. This operation completes and the objects actually exist before HTTP requests are handled 2. The file operation is performed only a single time when the server starts up and not once per request incurring massive overhead How can I organize my code to meet these goals in the context of an express app? This is how I am processing the CSV file: ``` var myMap = {}; fs.createReadStream('filename.csv') .pipe(csv()) .on('data', (row) => { // Build javascript object myMap[row['key']] = row['value']; }) .on('end', () => { console.log('Done.'); }); // Does this work? module.exports = myMap; ```
2019/03/28
[ "https://Stackoverflow.com/questions/55390770", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11270096/" ]
How about ensuring http object listens after the file is loaded into memory: ```js // server.js var myMap = {}; function readCsv(cb){ fs.createReadStream('filename.csv') .pipe(csv()) .on('data', (row) => { // Build javascript object myMap[row['key']] = row['value']; }) .on('end', () => { console.log('Done.'); cb(); }); } var app = express(); exports = Object.freeze({ server: http.createServer(app) init(){ readCsv(() => { this.server.listen(80) }) } }) ``` Something like that. You can also utilize Promise ```js // server.js var myMap = {}; function readCsv(){ return new Promise((resolve, reject) => { fs.createReadStream('filename.csv') .pipe(csv()) .on('data', (row) => { // Build javascript object myMap[row['key']] = row['value']; }) .on('end', () => { console.log('Done.'); resolve(); }) .on('error', reject) }) } var app = express(); exports = Object.freeze({ server: http.createServer(app) init(){ return readCsv().then(() => { this.server.listen(80) }) } }) ```
I would look for more synchronous way to read file and handle http request. Here is sample code of what it should look like, ``` import fs from 'fs'; async function processCSV() { try { let map = await readCsv(); //handle http request in another function with same async await way let http = await processHttpRequest(map); // process the http response } catch (e) { console.log('e', e); } } function readCsv() { let myMap = []; fs.createReadStream('filename.csv') .pipe(csv()) .on('data', (row) => { // Build javascript object return myMap[row['key']] = row['value']; }) .on('end', () => { console.log('Done.'); }); } async function processHttpRequest(map) { try { let reqres = await httpReuqest(map); // Your defined function for httpReuqest } catch (e) { } } processCSV(); processHttpReuqet(); ```
55,390,770
I am trying to write a simple express/node.js app that responds to GET requests using data found in a csv file. I would like to read this csv file to generate a javascript object (essentially a key-value mapping), and then make that generated map available for the HTTP request handling logic in the controller. I wrote a module that reads the csv files and exports the desired objects, but I'm not sure how to ensure: 1. This operation completes and the objects actually exist before HTTP requests are handled 2. The file operation is performed only a single time when the server starts up and not once per request incurring massive overhead How can I organize my code to meet these goals in the context of an express app? This is how I am processing the CSV file: ``` var myMap = {}; fs.createReadStream('filename.csv') .pipe(csv()) .on('data', (row) => { // Build javascript object myMap[row['key']] = row['value']; }) .on('end', () => { console.log('Done.'); }); // Does this work? module.exports = myMap; ```
2019/03/28
[ "https://Stackoverflow.com/questions/55390770", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11270096/" ]
How about ensuring http object listens after the file is loaded into memory: ```js // server.js var myMap = {}; function readCsv(cb){ fs.createReadStream('filename.csv') .pipe(csv()) .on('data', (row) => { // Build javascript object myMap[row['key']] = row['value']; }) .on('end', () => { console.log('Done.'); cb(); }); } var app = express(); exports = Object.freeze({ server: http.createServer(app) init(){ readCsv(() => { this.server.listen(80) }) } }) ``` Something like that. You can also utilize Promise ```js // server.js var myMap = {}; function readCsv(){ return new Promise((resolve, reject) => { fs.createReadStream('filename.csv') .pipe(csv()) .on('data', (row) => { // Build javascript object myMap[row['key']] = row['value']; }) .on('end', () => { console.log('Done.'); resolve(); }) .on('error', reject) }) } var app = express(); exports = Object.freeze({ server: http.createServer(app) init(){ return readCsv().then(() => { this.server.listen(80) }) } }) ```
**Update:** use <https://csv.js.org/parse/> Below one is deprecated, not maintained anymore. **Deprecated:** Hi I have created an npm package to read CSV synchronously or as a promise : <https://www.npmjs.com/package/csv-parser-sync-plus-promise> **Description:** **csv-parser-sync-plus-promise** A module to read csv synchronously or as promise **Features** now read any csv synchronously or as promise. Choice is yours **Usage** ``` let parser = require('csv-parser-sync-plus-promise') ``` // for sync ``` let a=parser.readCsvSync('<filepath>') ``` // for promise ``` let b=parser.readCsvPromise('<filepath>') **Note:** You can use both fully qualified and relative paths <filepath> ``` **Errors** All errors will be printed as console.error and the process will exit with exit code 222
55,390,770
I am trying to write a simple express/node.js app that responds to GET requests using data found in a csv file. I would like to read this csv file to generate a javascript object (essentially a key-value mapping), and then make that generated map available for the HTTP request handling logic in the controller. I wrote a module that reads the csv files and exports the desired objects, but I'm not sure how to ensure: 1. This operation completes and the objects actually exist before HTTP requests are handled 2. The file operation is performed only a single time when the server starts up and not once per request incurring massive overhead How can I organize my code to meet these goals in the context of an express app? This is how I am processing the CSV file: ``` var myMap = {}; fs.createReadStream('filename.csv') .pipe(csv()) .on('data', (row) => { // Build javascript object myMap[row['key']] = row['value']; }) .on('end', () => { console.log('Done.'); }); // Does this work? module.exports = myMap; ```
2019/03/28
[ "https://Stackoverflow.com/questions/55390770", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11270096/" ]
I would look for more synchronous way to read file and handle http request. Here is sample code of what it should look like, ``` import fs from 'fs'; async function processCSV() { try { let map = await readCsv(); //handle http request in another function with same async await way let http = await processHttpRequest(map); // process the http response } catch (e) { console.log('e', e); } } function readCsv() { let myMap = []; fs.createReadStream('filename.csv') .pipe(csv()) .on('data', (row) => { // Build javascript object return myMap[row['key']] = row['value']; }) .on('end', () => { console.log('Done.'); }); } async function processHttpRequest(map) { try { let reqres = await httpReuqest(map); // Your defined function for httpReuqest } catch (e) { } } processCSV(); processHttpReuqet(); ```
In order to meet both of your goals, you can include the code in the app.js file. App.js only runs when the express server starts. It doesn't reload on page refresh. You can run app.listen after the readstream ends. ``` var myMap = {}; fs.createReadStream('filename.csv') .pipe(csv()) .on('data', (row) => { // Build javascript object myMap[row['key']] = row['value']; }) .on('end', () => { app.listen(port, () => console.log(`Example app listening on port ${port}!`)); }); ``` However, since I don't think you're going to have a lot of data, it's better to use a synchronous (blocking) methods, for both the csv parser and file reader. This just makes it easier to understand. I use [csv-parse](https://csv.js.org/parse/api/#sync-api) below. ``` const express = require('express') const fs = require('fs') const parse = require('csv-parse/lib/sync') const app = express() const port = 3000 /* In this example assume myMap will be / ` / "key_1","key_2" / "value 1","value 2" / ` */ var myMap = fs.readFileSync('sample.csv', 'utf8'); /* parsing the csv will return: / [Object {key_1: "value 1", key_2: "value 2"}] */ const records = parse(myMap, { columns: true, skip_empty_lines: true }) app.get('/', (req, res) => res.send('Hello World!' + records[0].key_1)) app.listen(port, () => console.log(`Example app listening on port ${port}!`)) ``` [test it on runkit](https://runkit.com/pooya-raz/check-if-object-is-empty-before-running-app-listen)
55,390,770
I am trying to write a simple express/node.js app that responds to GET requests using data found in a csv file. I would like to read this csv file to generate a javascript object (essentially a key-value mapping), and then make that generated map available for the HTTP request handling logic in the controller. I wrote a module that reads the csv files and exports the desired objects, but I'm not sure how to ensure: 1. This operation completes and the objects actually exist before HTTP requests are handled 2. The file operation is performed only a single time when the server starts up and not once per request incurring massive overhead How can I organize my code to meet these goals in the context of an express app? This is how I am processing the CSV file: ``` var myMap = {}; fs.createReadStream('filename.csv') .pipe(csv()) .on('data', (row) => { // Build javascript object myMap[row['key']] = row['value']; }) .on('end', () => { console.log('Done.'); }); // Does this work? module.exports = myMap; ```
2019/03/28
[ "https://Stackoverflow.com/questions/55390770", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11270096/" ]
I would look for more synchronous way to read file and handle http request. Here is sample code of what it should look like, ``` import fs from 'fs'; async function processCSV() { try { let map = await readCsv(); //handle http request in another function with same async await way let http = await processHttpRequest(map); // process the http response } catch (e) { console.log('e', e); } } function readCsv() { let myMap = []; fs.createReadStream('filename.csv') .pipe(csv()) .on('data', (row) => { // Build javascript object return myMap[row['key']] = row['value']; }) .on('end', () => { console.log('Done.'); }); } async function processHttpRequest(map) { try { let reqres = await httpReuqest(map); // Your defined function for httpReuqest } catch (e) { } } processCSV(); processHttpReuqet(); ```
**Update:** use <https://csv.js.org/parse/> Below one is deprecated, not maintained anymore. **Deprecated:** Hi I have created an npm package to read CSV synchronously or as a promise : <https://www.npmjs.com/package/csv-parser-sync-plus-promise> **Description:** **csv-parser-sync-plus-promise** A module to read csv synchronously or as promise **Features** now read any csv synchronously or as promise. Choice is yours **Usage** ``` let parser = require('csv-parser-sync-plus-promise') ``` // for sync ``` let a=parser.readCsvSync('<filepath>') ``` // for promise ``` let b=parser.readCsvPromise('<filepath>') **Note:** You can use both fully qualified and relative paths <filepath> ``` **Errors** All errors will be printed as console.error and the process will exit with exit code 222
17,205,224
In UINavigationController this is child controller ``` .h @protocol childProtocol <NSObject> -(void)childMethod:(NSArray*)params; @end @property (strong, nonatomic) id<childProtocol>childDelegate; @property (weak, nonatomic) parentVC *pVC; ``` --- ``` .m if([self.childDelegate respondsToSelector:@selector(childMethod:)]) { [self.childDelegate performSelector:@selector(childMethod:) withObject:self.arry]; } ``` This is my parent controller ``` .m -(void)childMethod:(NSArray *)params { // some work } ... childVC *cVC = [[childVC alloc]init]; cVC.pVC = self; ``` But childMethod: is not getting called so I searched on internet and got this post [UINavigationControllers: How to pass value to higher (parent?) controller in stack?](https://stackoverflow.com/questions/6800226/uinavigationcontrollers-how-to-pass-value-to-higher-parent-controller-in-sta) I tried to create a weak reference but dont know how to use to make delegate pass data from child to parent?
2013/06/20
[ "https://Stackoverflow.com/questions/17205224", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1382104/" ]
This is child controller.h ``` @protocol childProtocol <NSObject> -(void)childMethod:(NSArray*)params; @end @property (strong, nonatomic) id<childProtocol>childDelegate; @property (weak, nonatomic) parentVC *pVC; ``` .m ``` if([self.childDelegate respondsToSelector:@selector(childMethod:)]) { [self.childDelegate performSelector:@selector(childMethod:) withObject:self.arry]; } ``` This is my parent controller.h ``` #import <UIKit/UIKit.h> #import "ChildController.h" @interface perentController : UIViewController < childProtocol > ``` .m ``` - (void)childMethod:(NSArray *)params { // some work } ``` **EDITED :** And Dont Forget to add `childViewOBJ.childDelegate = self;` at the time of create `ChildViewController's` object. such like, ``` childVC *cVC = [[childVC alloc]init]; cVC.childDelegate = self; cVC.pVC = self; [self presentModalViewController:cVC animated:YES]; ``` For More information about [How to create/use of Protocol.](https://stackoverflow.com/questions/6203799/dismissmodalviewcontroller-and-pass-data-back)
First of all, you are not checking for the same selector as you declared in your protocol declaration so it won't respond to that. You declared the method `childMethod:` whereas you are checking if your childDelegate responds to `myMethod:` selector which does not so it won't go into the if condition. Also the parent view controller is missing the implementation the method `childMethod:` in its .m. Implement that in your parent view controller or it will crash because of not finding the exact selector definition. Since you are using a `UINavigationController`, the parent view controller won't be lost till the child view controller exist so the `childDelegate` property must not be strong unless you intend to hold onto your delegate in child view controller for some reason.
17,205,224
In UINavigationController this is child controller ``` .h @protocol childProtocol <NSObject> -(void)childMethod:(NSArray*)params; @end @property (strong, nonatomic) id<childProtocol>childDelegate; @property (weak, nonatomic) parentVC *pVC; ``` --- ``` .m if([self.childDelegate respondsToSelector:@selector(childMethod:)]) { [self.childDelegate performSelector:@selector(childMethod:) withObject:self.arry]; } ``` This is my parent controller ``` .m -(void)childMethod:(NSArray *)params { // some work } ... childVC *cVC = [[childVC alloc]init]; cVC.pVC = self; ``` But childMethod: is not getting called so I searched on internet and got this post [UINavigationControllers: How to pass value to higher (parent?) controller in stack?](https://stackoverflow.com/questions/6800226/uinavigationcontrollers-how-to-pass-value-to-higher-parent-controller-in-sta) I tried to create a weak reference but dont know how to use to make delegate pass data from child to parent?
2013/06/20
[ "https://Stackoverflow.com/questions/17205224", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1382104/" ]
Try this. Check the sample project attached **ParentViewController.h** ``` #import <UIKit/UIKit.h> @interface ParentViewController : UIViewController - (void)passData:(NSString *)strText; @end ``` **ParentViewController.m** ``` - (IBAction)btnGoToSecondView:(id)sender { ChildViewController *secondVC = [[ChildViewController alloc] initWithNibName:@"ChildViewController" bundle:nil]; secondVC.delegate = self; [self presentViewController:secondVC animated:YES completion:nil]; } - (void)passData:(NSString *)strText { NSLog(@"Data Passed = %@",strText); } ``` **ChildViewController.h** ``` #import <UIKit/UIKit.h> #import "ParentViewController.h" @class ParentViewController; @interface ChildViewController : UIViewController @property(nonatomic, assign) ParentViewController *delegate; @end ``` **ChildViewController.m** ``` - (IBAction)btnPassDataBack:(id)sender { if([self.delegate respondsToSelector:@selector(passData:)]) { [self.delegate passData:@"Hello"]; } [self dismissViewControllerAnimated:YES completion:nil]; } ``` [Sample Project](https://www.dropbox.com/s/ilb0mpi0ia2fd9f/DelegateExample.zip)
This is child controller.h ``` @protocol childProtocol <NSObject> -(void)childMethod:(NSArray*)params; @end @property (strong, nonatomic) id<childProtocol>childDelegate; @property (weak, nonatomic) parentVC *pVC; ``` .m ``` if([self.childDelegate respondsToSelector:@selector(childMethod:)]) { [self.childDelegate performSelector:@selector(childMethod:) withObject:self.arry]; } ``` This is my parent controller.h ``` #import <UIKit/UIKit.h> #import "ChildController.h" @interface perentController : UIViewController < childProtocol > ``` .m ``` - (void)childMethod:(NSArray *)params { // some work } ``` **EDITED :** And Dont Forget to add `childViewOBJ.childDelegate = self;` at the time of create `ChildViewController's` object. such like, ``` childVC *cVC = [[childVC alloc]init]; cVC.childDelegate = self; cVC.pVC = self; [self presentModalViewController:cVC animated:YES]; ``` For More information about [How to create/use of Protocol.](https://stackoverflow.com/questions/6203799/dismissmodalviewcontroller-and-pass-data-back)
17,205,224
In UINavigationController this is child controller ``` .h @protocol childProtocol <NSObject> -(void)childMethod:(NSArray*)params; @end @property (strong, nonatomic) id<childProtocol>childDelegate; @property (weak, nonatomic) parentVC *pVC; ``` --- ``` .m if([self.childDelegate respondsToSelector:@selector(childMethod:)]) { [self.childDelegate performSelector:@selector(childMethod:) withObject:self.arry]; } ``` This is my parent controller ``` .m -(void)childMethod:(NSArray *)params { // some work } ... childVC *cVC = [[childVC alloc]init]; cVC.pVC = self; ``` But childMethod: is not getting called so I searched on internet and got this post [UINavigationControllers: How to pass value to higher (parent?) controller in stack?](https://stackoverflow.com/questions/6800226/uinavigationcontrollers-how-to-pass-value-to-higher-parent-controller-in-sta) I tried to create a weak reference but dont know how to use to make delegate pass data from child to parent?
2013/06/20
[ "https://Stackoverflow.com/questions/17205224", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1382104/" ]
Try this. Check the sample project attached **ParentViewController.h** ``` #import <UIKit/UIKit.h> @interface ParentViewController : UIViewController - (void)passData:(NSString *)strText; @end ``` **ParentViewController.m** ``` - (IBAction)btnGoToSecondView:(id)sender { ChildViewController *secondVC = [[ChildViewController alloc] initWithNibName:@"ChildViewController" bundle:nil]; secondVC.delegate = self; [self presentViewController:secondVC animated:YES completion:nil]; } - (void)passData:(NSString *)strText { NSLog(@"Data Passed = %@",strText); } ``` **ChildViewController.h** ``` #import <UIKit/UIKit.h> #import "ParentViewController.h" @class ParentViewController; @interface ChildViewController : UIViewController @property(nonatomic, assign) ParentViewController *delegate; @end ``` **ChildViewController.m** ``` - (IBAction)btnPassDataBack:(id)sender { if([self.delegate respondsToSelector:@selector(passData:)]) { [self.delegate passData:@"Hello"]; } [self dismissViewControllerAnimated:YES completion:nil]; } ``` [Sample Project](https://www.dropbox.com/s/ilb0mpi0ia2fd9f/DelegateExample.zip)
First of all, you are not checking for the same selector as you declared in your protocol declaration so it won't respond to that. You declared the method `childMethod:` whereas you are checking if your childDelegate responds to `myMethod:` selector which does not so it won't go into the if condition. Also the parent view controller is missing the implementation the method `childMethod:` in its .m. Implement that in your parent view controller or it will crash because of not finding the exact selector definition. Since you are using a `UINavigationController`, the parent view controller won't be lost till the child view controller exist so the `childDelegate` property must not be strong unless you intend to hold onto your delegate in child view controller for some reason.
8,618,264
I'm dealing with user subscriptions. A user creates a recurring subscription. Many things can happen to that subscription, such as it is renewed, or it's canceled, or the latest billing was unsuccessful, or the user has paused or restarted with subscription. Do you suggest: 1. Having one `subscriptions` record for each user, which has fields for all possible values such as started date, expires date, is active, failed billing date, canceled date, paused date, restarted date? 2. Or having one `subscriptions` record, with a secondary table `subscription_events`? A row in this secondary table could record "subscription X has been renewed". Then I would query the most recent event for a subscription to figure out its current status. 3. Or a better approach?
2011/12/23
[ "https://Stackoverflow.com/questions/8618264", "https://Stackoverflow.com", "https://Stackoverflow.com/users/248220/" ]
Don't go for 1. It's not flexible enough for new events. You don't want a design where you need to alter the table every time a new event comes along. You would also need columns for each event date and it just starts getting ugly when you want to know the order of things. Also what happens when a user can have multiple subscriptions? 2 is about right. To normalize it a bit, I would imagine you have a USER table and a SERVICE table with a SUBSCRIPTION mapping the two together. Then there would be an EVENT table with the known possible events and a SUBSCRIPTION\_EVENT\_MAP mapping SUBSCRIPTION to EVENT with a time stamp.
It comes down to the `intention` of the `design`. Here are some out of many---many---approaches to take: You could use a history table: ```sql -- stores info re:reason for the last update of a subscription CREATE TABLE subscription_history ( subscription_id INT , change_date DATETIME , change_reason VARCHAR(255) ) ``` Or a history table in conjunction with a lookup: ```sql -- stores info re:reason for the last update of a subscription -- but links to a change_reason table for reason id lookups CREATE TABLE subscription_history_L ( subscription_id INT , change_date DATETIME , change_reason_id INT ) -- lookup table containing change reasons CREATE TABLE change_reason ( change_reason_id INT , change_reason VARCHAR(255) ) ``` Or an audit table v1: ```sql -- contains all columns in your subscription table plus audit fields CREATE TABLE subscription_audit ( subscription_audit_id INT -- All the fields from your `subscriptions` table , audit_date DATETIME , audit_reason VARCHAR(255) , audit_by VARCHAR(255) -- example -- etc etc whatever other information that is pertinent to the change ) ``` Or an audit table v2: ```sql -- this could also act like a history table, so you can change the table name/purpose CREATE TABLE subscription_audit ( subscription_id INT , modified_column VARCHAR(255) , value_old VARCHAR(255) , value_new VARCHAR(255) , modified_date DATETIME ) -- Drawback here is that you'll have one audit record per column -- , and you may have to add extra columns for other data types -- , or convert your values to varchar or something else.. which isn't -- a really good idea! I just want to present this in case you can -- develop the idea you find interesting further ``` I dunno your RDBMS, but this is nearly general SQl (which I think I can better use as a method to explain than words and words)
24,121,287
Anybody knows how to make BUNDLE INSTALL Cache'ing work in latest DOCKER release? I've tried so far: ``` 1. WORKDIR /tmp ADD ./Gemfile Gemfile ADD ./Gemfile.lock Gemfile.lock RUN bundle install 2. ADD . opt/railsapp/ WORKIDR opt/rails/app RUN bundle install ``` None of them work, it still runs "BUNDE INSTALL" everytime from scratch without Gemfile being changed. Anyone knows how to make Caching for bundle install work correctly? Cheers, Andrew
2014/06/09
[ "https://Stackoverflow.com/questions/24121287", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3647232/" ]
Each time you change any file in your local app directory, the cache will be wiped out, forcing every step afterwards to be re-run, including the last `bundle install`. The solution is don't run `bundle install` in step 2. You have already installed your gems in step 1 and there is little chance the Gemfile will change between step 1 and step 2 ;-). The whole point of step 1 is to add your Gemfile, which should not change to often, so you can cache it and the subsequent bundle command before adding the rest of your app, which will probably change very often if you are still developing it. Here's how the Dockerfile could look like: ``` 1. WORKDIR /tmp ADD ./Gemfile Gemfile ADD ./Gemfile.lock Gemfile.lock RUN bundle install 2. ADD . opt/railsapp/ WORKIDR opt/rails/app ```
Versions of Docker before 0.9.1 did not cache ADD instructions. Can you check that you're running a version of Docker 0.9.1 or greater? Also, which installation of Docker are you using? According to [this GitHub issue](https://github.com/dotcloud/docker/issues/5053), some users have experienced cache-busting ADD behavior when using unsupported Docker builds. Make sure you're using an official Docker build.
24,121,287
Anybody knows how to make BUNDLE INSTALL Cache'ing work in latest DOCKER release? I've tried so far: ``` 1. WORKDIR /tmp ADD ./Gemfile Gemfile ADD ./Gemfile.lock Gemfile.lock RUN bundle install 2. ADD . opt/railsapp/ WORKIDR opt/rails/app RUN bundle install ``` None of them work, it still runs "BUNDE INSTALL" everytime from scratch without Gemfile being changed. Anyone knows how to make Caching for bundle install work correctly? Cheers, Andrew
2014/06/09
[ "https://Stackoverflow.com/questions/24121287", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3647232/" ]
Each time you change any file in your local app directory, the cache will be wiped out, forcing every step afterwards to be re-run, including the last `bundle install`. The solution is don't run `bundle install` in step 2. You have already installed your gems in step 1 and there is little chance the Gemfile will change between step 1 and step 2 ;-). The whole point of step 1 is to add your Gemfile, which should not change to often, so you can cache it and the subsequent bundle command before adding the rest of your app, which will probably change very often if you are still developing it. Here's how the Dockerfile could look like: ``` 1. WORKDIR /tmp ADD ./Gemfile Gemfile ADD ./Gemfile.lock Gemfile.lock RUN bundle install 2. ADD . opt/railsapp/ WORKIDR opt/rails/app ```
ADD caching is based on all the metadata of the file, not just the contents. if you are running `docker build` in a CI-like environment with a fresh checkout, then it is possible the timestamps of the files are being updated which would invalidate the cache.
27,687
Paypal offer [Automatic Billing Buttons](https://merchant.paypal.com/us/cgi-bin/?cmd=_render-content&content_ID=developer/e_howto_html_autobill_buttons#id105ED800NBF) which allow regular billing for different amounts. After a couple of hours googling I cannot find how to access this functionality using the API, so that it can be automated as opposed to done manually via the paypal account. Is it possible? Can someone point me to a sample/reference?
2012/03/23
[ "https://webmasters.stackexchange.com/questions/27687", "https://webmasters.stackexchange.com", "https://webmasters.stackexchange.com/users/13862/" ]
[This is the API documentation for creating recurring payments](https://cms.paypal.com/us/cgi-bin/?cmd=_render-content&content_ID=developer/e_howto_api_nvp_r_CreateRecurringPayments) Another useful page is here on [handling recurring payments.](https://cms.paypal.com/us/cgi-bin/?cmd=_render-content&content_ID=developer/e_howto_api_ECRecurringPayments)
Paypal have confirmed that this is not possible via the API :(
27,687
Paypal offer [Automatic Billing Buttons](https://merchant.paypal.com/us/cgi-bin/?cmd=_render-content&content_ID=developer/e_howto_html_autobill_buttons#id105ED800NBF) which allow regular billing for different amounts. After a couple of hours googling I cannot find how to access this functionality using the API, so that it can be automated as opposed to done manually via the paypal account. Is it possible? Can someone point me to a sample/reference?
2012/03/23
[ "https://webmasters.stackexchange.com/questions/27687", "https://webmasters.stackexchange.com", "https://webmasters.stackexchange.com/users/13862/" ]
Take a look at PayPal [Reference Transactions](https://developer.paypal.com/docs/classic/express-checkout/integration-guide/ECReferenceTxns/). It appears it does exactly what "Automatic Billing" does (i.e. automated regular billing for different amounts), but you can do it all through API's.
[This is the API documentation for creating recurring payments](https://cms.paypal.com/us/cgi-bin/?cmd=_render-content&content_ID=developer/e_howto_api_nvp_r_CreateRecurringPayments) Another useful page is here on [handling recurring payments.](https://cms.paypal.com/us/cgi-bin/?cmd=_render-content&content_ID=developer/e_howto_api_ECRecurringPayments)
27,687
Paypal offer [Automatic Billing Buttons](https://merchant.paypal.com/us/cgi-bin/?cmd=_render-content&content_ID=developer/e_howto_html_autobill_buttons#id105ED800NBF) which allow regular billing for different amounts. After a couple of hours googling I cannot find how to access this functionality using the API, so that it can be automated as opposed to done manually via the paypal account. Is it possible? Can someone point me to a sample/reference?
2012/03/23
[ "https://webmasters.stackexchange.com/questions/27687", "https://webmasters.stackexchange.com", "https://webmasters.stackexchange.com/users/13862/" ]
Doing it with the API is pretty much the same as doing it through a button. By default, PayPal is going to bill the same amount. This is the most common type of recurring payment, and also PayPal only has the fixed amount specified during the creation of the recurring payment. PayPal can be very convenient, but it's not magic. If you want to bill a different amount this month from the previous, you need to tell PayPal what you want the new amount to be. You can do this either manually through the admin panel, but you can also do it via the API. But you still need to tell PayPal what to change the amount to. So use the API call that Anagio linked to to create the recurring payment profile (after you've created the billing agreement), and then when you need to alter the billing amount, use the [`UpdateRecurringPaymentsProfile` API](https://cms.paypal.com/us/cgi-bin/?cmd=_render-content&content_ID=developer/e_howto_api_WPRecurringPayments#id086530108PM) to set the new amount.
Paypal have confirmed that this is not possible via the API :(
27,687
Paypal offer [Automatic Billing Buttons](https://merchant.paypal.com/us/cgi-bin/?cmd=_render-content&content_ID=developer/e_howto_html_autobill_buttons#id105ED800NBF) which allow regular billing for different amounts. After a couple of hours googling I cannot find how to access this functionality using the API, so that it can be automated as opposed to done manually via the paypal account. Is it possible? Can someone point me to a sample/reference?
2012/03/23
[ "https://webmasters.stackexchange.com/questions/27687", "https://webmasters.stackexchange.com", "https://webmasters.stackexchange.com/users/13862/" ]
Take a look at PayPal [Reference Transactions](https://developer.paypal.com/docs/classic/express-checkout/integration-guide/ECReferenceTxns/). It appears it does exactly what "Automatic Billing" does (i.e. automated regular billing for different amounts), but you can do it all through API's.
Paypal have confirmed that this is not possible via the API :(
27,687
Paypal offer [Automatic Billing Buttons](https://merchant.paypal.com/us/cgi-bin/?cmd=_render-content&content_ID=developer/e_howto_html_autobill_buttons#id105ED800NBF) which allow regular billing for different amounts. After a couple of hours googling I cannot find how to access this functionality using the API, so that it can be automated as opposed to done manually via the paypal account. Is it possible? Can someone point me to a sample/reference?
2012/03/23
[ "https://webmasters.stackexchange.com/questions/27687", "https://webmasters.stackexchange.com", "https://webmasters.stackexchange.com/users/13862/" ]
Take a look at PayPal [Reference Transactions](https://developer.paypal.com/docs/classic/express-checkout/integration-guide/ECReferenceTxns/). It appears it does exactly what "Automatic Billing" does (i.e. automated regular billing for different amounts), but you can do it all through API's.
Doing it with the API is pretty much the same as doing it through a button. By default, PayPal is going to bill the same amount. This is the most common type of recurring payment, and also PayPal only has the fixed amount specified during the creation of the recurring payment. PayPal can be very convenient, but it's not magic. If you want to bill a different amount this month from the previous, you need to tell PayPal what you want the new amount to be. You can do this either manually through the admin panel, but you can also do it via the API. But you still need to tell PayPal what to change the amount to. So use the API call that Anagio linked to to create the recurring payment profile (after you've created the billing agreement), and then when you need to alter the billing amount, use the [`UpdateRecurringPaymentsProfile` API](https://cms.paypal.com/us/cgi-bin/?cmd=_render-content&content_ID=developer/e_howto_api_WPRecurringPayments#id086530108PM) to set the new amount.
8,401,631
Any idea on how to create a decision tree stump for use with boosting in Matlab? I mean is there some parameter I can send to classregtree to make sure i end up with only 1 level? I tried pruning and it doesn't always give a stump (single cut). Sometimes I was only able to get 2 cuts (unbalanced tree). I'm aware of the ClassificationTree.template and the fitensemble functions but I want to write my own boosting algorithm to use it with LDA or other classifiers which are not provided by fitensemble. Thanks
2011/12/06
[ "https://Stackoverflow.com/questions/8401631", "https://Stackoverflow.com", "https://Stackoverflow.com/users/175843/" ]
I believe you can just set the `minparent` parameter equal to your number of observations. Using the iris example data: ``` >> load fisheriris; >> t = classregtree(meas,species,... 'names',{'SL' 'SW' 'PL' 'PW'}, 'minparent', 150) t = Decision tree for classification 1 if PL<2.45 then node 2 elseif PL>=2.45 then node 3 else setosa 2 class = setosa 3 class = versicolor ``` Not sure, but it may be quicker to eventually code it manually - especially if you're incorporating other custom code anyway. Good luck!
If `t1` is your tree, as returned by `classregtree`, I think you can create a decision stump `t2` with the command ``` t2 = prune(t1, 'level', max(prunelist(t1)-1)); ``` Does that do what you need?
70,816,347
I started learning App development in Android Studio, using the Flutter UI toolkit. Everything seems fine, however when i want to create a **New Image Asset** to edit my app's icon, i can't find it. When i right-click the *android/app/src/main/res* folder, it does not appear within *New*. I am following some older tutorials and they all have that option there. This is what comes up: [![enter image description here](https://i.stack.imgur.com/ov4G5.png)](https://i.stack.imgur.com/ov4G5.png) My version of Android Studio is: [![enter image description here](https://i.stack.imgur.com/2bDAf.png)](https://i.stack.imgur.com/2bDAf.png) And my version of Flutter is: 2.8.1 (Dart 2.15.1) How can i fix this, or are there any alternatives for modifying my app's icon?
2022/01/22
[ "https://Stackoverflow.com/questions/70816347", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17460377/" ]
Does it work for you? If that doesn't work, try right-clicking the drawable folder and selecting "New" -> "Image Asset". [![tools menu](https://i.stack.imgur.com/3MTuH.png)](https://i.stack.imgur.com/3MTuH.png) [![resource manager screen](https://i.stack.imgur.com/oo0gL.png)](https://i.stack.imgur.com/oo0gL.png)
Ah, I've seen this before as you're using Flutter. Despite all the answers, I'd recommend you to right-click the `android/` folder from your Flutter app root and select **Mark as... > Project Root**, then close and reopen the project in Android Studio. If Android finally recognizes this as an Android project, it will take a long, long time to download some of the project's dependencies (in which some of them are already downloaded through `flutter pub get` and `flutter run`/`build`. After it's ready, the project files will be finally available for you, including the option to launch the Image Asset Studio.
70,816,347
I started learning App development in Android Studio, using the Flutter UI toolkit. Everything seems fine, however when i want to create a **New Image Asset** to edit my app's icon, i can't find it. When i right-click the *android/app/src/main/res* folder, it does not appear within *New*. I am following some older tutorials and they all have that option there. This is what comes up: [![enter image description here](https://i.stack.imgur.com/ov4G5.png)](https://i.stack.imgur.com/ov4G5.png) My version of Android Studio is: [![enter image description here](https://i.stack.imgur.com/2bDAf.png)](https://i.stack.imgur.com/2bDAf.png) And my version of Flutter is: 2.8.1 (Dart 2.15.1) How can i fix this, or are there any alternatives for modifying my app's icon?
2022/01/22
[ "https://Stackoverflow.com/questions/70816347", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17460377/" ]
Does it work for you? If that doesn't work, try right-clicking the drawable folder and selecting "New" -> "Image Asset". [![tools menu](https://i.stack.imgur.com/3MTuH.png)](https://i.stack.imgur.com/3MTuH.png) [![resource manager screen](https://i.stack.imgur.com/oo0gL.png)](https://i.stack.imgur.com/oo0gL.png)
Update To Latest Version Frist. Android Studio Dolphin | 2021.3.1 Patch 1 Visit <https://developer.android.com/> And Download Manually And Install. After You Can Find Res/New\_resources\_deirectory/midmap It's Very Simple. #Android\_Studio
70,816,347
I started learning App development in Android Studio, using the Flutter UI toolkit. Everything seems fine, however when i want to create a **New Image Asset** to edit my app's icon, i can't find it. When i right-click the *android/app/src/main/res* folder, it does not appear within *New*. I am following some older tutorials and they all have that option there. This is what comes up: [![enter image description here](https://i.stack.imgur.com/ov4G5.png)](https://i.stack.imgur.com/ov4G5.png) My version of Android Studio is: [![enter image description here](https://i.stack.imgur.com/2bDAf.png)](https://i.stack.imgur.com/2bDAf.png) And my version of Flutter is: 2.8.1 (Dart 2.15.1) How can i fix this, or are there any alternatives for modifying my app's icon?
2022/01/22
[ "https://Stackoverflow.com/questions/70816347", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17460377/" ]
Does it work for you? If that doesn't work, try right-clicking the drawable folder and selecting "New" -> "Image Asset". [![tools menu](https://i.stack.imgur.com/3MTuH.png)](https://i.stack.imgur.com/3MTuH.png) [![resource manager screen](https://i.stack.imgur.com/oo0gL.png)](https://i.stack.imgur.com/oo0gL.png)
I got it to come up when I right click on the root node of the project (a flutter project) and selected `flutter` -> `Open Android module in Android Studio` Then I was able to right click the `res` folder and clicked on `new` -> `Image Asset`
70,816,347
I started learning App development in Android Studio, using the Flutter UI toolkit. Everything seems fine, however when i want to create a **New Image Asset** to edit my app's icon, i can't find it. When i right-click the *android/app/src/main/res* folder, it does not appear within *New*. I am following some older tutorials and they all have that option there. This is what comes up: [![enter image description here](https://i.stack.imgur.com/ov4G5.png)](https://i.stack.imgur.com/ov4G5.png) My version of Android Studio is: [![enter image description here](https://i.stack.imgur.com/2bDAf.png)](https://i.stack.imgur.com/2bDAf.png) And my version of Flutter is: 2.8.1 (Dart 2.15.1) How can i fix this, or are there any alternatives for modifying my app's icon?
2022/01/22
[ "https://Stackoverflow.com/questions/70816347", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17460377/" ]
Does it work for you? If that doesn't work, try right-clicking the drawable folder and selecting "New" -> "Image Asset". [![tools menu](https://i.stack.imgur.com/3MTuH.png)](https://i.stack.imgur.com/3MTuH.png) [![resource manager screen](https://i.stack.imgur.com/oo0gL.png)](https://i.stack.imgur.com/oo0gL.png)
For **Flutter** users: If you created the Android project via `flutter create`, make sure to open the Android Studio project in the `android` subfolder, not the one in the root folder. Then, Android Studio should automatically run gradle. Once this has finished (which can take quite some time on the first run), the Android Studio UI should automatically switch to the "Android View", and the "New > Image Asset" option should become available for the `res` folder. No need to manually mark anything. Just make sure that gradle runs through, otherwise the *real* "Android View" won't be available, even if it is selected.
70,816,347
I started learning App development in Android Studio, using the Flutter UI toolkit. Everything seems fine, however when i want to create a **New Image Asset** to edit my app's icon, i can't find it. When i right-click the *android/app/src/main/res* folder, it does not appear within *New*. I am following some older tutorials and they all have that option there. This is what comes up: [![enter image description here](https://i.stack.imgur.com/ov4G5.png)](https://i.stack.imgur.com/ov4G5.png) My version of Android Studio is: [![enter image description here](https://i.stack.imgur.com/2bDAf.png)](https://i.stack.imgur.com/2bDAf.png) And my version of Flutter is: 2.8.1 (Dart 2.15.1) How can i fix this, or are there any alternatives for modifying my app's icon?
2022/01/22
[ "https://Stackoverflow.com/questions/70816347", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17460377/" ]
Try to do the following: Right click on `res` directory -> Choose `Mark Directory as` -> `Resources root` [![Right click -> Mark Directory as -> Resourses root](https://i.stack.imgur.com/C6V0J.png)](https://i.stack.imgur.com/C6V0J.png) If it is not working, try to change file view to `Android`: [![enter image description here](https://i.stack.imgur.com/mHrGL.png)](https://i.stack.imgur.com/mHrGL.png)
Ah, I've seen this before as you're using Flutter. Despite all the answers, I'd recommend you to right-click the `android/` folder from your Flutter app root and select **Mark as... > Project Root**, then close and reopen the project in Android Studio. If Android finally recognizes this as an Android project, it will take a long, long time to download some of the project's dependencies (in which some of them are already downloaded through `flutter pub get` and `flutter run`/`build`. After it's ready, the project files will be finally available for you, including the option to launch the Image Asset Studio.
70,816,347
I started learning App development in Android Studio, using the Flutter UI toolkit. Everything seems fine, however when i want to create a **New Image Asset** to edit my app's icon, i can't find it. When i right-click the *android/app/src/main/res* folder, it does not appear within *New*. I am following some older tutorials and they all have that option there. This is what comes up: [![enter image description here](https://i.stack.imgur.com/ov4G5.png)](https://i.stack.imgur.com/ov4G5.png) My version of Android Studio is: [![enter image description here](https://i.stack.imgur.com/2bDAf.png)](https://i.stack.imgur.com/2bDAf.png) And my version of Flutter is: 2.8.1 (Dart 2.15.1) How can i fix this, or are there any alternatives for modifying my app's icon?
2022/01/22
[ "https://Stackoverflow.com/questions/70816347", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17460377/" ]
Try to do the following: Right click on `res` directory -> Choose `Mark Directory as` -> `Resources root` [![Right click -> Mark Directory as -> Resourses root](https://i.stack.imgur.com/C6V0J.png)](https://i.stack.imgur.com/C6V0J.png) If it is not working, try to change file view to `Android`: [![enter image description here](https://i.stack.imgur.com/mHrGL.png)](https://i.stack.imgur.com/mHrGL.png)
Update To Latest Version Frist. Android Studio Dolphin | 2021.3.1 Patch 1 Visit <https://developer.android.com/> And Download Manually And Install. After You Can Find Res/New\_resources\_deirectory/midmap It's Very Simple. #Android\_Studio
70,816,347
I started learning App development in Android Studio, using the Flutter UI toolkit. Everything seems fine, however when i want to create a **New Image Asset** to edit my app's icon, i can't find it. When i right-click the *android/app/src/main/res* folder, it does not appear within *New*. I am following some older tutorials and they all have that option there. This is what comes up: [![enter image description here](https://i.stack.imgur.com/ov4G5.png)](https://i.stack.imgur.com/ov4G5.png) My version of Android Studio is: [![enter image description here](https://i.stack.imgur.com/2bDAf.png)](https://i.stack.imgur.com/2bDAf.png) And my version of Flutter is: 2.8.1 (Dart 2.15.1) How can i fix this, or are there any alternatives for modifying my app's icon?
2022/01/22
[ "https://Stackoverflow.com/questions/70816347", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17460377/" ]
Try to do the following: Right click on `res` directory -> Choose `Mark Directory as` -> `Resources root` [![Right click -> Mark Directory as -> Resourses root](https://i.stack.imgur.com/C6V0J.png)](https://i.stack.imgur.com/C6V0J.png) If it is not working, try to change file view to `Android`: [![enter image description here](https://i.stack.imgur.com/mHrGL.png)](https://i.stack.imgur.com/mHrGL.png)
I got it to come up when I right click on the root node of the project (a flutter project) and selected `flutter` -> `Open Android module in Android Studio` Then I was able to right click the `res` folder and clicked on `new` -> `Image Asset`
70,816,347
I started learning App development in Android Studio, using the Flutter UI toolkit. Everything seems fine, however when i want to create a **New Image Asset** to edit my app's icon, i can't find it. When i right-click the *android/app/src/main/res* folder, it does not appear within *New*. I am following some older tutorials and they all have that option there. This is what comes up: [![enter image description here](https://i.stack.imgur.com/ov4G5.png)](https://i.stack.imgur.com/ov4G5.png) My version of Android Studio is: [![enter image description here](https://i.stack.imgur.com/2bDAf.png)](https://i.stack.imgur.com/2bDAf.png) And my version of Flutter is: 2.8.1 (Dart 2.15.1) How can i fix this, or are there any alternatives for modifying my app's icon?
2022/01/22
[ "https://Stackoverflow.com/questions/70816347", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17460377/" ]
Try to do the following: Right click on `res` directory -> Choose `Mark Directory as` -> `Resources root` [![Right click -> Mark Directory as -> Resourses root](https://i.stack.imgur.com/C6V0J.png)](https://i.stack.imgur.com/C6V0J.png) If it is not working, try to change file view to `Android`: [![enter image description here](https://i.stack.imgur.com/mHrGL.png)](https://i.stack.imgur.com/mHrGL.png)
For **Flutter** users: If you created the Android project via `flutter create`, make sure to open the Android Studio project in the `android` subfolder, not the one in the root folder. Then, Android Studio should automatically run gradle. Once this has finished (which can take quite some time on the first run), the Android Studio UI should automatically switch to the "Android View", and the "New > Image Asset" option should become available for the `res` folder. No need to manually mark anything. Just make sure that gradle runs through, otherwise the *real* "Android View" won't be available, even if it is selected.
18,166,563
I got a calculator like program If the user enters 1 they can add, 2 to subtract, 3 to multiply and 4 to divide I got functions named ``` add subtract multiply divide ``` By using switch case, if the user enters 1 it has to go to the add function 2 to subtract, 3 to multiply and 4 to divide. This is the code i got: ``` static void Main() { Console.WriteLine("Enter any number"); int a = Convert.ToInt32(ConsoleReadLine()); Console.WriteLine("Enter any number"); int b = Convert.ToInt32(ConsoleReadLine()); int c; Console.WriteLine("Enter 1 to add, 2 to subtract, 3 to multiply and 4 to divide"); int Choice = Convert.ToInt32(Console.ReadLine()); switch (Choice) case 1: break; //and so forth. public void add() { c = a + b; // similar codes for subtraction,multiplication and division. } ``` In switch case if the user enters 1 the add function should be invoked. How can i do it? Any suggestions. It's asking for object references please help
2013/08/10
[ "https://Stackoverflow.com/questions/18166563", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2669045/" ]
Do you really need to use functions? This seems pretty straight forward: ``` switch (Choice) { case 1: c = a + b; break; ... default: Console.WriteLine("Invalid choice"); break; } ``` But if you really do want to use functions, just define them outside of your `Main` method (they must be declared as `static` if you want to call them from `Main`): ``` public static int add(int x, int y) { return x + y; } ``` And then invoke them like this: ``` switch (Choice) { case 1: c = add(a, b); break; ... default: Console.WriteLine("Invalid choice"); break; } ```
Just call you function and return the result : ``` static void Main() { Console.WriteLine("Enter any number"); int a = Convert.ToInt32(ConsoleReadLine()); Console.WriteLine("Enter any number"); int b = Convert.ToInt32(ConsoleReadLine()); int c; Console.WriteLine("Enter 1 to add, 2 to subtract, 3 to multiply and 4 to divide"); int Choice = Convert.ToInt32(Console.ReadLine()); switch (Choice) case 1: c = add(a,b); break; //and so forth. } public static int add(int a, int b) { return a + b; } ```
18,166,563
I got a calculator like program If the user enters 1 they can add, 2 to subtract, 3 to multiply and 4 to divide I got functions named ``` add subtract multiply divide ``` By using switch case, if the user enters 1 it has to go to the add function 2 to subtract, 3 to multiply and 4 to divide. This is the code i got: ``` static void Main() { Console.WriteLine("Enter any number"); int a = Convert.ToInt32(ConsoleReadLine()); Console.WriteLine("Enter any number"); int b = Convert.ToInt32(ConsoleReadLine()); int c; Console.WriteLine("Enter 1 to add, 2 to subtract, 3 to multiply and 4 to divide"); int Choice = Convert.ToInt32(Console.ReadLine()); switch (Choice) case 1: break; //and so forth. public void add() { c = a + b; // similar codes for subtraction,multiplication and division. } ``` In switch case if the user enters 1 the add function should be invoked. How can i do it? Any suggestions. It's asking for object references please help
2013/08/10
[ "https://Stackoverflow.com/questions/18166563", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2669045/" ]
Do you really need to use functions? This seems pretty straight forward: ``` switch (Choice) { case 1: c = a + b; break; ... default: Console.WriteLine("Invalid choice"); break; } ``` But if you really do want to use functions, just define them outside of your `Main` method (they must be declared as `static` if you want to call them from `Main`): ``` public static int add(int x, int y) { return x + y; } ``` And then invoke them like this: ``` switch (Choice) { case 1: c = add(a, b); break; ... default: Console.WriteLine("Invalid choice"); break; } ```
you should just call the add function in switch case ``` switch (Choice) case 1: add(); break; //and so forth. public void add() { c = a + b; // similar codes for subtraction,multiplication and division. } ```
18,166,563
I got a calculator like program If the user enters 1 they can add, 2 to subtract, 3 to multiply and 4 to divide I got functions named ``` add subtract multiply divide ``` By using switch case, if the user enters 1 it has to go to the add function 2 to subtract, 3 to multiply and 4 to divide. This is the code i got: ``` static void Main() { Console.WriteLine("Enter any number"); int a = Convert.ToInt32(ConsoleReadLine()); Console.WriteLine("Enter any number"); int b = Convert.ToInt32(ConsoleReadLine()); int c; Console.WriteLine("Enter 1 to add, 2 to subtract, 3 to multiply and 4 to divide"); int Choice = Convert.ToInt32(Console.ReadLine()); switch (Choice) case 1: break; //and so forth. public void add() { c = a + b; // similar codes for subtraction,multiplication and division. } ``` In switch case if the user enters 1 the add function should be invoked. How can i do it? Any suggestions. It's asking for object references please help
2013/08/10
[ "https://Stackoverflow.com/questions/18166563", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2669045/" ]
Just call you function and return the result : ``` static void Main() { Console.WriteLine("Enter any number"); int a = Convert.ToInt32(ConsoleReadLine()); Console.WriteLine("Enter any number"); int b = Convert.ToInt32(ConsoleReadLine()); int c; Console.WriteLine("Enter 1 to add, 2 to subtract, 3 to multiply and 4 to divide"); int Choice = Convert.ToInt32(Console.ReadLine()); switch (Choice) case 1: c = add(a,b); break; //and so forth. } public static int add(int a, int b) { return a + b; } ```
you should just call the add function in switch case ``` switch (Choice) case 1: add(); break; //and so forth. public void add() { c = a + b; // similar codes for subtraction,multiplication and division. } ```
110,344
Not sure if this is my dishwasher or my clogged drains. A few years back, my dishwasher stopped draining; I called my neighbor, I tried all home remedies, my neighbor took the Bosch dishwasher apart and the hose inside was full of grease, so much that there was no way we could clean it. I ordered another one and replaced it. Still the water wasn't draining. He climbed my roof, looked thru the drain pipe and said he sees clogged drain, hair and stuff, cleared that out and everything was good for good 2 years I would say. Now, I have the same issue again. My neighbor has moved. I'm not sure why this is happening. Should I call a plumber or a dishwasher person? I'm afraid of termites due to standing water. This is Long Island, New York. Termites are a big issue. What should I do?
2017/03/15
[ "https://diy.stackexchange.com/questions/110344", "https://diy.stackexchange.com", "https://diy.stackexchange.com/users/67500/" ]
First, check and clean the drain filter in your dishwasher. This is a screen that can be pulled out from inside the dishwasher, designed to prevent food particles from getting sucked into the washing and drainage systems. Consult your manual for detailed instructions. This is something everyone should do regularly (every few months or more) to keep their dishwasher working well. If that doesn't help, call a plumber. These issues can compound each other. If your drain line is clogged, your dishwasher will be struggling to run its drain pump. This will wear the pump out sooner, and the slow drainage will mean that any dirt that might flow out the drain will be more likely to cling to the walls of the drainage hose. You should also look at how your dishwasher drain is connected. Usually it is attached to the same drain as your kitchen sink. Try filling up your sink with a stopper, then pull the stopper and see if it drains fast. If that is slow, then you most likely have a drain or venting issue which would affect the dishwasher as well. A plumber can fix that for you too. The only reason you'd need a dishwasher tech is if the drain pump in the dishwasher needs to be replaced. That is a possibility, but less likely than the others. If that does turn out to be the issue, then plumber should at least be able to figure it out definitely.
Here's a trick that will keep your drain hose, drain, and dishwasher free of repeated blockage. Place a coffee cup upright in the back of your dishwasher lower rack, Fill it full of white vinegar and leave it there for two weeks and then refill it and repeat. As the vinegar releases it cleans everything. Also check to see if you use too much soap most dishwashers only use about two gallons of water per cycle. If oversudsing occurs soap builds up
140,021
I have some question in closing port, I think I got some strange things. When I use execute ``` nmap --top-ports 10 192.168.1.1 ``` it shows that 23/TCP port is open. But when I execute ``` nmap --top-ports 10 localhost ``` it show that 23/tcp port is closed. Which of them is true? I want to close this port on my whole system, how can I do it?
2014/06/30
[ "https://unix.stackexchange.com/questions/140021", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/74080/" ]
A Linux system has a so called loopback interface, which is for internal communication. Its hostname is `localhost` and its IP address is `127.0.0.1`. When you run `nmap` on `localhost`, you actually run the portscan on the **virtual** loopback interface. `192.168.1.1` is the IP address of your **physical** (most likely `eth0`) interface. So you've run `nmap` on two different network interfaces, this is why there's a difference in the open ports. They are both true. If you have TCP port 23 open, it is likely that you have a `telnet` server running (which is not a good thing due to its lack of encryption) or you have some kind of trojan horse on your machine.
If you do `nmap localhost`, it tells you about a different situation: some programs on linux work as server although they are used only locally. This is because other programs use them like a server they connect to. **So both answers are true, since you ask something different.** Port 23 is used for telnet. Normally not used anymore. Try to do `nmap -sV 192.168.1.1` to find out which program opens the port. (192... is a local network IP, so the result of `nmap <your outside world IP>` will also give a different result, because of possible firewall settings etc)
140,021
I have some question in closing port, I think I got some strange things. When I use execute ``` nmap --top-ports 10 192.168.1.1 ``` it shows that 23/TCP port is open. But when I execute ``` nmap --top-ports 10 localhost ``` it show that 23/tcp port is closed. Which of them is true? I want to close this port on my whole system, how can I do it?
2014/06/30
[ "https://unix.stackexchange.com/questions/140021", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/74080/" ]
Nmap is a great port scanner, but sometimes you want something more authoritative. You can ask the kernel what processes have which ports open by using the `netstat` utility: ``` me@myhost:~$ sudo netstat -tlnp Active Internet connections (only servers) Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name tcp 0 0 127.0.0.1:53 0.0.0.0:* LISTEN 1004/dnsmasq tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 380/sshd tcp 0 0 127.0.0.1:631 0.0.0.0:* LISTEN 822/cupsd tcp6 0 0 :::22 :::* LISTEN 380/sshd tcp6 0 0 ::1:631 :::* LISTEN 822/cupsd ``` The options I have given are: * `-t` TCP only * `-l` Listening ports only * `-n` Don't look up service and host names, just display numbers * `-p` Show process information (requires root privilege) In this case, we can see that `sshd` is listening on any interface (`0.0.0.0`) port 22, and `cupsd` is listening on loopback (`127.0.0.1`) port 631. Your output may show that `telnetd` has a local address of `192.168.1.1:23`, meaning it will not answer to connections on the loopback adapter (e.g. you can't `telnet 127.0.0.1`). There are other tools that will show similar information (e.g. `lsof` or `/proc`), but netstat is the most widely available. It even works on Windows (`netstat -anb`). BSD netstat is a little different: you'll have to use [sockstat(1)](http://www.freebsd.org/cgi/man.cgi?query=sockstat&sektion=1) to get the process information instead. Once you have the process ID and program name, you can go about finding the process and killing it if you wish to close the port. For finer-grained control, you can use a firewall (iptables on Linux) to limit access to only certain addresses. You may need to disable a service startup. If the PID is "-" on Linux, it's probably a kernel process (this is common with NFS for instance), so good luck finding out what it is. Note: I said "authoritative" because you're not being hindered by network conditions and firewalls. If you trust your computer, that's great. However, if you suspect that you've been hacked, you may not be able to trust the tools on your computer. Replacing standard utilities (and sometimes even system calls) with ones that hide certain processes or ports (a.k.a. rootkits) is a standard practice among attackers. Your best bet at this point is to make a forensic copy of your disk and restore from backup; then use the copy to determine the way they got in and close it off.
A Linux system has a so called loopback interface, which is for internal communication. Its hostname is `localhost` and its IP address is `127.0.0.1`. When you run `nmap` on `localhost`, you actually run the portscan on the **virtual** loopback interface. `192.168.1.1` is the IP address of your **physical** (most likely `eth0`) interface. So you've run `nmap` on two different network interfaces, this is why there's a difference in the open ports. They are both true. If you have TCP port 23 open, it is likely that you have a `telnet` server running (which is not a good thing due to its lack of encryption) or you have some kind of trojan horse on your machine.
140,021
I have some question in closing port, I think I got some strange things. When I use execute ``` nmap --top-ports 10 192.168.1.1 ``` it shows that 23/TCP port is open. But when I execute ``` nmap --top-ports 10 localhost ``` it show that 23/tcp port is closed. Which of them is true? I want to close this port on my whole system, how can I do it?
2014/06/30
[ "https://unix.stackexchange.com/questions/140021", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/74080/" ]
A Linux system has a so called loopback interface, which is for internal communication. Its hostname is `localhost` and its IP address is `127.0.0.1`. When you run `nmap` on `localhost`, you actually run the portscan on the **virtual** loopback interface. `192.168.1.1` is the IP address of your **physical** (most likely `eth0`) interface. So you've run `nmap` on two different network interfaces, this is why there's a difference in the open ports. They are both true. If you have TCP port 23 open, it is likely that you have a `telnet` server running (which is not a good thing due to its lack of encryption) or you have some kind of trojan horse on your machine.
*If* you have a service running and listening on port 23, it is arguably cleaner to ***stop*** the process that listens to port 23 (probably `telnet`) than to keep it running and ***close or block*** port 23 using `iptables`. When there's no process listening on a port, even in the absence of a firewall block, any attempt to connect to it should result in an immediate "connection refused" (`ECONNREFUSED` to `connect(2)`) One way to find the process (and its pid) that listens on port 23, if there's such process, is: ``` sudo lsof -i -P | grep ':23 ' ``` In the above `-i` lists open internet ports (both UDP and TCP), and -P inhibits translation of ports to service names (via `/etc/services`) After you found the running process listening on port 23, you can figure out how it got started by looking at the process tree (with say, `pstree`). If its parent is `init` (very likely), you may recursively search for the name of the process under `/etc`. e.g.: ``` sudo grep -r telnet /etc ``` This should lead you to the best way to disable it from running in the 1st place.
140,021
I have some question in closing port, I think I got some strange things. When I use execute ``` nmap --top-ports 10 192.168.1.1 ``` it shows that 23/TCP port is open. But when I execute ``` nmap --top-ports 10 localhost ``` it show that 23/tcp port is closed. Which of them is true? I want to close this port on my whole system, how can I do it?
2014/06/30
[ "https://unix.stackexchange.com/questions/140021", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/74080/" ]
To "close" the port you can use `iptables` ``` sudo iptables -A INPUT -p tcp --dport 23 -m state --state NEW,ESTABLISHED -j DROP ```
If you do `nmap localhost`, it tells you about a different situation: some programs on linux work as server although they are used only locally. This is because other programs use them like a server they connect to. **So both answers are true, since you ask something different.** Port 23 is used for telnet. Normally not used anymore. Try to do `nmap -sV 192.168.1.1` to find out which program opens the port. (192... is a local network IP, so the result of `nmap <your outside world IP>` will also give a different result, because of possible firewall settings etc)
140,021
I have some question in closing port, I think I got some strange things. When I use execute ``` nmap --top-ports 10 192.168.1.1 ``` it shows that 23/TCP port is open. But when I execute ``` nmap --top-ports 10 localhost ``` it show that 23/tcp port is closed. Which of them is true? I want to close this port on my whole system, how can I do it?
2014/06/30
[ "https://unix.stackexchange.com/questions/140021", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/74080/" ]
Nmap is a great port scanner, but sometimes you want something more authoritative. You can ask the kernel what processes have which ports open by using the `netstat` utility: ``` me@myhost:~$ sudo netstat -tlnp Active Internet connections (only servers) Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name tcp 0 0 127.0.0.1:53 0.0.0.0:* LISTEN 1004/dnsmasq tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 380/sshd tcp 0 0 127.0.0.1:631 0.0.0.0:* LISTEN 822/cupsd tcp6 0 0 :::22 :::* LISTEN 380/sshd tcp6 0 0 ::1:631 :::* LISTEN 822/cupsd ``` The options I have given are: * `-t` TCP only * `-l` Listening ports only * `-n` Don't look up service and host names, just display numbers * `-p` Show process information (requires root privilege) In this case, we can see that `sshd` is listening on any interface (`0.0.0.0`) port 22, and `cupsd` is listening on loopback (`127.0.0.1`) port 631. Your output may show that `telnetd` has a local address of `192.168.1.1:23`, meaning it will not answer to connections on the loopback adapter (e.g. you can't `telnet 127.0.0.1`). There are other tools that will show similar information (e.g. `lsof` or `/proc`), but netstat is the most widely available. It even works on Windows (`netstat -anb`). BSD netstat is a little different: you'll have to use [sockstat(1)](http://www.freebsd.org/cgi/man.cgi?query=sockstat&sektion=1) to get the process information instead. Once you have the process ID and program name, you can go about finding the process and killing it if you wish to close the port. For finer-grained control, you can use a firewall (iptables on Linux) to limit access to only certain addresses. You may need to disable a service startup. If the PID is "-" on Linux, it's probably a kernel process (this is common with NFS for instance), so good luck finding out what it is. Note: I said "authoritative" because you're not being hindered by network conditions and firewalls. If you trust your computer, that's great. However, if you suspect that you've been hacked, you may not be able to trust the tools on your computer. Replacing standard utilities (and sometimes even system calls) with ones that hide certain processes or ports (a.k.a. rootkits) is a standard practice among attackers. Your best bet at this point is to make a forensic copy of your disk and restore from backup; then use the copy to determine the way they got in and close it off.
To "close" the port you can use `iptables` ``` sudo iptables -A INPUT -p tcp --dport 23 -m state --state NEW,ESTABLISHED -j DROP ```
140,021
I have some question in closing port, I think I got some strange things. When I use execute ``` nmap --top-ports 10 192.168.1.1 ``` it shows that 23/TCP port is open. But when I execute ``` nmap --top-ports 10 localhost ``` it show that 23/tcp port is closed. Which of them is true? I want to close this port on my whole system, how can I do it?
2014/06/30
[ "https://unix.stackexchange.com/questions/140021", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/74080/" ]
To "close" the port you can use `iptables` ``` sudo iptables -A INPUT -p tcp --dport 23 -m state --state NEW,ESTABLISHED -j DROP ```
*If* you have a service running and listening on port 23, it is arguably cleaner to ***stop*** the process that listens to port 23 (probably `telnet`) than to keep it running and ***close or block*** port 23 using `iptables`. When there's no process listening on a port, even in the absence of a firewall block, any attempt to connect to it should result in an immediate "connection refused" (`ECONNREFUSED` to `connect(2)`) One way to find the process (and its pid) that listens on port 23, if there's such process, is: ``` sudo lsof -i -P | grep ':23 ' ``` In the above `-i` lists open internet ports (both UDP and TCP), and -P inhibits translation of ports to service names (via `/etc/services`) After you found the running process listening on port 23, you can figure out how it got started by looking at the process tree (with say, `pstree`). If its parent is `init` (very likely), you may recursively search for the name of the process under `/etc`. e.g.: ``` sudo grep -r telnet /etc ``` This should lead you to the best way to disable it from running in the 1st place.
140,021
I have some question in closing port, I think I got some strange things. When I use execute ``` nmap --top-ports 10 192.168.1.1 ``` it shows that 23/TCP port is open. But when I execute ``` nmap --top-ports 10 localhost ``` it show that 23/tcp port is closed. Which of them is true? I want to close this port on my whole system, how can I do it?
2014/06/30
[ "https://unix.stackexchange.com/questions/140021", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/74080/" ]
Nmap is a great port scanner, but sometimes you want something more authoritative. You can ask the kernel what processes have which ports open by using the `netstat` utility: ``` me@myhost:~$ sudo netstat -tlnp Active Internet connections (only servers) Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name tcp 0 0 127.0.0.1:53 0.0.0.0:* LISTEN 1004/dnsmasq tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 380/sshd tcp 0 0 127.0.0.1:631 0.0.0.0:* LISTEN 822/cupsd tcp6 0 0 :::22 :::* LISTEN 380/sshd tcp6 0 0 ::1:631 :::* LISTEN 822/cupsd ``` The options I have given are: * `-t` TCP only * `-l` Listening ports only * `-n` Don't look up service and host names, just display numbers * `-p` Show process information (requires root privilege) In this case, we can see that `sshd` is listening on any interface (`0.0.0.0`) port 22, and `cupsd` is listening on loopback (`127.0.0.1`) port 631. Your output may show that `telnetd` has a local address of `192.168.1.1:23`, meaning it will not answer to connections on the loopback adapter (e.g. you can't `telnet 127.0.0.1`). There are other tools that will show similar information (e.g. `lsof` or `/proc`), but netstat is the most widely available. It even works on Windows (`netstat -anb`). BSD netstat is a little different: you'll have to use [sockstat(1)](http://www.freebsd.org/cgi/man.cgi?query=sockstat&sektion=1) to get the process information instead. Once you have the process ID and program name, you can go about finding the process and killing it if you wish to close the port. For finer-grained control, you can use a firewall (iptables on Linux) to limit access to only certain addresses. You may need to disable a service startup. If the PID is "-" on Linux, it's probably a kernel process (this is common with NFS for instance), so good luck finding out what it is. Note: I said "authoritative" because you're not being hindered by network conditions and firewalls. If you trust your computer, that's great. However, if you suspect that you've been hacked, you may not be able to trust the tools on your computer. Replacing standard utilities (and sometimes even system calls) with ones that hide certain processes or ports (a.k.a. rootkits) is a standard practice among attackers. Your best bet at this point is to make a forensic copy of your disk and restore from backup; then use the copy to determine the way they got in and close it off.
If you do `nmap localhost`, it tells you about a different situation: some programs on linux work as server although they are used only locally. This is because other programs use them like a server they connect to. **So both answers are true, since you ask something different.** Port 23 is used for telnet. Normally not used anymore. Try to do `nmap -sV 192.168.1.1` to find out which program opens the port. (192... is a local network IP, so the result of `nmap <your outside world IP>` will also give a different result, because of possible firewall settings etc)
140,021
I have some question in closing port, I think I got some strange things. When I use execute ``` nmap --top-ports 10 192.168.1.1 ``` it shows that 23/TCP port is open. But when I execute ``` nmap --top-ports 10 localhost ``` it show that 23/tcp port is closed. Which of them is true? I want to close this port on my whole system, how can I do it?
2014/06/30
[ "https://unix.stackexchange.com/questions/140021", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/74080/" ]
If you do `nmap localhost`, it tells you about a different situation: some programs on linux work as server although they are used only locally. This is because other programs use them like a server they connect to. **So both answers are true, since you ask something different.** Port 23 is used for telnet. Normally not used anymore. Try to do `nmap -sV 192.168.1.1` to find out which program opens the port. (192... is a local network IP, so the result of `nmap <your outside world IP>` will also give a different result, because of possible firewall settings etc)
*If* you have a service running and listening on port 23, it is arguably cleaner to ***stop*** the process that listens to port 23 (probably `telnet`) than to keep it running and ***close or block*** port 23 using `iptables`. When there's no process listening on a port, even in the absence of a firewall block, any attempt to connect to it should result in an immediate "connection refused" (`ECONNREFUSED` to `connect(2)`) One way to find the process (and its pid) that listens on port 23, if there's such process, is: ``` sudo lsof -i -P | grep ':23 ' ``` In the above `-i` lists open internet ports (both UDP and TCP), and -P inhibits translation of ports to service names (via `/etc/services`) After you found the running process listening on port 23, you can figure out how it got started by looking at the process tree (with say, `pstree`). If its parent is `init` (very likely), you may recursively search for the name of the process under `/etc`. e.g.: ``` sudo grep -r telnet /etc ``` This should lead you to the best way to disable it from running in the 1st place.
140,021
I have some question in closing port, I think I got some strange things. When I use execute ``` nmap --top-ports 10 192.168.1.1 ``` it shows that 23/TCP port is open. But when I execute ``` nmap --top-ports 10 localhost ``` it show that 23/tcp port is closed. Which of them is true? I want to close this port on my whole system, how can I do it?
2014/06/30
[ "https://unix.stackexchange.com/questions/140021", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/74080/" ]
Nmap is a great port scanner, but sometimes you want something more authoritative. You can ask the kernel what processes have which ports open by using the `netstat` utility: ``` me@myhost:~$ sudo netstat -tlnp Active Internet connections (only servers) Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name tcp 0 0 127.0.0.1:53 0.0.0.0:* LISTEN 1004/dnsmasq tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 380/sshd tcp 0 0 127.0.0.1:631 0.0.0.0:* LISTEN 822/cupsd tcp6 0 0 :::22 :::* LISTEN 380/sshd tcp6 0 0 ::1:631 :::* LISTEN 822/cupsd ``` The options I have given are: * `-t` TCP only * `-l` Listening ports only * `-n` Don't look up service and host names, just display numbers * `-p` Show process information (requires root privilege) In this case, we can see that `sshd` is listening on any interface (`0.0.0.0`) port 22, and `cupsd` is listening on loopback (`127.0.0.1`) port 631. Your output may show that `telnetd` has a local address of `192.168.1.1:23`, meaning it will not answer to connections on the loopback adapter (e.g. you can't `telnet 127.0.0.1`). There are other tools that will show similar information (e.g. `lsof` or `/proc`), but netstat is the most widely available. It even works on Windows (`netstat -anb`). BSD netstat is a little different: you'll have to use [sockstat(1)](http://www.freebsd.org/cgi/man.cgi?query=sockstat&sektion=1) to get the process information instead. Once you have the process ID and program name, you can go about finding the process and killing it if you wish to close the port. For finer-grained control, you can use a firewall (iptables on Linux) to limit access to only certain addresses. You may need to disable a service startup. If the PID is "-" on Linux, it's probably a kernel process (this is common with NFS for instance), so good luck finding out what it is. Note: I said "authoritative" because you're not being hindered by network conditions and firewalls. If you trust your computer, that's great. However, if you suspect that you've been hacked, you may not be able to trust the tools on your computer. Replacing standard utilities (and sometimes even system calls) with ones that hide certain processes or ports (a.k.a. rootkits) is a standard practice among attackers. Your best bet at this point is to make a forensic copy of your disk and restore from backup; then use the copy to determine the way they got in and close it off.
*If* you have a service running and listening on port 23, it is arguably cleaner to ***stop*** the process that listens to port 23 (probably `telnet`) than to keep it running and ***close or block*** port 23 using `iptables`. When there's no process listening on a port, even in the absence of a firewall block, any attempt to connect to it should result in an immediate "connection refused" (`ECONNREFUSED` to `connect(2)`) One way to find the process (and its pid) that listens on port 23, if there's such process, is: ``` sudo lsof -i -P | grep ':23 ' ``` In the above `-i` lists open internet ports (both UDP and TCP), and -P inhibits translation of ports to service names (via `/etc/services`) After you found the running process listening on port 23, you can figure out how it got started by looking at the process tree (with say, `pstree`). If its parent is `init` (very likely), you may recursively search for the name of the process under `/etc`. e.g.: ``` sudo grep -r telnet /etc ``` This should lead you to the best way to disable it from running in the 1st place.
39,788,811
I have an Azure Logic app which picks a file from the Sharepoint site. In the next step, I want to parse the file contents to read them line-by-line and to pass each line in an Azure function I have already created. At this stage I am unable to fetch and loop through each line of the file. I can get the complete file only. Any suggestion on how to achieve this?
2016/09/30
[ "https://Stackoverflow.com/questions/39788811", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1480090/" ]
As of now there is no out-of box connector or function in LogicApp which parses a CSV file line by line. You can always vote for new features [feedback.azure.com/forums/287593-logic-apps?query=CSV](http://feedback.azure.com/forums/287593-logic-apps?query=CSV) 1. You will have to pass the whole content to the Azure Function that you already have and perform the necessary operation on it Or 2. There is a CSVToJson connector available in LogicApps github repo to use <https://github.com/logicappsio/CSVtoJSON> *Not officially supported but should be able to use it.*
Currently, there is a feature is Azure Logic App which can read Excel file from the given location. Take a look at this blog - <https://www.pmichaels.net/2018/04/22/what-can-you-do-with-a-logic-app-part-two-use-excel-to-manage-an-e-mail-notification-system/>, it's written pretty well and should give you a heads-up about using the feature.
34,413,120
I got a bug on my MediaPlayer. When i click on an item of my playlist, it create a mp3Player. If i press back the music play in background (all is normal). But if i choose another song from my app, the app create a new mediaplayer: Then i got 2 music playing ! I tried to use "singleTask", "singleInstance", and it's not working. I tried "intent.setFlags(Intent.FLAG\_ACTIVITY\_CLEAR\_TASK);" None of this work! Maybe if i could resume the previous Activity, i could destroy it and then create a nex mediaplayer no? Can someone help please? :D
2015/12/22
[ "https://Stackoverflow.com/questions/34413120", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5651162/" ]
My guess would be that you have already added a package globally that used `symfony/process ~3.0.0` but Lumen installer requires `symfony/process ~2.3` so composer cannot install both. You can either try to resolve this yourself by removing that package and installing Lumen installer globally, add the installer to your working directory (i.e. leave out the `global` keyword and you should be able to use it in that directory) or Lumen provides a way to install itself directly, by simply running: `composer create-project laravel/lumen YourProjectName --prefer-dist` in your installation directory.
Checking out the latest commits for lumen installer <https://github.com/laravel/lumen-installer>. It appears there was a recent fix to the installers dependencies (i.e. symfony/process ~2.3|~3.0). If you're keen to use the installer sooner rather than later get the dev-master version `composer global require "laravel/lumen-installer=dev-master"` until there is an official release. Otherwise you can wait until the fix is properly released.
59,575,919
What is driver name to be given in quarkus application? ``` quarkus.datasource.ergoint.driver=org.xxx.xxx.Driver ``` If it does not provide native support then how can we fix this adding dependency in maven project? **Note**: On official website nothing mentioned related to Oracle -> <https://quarkus.io/guides/datasource#multiple-datasources>
2020/01/03
[ "https://Stackoverflow.com/questions/59575919", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1382647/" ]
For the moment, there is no Oracle specific extension inside Quarkus, but there is an open issue for it you can +1 on it : <https://github.com/quarkusio/quarkus/issues/1658> If you need to use Oracle database, you can do it the same way you did for othe framework: add the dependency inside your pom.xml (easy now that Oracle provides them in Maven central) and configure it inside the application.properties In your case it should be ``` quarkus.datasource.ergoint.driver=oracle.jdbc.driver.OracleDriver ``` If you need to deploy your application as a native image, you will need some work to make the Oracle driver works, you can find some information here: <https://github.com/oracle/graal/issues/1748>
Here started to work with the following: ``` quarkus.datasource.db-kind=other quarkus.hibernate-orm.dialect=org.hibernate.dialect.OracleDialect quarkus.datasource.jdbc.driver=oracle.jdbc.driver.OracleDriver quarkus.datasource.jdbc.url=jdbc:oracle:thin:@XXX.XXX.XXX.XXX:1521:XXXXX quarkus.datasource.username=USERNAME quarkus.datasource.password=PASSWORD ```
59,575,919
What is driver name to be given in quarkus application? ``` quarkus.datasource.ergoint.driver=org.xxx.xxx.Driver ``` If it does not provide native support then how can we fix this adding dependency in maven project? **Note**: On official website nothing mentioned related to Oracle -> <https://quarkus.io/guides/datasource#multiple-datasources>
2020/01/03
[ "https://Stackoverflow.com/questions/59575919", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1382647/" ]
For the moment, there is no Oracle specific extension inside Quarkus, but there is an open issue for it you can +1 on it : <https://github.com/quarkusio/quarkus/issues/1658> If you need to use Oracle database, you can do it the same way you did for othe framework: add the dependency inside your pom.xml (easy now that Oracle provides them in Maven central) and configure it inside the application.properties In your case it should be ``` quarkus.datasource.ergoint.driver=oracle.jdbc.driver.OracleDriver ``` If you need to deploy your application as a native image, you will need some work to make the Oracle driver works, you can find some information here: <https://github.com/oracle/graal/issues/1748>
In release 1.13.2.Final the support for oracle has been added. ``` <dependency> <groupId>io.quarkus</groupId> <artifactId>quarkus-jdbc-oracle</artifactId> </dependency> quarkus.datasource.db-kind=oracle ```
25,649
I was reading the [Z80's official manual by Zilog](https://www.zilog.com/docs/z80/um0080.pdf), and there's a passage in the description for the BUSREQ pin that states "Bus Request contains a higher priority than NMI and is always recognized at the end of the current machine cycle". It got me thinking though, is it possible to use the BUSREQ as an NMI, if for some reason the NMI pin is unavailable (e.g. burned out) and if so, how could that be done?
2022/11/20
[ "https://retrocomputing.stackexchange.com/questions/25649", "https://retrocomputing.stackexchange.com", "https://retrocomputing.stackexchange.com/users/25931/" ]
A hardware interrupt changes the Program Counter (PC) so that a CPU executes instructions from a specific address, where an interrupt service routine (ISR) is located. The Z80 Bus Request `/BUSREQ` doesn't change the PC. Instead, the Z80 suspends execution and tri-states its address/data/control buses. After `/BUSREQ` is negated, the Z80 carries on and executes the next instruction. The `/WAIT` pin also stops execution, with effectively higher priority than the interrupts, but also has nothing to do with generating interrupts. I think you're looking too deeply into the simple statement "*Bus Request contains a higher priority than NMI and is always recognized at the end of the current machine cycle*" and seeing a meaning and possibilities that aren't there.
The purpose of NMI is to cause the Z80 to execute code located at the NMI handler. The purpose of Bus Request is to prevent the Z80 from executing *any* code until whatever wanted the bus is done with it, but not affect the sequences of instructions and memory operations performed by Z80. By way of analogy, think of NMI as being a light-up "detour" sign and Bus Request as being an ordinary traffic signal. When Bus Request indicates that the Z80 should get off the bus as soon as possible, it can't stop any car which is in the intersection or too close through it, but it will be "recognized" once all cars that will go through before the next green light have done so.
25,235,453
I am just setting up nginx as a webserver that proxies directly to a tomcat app server. When the user connects to my website Nginx should redirect the request to port 8080 where the tomcat app server is running. I am doing everything on amazon ec2 instance that is running Redhat 7. What I have so far is this: ``` nginx.conf file user nginx; worker_processes 1; server { listen 80; server_name mydomainname; access_log /var/log/nginx/example.log; error_log /var/log/nginx/example.error.log; location / { proxy_pass http://localhost:8080/example/; } } ``` The error that I am getting is **(13: Permission denied) while connecting to upstream, client** This is definitely a user access issue, but cannot seem to figure it out. It seems like nginx does not have access to redirect to port 8080. Also, nginx is running under myuser ``` root 15736 nginx: master process /usr/sbin/nginx myuser 15996 nginx: worker process root 16017 grep --color=auto nginx ``` I have tried to put 127.0.0.1 instead of localhost, but no luck. I have also tried to change the user in the nginx.conf to myuser, still no luck. When I connect directly to the application sever I have no issues. ``` Example URL of my tomcat http://mydomain:8080/example/ ``` Thank you in advance.
2014/08/11
[ "https://Stackoverflow.com/questions/25235453", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1653068/" ]
I was able to find a solution after 2 days of searching. Somehow SELinux was not permitting Nginx to proxy to my server. Running the command below fixed the issue. ``` /usr/sbin/setsebool -P httpd_can_network_connect true ``` Adding the -P flag thanks to @DaveTrux
you can move to see this issue: [stackoverflow questions 23443398](https://stackoverflow.com/questions/23443398/nginx-error-connect-to-php5-fpm-sock-failed-13-permission-denied) Basically it's the problem of the permission for socket: *Set permissions for unix socket, if one is used. In Linux, read/write permissions must be set in order to allow connections from a web server...*
62,364,702
I have a list of lists such as ``` words_list=[['word1', 'word2','word3'],['word1', 'word2', 'word3','word4'],['word5', 'word6'],['word5', 'word6', 'word7'],['word5', 'word6', 'word7'],['... and so on ...']] ``` and I counted how many times a list is in the dataset: ``` c = Counter(tuple(x) for x in iter(words_list)) ``` output: ``` Counter({('word1', 'word2','word3'): 1, ('word1', 'word2', 'word3','word4'): 1, ('word5', 'word6'): 1, ('word5', 'word6', 'word7'): 2}) ``` I would like to also count as the same lists that are included in others; for example, I would like to count as one ``` ('word1', 'word2','word3') ('word1', 'word2', 'word3','word4') ``` and ``` ('word5', 'word6') ('word5', 'word6', 'word7') ('word5', 'word6', 'word7') ``` My expected output should be ``` ('word1', 'word2', 'word3','word4'): 2 ('word5', 'word6', 'word7'): 3 # UPDATED! ``` (or, alternatively - this would be actually better as a user let me notice: ``` ('word1', 'word2', 'word3'): 2 ('word5', 'word6'): 3 # UPDATED! ``` considering the smallest groups) To check if a list is contained in another one (separated) list, I would do ``` def removeElements(x, y): for i in range(len(y)-len(x)+1): for j in range(len(x)): if y[i + j] != x[j]: break else: return True return False ``` and this would give me a boolean value, so I could count the cases where the value is True. However I think this is not a good way to proceed...
2020/06/13
[ "https://Stackoverflow.com/questions/62364702", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
This declaration ``` int a[i][j] ; //i =number of rows and j = number of columns ``` requires that the variables `i` and `j` would be compile-time constants. Variable length arrays is not a standard C++n feature though some compilers can have their own language extensions that include this feature. The second problem that exists is if sizes of an array are too big then the compiler can be unable to create such an array with automatic storage duration. So if `i` and `j` are not compile-time constants or are too big then you have to allocated memory dynamically yourself or you can use the standard container `std::vector`.
If we can do it using the above normal declaration. It will make the code faster or something? no all in above code you create an array in the stack it will be deleted if the function out of scope it will be removed automatically the second is created in heap it will still in the heap until u delete it by self
62,364,702
I have a list of lists such as ``` words_list=[['word1', 'word2','word3'],['word1', 'word2', 'word3','word4'],['word5', 'word6'],['word5', 'word6', 'word7'],['word5', 'word6', 'word7'],['... and so on ...']] ``` and I counted how many times a list is in the dataset: ``` c = Counter(tuple(x) for x in iter(words_list)) ``` output: ``` Counter({('word1', 'word2','word3'): 1, ('word1', 'word2', 'word3','word4'): 1, ('word5', 'word6'): 1, ('word5', 'word6', 'word7'): 2}) ``` I would like to also count as the same lists that are included in others; for example, I would like to count as one ``` ('word1', 'word2','word3') ('word1', 'word2', 'word3','word4') ``` and ``` ('word5', 'word6') ('word5', 'word6', 'word7') ('word5', 'word6', 'word7') ``` My expected output should be ``` ('word1', 'word2', 'word3','word4'): 2 ('word5', 'word6', 'word7'): 3 # UPDATED! ``` (or, alternatively - this would be actually better as a user let me notice: ``` ('word1', 'word2', 'word3'): 2 ('word5', 'word6'): 3 # UPDATED! ``` considering the smallest groups) To check if a list is contained in another one (separated) list, I would do ``` def removeElements(x, y): for i in range(len(y)-len(x)+1): for j in range(len(x)): if y[i + j] != x[j]: break else: return True return False ``` and this would give me a boolean value, so I could count the cases where the value is True. However I think this is not a good way to proceed...
2020/06/13
[ "https://Stackoverflow.com/questions/62364702", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
This declaration ``` int a[i][j] ; //i =number of rows and j = number of columns ``` requires that the variables `i` and `j` would be compile-time constants. Variable length arrays is not a standard C++n feature though some compilers can have their own language extensions that include this feature. The second problem that exists is if sizes of an array are too big then the compiler can be unable to create such an array with automatic storage duration. So if `i` and `j` are not compile-time constants or are too big then you have to allocated memory dynamically yourself or you can use the standard container `std::vector`.
Both ways of array declaration are useful in different use cases. The declaration: ``` int a[i][j]; ``` declares an array statically and it uses stack memory to store the array or we can say that the memory is allocated at the runtime. This type of array declaration requires you to pass the value 'n' and the size of the array can not be altered after it's been declared. That's where it has a drawback as you can not increase the size if you want to store some more elements. Also if you stored less elements than 'n', then the remaining memory gets wasted. The other type of declaration: ``` int *a = new int[n]; //For 1D array ``` creates a dynamically allocated memory. In other words, in this type of declaration memory allocation takes place only when an element is placed in the array or at the runtime. This allocation ensures that there is no memory wastage and stores the elements of the array in the heap memory. But in this type of declaration, you also need to deallocate the memory otherwise it may cause memory leaks because C++ has nothing like a garbage collector.
3,363
I'm currently considering to buy one of the next generation enthusiast DSLRs. Either a Canon EOS 60D or the slightly more expensive Nikon D7000. I'm quite new to the SLR discussion but I know there are some controversial opinions about Canon vs. Nikon. But I often read that (the better) Nikon lenses are higher quality but also much more expensive (more premium, in quality and in price). Is that the case? What is your opinion of the Canon vs. Nikon lens comparison? Which types of lenses are better from Canon which are higher quality from Nikon? How do the prices compare? What is the quality/price ratio in your opinion?
2010/09/18
[ "https://photo.stackexchange.com/questions/3363", "https://photo.stackexchange.com", "https://photo.stackexchange.com/users/1387/" ]
Some starter references (while these sites might be biased, they do enumerate the points to look at). Some of the discussions also compare Nikon and Canon bodies 1. [Canon versus Nikon lenses](http://www.radiantlite.com/2008/07/canon-versus-nikon-lenses.html) at Radiant Lite Photography * rounds up with a reference to third party pro grade lenses such as Sigma, Tokina and Tamron. 2. [Nikon vs. Canon](http://www.kenrockwell.com/tech/nikon-vs-canon.htm) at `Kenrockwell.com` * [Canon cameras can use Nikon lenses](http://www.kenrockwell.com/tech/nikcan.htm), but [Nikon cameras can't use Canon lenses](http://photo.net/filters-bags-tripods-accessories-forum/009kjO). 3. A list of [Nikon D1 Lenses](http://www.outbackphoto.com/reviews/equipment/lenses/ronreznick.html) and one of [Canon lenses](http://www.luminous-landscape.com/reviews/lenses/canon_lenses.shtml). 4. An old (film) [Nikon and Canon comparison](http://photo.net/equipment/35mm/canon-v-nikon) as reference
It's worth knowing that there are certain lenses that only Canon or Nikon make, for example there is no Nikon 800mm f/5.6 currently in production. For some photography niches there's a genuine reasons to go with one manufacturer. It's also worth noting that there didn't used to be tilt-shift (perspective correction) lenses in production at Nikon a couple of years ago, but there are now. So just because there are gaps now in a manufacturers lineups doesn't mean it will stay that way for long in the ever more competitive DSLR market!
3,363
I'm currently considering to buy one of the next generation enthusiast DSLRs. Either a Canon EOS 60D or the slightly more expensive Nikon D7000. I'm quite new to the SLR discussion but I know there are some controversial opinions about Canon vs. Nikon. But I often read that (the better) Nikon lenses are higher quality but also much more expensive (more premium, in quality and in price). Is that the case? What is your opinion of the Canon vs. Nikon lens comparison? Which types of lenses are better from Canon which are higher quality from Nikon? How do the prices compare? What is the quality/price ratio in your opinion?
2010/09/18
[ "https://photo.stackexchange.com/questions/3363", "https://photo.stackexchange.com", "https://photo.stackexchange.com/users/1387/" ]
Some starter references (while these sites might be biased, they do enumerate the points to look at). Some of the discussions also compare Nikon and Canon bodies 1. [Canon versus Nikon lenses](http://www.radiantlite.com/2008/07/canon-versus-nikon-lenses.html) at Radiant Lite Photography * rounds up with a reference to third party pro grade lenses such as Sigma, Tokina and Tamron. 2. [Nikon vs. Canon](http://www.kenrockwell.com/tech/nikon-vs-canon.htm) at `Kenrockwell.com` * [Canon cameras can use Nikon lenses](http://www.kenrockwell.com/tech/nikcan.htm), but [Nikon cameras can't use Canon lenses](http://photo.net/filters-bags-tripods-accessories-forum/009kjO). 3. A list of [Nikon D1 Lenses](http://www.outbackphoto.com/reviews/equipment/lenses/ronreznick.html) and one of [Canon lenses](http://www.luminous-landscape.com/reviews/lenses/canon_lenses.shtml). 4. An old (film) [Nikon and Canon comparison](http://photo.net/equipment/35mm/canon-v-nikon) as reference
Well, Nikon makes a 12-24/2.8 zoom and Canon has nothing like it. Canon has the 85/1.2. For a given price point and spec (e.g. canon or nikon 300/2.8), there's little point arguing as differences will be insignificant. Canon L's are white, which can attract attention. I recall someone lauding the Canon 200/2.8 because it was black and more likely to pass-off as an amateur lens (and thus avoid scrutiny by overzealous security guards).
3,363
I'm currently considering to buy one of the next generation enthusiast DSLRs. Either a Canon EOS 60D or the slightly more expensive Nikon D7000. I'm quite new to the SLR discussion but I know there are some controversial opinions about Canon vs. Nikon. But I often read that (the better) Nikon lenses are higher quality but also much more expensive (more premium, in quality and in price). Is that the case? What is your opinion of the Canon vs. Nikon lens comparison? Which types of lenses are better from Canon which are higher quality from Nikon? How do the prices compare? What is the quality/price ratio in your opinion?
2010/09/18
[ "https://photo.stackexchange.com/questions/3363", "https://photo.stackexchange.com", "https://photo.stackexchange.com/users/1387/" ]
Some starter references (while these sites might be biased, they do enumerate the points to look at). Some of the discussions also compare Nikon and Canon bodies 1. [Canon versus Nikon lenses](http://www.radiantlite.com/2008/07/canon-versus-nikon-lenses.html) at Radiant Lite Photography * rounds up with a reference to third party pro grade lenses such as Sigma, Tokina and Tamron. 2. [Nikon vs. Canon](http://www.kenrockwell.com/tech/nikon-vs-canon.htm) at `Kenrockwell.com` * [Canon cameras can use Nikon lenses](http://www.kenrockwell.com/tech/nikcan.htm), but [Nikon cameras can't use Canon lenses](http://photo.net/filters-bags-tripods-accessories-forum/009kjO). 3. A list of [Nikon D1 Lenses](http://www.outbackphoto.com/reviews/equipment/lenses/ronreznick.html) and one of [Canon lenses](http://www.luminous-landscape.com/reviews/lenses/canon_lenses.shtml). 4. An old (film) [Nikon and Canon comparison](http://photo.net/equipment/35mm/canon-v-nikon) as reference
I will try to be as impartial as possible here. Both Canon and Nikon make some simply stunning lenses. As already noted, it's worth checking that if you have any specific requirements that the manufacturer does indeed make that lens. Although it doesn't make any difference to the photos note that the Canon's and Nikons attach to the body in different ways - the Canon twists counterclockwise to lock into place, whilst the Nikon twists clockwise. Also, any zoom rings on Nikon are the reverse of Canon, so on a Canon lens, a 24-70mm would read on the zoom ring as you look at it, as 24 on the left, twisting round to 70, whereas on a Nikon lens, the 70 would be on the left, and as you twist it goes down to 24. (I'm not sure I've explained that entirely well??). The other thing to note with Nikon lenses, is that depending on the body, it may not have the ability to autofocus. If the camera body you purchase does not have an in-built focus motor, then if it's not an AF-S or AF-I lens, it will not autofocus. With Canon, unless otherwise stated, all EF lenses have the motor built into them and so will autofocus regardless of the body they are mounted on (the EF MP-E 65mm f/2.8 is an example of a lens that won't autofocus - but it *is* a very specialised lens). That said, you did note that your Nikon body of choice would be the D7000, and this does indeed have a focus motor so this won't affect you. But it's just something you should bear in mind as a difference of the lens if you should ever wish, say, to put a lens on a D40 or something that doesn't have the focus motor. Another thing is the aperture control. In Nikon, this is mechanical. There is actually a little catch on the back of the lens, which you can manipulate with your finger and see the aperture open and close. Canon's are all electronic, so you can't do this. On the subject of aperture, Nikon also make their D series of lenses which have the aperture control ring on the lens, so if you wish you can manually stop your lens down to whatever you wish. No Canon EF lens (that I know of) allows you to do this. Optical quality between Canon and Nikon is subjective. Both companies make fantastic quality lenses with the Nikon 85mm f1.4G, or Canon 85mm f/1.2L, etc. But equally both companies also make comparitively cheap lenses such as the 18-55 kit lens and slow 70-300's etc. It really is 6 of one and half a dozen of each other. The camera you attach the lens to will have a lot to do with how the lens performs too. But I hear great things about the D7000. Not so sure about the 60D as I've not had any experience of it but I'm sure it's a fine camera. I believe it has the same sensor as the 7D so should be more than capable! Regarding third-party lenses, most manufacturers make their lenses for both Nikon F mount and Canon EF mount. Zeiss and Samyang lenses are all manual focus only. Sigma, Tamron, Tokina etc should be AF. Hope that helps.
3,363
I'm currently considering to buy one of the next generation enthusiast DSLRs. Either a Canon EOS 60D or the slightly more expensive Nikon D7000. I'm quite new to the SLR discussion but I know there are some controversial opinions about Canon vs. Nikon. But I often read that (the better) Nikon lenses are higher quality but also much more expensive (more premium, in quality and in price). Is that the case? What is your opinion of the Canon vs. Nikon lens comparison? Which types of lenses are better from Canon which are higher quality from Nikon? How do the prices compare? What is the quality/price ratio in your opinion?
2010/09/18
[ "https://photo.stackexchange.com/questions/3363", "https://photo.stackexchange.com", "https://photo.stackexchange.com/users/1387/" ]
Some starter references (while these sites might be biased, they do enumerate the points to look at). Some of the discussions also compare Nikon and Canon bodies 1. [Canon versus Nikon lenses](http://www.radiantlite.com/2008/07/canon-versus-nikon-lenses.html) at Radiant Lite Photography * rounds up with a reference to third party pro grade lenses such as Sigma, Tokina and Tamron. 2. [Nikon vs. Canon](http://www.kenrockwell.com/tech/nikon-vs-canon.htm) at `Kenrockwell.com` * [Canon cameras can use Nikon lenses](http://www.kenrockwell.com/tech/nikcan.htm), but [Nikon cameras can't use Canon lenses](http://photo.net/filters-bags-tripods-accessories-forum/009kjO). 3. A list of [Nikon D1 Lenses](http://www.outbackphoto.com/reviews/equipment/lenses/ronreznick.html) and one of [Canon lenses](http://www.luminous-landscape.com/reviews/lenses/canon_lenses.shtml). 4. An old (film) [Nikon and Canon comparison](http://photo.net/equipment/35mm/canon-v-nikon) as reference
CANON 1Dx is the fastest and toughest camera ever build. canon has 17mm TS-E, 100mm macro IS (truly effective not like Nikon), 50 mm and 85mm f/1.2 (fastest prime for less than $2k) Nikon has 14-24mm f/2.8 (sharpest wide angle zoom), 13mm (legendary but not as sharp as other) Similarity but price/performance different: 800mm (Nikon just launch it for $4000 more vs CAnon $14000), hard to kill cheap 17-40mm L (Nikon 16-35mm is fragile), 28-300mm L (Nikon version is inferior but half price), $1400 100-400mm L(Nikon version 80-400mm $1300 more but similar image quality), 200-400mm (CAnon is sharper but $4000 more expensive than Nikon).
3,363
I'm currently considering to buy one of the next generation enthusiast DSLRs. Either a Canon EOS 60D or the slightly more expensive Nikon D7000. I'm quite new to the SLR discussion but I know there are some controversial opinions about Canon vs. Nikon. But I often read that (the better) Nikon lenses are higher quality but also much more expensive (more premium, in quality and in price). Is that the case? What is your opinion of the Canon vs. Nikon lens comparison? Which types of lenses are better from Canon which are higher quality from Nikon? How do the prices compare? What is the quality/price ratio in your opinion?
2010/09/18
[ "https://photo.stackexchange.com/questions/3363", "https://photo.stackexchange.com", "https://photo.stackexchange.com/users/1387/" ]
It's worth knowing that there are certain lenses that only Canon or Nikon make, for example there is no Nikon 800mm f/5.6 currently in production. For some photography niches there's a genuine reasons to go with one manufacturer. It's also worth noting that there didn't used to be tilt-shift (perspective correction) lenses in production at Nikon a couple of years ago, but there are now. So just because there are gaps now in a manufacturers lineups doesn't mean it will stay that way for long in the ever more competitive DSLR market!
Well, Nikon makes a 12-24/2.8 zoom and Canon has nothing like it. Canon has the 85/1.2. For a given price point and spec (e.g. canon or nikon 300/2.8), there's little point arguing as differences will be insignificant. Canon L's are white, which can attract attention. I recall someone lauding the Canon 200/2.8 because it was black and more likely to pass-off as an amateur lens (and thus avoid scrutiny by overzealous security guards).
3,363
I'm currently considering to buy one of the next generation enthusiast DSLRs. Either a Canon EOS 60D or the slightly more expensive Nikon D7000. I'm quite new to the SLR discussion but I know there are some controversial opinions about Canon vs. Nikon. But I often read that (the better) Nikon lenses are higher quality but also much more expensive (more premium, in quality and in price). Is that the case? What is your opinion of the Canon vs. Nikon lens comparison? Which types of lenses are better from Canon which are higher quality from Nikon? How do the prices compare? What is the quality/price ratio in your opinion?
2010/09/18
[ "https://photo.stackexchange.com/questions/3363", "https://photo.stackexchange.com", "https://photo.stackexchange.com/users/1387/" ]
It's worth knowing that there are certain lenses that only Canon or Nikon make, for example there is no Nikon 800mm f/5.6 currently in production. For some photography niches there's a genuine reasons to go with one manufacturer. It's also worth noting that there didn't used to be tilt-shift (perspective correction) lenses in production at Nikon a couple of years ago, but there are now. So just because there are gaps now in a manufacturers lineups doesn't mean it will stay that way for long in the ever more competitive DSLR market!
I will try to be as impartial as possible here. Both Canon and Nikon make some simply stunning lenses. As already noted, it's worth checking that if you have any specific requirements that the manufacturer does indeed make that lens. Although it doesn't make any difference to the photos note that the Canon's and Nikons attach to the body in different ways - the Canon twists counterclockwise to lock into place, whilst the Nikon twists clockwise. Also, any zoom rings on Nikon are the reverse of Canon, so on a Canon lens, a 24-70mm would read on the zoom ring as you look at it, as 24 on the left, twisting round to 70, whereas on a Nikon lens, the 70 would be on the left, and as you twist it goes down to 24. (I'm not sure I've explained that entirely well??). The other thing to note with Nikon lenses, is that depending on the body, it may not have the ability to autofocus. If the camera body you purchase does not have an in-built focus motor, then if it's not an AF-S or AF-I lens, it will not autofocus. With Canon, unless otherwise stated, all EF lenses have the motor built into them and so will autofocus regardless of the body they are mounted on (the EF MP-E 65mm f/2.8 is an example of a lens that won't autofocus - but it *is* a very specialised lens). That said, you did note that your Nikon body of choice would be the D7000, and this does indeed have a focus motor so this won't affect you. But it's just something you should bear in mind as a difference of the lens if you should ever wish, say, to put a lens on a D40 or something that doesn't have the focus motor. Another thing is the aperture control. In Nikon, this is mechanical. There is actually a little catch on the back of the lens, which you can manipulate with your finger and see the aperture open and close. Canon's are all electronic, so you can't do this. On the subject of aperture, Nikon also make their D series of lenses which have the aperture control ring on the lens, so if you wish you can manually stop your lens down to whatever you wish. No Canon EF lens (that I know of) allows you to do this. Optical quality between Canon and Nikon is subjective. Both companies make fantastic quality lenses with the Nikon 85mm f1.4G, or Canon 85mm f/1.2L, etc. But equally both companies also make comparitively cheap lenses such as the 18-55 kit lens and slow 70-300's etc. It really is 6 of one and half a dozen of each other. The camera you attach the lens to will have a lot to do with how the lens performs too. But I hear great things about the D7000. Not so sure about the 60D as I've not had any experience of it but I'm sure it's a fine camera. I believe it has the same sensor as the 7D so should be more than capable! Regarding third-party lenses, most manufacturers make their lenses for both Nikon F mount and Canon EF mount. Zeiss and Samyang lenses are all manual focus only. Sigma, Tamron, Tokina etc should be AF. Hope that helps.
3,363
I'm currently considering to buy one of the next generation enthusiast DSLRs. Either a Canon EOS 60D or the slightly more expensive Nikon D7000. I'm quite new to the SLR discussion but I know there are some controversial opinions about Canon vs. Nikon. But I often read that (the better) Nikon lenses are higher quality but also much more expensive (more premium, in quality and in price). Is that the case? What is your opinion of the Canon vs. Nikon lens comparison? Which types of lenses are better from Canon which are higher quality from Nikon? How do the prices compare? What is the quality/price ratio in your opinion?
2010/09/18
[ "https://photo.stackexchange.com/questions/3363", "https://photo.stackexchange.com", "https://photo.stackexchange.com/users/1387/" ]
It's worth knowing that there are certain lenses that only Canon or Nikon make, for example there is no Nikon 800mm f/5.6 currently in production. For some photography niches there's a genuine reasons to go with one manufacturer. It's also worth noting that there didn't used to be tilt-shift (perspective correction) lenses in production at Nikon a couple of years ago, but there are now. So just because there are gaps now in a manufacturers lineups doesn't mean it will stay that way for long in the ever more competitive DSLR market!
CANON 1Dx is the fastest and toughest camera ever build. canon has 17mm TS-E, 100mm macro IS (truly effective not like Nikon), 50 mm and 85mm f/1.2 (fastest prime for less than $2k) Nikon has 14-24mm f/2.8 (sharpest wide angle zoom), 13mm (legendary but not as sharp as other) Similarity but price/performance different: 800mm (Nikon just launch it for $4000 more vs CAnon $14000), hard to kill cheap 17-40mm L (Nikon 16-35mm is fragile), 28-300mm L (Nikon version is inferior but half price), $1400 100-400mm L(Nikon version 80-400mm $1300 more but similar image quality), 200-400mm (CAnon is sharper but $4000 more expensive than Nikon).
3,363
I'm currently considering to buy one of the next generation enthusiast DSLRs. Either a Canon EOS 60D or the slightly more expensive Nikon D7000. I'm quite new to the SLR discussion but I know there are some controversial opinions about Canon vs. Nikon. But I often read that (the better) Nikon lenses are higher quality but also much more expensive (more premium, in quality and in price). Is that the case? What is your opinion of the Canon vs. Nikon lens comparison? Which types of lenses are better from Canon which are higher quality from Nikon? How do the prices compare? What is the quality/price ratio in your opinion?
2010/09/18
[ "https://photo.stackexchange.com/questions/3363", "https://photo.stackexchange.com", "https://photo.stackexchange.com/users/1387/" ]
I will try to be as impartial as possible here. Both Canon and Nikon make some simply stunning lenses. As already noted, it's worth checking that if you have any specific requirements that the manufacturer does indeed make that lens. Although it doesn't make any difference to the photos note that the Canon's and Nikons attach to the body in different ways - the Canon twists counterclockwise to lock into place, whilst the Nikon twists clockwise. Also, any zoom rings on Nikon are the reverse of Canon, so on a Canon lens, a 24-70mm would read on the zoom ring as you look at it, as 24 on the left, twisting round to 70, whereas on a Nikon lens, the 70 would be on the left, and as you twist it goes down to 24. (I'm not sure I've explained that entirely well??). The other thing to note with Nikon lenses, is that depending on the body, it may not have the ability to autofocus. If the camera body you purchase does not have an in-built focus motor, then if it's not an AF-S or AF-I lens, it will not autofocus. With Canon, unless otherwise stated, all EF lenses have the motor built into them and so will autofocus regardless of the body they are mounted on (the EF MP-E 65mm f/2.8 is an example of a lens that won't autofocus - but it *is* a very specialised lens). That said, you did note that your Nikon body of choice would be the D7000, and this does indeed have a focus motor so this won't affect you. But it's just something you should bear in mind as a difference of the lens if you should ever wish, say, to put a lens on a D40 or something that doesn't have the focus motor. Another thing is the aperture control. In Nikon, this is mechanical. There is actually a little catch on the back of the lens, which you can manipulate with your finger and see the aperture open and close. Canon's are all electronic, so you can't do this. On the subject of aperture, Nikon also make their D series of lenses which have the aperture control ring on the lens, so if you wish you can manually stop your lens down to whatever you wish. No Canon EF lens (that I know of) allows you to do this. Optical quality between Canon and Nikon is subjective. Both companies make fantastic quality lenses with the Nikon 85mm f1.4G, or Canon 85mm f/1.2L, etc. But equally both companies also make comparitively cheap lenses such as the 18-55 kit lens and slow 70-300's etc. It really is 6 of one and half a dozen of each other. The camera you attach the lens to will have a lot to do with how the lens performs too. But I hear great things about the D7000. Not so sure about the 60D as I've not had any experience of it but I'm sure it's a fine camera. I believe it has the same sensor as the 7D so should be more than capable! Regarding third-party lenses, most manufacturers make their lenses for both Nikon F mount and Canon EF mount. Zeiss and Samyang lenses are all manual focus only. Sigma, Tamron, Tokina etc should be AF. Hope that helps.
Well, Nikon makes a 12-24/2.8 zoom and Canon has nothing like it. Canon has the 85/1.2. For a given price point and spec (e.g. canon or nikon 300/2.8), there's little point arguing as differences will be insignificant. Canon L's are white, which can attract attention. I recall someone lauding the Canon 200/2.8 because it was black and more likely to pass-off as an amateur lens (and thus avoid scrutiny by overzealous security guards).
3,363
I'm currently considering to buy one of the next generation enthusiast DSLRs. Either a Canon EOS 60D or the slightly more expensive Nikon D7000. I'm quite new to the SLR discussion but I know there are some controversial opinions about Canon vs. Nikon. But I often read that (the better) Nikon lenses are higher quality but also much more expensive (more premium, in quality and in price). Is that the case? What is your opinion of the Canon vs. Nikon lens comparison? Which types of lenses are better from Canon which are higher quality from Nikon? How do the prices compare? What is the quality/price ratio in your opinion?
2010/09/18
[ "https://photo.stackexchange.com/questions/3363", "https://photo.stackexchange.com", "https://photo.stackexchange.com/users/1387/" ]
Well, Nikon makes a 12-24/2.8 zoom and Canon has nothing like it. Canon has the 85/1.2. For a given price point and spec (e.g. canon or nikon 300/2.8), there's little point arguing as differences will be insignificant. Canon L's are white, which can attract attention. I recall someone lauding the Canon 200/2.8 because it was black and more likely to pass-off as an amateur lens (and thus avoid scrutiny by overzealous security guards).
CANON 1Dx is the fastest and toughest camera ever build. canon has 17mm TS-E, 100mm macro IS (truly effective not like Nikon), 50 mm and 85mm f/1.2 (fastest prime for less than $2k) Nikon has 14-24mm f/2.8 (sharpest wide angle zoom), 13mm (legendary but not as sharp as other) Similarity but price/performance different: 800mm (Nikon just launch it for $4000 more vs CAnon $14000), hard to kill cheap 17-40mm L (Nikon 16-35mm is fragile), 28-300mm L (Nikon version is inferior but half price), $1400 100-400mm L(Nikon version 80-400mm $1300 more but similar image quality), 200-400mm (CAnon is sharper but $4000 more expensive than Nikon).
3,363
I'm currently considering to buy one of the next generation enthusiast DSLRs. Either a Canon EOS 60D or the slightly more expensive Nikon D7000. I'm quite new to the SLR discussion but I know there are some controversial opinions about Canon vs. Nikon. But I often read that (the better) Nikon lenses are higher quality but also much more expensive (more premium, in quality and in price). Is that the case? What is your opinion of the Canon vs. Nikon lens comparison? Which types of lenses are better from Canon which are higher quality from Nikon? How do the prices compare? What is the quality/price ratio in your opinion?
2010/09/18
[ "https://photo.stackexchange.com/questions/3363", "https://photo.stackexchange.com", "https://photo.stackexchange.com/users/1387/" ]
I will try to be as impartial as possible here. Both Canon and Nikon make some simply stunning lenses. As already noted, it's worth checking that if you have any specific requirements that the manufacturer does indeed make that lens. Although it doesn't make any difference to the photos note that the Canon's and Nikons attach to the body in different ways - the Canon twists counterclockwise to lock into place, whilst the Nikon twists clockwise. Also, any zoom rings on Nikon are the reverse of Canon, so on a Canon lens, a 24-70mm would read on the zoom ring as you look at it, as 24 on the left, twisting round to 70, whereas on a Nikon lens, the 70 would be on the left, and as you twist it goes down to 24. (I'm not sure I've explained that entirely well??). The other thing to note with Nikon lenses, is that depending on the body, it may not have the ability to autofocus. If the camera body you purchase does not have an in-built focus motor, then if it's not an AF-S or AF-I lens, it will not autofocus. With Canon, unless otherwise stated, all EF lenses have the motor built into them and so will autofocus regardless of the body they are mounted on (the EF MP-E 65mm f/2.8 is an example of a lens that won't autofocus - but it *is* a very specialised lens). That said, you did note that your Nikon body of choice would be the D7000, and this does indeed have a focus motor so this won't affect you. But it's just something you should bear in mind as a difference of the lens if you should ever wish, say, to put a lens on a D40 or something that doesn't have the focus motor. Another thing is the aperture control. In Nikon, this is mechanical. There is actually a little catch on the back of the lens, which you can manipulate with your finger and see the aperture open and close. Canon's are all electronic, so you can't do this. On the subject of aperture, Nikon also make their D series of lenses which have the aperture control ring on the lens, so if you wish you can manually stop your lens down to whatever you wish. No Canon EF lens (that I know of) allows you to do this. Optical quality between Canon and Nikon is subjective. Both companies make fantastic quality lenses with the Nikon 85mm f1.4G, or Canon 85mm f/1.2L, etc. But equally both companies also make comparitively cheap lenses such as the 18-55 kit lens and slow 70-300's etc. It really is 6 of one and half a dozen of each other. The camera you attach the lens to will have a lot to do with how the lens performs too. But I hear great things about the D7000. Not so sure about the 60D as I've not had any experience of it but I'm sure it's a fine camera. I believe it has the same sensor as the 7D so should be more than capable! Regarding third-party lenses, most manufacturers make their lenses for both Nikon F mount and Canon EF mount. Zeiss and Samyang lenses are all manual focus only. Sigma, Tamron, Tokina etc should be AF. Hope that helps.
CANON 1Dx is the fastest and toughest camera ever build. canon has 17mm TS-E, 100mm macro IS (truly effective not like Nikon), 50 mm and 85mm f/1.2 (fastest prime for less than $2k) Nikon has 14-24mm f/2.8 (sharpest wide angle zoom), 13mm (legendary but not as sharp as other) Similarity but price/performance different: 800mm (Nikon just launch it for $4000 more vs CAnon $14000), hard to kill cheap 17-40mm L (Nikon 16-35mm is fragile), 28-300mm L (Nikon version is inferior but half price), $1400 100-400mm L(Nikon version 80-400mm $1300 more but similar image quality), 200-400mm (CAnon is sharper but $4000 more expensive than Nikon).
65,591
i am adding the form field through the observer but cannot able to post form field on mass action below my code ``` public function render(Varien_Object $row) { $orderdata=Mage::getModel('sales/order')->load($row->getEntityId()); $value .='Carrier:'; $value .='<select name="carrier'.$row->getEntityId().'">'; $options=$this->getCarrierOption(); foreach ($options as $option) { $value .='<option value="'.$option['value'].'">'.$option['label'].'</option>'; } $value .='</select>'; return $value.$valyee; } } ``` any help will be appreciated.
2015/05/04
[ "https://magento.stackexchange.com/questions/65591", "https://magento.stackexchange.com", "https://magento.stackexchange.com/users/24541/" ]
This approach is wrong, you cannot post from the grid area because there is no form in grid area for posting the form fields, form fields must be in between tags. Try something like this. ``` <form method="post" id="sales_order_grid_massaction-form" action=""> <select class="required-entry select absolute-advice local-validation" id="sales_order_grid_massaction-select"> <option value="order">Order</option> </select> </form> ``` you can see in my code all fields are come under form tag so you should do like this.
rather than using an Observer why don't you create a module. You could override the collection class and display the carrier type for each order and mass actions will work. You could try with the references from the following sites to help you out <https://inchoo.net/magento/how-to-extend-magento-order-grid/> <http://www.demacmedia.com/magento-commerce/mini-tutorial-adding-column-to-orders-grid-in-magento-backend/> hope that helps!
21,103,732
Can I extend syntax in python for dict comprehensions for other dicts, like the OrderedDict in `collections` module or my own types which inherit from `dict`? Just rebinding the `dict` name obviously doesn't work, the `{key: value}` comprehension syntax still gives you a plain old dict for comprehensions and literals. ``` >>> from collections import OrderedDict >>> olddict, dict = dict, OrderedDict >>> {i: i*i for i in range(3)}.__class__ <type 'dict'> ``` So, if it's possible how would I go about doing that? It's OK if it only works in CPython. For syntax I guess I would try it with a `O{k: v}` prefix like we have on the `r'various' u'string' b'objects'`. *note:* Of course we can use a generator expression instead, but I'm more interested seeing how hackable python is in terms of the grammar.
2014/01/13
[ "https://Stackoverflow.com/questions/21103732", "https://Stackoverflow.com", "https://Stackoverflow.com/users/674039/" ]
Sorry, not possible. Dict literals and dict comprehensions map to the built-in dict type, in a way that's hardcoded at the C level. That can't be overridden. You can use this as an alternative, though: ``` OrderedDict((i, i * i) for i in range(3)) ``` Addendum: as of Python 3.6, all Python dictionaries are ordered. [As of 3.7](https://docs.python.org/3/whatsnew/3.7.html#what-s-new-in-python-3-7), it's even part of the language spec. If you're using those versions of Python, no need for OrderedDict: the dict comprehension will Just Work (TM).
There is no direct way to change Python's syntax from within the language. A dictionary comprehension (or plain display) is always going to create a `dict`, and there's nothing you can do about that. If you're using CPython, it's using special bytecodes that generate a dict directly, which ultimately call the [`PyDict`](http://docs.python.org/3/c-api/dict.html) API functions and/or the same underlying functions used by that API. If you're using PyPy, those bytecodes are instead implemented on top of an RPython `dict` object which in turn is implemented on top of a compiled-and-optimized Python `dict`. And so on. There is an *indirect* way to do it, but you're not going to like it. If you read the docs on [the import system](http://docs.python.org/dev/reference/import.html), you'll see that it's the importer that searches for cached compiled code or calls the compiler, and the compiler that calls the parser, and so on. In Python 3.3+, almost everything in this chain either is written in pure Python, or has an alternate pure Python implementation, meaning you can fork the code and do your own thing. Which includes parsing source with your own PyParsing code that builds ASTs, or compiling a dict comprehension AST node into your own custom bytecode instead of the default, or post-processing the bytecode, or… In many cases, an [import hook](http://www.python.org/dev/peps/pep-0302/) is sufficient; if not, you can always write a custom finder and loader. If you're not already using Python 3.3 or later, I'd strongly suggest migrating before playing with this stuff. In older versions, it's harder, and less well documented, and you'll ultimately be putting in 10x the effort to learn something that will be obsolete whenever you do migrate. Anyway, if this approach sounds interesting to you, you might want to take a look at [MacroPy](https://github.com/lihaoyi/macropy). You could borrow some code from it—and, maybe more importantly, learn how some of these features (that have no good examples in the docs) are used. Or, if you're willing to settle for something less cool, you can just use `MacroPy` to build an "odict comprehension macro" and use that. (Note that MacroPy currently only works in Python 2.7, not 3.x.) You can't quite get `o{…}`, but you can get, say, `od[{…}]`, which isn't too bad. Download [`od.py`](http://pastebin.com/MbLPADJW), [`realmain.py`](http://pastebin.com/F9uJDQ4f), and [`main.py`](http://pastebin.com/dDSaL5MA), and run `python main.py` to see it working. The key is this code, which takes a `DictionaryComp` AST, converts it to an equivalent `GeneratorExpr` on key-value `Tuple`s, and wraps it in a `Call` to `collections.OrderedDict`: ``` def od(tree, **kw): pair = ast.Tuple(elts=[tree.key, tree.value]) gx = ast.GeneratorExp(elt=pair, generators=tree.generators) odict = ast.Attribute(value=ast.Name(id='collections'), attr='OrderedDict') call = ast.Call(func=odict, args=[gx], keywords=[]) return call ``` --- A different alternative is, of course, to modify the Python interpreter. I would suggest dropping the `O{…}` syntax idea for your first go, and just making normal dict comprehensions compile to odicts. The good news is, you don't really need to change the grammar (which is beyond hairy…), just any one of: * the bytecodes that dictcomps compile to, * the way the interpreter runs those bytecodes, or * the implementation of the `PyDict` type The bad news, while all of those are a lot easier than changing the grammar, none of them can be done from an extension module. (Well, you can do the first one by doing basically the same thing you'd do from pure Python… and you can do any of them by hooking the .so/.dll/.dylib to patch in your own functions, but that's the exact same work as hacking on Python plus the extra work of hooking at runtime.) If you want to hack on [CPython source](http://hg.python.org/cpython/file/), the code you want is in `Python/compile.c`, `Python/ceval.c`, and `Objects/dictobject.c`, and the [dev guide](http://docs.python.org/devguide/) tells you how to find everything you need. But you might want to consider hacking on [PyPy source](https://bitbucket.org/pypy/pypy/src) instead, since it's mostly written in (a subset of) Python rather than C. --- As a side note, your attempt wouldn't have worked even if everything were done at the Python language level. `olddict, dict = dict, OrderedDict` creates a binding named `dict` in your module's globals, which *shadows* the name in builtins, but doesn't replace it. You *can* replace things in builtins (well, Python doesn't guarantee this, but there are implementation/version-specific things-that-happen-to-work for every implementation/version I've tried…), but what you did isn't the way to do it.
21,103,732
Can I extend syntax in python for dict comprehensions for other dicts, like the OrderedDict in `collections` module or my own types which inherit from `dict`? Just rebinding the `dict` name obviously doesn't work, the `{key: value}` comprehension syntax still gives you a plain old dict for comprehensions and literals. ``` >>> from collections import OrderedDict >>> olddict, dict = dict, OrderedDict >>> {i: i*i for i in range(3)}.__class__ <type 'dict'> ``` So, if it's possible how would I go about doing that? It's OK if it only works in CPython. For syntax I guess I would try it with a `O{k: v}` prefix like we have on the `r'various' u'string' b'objects'`. *note:* Of course we can use a generator expression instead, but I'm more interested seeing how hackable python is in terms of the grammar.
2014/01/13
[ "https://Stackoverflow.com/questions/21103732", "https://Stackoverflow.com", "https://Stackoverflow.com/users/674039/" ]
Sorry, not possible. Dict literals and dict comprehensions map to the built-in dict type, in a way that's hardcoded at the C level. That can't be overridden. You can use this as an alternative, though: ``` OrderedDict((i, i * i) for i in range(3)) ``` Addendum: as of Python 3.6, all Python dictionaries are ordered. [As of 3.7](https://docs.python.org/3/whatsnew/3.7.html#what-s-new-in-python-3-7), it's even part of the language spec. If you're using those versions of Python, no need for OrderedDict: the dict comprehension will Just Work (TM).
Slightly modifying the response of @Max Noel, you can use list comprehension instead of a generator to create an OrderedDict in an ordered way (which of course is not possible using dict comprehension). ``` >>> OrderedDict([(i, i * i) for i in range(5)]) OrderedDict([(0, 0), (1, 1), (2, 4), (3, 9), (4, 16)]) ```
21,103,732
Can I extend syntax in python for dict comprehensions for other dicts, like the OrderedDict in `collections` module or my own types which inherit from `dict`? Just rebinding the `dict` name obviously doesn't work, the `{key: value}` comprehension syntax still gives you a plain old dict for comprehensions and literals. ``` >>> from collections import OrderedDict >>> olddict, dict = dict, OrderedDict >>> {i: i*i for i in range(3)}.__class__ <type 'dict'> ``` So, if it's possible how would I go about doing that? It's OK if it only works in CPython. For syntax I guess I would try it with a `O{k: v}` prefix like we have on the `r'various' u'string' b'objects'`. *note:* Of course we can use a generator expression instead, but I'm more interested seeing how hackable python is in terms of the grammar.
2014/01/13
[ "https://Stackoverflow.com/questions/21103732", "https://Stackoverflow.com", "https://Stackoverflow.com/users/674039/" ]
There is no direct way to change Python's syntax from within the language. A dictionary comprehension (or plain display) is always going to create a `dict`, and there's nothing you can do about that. If you're using CPython, it's using special bytecodes that generate a dict directly, which ultimately call the [`PyDict`](http://docs.python.org/3/c-api/dict.html) API functions and/or the same underlying functions used by that API. If you're using PyPy, those bytecodes are instead implemented on top of an RPython `dict` object which in turn is implemented on top of a compiled-and-optimized Python `dict`. And so on. There is an *indirect* way to do it, but you're not going to like it. If you read the docs on [the import system](http://docs.python.org/dev/reference/import.html), you'll see that it's the importer that searches for cached compiled code or calls the compiler, and the compiler that calls the parser, and so on. In Python 3.3+, almost everything in this chain either is written in pure Python, or has an alternate pure Python implementation, meaning you can fork the code and do your own thing. Which includes parsing source with your own PyParsing code that builds ASTs, or compiling a dict comprehension AST node into your own custom bytecode instead of the default, or post-processing the bytecode, or… In many cases, an [import hook](http://www.python.org/dev/peps/pep-0302/) is sufficient; if not, you can always write a custom finder and loader. If you're not already using Python 3.3 or later, I'd strongly suggest migrating before playing with this stuff. In older versions, it's harder, and less well documented, and you'll ultimately be putting in 10x the effort to learn something that will be obsolete whenever you do migrate. Anyway, if this approach sounds interesting to you, you might want to take a look at [MacroPy](https://github.com/lihaoyi/macropy). You could borrow some code from it—and, maybe more importantly, learn how some of these features (that have no good examples in the docs) are used. Or, if you're willing to settle for something less cool, you can just use `MacroPy` to build an "odict comprehension macro" and use that. (Note that MacroPy currently only works in Python 2.7, not 3.x.) You can't quite get `o{…}`, but you can get, say, `od[{…}]`, which isn't too bad. Download [`od.py`](http://pastebin.com/MbLPADJW), [`realmain.py`](http://pastebin.com/F9uJDQ4f), and [`main.py`](http://pastebin.com/dDSaL5MA), and run `python main.py` to see it working. The key is this code, which takes a `DictionaryComp` AST, converts it to an equivalent `GeneratorExpr` on key-value `Tuple`s, and wraps it in a `Call` to `collections.OrderedDict`: ``` def od(tree, **kw): pair = ast.Tuple(elts=[tree.key, tree.value]) gx = ast.GeneratorExp(elt=pair, generators=tree.generators) odict = ast.Attribute(value=ast.Name(id='collections'), attr='OrderedDict') call = ast.Call(func=odict, args=[gx], keywords=[]) return call ``` --- A different alternative is, of course, to modify the Python interpreter. I would suggest dropping the `O{…}` syntax idea for your first go, and just making normal dict comprehensions compile to odicts. The good news is, you don't really need to change the grammar (which is beyond hairy…), just any one of: * the bytecodes that dictcomps compile to, * the way the interpreter runs those bytecodes, or * the implementation of the `PyDict` type The bad news, while all of those are a lot easier than changing the grammar, none of them can be done from an extension module. (Well, you can do the first one by doing basically the same thing you'd do from pure Python… and you can do any of them by hooking the .so/.dll/.dylib to patch in your own functions, but that's the exact same work as hacking on Python plus the extra work of hooking at runtime.) If you want to hack on [CPython source](http://hg.python.org/cpython/file/), the code you want is in `Python/compile.c`, `Python/ceval.c`, and `Objects/dictobject.c`, and the [dev guide](http://docs.python.org/devguide/) tells you how to find everything you need. But you might want to consider hacking on [PyPy source](https://bitbucket.org/pypy/pypy/src) instead, since it's mostly written in (a subset of) Python rather than C. --- As a side note, your attempt wouldn't have worked even if everything were done at the Python language level. `olddict, dict = dict, OrderedDict` creates a binding named `dict` in your module's globals, which *shadows* the name in builtins, but doesn't replace it. You *can* replace things in builtins (well, Python doesn't guarantee this, but there are implementation/version-specific things-that-happen-to-work for every implementation/version I've tried…), but what you did isn't the way to do it.
Slightly modifying the response of @Max Noel, you can use list comprehension instead of a generator to create an OrderedDict in an ordered way (which of course is not possible using dict comprehension). ``` >>> OrderedDict([(i, i * i) for i in range(5)]) OrderedDict([(0, 0), (1, 1), (2, 4), (3, 9), (4, 16)]) ```
21,066,401
I am developing a website using Adobe Dreamweaver, and when I open up the HTML file in chrome from my local computer, everything is as it should be (mainly the margins). But when I upload it to my hosting service all the margins go wrong. I have compared the source code and they are exactly the same.
2014/01/11
[ "https://Stackoverflow.com/questions/21066401", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3185753/" ]
You probably forgot to upload the CSS files as well. You can see them in your code by looking for `<link rel="stylesheet" href="...">` tags. You could open the Chrome dev-tools window by pressing `F12` and going to the `Console` tab where you would probably see some `Failed to load resource` messages indicating that it couldn't find the files. Just upload them and make sure they're in the right path.
Because your paths for resources may be referenced as absolute paths(for example: `<img src="c:\mydocs\myimage.jpg">`). Check all your paths and tehn come back if they dont fix your issues
24,277,087
I want to be able to found out if two values are equal in a controller action. ``` def completed @meeting = Meeting.find(params[:id]) if @meeting.day_of_meeting == @meeting.days @meeting.update_attribute(:day_of_meeting, '1') redirect_to :back else @meeting.increment! redirect_to :back end end ``` The line I have in question is: ``` if @meeting.day_of_meeting == @meeting.days ``` When I run it, it never seems to be able to validate that both those fields are equal and just increments the day\_of\_meeting field. Any help would be appreciated. UPDATE In the model increment! ``` def increment! update_attribute(:day_of_meeting, day_of_meeting + 1) end ``` Essentially, @meeting.day\_of\_meeting is a ticker that when equaled to @meeting.day, I want @meeting.day\_of\_workout to be reset back to '1'. What is happening is @meeting.day\_of\_meeting never resets and continues to increment. Both values are integers.
2014/06/18
[ "https://Stackoverflow.com/questions/24277087", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2004710/" ]
Without seeing more code, I'm guessing that either @meeting.day\_of\_meeting or @meeting.days maybe a string. ``` @meeting.day_of_meeting == @meeting.days.to_i ``` assuming @meeting.days is a string, you can convert to integer and compare.
It's possible the two lists have the same contents, but in a different order, then not exactly the same. So try: ``` @meeting.day_of_meeting.sort == @meeting.days.sort ```
15,043
I want to show entries according to an array. This is my code: ``` {% set navsubids = craft.amNav.getNavRaw("hoofdnavigatie", {startFromId:25}) %} {% set navsubidarray = [] %} {% for navsubid in navsubids %} {% set navsubidarray = navsubidarray|merge([navsubid.elementId]) %} {% endfor %} {% set navsubidarray = navsubidarray|join(', ') %} {{ navsubidarray }}<br> {% for entry in craft.entries.id('{{ navsubidarray }}') %} {{ entry.title }}<br> {% endfor %} ``` The variable gives back that what I need `(18, 17, 19, 4, 20, 21, 22, 23)` but the for entry loop isn't returning anything.
2016/05/16
[ "https://craftcms.stackexchange.com/questions/15043", "https://craftcms.stackexchange.com", "https://craftcms.stackexchange.com/users/4892/" ]
As with most performance related questions, the answer is "it depends". :) Apps like Redis and Memcache store their key => value stores in memory as opposed to disk-based file caching. Accessing data from memory is usually orders of magnitude faster than accessing data from disk. All of these fall under "[General purpose data caching](https://craftcms.stackexchange.com/a/13383/57)" and Craft will use them internally for its own operations and plugins can certainly make use of them as well. If you have a plugin that makes extensive use of data caching and/or you've got a heavily trafficked site, then you will likely see some tangible performance benefits. If you're just doing a basic stock Craft install on a low trafficked site, then you likely won't see much of a difference at all.
How many servers do you have? Redis and Memcached are most beneficial/intended for a multiple server setup so if you only have one server, there's probably other/betters thing to worry about. (Best speed increase I've found so far: PHP 7.) As Brad points out, it all depends on your content, traffic, concurrent users, etc. It goes without saying having enough ram so you're not swapping can have a huge benefit. Just because those files are stored on disk doesn't mean PHP itself is actually hitting the disk for each request. SSDs are also now coming standard with a lot of the better hosting plans. SSDs can rival in-memory access times. Just changing your hosting can have a big impact on your app's performance. If you go down the deamon route, Redis seems more modern and is the newest contender in this space. I haven't extensively used Redis or memached with Craft but I have a client with WP on a dedicated server. We tried memcached awhile back and it was actually slower than without it. It's not hard to see why: there's going to be overhead reading/writing to either daemon—after all they communicate via socket or TCP/IP—and whether that solves your particular performance problem is up for debate. memcached hasn't really evolved much as of late. While memcached is strictly a key/value store, Redis is intended to store object structures better. `tmpfs` could be an alternative as well. It's basically a ram disk and is built into most Linux distros. It's pretty easy to setup and like everything else it has some caveats (making sure it comes back up on reboot, having enough space so you don't swap to begin with, clearing etc). Some further reading: * [temps vs memcached](https://stackoverflow.com/questions/2393783/php-tmpfs-vs-memcached) * [memcached vs redis](https://stackoverflow.com/a/11257333)
15,043
I want to show entries according to an array. This is my code: ``` {% set navsubids = craft.amNav.getNavRaw("hoofdnavigatie", {startFromId:25}) %} {% set navsubidarray = [] %} {% for navsubid in navsubids %} {% set navsubidarray = navsubidarray|merge([navsubid.elementId]) %} {% endfor %} {% set navsubidarray = navsubidarray|join(', ') %} {{ navsubidarray }}<br> {% for entry in craft.entries.id('{{ navsubidarray }}') %} {{ entry.title }}<br> {% endfor %} ``` The variable gives back that what I need `(18, 17, 19, 4, 20, 21, 22, 23)` but the for entry loop isn't returning anything.
2016/05/16
[ "https://craftcms.stackexchange.com/questions/15043", "https://craftcms.stackexchange.com", "https://craftcms.stackexchange.com/users/4892/" ]
As with most performance related questions, the answer is "it depends". :) Apps like Redis and Memcache store their key => value stores in memory as opposed to disk-based file caching. Accessing data from memory is usually orders of magnitude faster than accessing data from disk. All of these fall under "[General purpose data caching](https://craftcms.stackexchange.com/a/13383/57)" and Craft will use them internally for its own operations and plugins can certainly make use of them as well. If you have a plugin that makes extensive use of data caching and/or you've got a heavily trafficked site, then you will likely see some tangible performance benefits. If you're just doing a basic stock Craft install on a low trafficked site, then you likely won't see much of a difference at all.
Redis and Memcache are both Key value pair storage, their key => value stores in memory as opposed to disk-based file caching that make is faster to access compare with accessing data from disk Few Interesting properties of Redis: > > 1. Redis can be accessed by all the processes of your applications, possibly running on several nodes (something local memory cannot achieve). > 2. Redis memory storage is quite efficient, and done in a separate process. If the application runs on a platform whose memory is garbage collected (node.js, java, etc ...), it allows handling a much bigger memory cache/store. In practice, very large heaps do not perform well with garbage collected languages. > 3. Redis can persist the data on disk if needed. > 4. Redis is a bit more than a simple cache: it provides various data structures, various item eviction policies, blocking queues, pub/sub, atomicity, Lua scripting, etc ... > 5. Redis can replicate its activity with a master/slave mechanism in order to implement high-availability. > > >
15,043
I want to show entries according to an array. This is my code: ``` {% set navsubids = craft.amNav.getNavRaw("hoofdnavigatie", {startFromId:25}) %} {% set navsubidarray = [] %} {% for navsubid in navsubids %} {% set navsubidarray = navsubidarray|merge([navsubid.elementId]) %} {% endfor %} {% set navsubidarray = navsubidarray|join(', ') %} {{ navsubidarray }}<br> {% for entry in craft.entries.id('{{ navsubidarray }}') %} {{ entry.title }}<br> {% endfor %} ``` The variable gives back that what I need `(18, 17, 19, 4, 20, 21, 22, 23)` but the for entry loop isn't returning anything.
2016/05/16
[ "https://craftcms.stackexchange.com/questions/15043", "https://craftcms.stackexchange.com", "https://craftcms.stackexchange.com/users/4892/" ]
As with most performance related questions, the answer is "it depends". :) Apps like Redis and Memcache store their key => value stores in memory as opposed to disk-based file caching. Accessing data from memory is usually orders of magnitude faster than accessing data from disk. All of these fall under "[General purpose data caching](https://craftcms.stackexchange.com/a/13383/57)" and Craft will use them internally for its own operations and plugins can certainly make use of them as well. If you have a plugin that makes extensive use of data caching and/or you've got a heavily trafficked site, then you will likely see some tangible performance benefits. If you're just doing a basic stock Craft install on a low trafficked site, then you likely won't see much of a difference at all.
Here you can find an interesting benchmarking between Redis (remote or local) and Python Disk caching. The answer from Didier Spezia is good enough to understand the results. <https://stackoverflow.com/a/12871072/8520235> Enough RAM and disk caching are always better solutions for reasonable amounts of data. Any local, not to say remote, Redis solution includes network roundtrips, that these days are slower than Linux disk caching or even SSD disk access.
15,043
I want to show entries according to an array. This is my code: ``` {% set navsubids = craft.amNav.getNavRaw("hoofdnavigatie", {startFromId:25}) %} {% set navsubidarray = [] %} {% for navsubid in navsubids %} {% set navsubidarray = navsubidarray|merge([navsubid.elementId]) %} {% endfor %} {% set navsubidarray = navsubidarray|join(', ') %} {{ navsubidarray }}<br> {% for entry in craft.entries.id('{{ navsubidarray }}') %} {{ entry.title }}<br> {% endfor %} ``` The variable gives back that what I need `(18, 17, 19, 4, 20, 21, 22, 23)` but the for entry loop isn't returning anything.
2016/05/16
[ "https://craftcms.stackexchange.com/questions/15043", "https://craftcms.stackexchange.com", "https://craftcms.stackexchange.com/users/4892/" ]
How many servers do you have? Redis and Memcached are most beneficial/intended for a multiple server setup so if you only have one server, there's probably other/betters thing to worry about. (Best speed increase I've found so far: PHP 7.) As Brad points out, it all depends on your content, traffic, concurrent users, etc. It goes without saying having enough ram so you're not swapping can have a huge benefit. Just because those files are stored on disk doesn't mean PHP itself is actually hitting the disk for each request. SSDs are also now coming standard with a lot of the better hosting plans. SSDs can rival in-memory access times. Just changing your hosting can have a big impact on your app's performance. If you go down the deamon route, Redis seems more modern and is the newest contender in this space. I haven't extensively used Redis or memached with Craft but I have a client with WP on a dedicated server. We tried memcached awhile back and it was actually slower than without it. It's not hard to see why: there's going to be overhead reading/writing to either daemon—after all they communicate via socket or TCP/IP—and whether that solves your particular performance problem is up for debate. memcached hasn't really evolved much as of late. While memcached is strictly a key/value store, Redis is intended to store object structures better. `tmpfs` could be an alternative as well. It's basically a ram disk and is built into most Linux distros. It's pretty easy to setup and like everything else it has some caveats (making sure it comes back up on reboot, having enough space so you don't swap to begin with, clearing etc). Some further reading: * [temps vs memcached](https://stackoverflow.com/questions/2393783/php-tmpfs-vs-memcached) * [memcached vs redis](https://stackoverflow.com/a/11257333)
Redis and Memcache are both Key value pair storage, their key => value stores in memory as opposed to disk-based file caching that make is faster to access compare with accessing data from disk Few Interesting properties of Redis: > > 1. Redis can be accessed by all the processes of your applications, possibly running on several nodes (something local memory cannot achieve). > 2. Redis memory storage is quite efficient, and done in a separate process. If the application runs on a platform whose memory is garbage collected (node.js, java, etc ...), it allows handling a much bigger memory cache/store. In practice, very large heaps do not perform well with garbage collected languages. > 3. Redis can persist the data on disk if needed. > 4. Redis is a bit more than a simple cache: it provides various data structures, various item eviction policies, blocking queues, pub/sub, atomicity, Lua scripting, etc ... > 5. Redis can replicate its activity with a master/slave mechanism in order to implement high-availability. > > >
15,043
I want to show entries according to an array. This is my code: ``` {% set navsubids = craft.amNav.getNavRaw("hoofdnavigatie", {startFromId:25}) %} {% set navsubidarray = [] %} {% for navsubid in navsubids %} {% set navsubidarray = navsubidarray|merge([navsubid.elementId]) %} {% endfor %} {% set navsubidarray = navsubidarray|join(', ') %} {{ navsubidarray }}<br> {% for entry in craft.entries.id('{{ navsubidarray }}') %} {{ entry.title }}<br> {% endfor %} ``` The variable gives back that what I need `(18, 17, 19, 4, 20, 21, 22, 23)` but the for entry loop isn't returning anything.
2016/05/16
[ "https://craftcms.stackexchange.com/questions/15043", "https://craftcms.stackexchange.com", "https://craftcms.stackexchange.com/users/4892/" ]
Here you can find an interesting benchmarking between Redis (remote or local) and Python Disk caching. The answer from Didier Spezia is good enough to understand the results. <https://stackoverflow.com/a/12871072/8520235> Enough RAM and disk caching are always better solutions for reasonable amounts of data. Any local, not to say remote, Redis solution includes network roundtrips, that these days are slower than Linux disk caching or even SSD disk access.
Redis and Memcache are both Key value pair storage, their key => value stores in memory as opposed to disk-based file caching that make is faster to access compare with accessing data from disk Few Interesting properties of Redis: > > 1. Redis can be accessed by all the processes of your applications, possibly running on several nodes (something local memory cannot achieve). > 2. Redis memory storage is quite efficient, and done in a separate process. If the application runs on a platform whose memory is garbage collected (node.js, java, etc ...), it allows handling a much bigger memory cache/store. In practice, very large heaps do not perform well with garbage collected languages. > 3. Redis can persist the data on disk if needed. > 4. Redis is a bit more than a simple cache: it provides various data structures, various item eviction policies, blocking queues, pub/sub, atomicity, Lua scripting, etc ... > 5. Redis can replicate its activity with a master/slave mechanism in order to implement high-availability. > > >
64,678,856
I am trying to run an azure container instance but it appears to be getting killed off the second I run it. This works fine in 2 other resource groups but not my production resource group where I see the following: * In events I see 'Successfully pulled image selenium/standalone-chrome:latest' with count 1 and then 'Started container' and then 'Killing container' with count 31. The times for started and killed are the same. * In logs, it just says 'No logs available' * The metrics for CPU and memory on the container never show any change from zero. Looked at this article but the proposed solution didn't work: [Azure Container Group Instance](https://stackoverflow.com/questions/49544077/azure-container-group-instance) I have tried putting on both an empty directory volume and 2Gb of ram as advised here: <https://github.com/SeleniumHQ/docker-selenium> but nothing works. This is the code I am using to create the container: ``` containerGroup = await azure.ContainerGroups.Define(containerName) .WithRegion("West Europe") .WithExistingResourceGroup(configuration.ContainerResourceGroup) .WithLinux() .WithPublicImageRegistryOnly() .WithEmptyDirectoryVolume("devshm") .DefineContainerInstance(containerName) .WithImage("selenium/standalone-chrome") .WithExternalTcpPorts(4444) .WithVolumeMountSetting("devshm", "/dev/shm") .WithMemorySizeInGB(2) .Attach() .WithDnsPrefix(configuration.AppServiceName + "container") .WithRestartPolicy(ContainerGroupRestartPolicy.OnFailure) .CreateAsync(cancellationToken); ``` How do I debug what is going wrong? What is wrong with the container?
2020/11/04
[ "https://Stackoverflow.com/questions/64678856", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1702827/" ]
In case this helps someone I renamed the "containerName" parameter in the above example from myinstance to myinstance1 and changed the region from West Europe to UK South. This fixed the issue. I can only think that Azure caches instances somehow to reduce start up times and the cached image I was using was poisoned somehow.
One issue could be the restart policy - have a look at the Microsoft restart policy troubleshooting on [Microsoft's ACI troubleshooting page](https://learn.microsoft.com/en-us/azure/container-instances/container-instances-troubleshooting?WT.mc_id=Portal-Microsoft_Azure_Support). According to the website under the **Container continually exits and restarts (no long-running process)** header in the page: > > Container groups default to a restart policy of Always, so containers > in the container group always restart after they run to completion. > You may need to change this to OnFailure or Never if you intend to run > task-based containers. If you specify OnFailure and still see > continual restarts, there might be an issue with the application or > script executed in your container. > > > In your case you may need to adjust the code as follows using the withStartingCommand: ``` containerGroup = await azure.ContainerGroups.Define(containerName) .WithRegion("West Europe") .WithExistingResourceGroup(configuration.ContainerResourceGroup) .WithLinux() .WithPublicImageRegistryOnly() .WithEmptyDirectoryVolume("devshm") .DefineContainerInstance(containerName) .WithImage("selenium/standalone-chrome") .WithExternalTcpPorts(4444) .WithVolumeMountSetting("devshm", "/dev/shm") .WithMemorySizeInGB(2) .WithStartingCommandLine("tail") .WithStartingCommandLine("-f") .WithStartingCommandLine("/dev/null") .Attach() .WithDnsPrefix(configuration.AppServiceName + "container") .WithRestartPolicy(ContainerGroupRestartPolicy.OnFailure) .CreateAsync(cancellationToken); ```
64,678,856
I am trying to run an azure container instance but it appears to be getting killed off the second I run it. This works fine in 2 other resource groups but not my production resource group where I see the following: * In events I see 'Successfully pulled image selenium/standalone-chrome:latest' with count 1 and then 'Started container' and then 'Killing container' with count 31. The times for started and killed are the same. * In logs, it just says 'No logs available' * The metrics for CPU and memory on the container never show any change from zero. Looked at this article but the proposed solution didn't work: [Azure Container Group Instance](https://stackoverflow.com/questions/49544077/azure-container-group-instance) I have tried putting on both an empty directory volume and 2Gb of ram as advised here: <https://github.com/SeleniumHQ/docker-selenium> but nothing works. This is the code I am using to create the container: ``` containerGroup = await azure.ContainerGroups.Define(containerName) .WithRegion("West Europe") .WithExistingResourceGroup(configuration.ContainerResourceGroup) .WithLinux() .WithPublicImageRegistryOnly() .WithEmptyDirectoryVolume("devshm") .DefineContainerInstance(containerName) .WithImage("selenium/standalone-chrome") .WithExternalTcpPorts(4444) .WithVolumeMountSetting("devshm", "/dev/shm") .WithMemorySizeInGB(2) .Attach() .WithDnsPrefix(configuration.AppServiceName + "container") .WithRestartPolicy(ContainerGroupRestartPolicy.OnFailure) .CreateAsync(cancellationToken); ``` How do I debug what is going wrong? What is wrong with the container?
2020/11/04
[ "https://Stackoverflow.com/questions/64678856", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1702827/" ]
In case this helps someone I renamed the "containerName" parameter in the above example from myinstance to myinstance1 and changed the region from West Europe to UK South. This fixed the issue. I can only think that Azure caches instances somehow to reduce start up times and the cached image I was using was poisoned somehow.
This [link](https://learn.microsoft.com/en-us/azure/container-instances/container-instances-troubleshooting#container-continually-exits-and-restarts-no-long-running-process) is helpful for this issue. ``` --command-line linux => "tail -f /dev/null" windows => "ping -t localhost" # .yml command: tail -f /dev/null ``` It will keep your azure instance running. As now azure do have a endpoint to connect/analyze the process on.
64,678,856
I am trying to run an azure container instance but it appears to be getting killed off the second I run it. This works fine in 2 other resource groups but not my production resource group where I see the following: * In events I see 'Successfully pulled image selenium/standalone-chrome:latest' with count 1 and then 'Started container' and then 'Killing container' with count 31. The times for started and killed are the same. * In logs, it just says 'No logs available' * The metrics for CPU and memory on the container never show any change from zero. Looked at this article but the proposed solution didn't work: [Azure Container Group Instance](https://stackoverflow.com/questions/49544077/azure-container-group-instance) I have tried putting on both an empty directory volume and 2Gb of ram as advised here: <https://github.com/SeleniumHQ/docker-selenium> but nothing works. This is the code I am using to create the container: ``` containerGroup = await azure.ContainerGroups.Define(containerName) .WithRegion("West Europe") .WithExistingResourceGroup(configuration.ContainerResourceGroup) .WithLinux() .WithPublicImageRegistryOnly() .WithEmptyDirectoryVolume("devshm") .DefineContainerInstance(containerName) .WithImage("selenium/standalone-chrome") .WithExternalTcpPorts(4444) .WithVolumeMountSetting("devshm", "/dev/shm") .WithMemorySizeInGB(2) .Attach() .WithDnsPrefix(configuration.AppServiceName + "container") .WithRestartPolicy(ContainerGroupRestartPolicy.OnFailure) .CreateAsync(cancellationToken); ``` How do I debug what is going wrong? What is wrong with the container?
2020/11/04
[ "https://Stackoverflow.com/questions/64678856", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1702827/" ]
One issue could be the restart policy - have a look at the Microsoft restart policy troubleshooting on [Microsoft's ACI troubleshooting page](https://learn.microsoft.com/en-us/azure/container-instances/container-instances-troubleshooting?WT.mc_id=Portal-Microsoft_Azure_Support). According to the website under the **Container continually exits and restarts (no long-running process)** header in the page: > > Container groups default to a restart policy of Always, so containers > in the container group always restart after they run to completion. > You may need to change this to OnFailure or Never if you intend to run > task-based containers. If you specify OnFailure and still see > continual restarts, there might be an issue with the application or > script executed in your container. > > > In your case you may need to adjust the code as follows using the withStartingCommand: ``` containerGroup = await azure.ContainerGroups.Define(containerName) .WithRegion("West Europe") .WithExistingResourceGroup(configuration.ContainerResourceGroup) .WithLinux() .WithPublicImageRegistryOnly() .WithEmptyDirectoryVolume("devshm") .DefineContainerInstance(containerName) .WithImage("selenium/standalone-chrome") .WithExternalTcpPorts(4444) .WithVolumeMountSetting("devshm", "/dev/shm") .WithMemorySizeInGB(2) .WithStartingCommandLine("tail") .WithStartingCommandLine("-f") .WithStartingCommandLine("/dev/null") .Attach() .WithDnsPrefix(configuration.AppServiceName + "container") .WithRestartPolicy(ContainerGroupRestartPolicy.OnFailure) .CreateAsync(cancellationToken); ```
This [link](https://learn.microsoft.com/en-us/azure/container-instances/container-instances-troubleshooting#container-continually-exits-and-restarts-no-long-running-process) is helpful for this issue. ``` --command-line linux => "tail -f /dev/null" windows => "ping -t localhost" # .yml command: tail -f /dev/null ``` It will keep your azure instance running. As now azure do have a endpoint to connect/analyze the process on.
64,191,109
[![enter image description here](https://i.stack.imgur.com/9NC4P.png)](https://i.stack.imgur.com/9NC4P.png)In a basic bar plot, I want to add text in a right place but my text overlap with the standard error bar. Here are my code and output. Thank you. ``` d<-data.frame(Proband=c(1400,1500), Sibling=c( 1700,1800), Proband2=c( 1200, 1250), Sibling2=c( 1300, 1500)) d <- do.call(rbind, d) colnames(d) <- c("A","B") Se<-data.frame(Proband=c( 100,450 ), Sibling=c( 170, 180 ), Proband2=c(120,125 ), Sibling2=c(130,150 )) Se <- do.call(rbind, Se) colnames(Se) <- c("A","B")) freq<- c(21,26,32,56,45,66,78,88) mycolors2<-c(paste0("royalblue", c(4:3)), c("steelblue4", "steelblue3")) barCenters<-barplot(d, beside = TRUE, ylim=c(0,5000), legend.text = rownames(d), args.legend = list(x = "topleft", bty="n"), col=mycolors2, xlab="[![enter image description here][1]][1]Size (kb)", ylab="Average ") arrows(barCenters, d - Se * 2, barCenters, d + Se * 2, lwd = 1.5, angle = 90, code = 3, length = 0.05) text(barCenters, d + Se * 2 , freq ,cex=1,srt = 90) ```
2020/10/04
[ "https://Stackoverflow.com/questions/64191109", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12617911/" ]
You can do it in separate lines ```js const ReduxApp = connect(null,mapDispatchToProps)(App) export default withRouter(ReduxApp) ``` You won't need `withRouter` if you pass the props in the `Routes` ``` <Route path="/" component={(p) => <Component {...p} {...props}/>} /> ``` Here `p` is the props related to react router and `props` is the redux state
Can you try this ``` import {BrowserRouter,Switch,Route,withRouter} from 'react-router-dom'; export default connect(null,mapDispatchToProps)(withRouter(App))); ```
30,778,845
Im trying to use this <https://gist.github.com/linssen/2773872> on my php work but that code only shows a array text and doesnt update in my database. Main page: ``` <ul id="test-list"> <?php do { ?> <li id="listItem_<?php echo $row_dados['id']; ?>"><img src="images/arrow.png" alt="move" width="16" height="16" class="handle" /><strong><?php echo $row_dados['posicao']; ?></strong></li> <?php } while ($row_dados = mysql_fetch_assoc($dados)); ?> </ul> ``` This is creating a loop to get all the records from database and show it. Script: ``` <script type="text/javascript"> // When the document is ready set up our sortable with it's inherant function(s) $(document).ready(function() { $("#test-list").sortable({ handle : '.handle', update : function () { var order = $('#test-list').sortable('serialize'); $("#info").load("process-sortable.php?"+order); } }); }); </script> ``` process-sortable.php: ``` <?php /* This is where you would inject your sql into the database but we're just going to format it and send it back */ foreach ($_GET['listItem'] as $position => $item) : $sql[] = "UPDATE `dados` SET `posicao` = $position WHERE `id` = $item"; endforeach; print_r ($sql); ?> ``` But this only prints the result i would like to change this code to actually update my database. The result: ``` Array ( [0] => UPDATE `dados` SET `posicao` = 0 WHERE `id` = 4 [1] => UPDATE `dados` SET `posicao` = 1 WHERE `id` = 3 [2] => UPDATE `dados` SET `posicao` = 2 WHERE `id` = 1 [3] => UPDATE `dados` SET `posicao` = 3 WHERE `id` = 2 [4] => UPDATE `dados` SET `posicao` = 4 WHERE `id` = 5 [5] => UPDATE `dados` SET `posicao` = 5 WHERE `id` = 6 [6] => UPDATE `dados` SET `posicao` = 6 WHERE `id` = 7 [7] => UPDATE `dados` SET `posicao` = 7 WHERE `id` = 8 [8] => UPDATE `dados` SET `posicao` = 8 WHERE `id` = 9 [9] => UPDATE `dados` SET `posicao` = 9 WHERE `id` = 10 [10] => UPDATE `dados` SET `posicao` = 10 WHERE `id` = 277 [11] => UPDATE `dados` SET `posicao` = 11 WHERE `id` = 278 ) ``` So its working fine, but doesnt change the database based on this lines. So the probem is probably on process-sortable.php, so any help would be awesome. Cumps.
2015/06/11
[ "https://Stackoverflow.com/questions/30778845", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4978549/" ]
When opening access i was getting security warning which required user confirmation. I changed the security level to low in `tool->macros->security` to make this go away and success. On the server i had a different warning saying that the file is corrupt or badly closed. Still have not got round to fixing but shouldn't be too hard. Conclusion: Make sure Access can open the file with the appropriate user without warnings.
Do this: Run Regedit Local User -> Software -> Microsoft-> Office -> Access -> (Office Version) -> Security Add: ``` DWORD 32 - VBAWarnings = 1 ```
1,667,212
Is there a way to add references to one or more of a method's parameters from the method documentation body? Something like: ``` /** * When {@paramref a} is null, we rely on b for the discombobulation. * * @param a this is one of the parameters * @param b another param */ void foo(String a, int b) {...} ```
2009/11/03
[ "https://Stackoverflow.com/questions/1667212", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11236/" ]
As you can see in the Java Source of the `java.lang.String` class: ``` /** * Allocates a new <code>String</code> that contains characters from * a subarray of the character array argument. The <code>offset</code> * argument is the index of the first character of the subarray and * the <code>count</code> argument specifies the length of the * subarray. The contents of the subarray are copied; subsequent * modification of the character array does not affect the newly * created string. * * @param value array that is the source of characters. * @param offset the initial offset. * @param count the length. * @exception IndexOutOfBoundsException if the <code>offset</code> * and <code>count</code> arguments index characters outside * the bounds of the <code>value</code> array. */ public String(char value[], int offset, int count) { if (offset < 0) { throw new StringIndexOutOfBoundsException(offset); } if (count < 0) { throw new StringIndexOutOfBoundsException(count); } // Note: offset or count might be near -1>>>1. if (offset > value.length - count) { throw new StringIndexOutOfBoundsException(offset + count); } this.value = new char[count]; this.count = count; System.arraycopy(value, offset, this.value, 0, count); } ``` Parameter references are surrounded by `<code></code>` tags, which means that the Javadoc syntax does not provide any way to do such a thing. (I think String.class is a good example of javadoc usage).
I guess you could write your own doclet or taglet to support this behaviour. [Taglet Overview](http://java.sun.com/j2se/1.5.0/docs/guide/javadoc/taglet/overview.html) [Doclet Overview](http://java.sun.com/j2se/1.5.0/docs/guide/javadoc/doclet/overview.html)
1,667,212
Is there a way to add references to one or more of a method's parameters from the method documentation body? Something like: ``` /** * When {@paramref a} is null, we rely on b for the discombobulation. * * @param a this is one of the parameters * @param b another param */ void foo(String a, int b) {...} ```
2009/11/03
[ "https://Stackoverflow.com/questions/1667212", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11236/" ]
As far as I can tell after reading [the docs for javadoc](http://docs.oracle.com/javase/8/docs/technotes/tools/unix/javadoc.html) there is no such feature. Don't use `<code>foo</code>` as recommended in other answers; you can use `{@code foo}`. This is especially good to know when you refer to a generic type such as `{@code Iterator<String>}` -- sure looks nicer than `<code>Iterator&lt;String&gt;</code>`, doesn't it!
I guess you could write your own doclet or taglet to support this behaviour. [Taglet Overview](http://java.sun.com/j2se/1.5.0/docs/guide/javadoc/taglet/overview.html) [Doclet Overview](http://java.sun.com/j2se/1.5.0/docs/guide/javadoc/doclet/overview.html)
1,667,212
Is there a way to add references to one or more of a method's parameters from the method documentation body? Something like: ``` /** * When {@paramref a} is null, we rely on b for the discombobulation. * * @param a this is one of the parameters * @param b another param */ void foo(String a, int b) {...} ```
2009/11/03
[ "https://Stackoverflow.com/questions/1667212", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11236/" ]
The correct way of referring to a method parameter is like this: [![enter image description here](https://i.stack.imgur.com/Z1IGb.png)](https://i.stack.imgur.com/Z1IGb.png)
I guess you could write your own doclet or taglet to support this behaviour. [Taglet Overview](http://java.sun.com/j2se/1.5.0/docs/guide/javadoc/taglet/overview.html) [Doclet Overview](http://java.sun.com/j2se/1.5.0/docs/guide/javadoc/doclet/overview.html)
1,667,212
Is there a way to add references to one or more of a method's parameters from the method documentation body? Something like: ``` /** * When {@paramref a} is null, we rely on b for the discombobulation. * * @param a this is one of the parameters * @param b another param */ void foo(String a, int b) {...} ```
2009/11/03
[ "https://Stackoverflow.com/questions/1667212", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11236/" ]
I guess you could write your own doclet or taglet to support this behaviour. [Taglet Overview](http://java.sun.com/j2se/1.5.0/docs/guide/javadoc/taglet/overview.html) [Doclet Overview](http://java.sun.com/j2se/1.5.0/docs/guide/javadoc/doclet/overview.html)
Here is how it is written in Eclipse Temurin JDK 8 sources: [![enter image description here](https://i.stack.imgur.com/CFcSZ.png)](https://i.stack.imgur.com/CFcSZ.png) It looks like the only way is or {@code }, but it's not a link - it's just formatting.
1,667,212
Is there a way to add references to one or more of a method's parameters from the method documentation body? Something like: ``` /** * When {@paramref a} is null, we rely on b for the discombobulation. * * @param a this is one of the parameters * @param b another param */ void foo(String a, int b) {...} ```
2009/11/03
[ "https://Stackoverflow.com/questions/1667212", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11236/" ]
As far as I can tell after reading [the docs for javadoc](http://docs.oracle.com/javase/8/docs/technotes/tools/unix/javadoc.html) there is no such feature. Don't use `<code>foo</code>` as recommended in other answers; you can use `{@code foo}`. This is especially good to know when you refer to a generic type such as `{@code Iterator<String>}` -- sure looks nicer than `<code>Iterator&lt;String&gt;</code>`, doesn't it!
As you can see in the Java Source of the `java.lang.String` class: ``` /** * Allocates a new <code>String</code> that contains characters from * a subarray of the character array argument. The <code>offset</code> * argument is the index of the first character of the subarray and * the <code>count</code> argument specifies the length of the * subarray. The contents of the subarray are copied; subsequent * modification of the character array does not affect the newly * created string. * * @param value array that is the source of characters. * @param offset the initial offset. * @param count the length. * @exception IndexOutOfBoundsException if the <code>offset</code> * and <code>count</code> arguments index characters outside * the bounds of the <code>value</code> array. */ public String(char value[], int offset, int count) { if (offset < 0) { throw new StringIndexOutOfBoundsException(offset); } if (count < 0) { throw new StringIndexOutOfBoundsException(count); } // Note: offset or count might be near -1>>>1. if (offset > value.length - count) { throw new StringIndexOutOfBoundsException(offset + count); } this.value = new char[count]; this.count = count; System.arraycopy(value, offset, this.value, 0, count); } ``` Parameter references are surrounded by `<code></code>` tags, which means that the Javadoc syntax does not provide any way to do such a thing. (I think String.class is a good example of javadoc usage).
1,667,212
Is there a way to add references to one or more of a method's parameters from the method documentation body? Something like: ``` /** * When {@paramref a} is null, we rely on b for the discombobulation. * * @param a this is one of the parameters * @param b another param */ void foo(String a, int b) {...} ```
2009/11/03
[ "https://Stackoverflow.com/questions/1667212", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11236/" ]
As you can see in the Java Source of the `java.lang.String` class: ``` /** * Allocates a new <code>String</code> that contains characters from * a subarray of the character array argument. The <code>offset</code> * argument is the index of the first character of the subarray and * the <code>count</code> argument specifies the length of the * subarray. The contents of the subarray are copied; subsequent * modification of the character array does not affect the newly * created string. * * @param value array that is the source of characters. * @param offset the initial offset. * @param count the length. * @exception IndexOutOfBoundsException if the <code>offset</code> * and <code>count</code> arguments index characters outside * the bounds of the <code>value</code> array. */ public String(char value[], int offset, int count) { if (offset < 0) { throw new StringIndexOutOfBoundsException(offset); } if (count < 0) { throw new StringIndexOutOfBoundsException(count); } // Note: offset or count might be near -1>>>1. if (offset > value.length - count) { throw new StringIndexOutOfBoundsException(offset + count); } this.value = new char[count]; this.count = count; System.arraycopy(value, offset, this.value, 0, count); } ``` Parameter references are surrounded by `<code></code>` tags, which means that the Javadoc syntax does not provide any way to do such a thing. (I think String.class is a good example of javadoc usage).
Here is how it is written in Eclipse Temurin JDK 8 sources: [![enter image description here](https://i.stack.imgur.com/CFcSZ.png)](https://i.stack.imgur.com/CFcSZ.png) It looks like the only way is or {@code }, but it's not a link - it's just formatting.
1,667,212
Is there a way to add references to one or more of a method's parameters from the method documentation body? Something like: ``` /** * When {@paramref a} is null, we rely on b for the discombobulation. * * @param a this is one of the parameters * @param b another param */ void foo(String a, int b) {...} ```
2009/11/03
[ "https://Stackoverflow.com/questions/1667212", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11236/" ]
As far as I can tell after reading [the docs for javadoc](http://docs.oracle.com/javase/8/docs/technotes/tools/unix/javadoc.html) there is no such feature. Don't use `<code>foo</code>` as recommended in other answers; you can use `{@code foo}`. This is especially good to know when you refer to a generic type such as `{@code Iterator<String>}` -- sure looks nicer than `<code>Iterator&lt;String&gt;</code>`, doesn't it!
The correct way of referring to a method parameter is like this: [![enter image description here](https://i.stack.imgur.com/Z1IGb.png)](https://i.stack.imgur.com/Z1IGb.png)
1,667,212
Is there a way to add references to one or more of a method's parameters from the method documentation body? Something like: ``` /** * When {@paramref a} is null, we rely on b for the discombobulation. * * @param a this is one of the parameters * @param b another param */ void foo(String a, int b) {...} ```
2009/11/03
[ "https://Stackoverflow.com/questions/1667212", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11236/" ]
As far as I can tell after reading [the docs for javadoc](http://docs.oracle.com/javase/8/docs/technotes/tools/unix/javadoc.html) there is no such feature. Don't use `<code>foo</code>` as recommended in other answers; you can use `{@code foo}`. This is especially good to know when you refer to a generic type such as `{@code Iterator<String>}` -- sure looks nicer than `<code>Iterator&lt;String&gt;</code>`, doesn't it!
Here is how it is written in Eclipse Temurin JDK 8 sources: [![enter image description here](https://i.stack.imgur.com/CFcSZ.png)](https://i.stack.imgur.com/CFcSZ.png) It looks like the only way is or {@code }, but it's not a link - it's just formatting.
1,667,212
Is there a way to add references to one or more of a method's parameters from the method documentation body? Something like: ``` /** * When {@paramref a} is null, we rely on b for the discombobulation. * * @param a this is one of the parameters * @param b another param */ void foo(String a, int b) {...} ```
2009/11/03
[ "https://Stackoverflow.com/questions/1667212", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11236/" ]
The correct way of referring to a method parameter is like this: [![enter image description here](https://i.stack.imgur.com/Z1IGb.png)](https://i.stack.imgur.com/Z1IGb.png)
Here is how it is written in Eclipse Temurin JDK 8 sources: [![enter image description here](https://i.stack.imgur.com/CFcSZ.png)](https://i.stack.imgur.com/CFcSZ.png) It looks like the only way is or {@code }, but it's not a link - it's just formatting.
27,151,130
I want to repeat first row first column value in every row in a particular column like a group. Please let me know how i will do it? ``` Table Id - Title 1 - ABC1 2 - ABC2 3 - ABC3 4 - ABC4 5 - ABC5 ``` I want result like this in a simple select query, Please dont use variable for it means storing first row value in a variable, Resultant Table ``` Table Id - Title - Group 1 - ABC1 - 1 2 - ABC2 - 1 3 - ABC3 - 1 4 - ABC4 - 1 5 - ABC5 - 1 ```
2014/11/26
[ "https://Stackoverflow.com/questions/27151130", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2331073/" ]
This query will be helpful to get expected result. ``` SELECT Id, Title, (SELECT TOP 1 Id FROm Table ORDER BY ID) AS [Group] FROM Table ```
Something like: SELECT Id, Title, 1 AS [Group] FROM Table If the Group value is different, then we need to know where that value is coming from.
27,151,130
I want to repeat first row first column value in every row in a particular column like a group. Please let me know how i will do it? ``` Table Id - Title 1 - ABC1 2 - ABC2 3 - ABC3 4 - ABC4 5 - ABC5 ``` I want result like this in a simple select query, Please dont use variable for it means storing first row value in a variable, Resultant Table ``` Table Id - Title - Group 1 - ABC1 - 1 2 - ABC2 - 1 3 - ABC3 - 1 4 - ABC4 - 1 5 - ABC5 - 1 ```
2014/11/26
[ "https://Stackoverflow.com/questions/27151130", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2331073/" ]
This query will be helpful to get expected result. ``` SELECT Id, Title, (SELECT TOP 1 Id FROm Table ORDER BY ID) AS [Group] FROM Table ```
USE THE QUERY: (ORDER BY ID ASC will make sure that the first ID will selected always even if there is a change of order in ID.) ``` SELECT Id, Title, (SELECT TOP 1 ID FROM Table ORDER BY ID ASC) AS [Group] FROM Table ```
27,151,130
I want to repeat first row first column value in every row in a particular column like a group. Please let me know how i will do it? ``` Table Id - Title 1 - ABC1 2 - ABC2 3 - ABC3 4 - ABC4 5 - ABC5 ``` I want result like this in a simple select query, Please dont use variable for it means storing first row value in a variable, Resultant Table ``` Table Id - Title - Group 1 - ABC1 - 1 2 - ABC2 - 1 3 - ABC3 - 1 4 - ABC4 - 1 5 - ABC5 - 1 ```
2014/11/26
[ "https://Stackoverflow.com/questions/27151130", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2331073/" ]
USE THE QUERY: (ORDER BY ID ASC will make sure that the first ID will selected always even if there is a change of order in ID.) ``` SELECT Id, Title, (SELECT TOP 1 ID FROM Table ORDER BY ID ASC) AS [Group] FROM Table ```
Something like: SELECT Id, Title, 1 AS [Group] FROM Table If the Group value is different, then we need to know where that value is coming from.
4,349,772
I am using some of the functions from cutil.h to time my code. It compiles fine on windows xp with vs 2008. Recently, I switch to window 7 and vs 2008. The same code doesn't compile and I have following error, > > 1>LINK : C:\Users\weiqi\Documents\Visual Studio > 2008\Projects\corrColumnLateral\Debug\corrColumnLateral.exe not found > or not built by the last incremental link; performing full > link1>corrColumnLateral.cu.obj : error LNK2019: unresolved external > symbol \_*imp*\_cutStopTimer@4 referenced in function > \_main1>corrColumnLateral.cu.obj : error LNK2019: unresolved external symbol \_*imp*\_cutStartTimer@4 referenced in function > \_main1>corrColumnLateral.cu.obj : error LNK2019: unresolved external symbol \_*imp*\_cutResetTimer@4 referenced in function > \_main1>corrColumnLateral.cu.obj : error LNK2019: unresolved external symbol \_*imp*\_cutGetTimerValue@4 referenced in function > \_main1>corrColumnLateral.cu.obj : error LNK2019: unresolved external symbol \_*imp*\_cutCreateTimer@4 referenced in function \_main > > > The macros from the header file, such as CUDA\_SAFE\_CALL, work fine, but timing functions like cutCreatTimer fail to compile. Does anyone knows what is going on?
2010/12/03
[ "https://Stackoverflow.com/questions/4349772", "https://Stackoverflow.com", "https://Stackoverflow.com/users/236473/" ]
IF you right click your cu source file and select properties: Then go to CUDA C/C++ and under Common add the location of the cutil.h to the Additional Include Directories folder. For me this was: C:\ProgramData\NVIDIA Corporation\NVIDIA GPU Computing SDK 3.2\C\common\inc
You need to link to the cutil library. On linux it's called libcutil.so or libcutil.a. The windows version probably also has "cutil" in its name, so you can search for that file and add it to your linker options.
66,371,839
I'm trying to figure out how Stack and Heap work. So my question about Stack. For example, we have next code: ``` static void Main() { int a = 1; int b = 2; Console.WriteLine(a); } ``` Both variables will be pushed onto the stack, and variable 'b' will on top of variable 'a'. If Stack has only Push and Pop operations, how variable 'a' can be read, without popping from stack 'b'?
2021/02/25
[ "https://Stackoverflow.com/questions/66371839", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11324339/" ]
Local variables are defined *before* the dynamic / flexible part of the stack, so what you actually have is (assuming no optimisations): * define a & b in the stack-frame * push 1 onto the dynamic stack (*after* a & b) * write (pop) the value at the top of the stack into the location of a * push 2 onto the dynamic stack * write (pop) the value at the top of the stack into the location of b * load (push) the value from the location of a onto the dynamic stack * call Console.WriteLine Local variable values can be accessed at any time; they are just relative offsets from the stack frame. The dynamic part of the stack used for transient values can only usually be accessed in strict order, but that isn't what contains the locations we're naming a and b.
You've got a misunderstanding here. Both a and b are put into the same stack frame, as they belong to the same method. Within `main` it is always known that a is at address Stackpointer + 8 and b at Stackpointer + 4 (for instance). For the execution stack, each method call is one stack frame (containing all local variables of a method). This is different from the `Stack` class, which contains one value per slot.
48,365,051
I have spent the last four days studying promises, coroutines, fibers, continuations, etc. I am still unable to see how to resolve my multiplayer turn-based card game moves, in which the starting player is effectively the game 'controller' of up to five, either AI or human players. The code below works but has one problem:- it cannot detect human oppo's card moves and therefore continues playing without them, which, of course makes a mess. Can anyone please suggest either a change to my overall concept or a way to use promise or one of any other 'synchronising' constructs? Here are the four key areas of my code: ``` function oppoPlays () { // can only go through here if game starter if (joiner!="") {return;} for (pp=1; pp<numberofplayers; pp++) { if (oppoType[pp] == "AI") { // an AI player moves . . } else { // non-AI player var yourTurnmsg="It's "+playerNames[pp]+"'s turn"; // tell human player that it's their turn $("#text_message").val(yourTurnmsg).trigger(jQuery.Event('keypress', { keyCode: 13, which: 13 })); // how to detect human oppo's card moved? } } } ``` --- ``` // chat functionality $("#text_message").on("keypress", function(e) { if (e.keyCode == 13){ payload = new Object(); payload.action = 'chat_text'; payload.chat_text = tmsg; // It's michael29's turn payload.user_id = playerNames[pp]; payload.game_no = game_no; socket.send(JSON.stringify(payload)); } }); ``` --- ``` // socket gets oppo's response function checkJson(res, sttr_id, game_no) { if(res.action=="game_move"){ // find player var pp=playerNames.indexOf(res.user_id); cpos=res.cardno; playCard_oppo(pp, cpos); } } ``` --- ``` // turn an oppo's card face up and update scores function playCard_oppo(pp, cardno) { // and move it to the stack topoc= parseInt($("#oppo_card" + cardno).css('top')); leftoc=parseInt($("#oppo_card" + cardno).css('left')); $("#oppo_card" + cardno).css({ top: topoc, left: leftoc, opacity: "50%" }); . . if (joiner=="") { // tell oppoPlays fn that the card has moved } } ``` The game is similar to uno in concept but with a scoring component (aimed to help children with basic arithmetic).
2018/01/21
[ "https://Stackoverflow.com/questions/48365051", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1530235/" ]
Consider having a board state that is a global and player/AI moves modify it. Then, when it is time for the AI opponent to make a move, it consults the current board state and decides the move. If your board state is just represented by elements on the page you'll need a way to scan it and calculate a useful in-memory representation of the board state. Without details of your implementation it's hard to be more specific.
Maybe start thinking in terms of a play-cycle, something like this : 1. (host) Broadcasts game state. 2. (host) Awaits confirmation from all clients that broadcast was received. 3. (clients) Render game state. 4. (host) Receives confirmations then informs next client (and hence its player) that it is his/her/its turn. 5. (host) Awaits player's move 6. (client) Unlocks UI allowing player to make move. 7. (player) Makes move. 8. (client) Sends move command and re-locks UI. 9. (host) Receives move command and modifies game state accordingly. Then back to 1. Also, think of AI players as just a special case of human players. If you can get it right for humans, then (re)introducing AI should be fairly simple.
48,365,051
I have spent the last four days studying promises, coroutines, fibers, continuations, etc. I am still unable to see how to resolve my multiplayer turn-based card game moves, in which the starting player is effectively the game 'controller' of up to five, either AI or human players. The code below works but has one problem:- it cannot detect human oppo's card moves and therefore continues playing without them, which, of course makes a mess. Can anyone please suggest either a change to my overall concept or a way to use promise or one of any other 'synchronising' constructs? Here are the four key areas of my code: ``` function oppoPlays () { // can only go through here if game starter if (joiner!="") {return;} for (pp=1; pp<numberofplayers; pp++) { if (oppoType[pp] == "AI") { // an AI player moves . . } else { // non-AI player var yourTurnmsg="It's "+playerNames[pp]+"'s turn"; // tell human player that it's their turn $("#text_message").val(yourTurnmsg).trigger(jQuery.Event('keypress', { keyCode: 13, which: 13 })); // how to detect human oppo's card moved? } } } ``` --- ``` // chat functionality $("#text_message").on("keypress", function(e) { if (e.keyCode == 13){ payload = new Object(); payload.action = 'chat_text'; payload.chat_text = tmsg; // It's michael29's turn payload.user_id = playerNames[pp]; payload.game_no = game_no; socket.send(JSON.stringify(payload)); } }); ``` --- ``` // socket gets oppo's response function checkJson(res, sttr_id, game_no) { if(res.action=="game_move"){ // find player var pp=playerNames.indexOf(res.user_id); cpos=res.cardno; playCard_oppo(pp, cpos); } } ``` --- ``` // turn an oppo's card face up and update scores function playCard_oppo(pp, cardno) { // and move it to the stack topoc= parseInt($("#oppo_card" + cardno).css('top')); leftoc=parseInt($("#oppo_card" + cardno).css('left')); $("#oppo_card" + cardno).css({ top: topoc, left: leftoc, opacity: "50%" }); . . if (joiner=="") { // tell oppoPlays fn that the card has moved } } ``` The game is similar to uno in concept but with a scoring component (aimed to help children with basic arithmetic).
2018/01/21
[ "https://Stackoverflow.com/questions/48365051", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1530235/" ]
Consider having a board state that is a global and player/AI moves modify it. Then, when it is time for the AI opponent to make a move, it consults the current board state and decides the move. If your board state is just represented by elements on the page you'll need a way to scan it and calculate a useful in-memory representation of the board state. Without details of your implementation it's hard to be more specific.
The solution hinged around two things:- 1. separating the AI player code from the human player code; 2. adding and removing a window event that's triggered after a human's move is detected. The condensed code now looks like this:- ``` // if this is game starter give each player a turn if (joiner == "") { // there's always at least one pp = 1; if (oppoType[pp] == "AI") { AIplays(); } else { humanPlays(); } } function humanPlays () { // tell human player that it's their turn var yourTurnmsg="It's "+playerNames[pp]+"'s turn" $("#text_message").val(yourTurnmsg).trigger(jQuery.Event('keypress', { keyCode: 13, which: 13 })); //window.addEventListener("humanPlayed", function(evnt) { $(window).on("humanPlayed", function(evnt) { endOfTurn(); }); } function endOfTurn () { if (!(winner)) { if (pp++ != numberofplayers) { if (oppoType[pp] == "AI") { setTimeout(function (){ $("#clickForNextPlayer").show(); }, 1000); } else { $("#clickForNextPlayer").trigger('click'); } } } } // click for next player $("#clickForNextPlayer").on('click', function() { $("#clickForNextPlayer").hide(); $(window).off("humanPlayed"); if (pp == numberofplayers) { // uncover outStack for game starter to play $("#outStackcover").hide(); return; } if (oppoType[pp] == "AI") { AIplays(); } else { humanPlays(); } }); function AIplays () { AIcardno = chooseCard(pp, diffLevel); . . if ($("#chatWindow").is(":visible")) { payload = new Object(); payload.action="game_move"; payload.game_no=gamestarted; payload.user_id=playerNames[pp]; payload.cardno=AIcardno; socket.send(JSON.stringify(payload)); } $("#oppo_card" + cc).css('background-image', "url(JerseyTeam" + playerNumbers[(pp == numberofplayers ? 1 : pp)] + ".gif)"); outStackturn(); endOfTurn(); } ```
1,899,977
[![Problem solution](https://i.stack.imgur.com/dmeLa.jpg)](https://i.stack.imgur.com/dmeLa.jpg) So i have this solution for proving that the chromatic index of graph G, that is drawn on the image, equals 5. I understand everything until that point, where i put "$?$" in circle. I don't know what that means, also the solution was orginally in a different language, so perhaps "$color$ $class$" isn't the right name for it, i used direct translation from slovene into english. Also that lemma means that $2m$ (where m is the number of edges) is equal to a product of number of vertices and number of edges in a single vertice, because the number of edges to every vertice is the same(4). If anyone can help me understand how we got to that inclusion, where i have a question mark, it would be great. Thank you in advance.
2016/08/22
[ "https://math.stackexchange.com/questions/1899977", "https://math.stackexchange.com", "https://math.stackexchange.com/users/246608/" ]
The proof is by contradiction. It assumes the graph can be edge colored using four colors. If each color class had at most four edges, then all the color classes together would contain at most $4\cdot4=16$ edges. But the graph has $18$ edges, so at least one color class must have at least five edges in it. Now the five same-colored edges must never be incident on the same vertex. So the ten endpoints of those five edges are distinct vertices. That is the contradiction, since the graph has only nine vertices.
I think they mean there exists a color such that the number of edges of that color is at least $5$. Notice it's first assumed the chromatic index is $4$ so if each color had only $4$ or less edges of that color, you'd have at most $16$ edges, a contradiction since you have $18$ edges. Since there exists $5$ edges of a single color, and since none of these edges share a vertex, then there are $10$ vertices associated with these edges, a contradiction since there are $9$ vertices. Thus, the chromatic index is at least $5$.
185,346
I have a feeling this is a duplicate somewhere, but how can I ensure that TeX will keep scanning until `\relax` or something similar? ``` \documentclass{article} \usepackage{xparse} \pagestyle{empty} \setlength\parindent{0pt} \begin{document} Plain: \def\test#1/#2/#3{ year:#1 \newline month:#2 \newline day:#3 \newline } \test 01/02/03 \bigskip Expl3: \ExplSyntaxOn \cs_new:Npn \test:w #1/#2/#3 { year:#1 \newline month:#2 \newline day:#3 \newline } \test:w 01/02/03 \ExplSyntaxOff \bigskip Keys: \ExplSyntaxOn \keys_define:nn { test } { date .code:n = { \test:w #1 }, title .code:n = { title: #1 \newline}, } \keys_set:nn {test} { title = hello, date = 15/16/17, title = hi} \ExplSyntaxOff \end{document} ``` ![output](https://i.stack.imgur.com/tmHiW.png) I realize that I could introduce some token—perhaps the quark `\q_stop`—to the `l3keys` `.code:n` usage to terminate it 'normally'. Is there a way to go about doing this without such an introduction?
2014/06/17
[ "https://tex.stackexchange.com/questions/185346", "https://tex.stackexchange.com", "https://tex.stackexchange.com/users/17423/" ]
An argument is either delimited or undelimited; in the latter case only the first token or braced group is taken as the argument. Your `\test:w` macro has an undelimited third argument; delimit also the third argument and add the final delimiter in the `.code:n` part. ``` \documentclass{article} \usepackage{xparse} \pagestyle{empty} \setlength\parindent{0pt} \begin{document} \ExplSyntaxOn \cs_new:Npn \test:www #1 / #2 / #3 \q_stop { year:#1 \newline month:#2 \newline day:#3 \newline } \test:w 01/02/03 \q_stop \ExplSyntaxOff \bigskip Keys: \ExplSyntaxOn \keys_define:nn { test } { date .code:n = { \test:www #1 \q_stop }, title .code:n = { title: #1 \newline}, } \keys_set:nn {test} { title = hello, date = 15/16/17, title = hi} \ExplSyntaxOff \end{document} ``` ![enter image description here](https://i.stack.imgur.com/ba0L3.png) --- Possibly better code that doesn't use delimited arguments explicitly. Less efficient, perhaps, but clearer. You can add several checks that the date is legal; wrong input with `\test:www` would result in an unscrutable error. ``` \documentclass{article} \usepackage{xparse} \ExplSyntaxOn \NewDocumentCommand{\test}{ m } { \keys_set:nn { sean/test } { #1 } } \cs_new:Npn \sean_test:nn #1 #2 { \seq_set_split:Nnn \l__sean_date_seq { #1 } { #2 } \int_compare:nTF { \seq_count:N \l__sean_date_seq == 3 } { year: ~\seq_item:Nn \l__sean_date_seq { 1 } \newline month:~\seq_item:Nn \l__sean_date_seq { 2 } \newline day: ~\seq_item:Nn \l__sean_date_seq { 3 } \newline } { BAD~DATE! } } \cs_generate_variant:Nn \sean_test:nn { V } \keys_define:nn { sean/test } { date-delimiter .tl_set:N = \l_sean_date_delimiter_tl, date-delimiter .initial:n = { / }, date .code:n = { \sean_test:Vn \l_sean_date_delimiter_tl { #1 } }, title .code:n = { title: ~ #1 \newline }, } \ExplSyntaxOff \setlength{\parindent}{0pt} \pagestyle{empty} \begin{document} \test{ title = hello, date = 15/16/17, title = hi } \bigskip \test{ title = hi, date-delimiter = - , date = 01-02-03 } \end{document} ``` ![enter image description here](https://i.stack.imgur.com/JAH2v.png)
Not sure what you need, perhaps: ``` \documentclass{article} \usepackage{xparse} \pagestyle{empty} \setlength\parindent{0pt} \begin{document} Plain: \def\test#1/#2/#3 { year:#1 \newline month:#2 \newline day:#3 \newline } \test 01/02/03 \bigskip Expl3: \ExplSyntaxOn \cs_new:Npn \test:w #1/#2/#3~{ year:#1 \newline month:#2 \newline day:#3 \newline } \test:w 01/02/03~ \ExplSyntaxOff \bigskip Keys: \ExplSyntaxOn \keys_define:nn { test } { date .code:n = { \test:w #1~ }, title .code:n = { title: #1 \newline}, } \keys_set:nn {test} { title = hello, date = 15/16/17, title = hi} \ExplSyntaxOff \end{document} ```
5,724
I studied math and economics at a poorly ranked university, and I will graduate in the near future. I have a position lined up at a prestigious, data-heavy research institution, where I'll work with numerous economists for a few years before applying to top PhD programs (Berkeley, Chicago, MIT, Harvard, etc.) I took two courses in analysis and did well, although per the quality of my institution, the courses were not challenging. I also worked as a research assistant and conducted self-guided researched (not published outside my university), so I have several professors willing to write detailed recommendations for me. Apart from a few hiccups in non math/econ courses, my grades are perfect. Will the fact that my undergraduate degree comes from an unranked institution affect my chances of attending a top PhD program? Will it affect my chances even though my experience after undergrad should speak in my favor?
2012/12/13
[ "https://academia.stackexchange.com/questions/5724", "https://academia.stackexchange.com", "https://academia.stackexchange.com/users/4317/" ]
As the commenters have pointed out, a lot will depend on your ability to get good letters of recommendation. However, there is an important issue to note: a good letter of recommendation does **not** mean the same thing as "a letter from someone famous." You can get a letter of recommendation from a big name that is completely useless, if it doesn't provide any real information of value about the candidate. Instead, what you want are people who can testify that you are a good student, and show evidence that you can become a good researcher. Since you have excellent records, and are working with a research group before applying to graduate school, I think you have the right groundwork for getting good letters. To make sure that you do so, you'll want to meet with the people who will be writing the letters, make sure that they are willing and enthusiastic about writing the letters (hint: if they are at all hesitant, do *not* get a letter from them!), and then provide them with the necessary material they'll need (CV's, samples of writing and research work, citations and awards, etc.) to write the letter. Ultimately, the only way attending an unranked school will affect your chances of getting in as a graduate student is if the admissions committee at the school you're applying to shows such a bias. If you're concerned about such a possibility, and have the resources (time, money, motivation) to do so, setting up a meeting with the person in charge of graduate admissions at the department you're interested in probably can't hurt.
*It will probably affect your chances. But it's not a show-stopper.* Coming from a top school means students are more likely to get that second look and it means that students are more likely to have recommendations from people than the folks on the admission committee already know and trust. For those reasons, coming from a top school affords a real advantage over unranked schools. It's not fair but there are lots of reasons to believe that an applicant from a top school will get more bites than an identical one from an unranked school. That said, if you think you can put together a solid application, you shouldn't get too hung up about the status symbols you won't have and others might. Nobody is making decisions based *only* on where the applicant went to college. If you have great test scores, a history of excellent academic performance (sounds like you do), a demonstrated ability to do solid research, and a glowing set of letters from a good set of letter writers, you have a good chance at a top program. Focus on the things you can change, improve, and build on and not on the stuff you can't. FWIW: I did my undergrad at an unranked liberal arts college and graduate school at a top school — although not in economics. Moving up the status hierarchy is always harder than lateral or downward moves, but it happens all the time.
5,724
I studied math and economics at a poorly ranked university, and I will graduate in the near future. I have a position lined up at a prestigious, data-heavy research institution, where I'll work with numerous economists for a few years before applying to top PhD programs (Berkeley, Chicago, MIT, Harvard, etc.) I took two courses in analysis and did well, although per the quality of my institution, the courses were not challenging. I also worked as a research assistant and conducted self-guided researched (not published outside my university), so I have several professors willing to write detailed recommendations for me. Apart from a few hiccups in non math/econ courses, my grades are perfect. Will the fact that my undergraduate degree comes from an unranked institution affect my chances of attending a top PhD program? Will it affect my chances even though my experience after undergrad should speak in my favor?
2012/12/13
[ "https://academia.stackexchange.com/questions/5724", "https://academia.stackexchange.com", "https://academia.stackexchange.com/users/4317/" ]
As the commenters have pointed out, a lot will depend on your ability to get good letters of recommendation. However, there is an important issue to note: a good letter of recommendation does **not** mean the same thing as "a letter from someone famous." You can get a letter of recommendation from a big name that is completely useless, if it doesn't provide any real information of value about the candidate. Instead, what you want are people who can testify that you are a good student, and show evidence that you can become a good researcher. Since you have excellent records, and are working with a research group before applying to graduate school, I think you have the right groundwork for getting good letters. To make sure that you do so, you'll want to meet with the people who will be writing the letters, make sure that they are willing and enthusiastic about writing the letters (hint: if they are at all hesitant, do *not* get a letter from them!), and then provide them with the necessary material they'll need (CV's, samples of writing and research work, citations and awards, etc.) to write the letter. Ultimately, the only way attending an unranked school will affect your chances of getting in as a graduate student is if the admissions committee at the school you're applying to shows such a bias. If you're concerned about such a possibility, and have the resources (time, money, motivation) to do so, setting up a meeting with the person in charge of graduate admissions at the department you're interested in probably can't hurt.
I would advise to develop a relationship via email with professors at your target schools. Dig in and learn about their research and show how interested you are in working with them. Also target assistant and associate professors at those schools as they are more likely to be in the admissions committee paying their dues. They might be the difference if everything else is good. I know Penn accepts some students from schools I had never heard at all. They try to diversify, just the odds might be different.
5,724
I studied math and economics at a poorly ranked university, and I will graduate in the near future. I have a position lined up at a prestigious, data-heavy research institution, where I'll work with numerous economists for a few years before applying to top PhD programs (Berkeley, Chicago, MIT, Harvard, etc.) I took two courses in analysis and did well, although per the quality of my institution, the courses were not challenging. I also worked as a research assistant and conducted self-guided researched (not published outside my university), so I have several professors willing to write detailed recommendations for me. Apart from a few hiccups in non math/econ courses, my grades are perfect. Will the fact that my undergraduate degree comes from an unranked institution affect my chances of attending a top PhD program? Will it affect my chances even though my experience after undergrad should speak in my favor?
2012/12/13
[ "https://academia.stackexchange.com/questions/5724", "https://academia.stackexchange.com", "https://academia.stackexchange.com/users/4317/" ]
As the commenters have pointed out, a lot will depend on your ability to get good letters of recommendation. However, there is an important issue to note: a good letter of recommendation does **not** mean the same thing as "a letter from someone famous." You can get a letter of recommendation from a big name that is completely useless, if it doesn't provide any real information of value about the candidate. Instead, what you want are people who can testify that you are a good student, and show evidence that you can become a good researcher. Since you have excellent records, and are working with a research group before applying to graduate school, I think you have the right groundwork for getting good letters. To make sure that you do so, you'll want to meet with the people who will be writing the letters, make sure that they are willing and enthusiastic about writing the letters (hint: if they are at all hesitant, do *not* get a letter from them!), and then provide them with the necessary material they'll need (CV's, samples of writing and research work, citations and awards, etc.) to write the letter. Ultimately, the only way attending an unranked school will affect your chances of getting in as a graduate student is if the admissions committee at the school you're applying to shows such a bias. If you're concerned about such a possibility, and have the resources (time, money, motivation) to do so, setting up a meeting with the person in charge of graduate admissions at the department you're interested in probably can't hurt.
I have been in your situation several years ago (in 2011). I graduated BA in Economics and Business Adminsitration from anranked university from one of the developing countries in Eastern Europe. But then I enrolled in Master's Program where I had a chance to meet highly respected Economists who were professors in US programs as well. Neither my Master's Program was ranked. They were just funded by the World Bank and had enough money to invite US professors. By getting As and A-s in all of their courses and being engaged with the professors I earned quite good reputation and showed them that I was motivated and knowledgeable enough to study in some 30-40 US programs. Despite the fact that my school was not ranked after getting recommendation letters from these well-known US professors I was admitted in top 30 programs in the US. The take away from my story is that the rank of the university does not as far as you get strong recommendation letters from well-known and well-published economists, researchers.
5,724
I studied math and economics at a poorly ranked university, and I will graduate in the near future. I have a position lined up at a prestigious, data-heavy research institution, where I'll work with numerous economists for a few years before applying to top PhD programs (Berkeley, Chicago, MIT, Harvard, etc.) I took two courses in analysis and did well, although per the quality of my institution, the courses were not challenging. I also worked as a research assistant and conducted self-guided researched (not published outside my university), so I have several professors willing to write detailed recommendations for me. Apart from a few hiccups in non math/econ courses, my grades are perfect. Will the fact that my undergraduate degree comes from an unranked institution affect my chances of attending a top PhD program? Will it affect my chances even though my experience after undergrad should speak in my favor?
2012/12/13
[ "https://academia.stackexchange.com/questions/5724", "https://academia.stackexchange.com", "https://academia.stackexchange.com/users/4317/" ]
*It will probably affect your chances. But it's not a show-stopper.* Coming from a top school means students are more likely to get that second look and it means that students are more likely to have recommendations from people than the folks on the admission committee already know and trust. For those reasons, coming from a top school affords a real advantage over unranked schools. It's not fair but there are lots of reasons to believe that an applicant from a top school will get more bites than an identical one from an unranked school. That said, if you think you can put together a solid application, you shouldn't get too hung up about the status symbols you won't have and others might. Nobody is making decisions based *only* on where the applicant went to college. If you have great test scores, a history of excellent academic performance (sounds like you do), a demonstrated ability to do solid research, and a glowing set of letters from a good set of letter writers, you have a good chance at a top program. Focus on the things you can change, improve, and build on and not on the stuff you can't. FWIW: I did my undergrad at an unranked liberal arts college and graduate school at a top school — although not in economics. Moving up the status hierarchy is always harder than lateral or downward moves, but it happens all the time.
I would advise to develop a relationship via email with professors at your target schools. Dig in and learn about their research and show how interested you are in working with them. Also target assistant and associate professors at those schools as they are more likely to be in the admissions committee paying their dues. They might be the difference if everything else is good. I know Penn accepts some students from schools I had never heard at all. They try to diversify, just the odds might be different.