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
33,547,179
Recently I am being challenged by quite an "easy" problem. Suppose that there is sentences (saved in a String), and I need to find out if there is any date in this String. The challenges is that the date can be in a lot of different formats. Some examples are shown in the list: * June 12, 1956 * London, 21st October 2014 * 13 October 1999 * 01/11/2003 Worth mentioning that these are contained in one string. So as an example it can be like: ``` String s = "This event took place on 13 October 1999."; ``` My question in this case would be how can I detect that there is a date in this string. My first approach was to search for the word "event", and then try to localize the date. But with more and more possible formats of the date this solution is not very beautiful. The second solution that I tried is to create a list for months and search. This had good results but still misses the cases when the date is expressed all in digits. One solution which I have not tried till now is to design regular expressions and try to find a match in the string. Not sure how much this solution might decrease the performance. What could be a good solution that I should probably consider? Did anybody face a similar problem before and what solutions did you find? One thing is for sure that there are no time, so the only interesting part is the date.
2015/11/05
[ "https://Stackoverflow.com/questions/33547179", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4348290/" ]
Using the [natty.joestelmach.com](http://natty.joestelmach.com) library Natty is a natural language date parser written in Java. Given a date expression, natty will apply standard language recognition and translation techniques to produce a list of corresponding dates with optional parse and syntax information. ``` import com.joestelmach.natty.*; List<Date> dates =new Parser().parse("Start date 11/30/2013 , end date Friday, Sept. 7, 2013").get(0).getDates(); System.out.println(dates.get(0)); System.out.println(dates.get(1)); //output: //Sat Nov 30 11:14:30 BDT 2013 //Sat Sep 07 11:14:30 BDT 2013 ```
If it's only one String you could use the Regular Expression as you mentioned. Having to find the different date format expressions. Here are some examples: [Regular Expressions - dates](http://www.regular-expressions.info/dates.html) In case it's a document or a big text, you will need a parser. You could use a [Lexical analysis](https://en.wikipedia.org/wiki/Lexical_analysis) approach. Depending on the project using an external library as mentioned in some answers might be a good idea. Sometimes it's not an option.
33,547,179
Recently I am being challenged by quite an "easy" problem. Suppose that there is sentences (saved in a String), and I need to find out if there is any date in this String. The challenges is that the date can be in a lot of different formats. Some examples are shown in the list: * June 12, 1956 * London, 21st October 2014 * 13 October 1999 * 01/11/2003 Worth mentioning that these are contained in one string. So as an example it can be like: ``` String s = "This event took place on 13 October 1999."; ``` My question in this case would be how can I detect that there is a date in this string. My first approach was to search for the word "event", and then try to localize the date. But with more and more possible formats of the date this solution is not very beautiful. The second solution that I tried is to create a list for months and search. This had good results but still misses the cases when the date is expressed all in digits. One solution which I have not tried till now is to design regular expressions and try to find a match in the string. Not sure how much this solution might decrease the performance. What could be a good solution that I should probably consider? Did anybody face a similar problem before and what solutions did you find? One thing is for sure that there are no time, so the only interesting part is the date.
2015/11/05
[ "https://Stackoverflow.com/questions/33547179", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4348290/" ]
Using the [natty.joestelmach.com](http://natty.joestelmach.com) library Natty is a natural language date parser written in Java. Given a date expression, natty will apply standard language recognition and translation techniques to produce a list of corresponding dates with optional parse and syntax information. ``` import com.joestelmach.natty.*; List<Date> dates =new Parser().parse("Start date 11/30/2013 , end date Friday, Sept. 7, 2013").get(0).getDates(); System.out.println(dates.get(0)); System.out.println(dates.get(1)); //output: //Sat Nov 30 11:14:30 BDT 2013 //Sat Sep 07 11:14:30 BDT 2013 ```
You are after [Named Entity Recognition](https://en.wikipedia.org/wiki/Named-entity_recognition). I'd start with [Stanford NLP](http://nlp.stanford.edu/software/CRF-NER.shtml). The 7 class model includes date, but the online [demo struggles](http://nlp.stanford.edu:8080/ner/) and misses the "13". :( Natty mentioned above gives a [better answer](http://natty.joestelmach.com/try.jsp#).
33,547,179
Recently I am being challenged by quite an "easy" problem. Suppose that there is sentences (saved in a String), and I need to find out if there is any date in this String. The challenges is that the date can be in a lot of different formats. Some examples are shown in the list: * June 12, 1956 * London, 21st October 2014 * 13 October 1999 * 01/11/2003 Worth mentioning that these are contained in one string. So as an example it can be like: ``` String s = "This event took place on 13 October 1999."; ``` My question in this case would be how can I detect that there is a date in this string. My first approach was to search for the word "event", and then try to localize the date. But with more and more possible formats of the date this solution is not very beautiful. The second solution that I tried is to create a list for months and search. This had good results but still misses the cases when the date is expressed all in digits. One solution which I have not tried till now is to design regular expressions and try to find a match in the string. Not sure how much this solution might decrease the performance. What could be a good solution that I should probably consider? Did anybody face a similar problem before and what solutions did you find? One thing is for sure that there are no time, so the only interesting part is the date.
2015/11/05
[ "https://Stackoverflow.com/questions/33547179", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4348290/" ]
Using the [natty.joestelmach.com](http://natty.joestelmach.com) library Natty is a natural language date parser written in Java. Given a date expression, natty will apply standard language recognition and translation techniques to produce a list of corresponding dates with optional parse and syntax information. ``` import com.joestelmach.natty.*; List<Date> dates =new Parser().parse("Start date 11/30/2013 , end date Friday, Sept. 7, 2013").get(0).getDates(); System.out.println(dates.get(0)); System.out.println(dates.get(1)); //output: //Sat Nov 30 11:14:30 BDT 2013 //Sat Sep 07 11:14:30 BDT 2013 ```
I've done this before with good `precision` and `recall`. You'll need [GATE](https://gate.ac.uk/) and its `ANNIE` plugin. 1. Use GATE UI tool to create a `.GAPP` file that will contain your `processing resources`. 2. Use the `.GAPP` file to use the extracted `Date` annotation set. Step 2 can be done as follows: ``` Corpus corpus = Factory.newCorpus("Gate Corpus"); Document gateDoc = Factory.newDocument("This event took place on 13 October 1999."); corpus.add(gateDoc); File pluginsHome = Gate.getPluginsHome(); File ANNIEPlugin = new File(pluginsHome, "ANNIE"); File AnnieGapp = new File(ANNIEPlugin, "Test.gapp"); AnnieController =(CorpusController) PersistenceManager.loadObjectFromFile(AnnieGapp); AnnieController.setCorpus(corpus); AnnieController.execute(); ``` Later you can see the extracted annotations like this: ``` AnnotationSetImpl ann = (AnnotationSetImpl) gateDoc.getAnnotations(); System.out.println("Found annotations of the following types: "+ gateDoc.getAnnotations().getAllTypes()); ``` I'm sure you can do it easily with the inbuilt annotation set `Date`. It is also very enhancable. To enhance the annotation set `Date` create a lenient annotation rule in [JAPE](https://gate.ac.uk/sale/tao/splitch8.html#chap:jape) say 'DateEnhanced' from inbuilt ANNIE annotation `Date` to include certain kinds of dates like "9/11" and use a Chaining of Java regex on R.H.S. of the 'DateEnhanced' annotations JAPE RULE, to filter some unwanted outputs (if any).
33,547,179
Recently I am being challenged by quite an "easy" problem. Suppose that there is sentences (saved in a String), and I need to find out if there is any date in this String. The challenges is that the date can be in a lot of different formats. Some examples are shown in the list: * June 12, 1956 * London, 21st October 2014 * 13 October 1999 * 01/11/2003 Worth mentioning that these are contained in one string. So as an example it can be like: ``` String s = "This event took place on 13 October 1999."; ``` My question in this case would be how can I detect that there is a date in this string. My first approach was to search for the word "event", and then try to localize the date. But with more and more possible formats of the date this solution is not very beautiful. The second solution that I tried is to create a list for months and search. This had good results but still misses the cases when the date is expressed all in digits. One solution which I have not tried till now is to design regular expressions and try to find a match in the string. Not sure how much this solution might decrease the performance. What could be a good solution that I should probably consider? Did anybody face a similar problem before and what solutions did you find? One thing is for sure that there are no time, so the only interesting part is the date.
2015/11/05
[ "https://Stackoverflow.com/questions/33547179", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4348290/" ]
You are after [Named Entity Recognition](https://en.wikipedia.org/wiki/Named-entity_recognition). I'd start with [Stanford NLP](http://nlp.stanford.edu/software/CRF-NER.shtml). The 7 class model includes date, but the online [demo struggles](http://nlp.stanford.edu:8080/ner/) and misses the "13". :( Natty mentioned above gives a [better answer](http://natty.joestelmach.com/try.jsp#).
If it's only one String you could use the Regular Expression as you mentioned. Having to find the different date format expressions. Here are some examples: [Regular Expressions - dates](http://www.regular-expressions.info/dates.html) In case it's a document or a big text, you will need a parser. You could use a [Lexical analysis](https://en.wikipedia.org/wiki/Lexical_analysis) approach. Depending on the project using an external library as mentioned in some answers might be a good idea. Sometimes it's not an option.
33,547,179
Recently I am being challenged by quite an "easy" problem. Suppose that there is sentences (saved in a String), and I need to find out if there is any date in this String. The challenges is that the date can be in a lot of different formats. Some examples are shown in the list: * June 12, 1956 * London, 21st October 2014 * 13 October 1999 * 01/11/2003 Worth mentioning that these are contained in one string. So as an example it can be like: ``` String s = "This event took place on 13 October 1999."; ``` My question in this case would be how can I detect that there is a date in this string. My first approach was to search for the word "event", and then try to localize the date. But with more and more possible formats of the date this solution is not very beautiful. The second solution that I tried is to create a list for months and search. This had good results but still misses the cases when the date is expressed all in digits. One solution which I have not tried till now is to design regular expressions and try to find a match in the string. Not sure how much this solution might decrease the performance. What could be a good solution that I should probably consider? Did anybody face a similar problem before and what solutions did you find? One thing is for sure that there are no time, so the only interesting part is the date.
2015/11/05
[ "https://Stackoverflow.com/questions/33547179", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4348290/" ]
If it's only one String you could use the Regular Expression as you mentioned. Having to find the different date format expressions. Here are some examples: [Regular Expressions - dates](http://www.regular-expressions.info/dates.html) In case it's a document or a big text, you will need a parser. You could use a [Lexical analysis](https://en.wikipedia.org/wiki/Lexical_analysis) approach. Depending on the project using an external library as mentioned in some answers might be a good idea. Sometimes it's not an option.
I've done this before with good `precision` and `recall`. You'll need [GATE](https://gate.ac.uk/) and its `ANNIE` plugin. 1. Use GATE UI tool to create a `.GAPP` file that will contain your `processing resources`. 2. Use the `.GAPP` file to use the extracted `Date` annotation set. Step 2 can be done as follows: ``` Corpus corpus = Factory.newCorpus("Gate Corpus"); Document gateDoc = Factory.newDocument("This event took place on 13 October 1999."); corpus.add(gateDoc); File pluginsHome = Gate.getPluginsHome(); File ANNIEPlugin = new File(pluginsHome, "ANNIE"); File AnnieGapp = new File(ANNIEPlugin, "Test.gapp"); AnnieController =(CorpusController) PersistenceManager.loadObjectFromFile(AnnieGapp); AnnieController.setCorpus(corpus); AnnieController.execute(); ``` Later you can see the extracted annotations like this: ``` AnnotationSetImpl ann = (AnnotationSetImpl) gateDoc.getAnnotations(); System.out.println("Found annotations of the following types: "+ gateDoc.getAnnotations().getAllTypes()); ``` I'm sure you can do it easily with the inbuilt annotation set `Date`. It is also very enhancable. To enhance the annotation set `Date` create a lenient annotation rule in [JAPE](https://gate.ac.uk/sale/tao/splitch8.html#chap:jape) say 'DateEnhanced' from inbuilt ANNIE annotation `Date` to include certain kinds of dates like "9/11" and use a Chaining of Java regex on R.H.S. of the 'DateEnhanced' annotations JAPE RULE, to filter some unwanted outputs (if any).
33,547,179
Recently I am being challenged by quite an "easy" problem. Suppose that there is sentences (saved in a String), and I need to find out if there is any date in this String. The challenges is that the date can be in a lot of different formats. Some examples are shown in the list: * June 12, 1956 * London, 21st October 2014 * 13 October 1999 * 01/11/2003 Worth mentioning that these are contained in one string. So as an example it can be like: ``` String s = "This event took place on 13 October 1999."; ``` My question in this case would be how can I detect that there is a date in this string. My first approach was to search for the word "event", and then try to localize the date. But with more and more possible formats of the date this solution is not very beautiful. The second solution that I tried is to create a list for months and search. This had good results but still misses the cases when the date is expressed all in digits. One solution which I have not tried till now is to design regular expressions and try to find a match in the string. Not sure how much this solution might decrease the performance. What could be a good solution that I should probably consider? Did anybody face a similar problem before and what solutions did you find? One thing is for sure that there are no time, so the only interesting part is the date.
2015/11/05
[ "https://Stackoverflow.com/questions/33547179", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4348290/" ]
You are after [Named Entity Recognition](https://en.wikipedia.org/wiki/Named-entity_recognition). I'd start with [Stanford NLP](http://nlp.stanford.edu/software/CRF-NER.shtml). The 7 class model includes date, but the online [demo struggles](http://nlp.stanford.edu:8080/ner/) and misses the "13". :( Natty mentioned above gives a [better answer](http://natty.joestelmach.com/try.jsp#).
I've done this before with good `precision` and `recall`. You'll need [GATE](https://gate.ac.uk/) and its `ANNIE` plugin. 1. Use GATE UI tool to create a `.GAPP` file that will contain your `processing resources`. 2. Use the `.GAPP` file to use the extracted `Date` annotation set. Step 2 can be done as follows: ``` Corpus corpus = Factory.newCorpus("Gate Corpus"); Document gateDoc = Factory.newDocument("This event took place on 13 October 1999."); corpus.add(gateDoc); File pluginsHome = Gate.getPluginsHome(); File ANNIEPlugin = new File(pluginsHome, "ANNIE"); File AnnieGapp = new File(ANNIEPlugin, "Test.gapp"); AnnieController =(CorpusController) PersistenceManager.loadObjectFromFile(AnnieGapp); AnnieController.setCorpus(corpus); AnnieController.execute(); ``` Later you can see the extracted annotations like this: ``` AnnotationSetImpl ann = (AnnotationSetImpl) gateDoc.getAnnotations(); System.out.println("Found annotations of the following types: "+ gateDoc.getAnnotations().getAllTypes()); ``` I'm sure you can do it easily with the inbuilt annotation set `Date`. It is also very enhancable. To enhance the annotation set `Date` create a lenient annotation rule in [JAPE](https://gate.ac.uk/sale/tao/splitch8.html#chap:jape) say 'DateEnhanced' from inbuilt ANNIE annotation `Date` to include certain kinds of dates like "9/11" and use a Chaining of Java regex on R.H.S. of the 'DateEnhanced' annotations JAPE RULE, to filter some unwanted outputs (if any).
17,758,908
I've developed website based on .NET MVC4. I used simple membership .NET built in forms authentication. I saw that the application uses some kind of MS database, but I don't really know what kind. I want to upload my site to server and publish it. Do I need to install some kind of database on the server? or I'll just need to upload the application and it will create the database on the server automatically? Thanks.
2013/07/20
[ "https://Stackoverflow.com/questions/17758908", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2270166/" ]
The database created by default when using the MVC 4 Internet template is a [SQL Server Express LocalDB](http://msdn.microsoft.com/en-us/library/hh510202.aspx), which is really intended for development and testing and not for deployment. Although I think some people do use it in production. If the correct components are on the server you are deploying to it will automatically create this database. If you look at the web.config generated by the template it looks something like this. ``` <add name="SimpleSecurityConnection" connectionString="Data Source=(LocalDb)\v11.0;Initial Catalog=aspnet-SeedSimple-20130125152904;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\aspnet-SeedSimple-20130125152904.mdf" providerName="System.Data.SqlClient" /> ``` The name for the configuration string to use is defined in the [WebSecurity.InitializeDatabaseConnection](http://msdn.microsoft.com/en-us/library/gg569134%28v=vs.111%29.aspx) method as the first parameter. You will notice that the data source starts out with "(LocalDb)" which tells the runtime to use a LocalDB instance. I would recommend installing something like SQL Server Express or a full blown SQL Server instance on the server and changing the connection string to point to it instead for production.
You should explain more about state of your application database. At least you should let us see your working connection string(s). If you have all your data in a single database - your own tables and the membership made tables - and your database is attached to a local database instance, you just need to generate a script from your current database and run that script on the database server of your web host. Many scenarios exist according to the type of your application database (source) and the type of your web hosting database server (destination)...
31,953
> > **Possible Duplicate:** > > [Basic Frequency Control Circuit](https://electronics.stackexchange.com/questions/31888/basic-frequency-control-circuit) > > > In the following schematic, why can't R4 be taken away and the feedback network pass output feedback through C2 and R2? ![Schematic](https://i.stack.imgur.com/WG4tD.jpg)
2012/05/15
[ "https://electronics.stackexchange.com/questions/31953", "https://electronics.stackexchange.com", "https://electronics.stackexchange.com/users/9374/" ]
You said it yourself *"DC feedback is necessary"*. Capacitors block DC, so a capacitor in series with the feedback path eliminates DC feedback. For the purpose of DC analysis, think of a capacitor as a open circuit.
In a perfect world with ideal op-amps, this appears to work fine since with the pot at mid-position, the gain is -1 at all frequencies\* (after all, C1 blocks any dc from reaching the op-amp, so the infinite gain after point 'a' has nothing to amplify). The problem is that op-amps have input offset voltage and input bias current. Offset voltage is a small voltage that appears to exist between the + and - inputs. Bias current is a small current which flows into the + and - inputs. The offset voltage will cause the output to change but the capacitor C2 blocks this change from feeding-back to the input and cancelling the effect. Similarly the bias current causes C2 to charge-up, causing the output voltage to increase. Eventually, the output voltage reaches the supply rail and the op-amp saturates. * *Edit - strictly speaking, the gain at dc is undefined* (\$\frac{\infty}{\infty}\$)
69,167,234
I'm currently writing a minecraft plugin in java. But i'm facing an issue, an else statement is being fired while it shouldn't I'm checking if a player is in a region called "safezone" This will return true, i debugged this. However it fires the else Both if and else statements I'm unsure why this is happening, and can't quite put my finger on it. Here's my method ``` @EventHandler public void entityDamageEvent(EntityDamageByEntityEvent event) { if (event.getEntity() instanceof Player) { Player attacker = (Player) event.getDamager(); Player player = (Player) event.getEntity(); Location location = player.getLocation(); WorldGuardPlatform platform = com.sk89q.worldguard.WorldGuard.getInstance().getPlatform(); RegionContainer container = platform.getRegionContainer(); if (location.getWorld() != null) { RegionManager regionManager = container.get(BukkitAdapter.adapt(location.getWorld())); ApplicableRegionSet set = regionManager.getApplicableRegions(BukkitAdapter.asBlockVector(location)); for (ProtectedRegion r : set) { if (r.getId().equals("safezone")) { player.sendMessage("true"); attacker.sendMessage(ChatColor.RED + "Can't attack palyers here"); } else { attacker.sendMessage(ChatColor.RED + "You're now in combat, logging out will cost you!"); player.sendMessage(ChatColor.RED + "You're now in combat, logging out will cost you!"); } } } } } ``` I'll leave the contents of the set as well ``` ProtectedRegion{id='arena', type='CUBOID'} ProtectedRegion{id='safezone', type='CUBOID'} ```
2021/09/13
[ "https://Stackoverflow.com/questions/69167234", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5724893/" ]
You can use [`pd.to_timedelta()`](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.to_timedelta.html) and specify the unit as second, as follows: ``` df['laikas_s'] = pd.to_timedelta(df['laikas_s'], unit='S') ``` Result: ``` print(df) x laikas_s 0 meh 0 days 01:27:17 1 elec 0 days 05:48:45 ```
I just add solution with `datetime.timedelta` (the result is string, without the `0 days`): ```py import datetime df["laikas_s"] = df["laikas_s"].apply( lambda sec: str(datetime.timedelta(seconds=sec)) ) ``` Prints: ```none x laikas_s 0 meh 1:27:17 1 elec 5:48:45 ```
55,124
I'm using a Toshiba satellite L305 running Ubuntu. One issue, the laptop usually suspends itself when the lid closed, however Ubuntu only does this half of the time, the other half it keeps the system running. Very inconvenient, because when I put my laptop in my briefcase, if it's not suspended, it's just blowing hot air, can't be good for the computer. I don't think it's a hardware issue, because when I was running Windows on this machine I never had this problem.
2011/07/30
[ "https://askubuntu.com/questions/55124", "https://askubuntu.com", "https://askubuntu.com/users/21898/" ]
I would like to suggest first (unless you have done already) that you hit the unity button in the corner or win/super key and type Power Management. Here you should be able to select what action happens when you shut the laptop lid ie suspend/blank screen. It usually works on my laptop but more often than not. ![Power Management Options](https://i.stack.imgur.com/VJnvs.jpg) Apologies if you have done this already but for some people it is an easier method Let us know how you get on.
search for ACPI fixes, my asus wouldn't suspend, but a few lines of code in a wiki fixed it.
2,593,338
So let's assume I have a class named ABC that will have a list of Point objects. I need to make some drawing logic with them. Each one of those Point objects will have a Draw() method that will be called by the ABC class. The Draw() method code will need info from ABC class. I can only see two ways to make them have this info: 1. Having Abc class make public some properties that would allow draw() to make its decisions. 2. Having Abc class pass to draw() a class full of properties. The properties in both cases would be the same, my question is what is preferred in this case. Maybe the second approach is more flexible? Maybe not? I don't see here a clear winner, but that sure has more to do with my inexperience than any other thing. If there are other good approaches, feel free to share them. Here are both cases: ``` class Abc1 { public property a; public property b; public property c; ... public property z; public void method1(); ... public void methodn(); } ``` and here is approach 2: ``` class Abc2 { //here we make take down all properties public void method1(); ... public void methodn(); } class Abc2MethodArgs { //and we put them here. this class will be passed as argument to //Point's draw() method! public property a; public property b; public property c; ... public property z; } ``` Also, if there are any "formal" names for these two approaches, I'd like to know them so I can better choose the tags/thread name, so it's more useful for searching purposes. That or feel free to edit them.
2010/04/07
[ "https://Stackoverflow.com/questions/2593338", "https://Stackoverflow.com", "https://Stackoverflow.com/users/130758/" ]
It will be more work to create and maintain a separate class to pass state between `ABC` and `point`, but it's worth doing if you want to decouple `point` from `ABC`. The main question is, how much does decoupling them matter to you, if it matters at all? If it makes sense in your domain for point instances to know about abc instances, it probably isn't worth creating the parameter class and you should just go with option 1.
Go with approach #2, but without the object. Just pass the parameters to `Draw` directly.
2,593,338
So let's assume I have a class named ABC that will have a list of Point objects. I need to make some drawing logic with them. Each one of those Point objects will have a Draw() method that will be called by the ABC class. The Draw() method code will need info from ABC class. I can only see two ways to make them have this info: 1. Having Abc class make public some properties that would allow draw() to make its decisions. 2. Having Abc class pass to draw() a class full of properties. The properties in both cases would be the same, my question is what is preferred in this case. Maybe the second approach is more flexible? Maybe not? I don't see here a clear winner, but that sure has more to do with my inexperience than any other thing. If there are other good approaches, feel free to share them. Here are both cases: ``` class Abc1 { public property a; public property b; public property c; ... public property z; public void method1(); ... public void methodn(); } ``` and here is approach 2: ``` class Abc2 { //here we make take down all properties public void method1(); ... public void methodn(); } class Abc2MethodArgs { //and we put them here. this class will be passed as argument to //Point's draw() method! public property a; public property b; public property c; ... public property z; } ``` Also, if there are any "formal" names for these two approaches, I'd like to know them so I can better choose the tags/thread name, so it's more useful for searching purposes. That or feel free to edit them.
2010/04/07
[ "https://Stackoverflow.com/questions/2593338", "https://Stackoverflow.com", "https://Stackoverflow.com/users/130758/" ]
The best approach depends on the nature of the information ABC needs to provide to the Point instances, the nature of the relationship between these classes, and the "expected" future for them. In other words there are a lot of qualitative factors. If you do go with passing the Point an ABC instance, *don't* - rather, work out an appropriate abstraction for whatever it is Point needs from ABC, and encapsulate that in an interface. In static terms this is similar to simply creating a new class to encapsulate the information, but dynamically quite different. The reason you shouldn't simply pass an instance of ABC is that it creates a circular dependency. Without going into too much detail, this should generally be regarded as a Very Bad Thing and avoided unless absolutely necessary. And, at a more abstract level, it will make more sense and enable logical changes later if you identify the reason for this apparent circular dependency and factor that out - ie, create an interface to represent this 'data source for Points' role which ABC must fulfil. This role is distinct from the 'container for Points' role and that should be reflected in your design. You could also pass the parameters to the draw() method - again this may be good or bad depending on a heap of factors. It's certainly not a Very Bad Thing, as long as you've thought about the implications.
Go with approach #2, but without the object. Just pass the parameters to `Draw` directly.
2,593,338
So let's assume I have a class named ABC that will have a list of Point objects. I need to make some drawing logic with them. Each one of those Point objects will have a Draw() method that will be called by the ABC class. The Draw() method code will need info from ABC class. I can only see two ways to make them have this info: 1. Having Abc class make public some properties that would allow draw() to make its decisions. 2. Having Abc class pass to draw() a class full of properties. The properties in both cases would be the same, my question is what is preferred in this case. Maybe the second approach is more flexible? Maybe not? I don't see here a clear winner, but that sure has more to do with my inexperience than any other thing. If there are other good approaches, feel free to share them. Here are both cases: ``` class Abc1 { public property a; public property b; public property c; ... public property z; public void method1(); ... public void methodn(); } ``` and here is approach 2: ``` class Abc2 { //here we make take down all properties public void method1(); ... public void methodn(); } class Abc2MethodArgs { //and we put them here. this class will be passed as argument to //Point's draw() method! public property a; public property b; public property c; ... public property z; } ``` Also, if there are any "formal" names for these two approaches, I'd like to know them so I can better choose the tags/thread name, so it's more useful for searching purposes. That or feel free to edit them.
2010/04/07
[ "https://Stackoverflow.com/questions/2593338", "https://Stackoverflow.com", "https://Stackoverflow.com/users/130758/" ]
It will be more work to create and maintain a separate class to pass state between `ABC` and `point`, but it's worth doing if you want to decouple `point` from `ABC`. The main question is, how much does decoupling them matter to you, if it matters at all? If it makes sense in your domain for point instances to know about abc instances, it probably isn't worth creating the parameter class and you should just go with option 1.
Since the `Point` class and `ABC` appear to have to mediate between themselves as to what to draw, why not call the `draw()` method on the `Point`, passing the actual `ABC` object as an argument. The `ABC` object can provide accessor methods (don't expose those properties!) and the point class (or subclass implementations) can decide what to call back on `ABC` for.
2,593,338
So let's assume I have a class named ABC that will have a list of Point objects. I need to make some drawing logic with them. Each one of those Point objects will have a Draw() method that will be called by the ABC class. The Draw() method code will need info from ABC class. I can only see two ways to make them have this info: 1. Having Abc class make public some properties that would allow draw() to make its decisions. 2. Having Abc class pass to draw() a class full of properties. The properties in both cases would be the same, my question is what is preferred in this case. Maybe the second approach is more flexible? Maybe not? I don't see here a clear winner, but that sure has more to do with my inexperience than any other thing. If there are other good approaches, feel free to share them. Here are both cases: ``` class Abc1 { public property a; public property b; public property c; ... public property z; public void method1(); ... public void methodn(); } ``` and here is approach 2: ``` class Abc2 { //here we make take down all properties public void method1(); ... public void methodn(); } class Abc2MethodArgs { //and we put them here. this class will be passed as argument to //Point's draw() method! public property a; public property b; public property c; ... public property z; } ``` Also, if there are any "formal" names for these two approaches, I'd like to know them so I can better choose the tags/thread name, so it's more useful for searching purposes. That or feel free to edit them.
2010/04/07
[ "https://Stackoverflow.com/questions/2593338", "https://Stackoverflow.com", "https://Stackoverflow.com/users/130758/" ]
The best approach depends on the nature of the information ABC needs to provide to the Point instances, the nature of the relationship between these classes, and the "expected" future for them. In other words there are a lot of qualitative factors. If you do go with passing the Point an ABC instance, *don't* - rather, work out an appropriate abstraction for whatever it is Point needs from ABC, and encapsulate that in an interface. In static terms this is similar to simply creating a new class to encapsulate the information, but dynamically quite different. The reason you shouldn't simply pass an instance of ABC is that it creates a circular dependency. Without going into too much detail, this should generally be regarded as a Very Bad Thing and avoided unless absolutely necessary. And, at a more abstract level, it will make more sense and enable logical changes later if you identify the reason for this apparent circular dependency and factor that out - ie, create an interface to represent this 'data source for Points' role which ABC must fulfil. This role is distinct from the 'container for Points' role and that should be reflected in your design. You could also pass the parameters to the draw() method - again this may be good or bad depending on a heap of factors. It's certainly not a Very Bad Thing, as long as you've thought about the implications.
Since the `Point` class and `ABC` appear to have to mediate between themselves as to what to draw, why not call the `draw()` method on the `Point`, passing the actual `ABC` object as an argument. The `ABC` object can provide accessor methods (don't expose those properties!) and the point class (or subclass implementations) can decide what to call back on `ABC` for.
2,593,338
So let's assume I have a class named ABC that will have a list of Point objects. I need to make some drawing logic with them. Each one of those Point objects will have a Draw() method that will be called by the ABC class. The Draw() method code will need info from ABC class. I can only see two ways to make them have this info: 1. Having Abc class make public some properties that would allow draw() to make its decisions. 2. Having Abc class pass to draw() a class full of properties. The properties in both cases would be the same, my question is what is preferred in this case. Maybe the second approach is more flexible? Maybe not? I don't see here a clear winner, but that sure has more to do with my inexperience than any other thing. If there are other good approaches, feel free to share them. Here are both cases: ``` class Abc1 { public property a; public property b; public property c; ... public property z; public void method1(); ... public void methodn(); } ``` and here is approach 2: ``` class Abc2 { //here we make take down all properties public void method1(); ... public void methodn(); } class Abc2MethodArgs { //and we put them here. this class will be passed as argument to //Point's draw() method! public property a; public property b; public property c; ... public property z; } ``` Also, if there are any "formal" names for these two approaches, I'd like to know them so I can better choose the tags/thread name, so it's more useful for searching purposes. That or feel free to edit them.
2010/04/07
[ "https://Stackoverflow.com/questions/2593338", "https://Stackoverflow.com", "https://Stackoverflow.com/users/130758/" ]
The best approach depends on the nature of the information ABC needs to provide to the Point instances, the nature of the relationship between these classes, and the "expected" future for them. In other words there are a lot of qualitative factors. If you do go with passing the Point an ABC instance, *don't* - rather, work out an appropriate abstraction for whatever it is Point needs from ABC, and encapsulate that in an interface. In static terms this is similar to simply creating a new class to encapsulate the information, but dynamically quite different. The reason you shouldn't simply pass an instance of ABC is that it creates a circular dependency. Without going into too much detail, this should generally be regarded as a Very Bad Thing and avoided unless absolutely necessary. And, at a more abstract level, it will make more sense and enable logical changes later if you identify the reason for this apparent circular dependency and factor that out - ie, create an interface to represent this 'data source for Points' role which ABC must fulfil. This role is distinct from the 'container for Points' role and that should be reflected in your design. You could also pass the parameters to the draw() method - again this may be good or bad depending on a heap of factors. It's certainly not a Very Bad Thing, as long as you've thought about the implications.
It will be more work to create and maintain a separate class to pass state between `ABC` and `point`, but it's worth doing if you want to decouple `point` from `ABC`. The main question is, how much does decoupling them matter to you, if it matters at all? If it makes sense in your domain for point instances to know about abc instances, it probably isn't worth creating the parameter class and you should just go with option 1.
2,593,338
So let's assume I have a class named ABC that will have a list of Point objects. I need to make some drawing logic with them. Each one of those Point objects will have a Draw() method that will be called by the ABC class. The Draw() method code will need info from ABC class. I can only see two ways to make them have this info: 1. Having Abc class make public some properties that would allow draw() to make its decisions. 2. Having Abc class pass to draw() a class full of properties. The properties in both cases would be the same, my question is what is preferred in this case. Maybe the second approach is more flexible? Maybe not? I don't see here a clear winner, but that sure has more to do with my inexperience than any other thing. If there are other good approaches, feel free to share them. Here are both cases: ``` class Abc1 { public property a; public property b; public property c; ... public property z; public void method1(); ... public void methodn(); } ``` and here is approach 2: ``` class Abc2 { //here we make take down all properties public void method1(); ... public void methodn(); } class Abc2MethodArgs { //and we put them here. this class will be passed as argument to //Point's draw() method! public property a; public property b; public property c; ... public property z; } ``` Also, if there are any "formal" names for these two approaches, I'd like to know them so I can better choose the tags/thread name, so it's more useful for searching purposes. That or feel free to edit them.
2010/04/07
[ "https://Stackoverflow.com/questions/2593338", "https://Stackoverflow.com", "https://Stackoverflow.com/users/130758/" ]
It will be more work to create and maintain a separate class to pass state between `ABC` and `point`, but it's worth doing if you want to decouple `point` from `ABC`. The main question is, how much does decoupling them matter to you, if it matters at all? If it makes sense in your domain for point instances to know about abc instances, it probably isn't worth creating the parameter class and you should just go with option 1.
You may want to consider reversing the dependencies. Instead of Points accessing properties from ABC, have ABC set properties on the points when (or just before) calling "draw()" on each of them. Something similar to the [Flyweight pattern](http://en.wikipedia.org/wiki/Flyweight_pattern) used when rendering cells in Swing's JTables (see [javadoc](http://java.sun.com/javase/6/docs/api/javax/swing/table/TableCellRenderer.html)). You may also consider decoupling `Point` (data model) from `PointDrawer` (reusable rendering code). That way your Points will not depend on all those properties, only your PointDrawers will. And yes, it is OO programming even if you explicitly pass in all parameters to each Point at drawing time - that way, Points have no dependency at all on either ABC or on ABC's would-be "parameter-passing class".
2,593,338
So let's assume I have a class named ABC that will have a list of Point objects. I need to make some drawing logic with them. Each one of those Point objects will have a Draw() method that will be called by the ABC class. The Draw() method code will need info from ABC class. I can only see two ways to make them have this info: 1. Having Abc class make public some properties that would allow draw() to make its decisions. 2. Having Abc class pass to draw() a class full of properties. The properties in both cases would be the same, my question is what is preferred in this case. Maybe the second approach is more flexible? Maybe not? I don't see here a clear winner, but that sure has more to do with my inexperience than any other thing. If there are other good approaches, feel free to share them. Here are both cases: ``` class Abc1 { public property a; public property b; public property c; ... public property z; public void method1(); ... public void methodn(); } ``` and here is approach 2: ``` class Abc2 { //here we make take down all properties public void method1(); ... public void methodn(); } class Abc2MethodArgs { //and we put them here. this class will be passed as argument to //Point's draw() method! public property a; public property b; public property c; ... public property z; } ``` Also, if there are any "formal" names for these two approaches, I'd like to know them so I can better choose the tags/thread name, so it's more useful for searching purposes. That or feel free to edit them.
2010/04/07
[ "https://Stackoverflow.com/questions/2593338", "https://Stackoverflow.com", "https://Stackoverflow.com/users/130758/" ]
The best approach depends on the nature of the information ABC needs to provide to the Point instances, the nature of the relationship between these classes, and the "expected" future for them. In other words there are a lot of qualitative factors. If you do go with passing the Point an ABC instance, *don't* - rather, work out an appropriate abstraction for whatever it is Point needs from ABC, and encapsulate that in an interface. In static terms this is similar to simply creating a new class to encapsulate the information, but dynamically quite different. The reason you shouldn't simply pass an instance of ABC is that it creates a circular dependency. Without going into too much detail, this should generally be regarded as a Very Bad Thing and avoided unless absolutely necessary. And, at a more abstract level, it will make more sense and enable logical changes later if you identify the reason for this apparent circular dependency and factor that out - ie, create an interface to represent this 'data source for Points' role which ABC must fulfil. This role is distinct from the 'container for Points' role and that should be reflected in your design. You could also pass the parameters to the draw() method - again this may be good or bad depending on a heap of factors. It's certainly not a Very Bad Thing, as long as you've thought about the implications.
You may want to consider reversing the dependencies. Instead of Points accessing properties from ABC, have ABC set properties on the points when (or just before) calling "draw()" on each of them. Something similar to the [Flyweight pattern](http://en.wikipedia.org/wiki/Flyweight_pattern) used when rendering cells in Swing's JTables (see [javadoc](http://java.sun.com/javase/6/docs/api/javax/swing/table/TableCellRenderer.html)). You may also consider decoupling `Point` (data model) from `PointDrawer` (reusable rendering code). That way your Points will not depend on all those properties, only your PointDrawers will. And yes, it is OO programming even if you explicitly pass in all parameters to each Point at drawing time - that way, Points have no dependency at all on either ABC or on ABC's would-be "parameter-passing class".
35,165,271
This should be simple. How can I assign my own colors to the bars in [Google Gantt Charts](https://developers.google.com/chart/interactive/docs/gallery/ganttchart)? The gantt is ignoring my colors and automatically assigning blue, red and yellow colors (in that order) to the bars and I can't seem to figure out the problem. Can someone please point out if I am missing something here or is it not supported at all at this time? Here is what I have: ``` function drawChart() { var data = new google.visualization.DataTable(); data.addColumn({ type: 'string', id: 'task_id' }, 'Task ID'); data.addColumn({ type: 'string', id: 'task_name' }, 'Task Name'); data.addColumn({ type: 'string', id: 'resource' }, 'Resource'); data.addColumn({ type: 'date', id: 'start_date' }, 'Start Date'); data.addColumn({ type: 'date', id: 'end_date' }, 'End Date'); data.addColumn({ type: 'number', id: 'duration' }, 'Duration'); data.addColumn({ type: 'number', id: 'percent_complete' }, 'Percent Complete'); data.addColumn({ type: 'string', id: 'dependencies' }, 'Dependencies'); data.addRows([ ['Research', 'Find sources', null, new Date(2015, 0, 1), new Date(2015, 0, 5), null, 100, null], ['Write', 'Write paper', 'write', null, new Date(2015, 0, 9), daysToMilliseconds(3), 25, 'Research,Outline'], ['Cite', 'Create bibliography', 'write', null, new Date(2015, 0, 7), daysToMilliseconds(1), 20, 'Research'], ['Complete', 'Hand in paper', 'complete', null, new Date(2015, 0, 10), daysToMilliseconds(1), 0, 'Cite,Write'], ['Outline', 'Outline paper', 'write', null, new Date(2015, 0, 6), daysToMilliseconds(1), 100, 'Research'] ]); var colors = []; var colorMap = { write: '#e63b6f', complete: '#19c362' } for (var i = 0; i < data.getNumberOfRows(); i++) { colors.push(colorMap[data.getValue(i, 2)]); } var options = { height: 275, gantt: { criticalPathEnabled: true, criticalPathStyle: { stroke: '#e64a19', strokeWidth: 5 } }, colors: colors }; var chart = new google.visualization.Gantt(document.getElementById('chart_div')); chart.draw(data, options); } ```
2016/02/02
[ "https://Stackoverflow.com/questions/35165271", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3207927/" ]
I figured out a hacky way of doing it. You basically have to listen to every single event fired by the chart and override them with a function that colors the chart.
This is pretty old, but just in case anyone needs to do this... Not a super elegant solution, but it works. ``` function changeColors() { $("text[fill='#5e97f6']").attr('fill',"#0099D8"); // Left Text $("rect[fill='#5e97f6']").attr('fill',"#0099D8"); // Full bar $("path[fill='#2a56c6']").attr('fill', '#006B99'); // Percentage completed $("rect[fill='#2a56c6']").attr('fill', '#0099D8'); // Hover Full Bar $("path[fill='#204195']").attr('fill', '#006B99'); // Hover Percentage // Change Old red to new Red $("text[fill='#db4437']").attr('fill',"#D41647"); $("rect[fill='#db4437']").attr('fill',"#D41647"); $("path[fill='#a52714']").attr('fill', '#A21135'); $("rect[fill='#a52714']").attr('fill', '#D41647'); $("path[fill='#7c1d0f']").attr('fill', '#A21135'); // Change Old Yellow to new Yellow $("text[fill='#f2a600']").attr('fill',"#FCB813"); $("rect[fill='#f2a600']").attr('fill',"#FCB813"); $("path[fill='#ee8100']").attr('fill', '#C98e03'); $("rect[fill='#ee8100']").attr('fill', '#FCB813'); $("path[fill='#b36100']").attr('fill', '#C98e03'); } ``` ...and then after you draw the chart, add a "ready" and these other event listeners to run changeColors any time anything happens. ``` chart.draw(data, options); google.visualization.events.addListener(chart, 'ready', changeColors); google.visualization.events.addListener(chart, 'onmouseover', changeColors); google.visualization.events.addListener(chart, 'onmouseout', changeColors); google.visualization.events.addListener(chart, 'select', changeColors); google.visualization.events.addListener(chart, 'error', changeColors); google.visualization.events.addListener(chart, 'click', changeColors); google.visualization.events.addListener(chart, 'animationfinish', changeColors); ``` Issues: ------- There seems to be some switching of the colors in certain situations, as you mouse around on it.
35,165,271
This should be simple. How can I assign my own colors to the bars in [Google Gantt Charts](https://developers.google.com/chart/interactive/docs/gallery/ganttchart)? The gantt is ignoring my colors and automatically assigning blue, red and yellow colors (in that order) to the bars and I can't seem to figure out the problem. Can someone please point out if I am missing something here or is it not supported at all at this time? Here is what I have: ``` function drawChart() { var data = new google.visualization.DataTable(); data.addColumn({ type: 'string', id: 'task_id' }, 'Task ID'); data.addColumn({ type: 'string', id: 'task_name' }, 'Task Name'); data.addColumn({ type: 'string', id: 'resource' }, 'Resource'); data.addColumn({ type: 'date', id: 'start_date' }, 'Start Date'); data.addColumn({ type: 'date', id: 'end_date' }, 'End Date'); data.addColumn({ type: 'number', id: 'duration' }, 'Duration'); data.addColumn({ type: 'number', id: 'percent_complete' }, 'Percent Complete'); data.addColumn({ type: 'string', id: 'dependencies' }, 'Dependencies'); data.addRows([ ['Research', 'Find sources', null, new Date(2015, 0, 1), new Date(2015, 0, 5), null, 100, null], ['Write', 'Write paper', 'write', null, new Date(2015, 0, 9), daysToMilliseconds(3), 25, 'Research,Outline'], ['Cite', 'Create bibliography', 'write', null, new Date(2015, 0, 7), daysToMilliseconds(1), 20, 'Research'], ['Complete', 'Hand in paper', 'complete', null, new Date(2015, 0, 10), daysToMilliseconds(1), 0, 'Cite,Write'], ['Outline', 'Outline paper', 'write', null, new Date(2015, 0, 6), daysToMilliseconds(1), 100, 'Research'] ]); var colors = []; var colorMap = { write: '#e63b6f', complete: '#19c362' } for (var i = 0; i < data.getNumberOfRows(); i++) { colors.push(colorMap[data.getValue(i, 2)]); } var options = { height: 275, gantt: { criticalPathEnabled: true, criticalPathStyle: { stroke: '#e64a19', strokeWidth: 5 } }, colors: colors }; var chart = new google.visualization.Gantt(document.getElementById('chart_div')); chart.draw(data, options); } ```
2016/02/02
[ "https://Stackoverflow.com/questions/35165271", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3207927/" ]
There is an option`gantt.palette` which takes an array of objects. ``` var options = { gantt: { palette: [ { "color": "#cccccc", "dark": "#333333", "light": "#eeeeee" } ] } } ``` By providing your own array of objects, you can override the default palette. **This is the default palette that the chart uses:** ``` [ { "color": "#5e97f6", "dark": "#2a56c6", "light": "#c6dafc" }, { "color": "#db4437", "dark": "#a52714", "light": "#f4c7c3" }, { "color": "#f2a600", "dark": "#ee8100", "light": "#fce8b2" }, { "color": "#0f9d58", "dark": "#0b8043", "light": "#b7e1cd" }, { "color": "#ab47bc", "dark": "#6a1b9a", "light": "#e1bee7" }, { "color": "#00acc1", "dark": "#00838f", "light": "#b2ebf2" }, { "color": "#ff7043", "dark": "#e64a19", "light": "#ffccbc" }, { "color": "#9e9d24", "dark": "#827717", "light": "#f0f4c3" }, { "color": "#5c6bc0", "dark": "#3949ab", "light": "#c5cae9" }, { "color": "#f06292", "dark": "#e91e63", "light": "#f8bbd0" }, { "color": "#00796b", "dark": "#004d40", "light": "#b2dfdb" }, { "color": "#c2185b", "dark": "#880e4f", "light": "#f48fb1" } ] ```
I figured out a hacky way of doing it. You basically have to listen to every single event fired by the chart and override them with a function that colors the chart.
35,165,271
This should be simple. How can I assign my own colors to the bars in [Google Gantt Charts](https://developers.google.com/chart/interactive/docs/gallery/ganttchart)? The gantt is ignoring my colors and automatically assigning blue, red and yellow colors (in that order) to the bars and I can't seem to figure out the problem. Can someone please point out if I am missing something here or is it not supported at all at this time? Here is what I have: ``` function drawChart() { var data = new google.visualization.DataTable(); data.addColumn({ type: 'string', id: 'task_id' }, 'Task ID'); data.addColumn({ type: 'string', id: 'task_name' }, 'Task Name'); data.addColumn({ type: 'string', id: 'resource' }, 'Resource'); data.addColumn({ type: 'date', id: 'start_date' }, 'Start Date'); data.addColumn({ type: 'date', id: 'end_date' }, 'End Date'); data.addColumn({ type: 'number', id: 'duration' }, 'Duration'); data.addColumn({ type: 'number', id: 'percent_complete' }, 'Percent Complete'); data.addColumn({ type: 'string', id: 'dependencies' }, 'Dependencies'); data.addRows([ ['Research', 'Find sources', null, new Date(2015, 0, 1), new Date(2015, 0, 5), null, 100, null], ['Write', 'Write paper', 'write', null, new Date(2015, 0, 9), daysToMilliseconds(3), 25, 'Research,Outline'], ['Cite', 'Create bibliography', 'write', null, new Date(2015, 0, 7), daysToMilliseconds(1), 20, 'Research'], ['Complete', 'Hand in paper', 'complete', null, new Date(2015, 0, 10), daysToMilliseconds(1), 0, 'Cite,Write'], ['Outline', 'Outline paper', 'write', null, new Date(2015, 0, 6), daysToMilliseconds(1), 100, 'Research'] ]); var colors = []; var colorMap = { write: '#e63b6f', complete: '#19c362' } for (var i = 0; i < data.getNumberOfRows(); i++) { colors.push(colorMap[data.getValue(i, 2)]); } var options = { height: 275, gantt: { criticalPathEnabled: true, criticalPathStyle: { stroke: '#e64a19', strokeWidth: 5 } }, colors: colors }; var chart = new google.visualization.Gantt(document.getElementById('chart_div')); chart.draw(data, options); } ```
2016/02/02
[ "https://Stackoverflow.com/questions/35165271", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3207927/" ]
There is an option`gantt.palette` which takes an array of objects. ``` var options = { gantt: { palette: [ { "color": "#cccccc", "dark": "#333333", "light": "#eeeeee" } ] } } ``` By providing your own array of objects, you can override the default palette. **This is the default palette that the chart uses:** ``` [ { "color": "#5e97f6", "dark": "#2a56c6", "light": "#c6dafc" }, { "color": "#db4437", "dark": "#a52714", "light": "#f4c7c3" }, { "color": "#f2a600", "dark": "#ee8100", "light": "#fce8b2" }, { "color": "#0f9d58", "dark": "#0b8043", "light": "#b7e1cd" }, { "color": "#ab47bc", "dark": "#6a1b9a", "light": "#e1bee7" }, { "color": "#00acc1", "dark": "#00838f", "light": "#b2ebf2" }, { "color": "#ff7043", "dark": "#e64a19", "light": "#ffccbc" }, { "color": "#9e9d24", "dark": "#827717", "light": "#f0f4c3" }, { "color": "#5c6bc0", "dark": "#3949ab", "light": "#c5cae9" }, { "color": "#f06292", "dark": "#e91e63", "light": "#f8bbd0" }, { "color": "#00796b", "dark": "#004d40", "light": "#b2dfdb" }, { "color": "#c2185b", "dark": "#880e4f", "light": "#f48fb1" } ] ```
This is pretty old, but just in case anyone needs to do this... Not a super elegant solution, but it works. ``` function changeColors() { $("text[fill='#5e97f6']").attr('fill',"#0099D8"); // Left Text $("rect[fill='#5e97f6']").attr('fill',"#0099D8"); // Full bar $("path[fill='#2a56c6']").attr('fill', '#006B99'); // Percentage completed $("rect[fill='#2a56c6']").attr('fill', '#0099D8'); // Hover Full Bar $("path[fill='#204195']").attr('fill', '#006B99'); // Hover Percentage // Change Old red to new Red $("text[fill='#db4437']").attr('fill',"#D41647"); $("rect[fill='#db4437']").attr('fill',"#D41647"); $("path[fill='#a52714']").attr('fill', '#A21135'); $("rect[fill='#a52714']").attr('fill', '#D41647'); $("path[fill='#7c1d0f']").attr('fill', '#A21135'); // Change Old Yellow to new Yellow $("text[fill='#f2a600']").attr('fill',"#FCB813"); $("rect[fill='#f2a600']").attr('fill',"#FCB813"); $("path[fill='#ee8100']").attr('fill', '#C98e03'); $("rect[fill='#ee8100']").attr('fill', '#FCB813'); $("path[fill='#b36100']").attr('fill', '#C98e03'); } ``` ...and then after you draw the chart, add a "ready" and these other event listeners to run changeColors any time anything happens. ``` chart.draw(data, options); google.visualization.events.addListener(chart, 'ready', changeColors); google.visualization.events.addListener(chart, 'onmouseover', changeColors); google.visualization.events.addListener(chart, 'onmouseout', changeColors); google.visualization.events.addListener(chart, 'select', changeColors); google.visualization.events.addListener(chart, 'error', changeColors); google.visualization.events.addListener(chart, 'click', changeColors); google.visualization.events.addListener(chart, 'animationfinish', changeColors); ``` Issues: ------- There seems to be some switching of the colors in certain situations, as you mouse around on it.
50,555,587
``` sudo php bin/console doctrine:database:create In AbstractMySQLDriver.php line 125: An exception occurred in driver: could not find driver In PDOConnection.php line 50: could not find driver In PDOConnection.php line 46: could not find driver doctrine:database:create [--shard SHARD] [--connection [CONNECTION]] [--if-not-exists] [-h|--help] [-q|--quiet] [-v|vv|vvv|--verbose] [-V|--version] [--ansi] [--no-ansi] [-n|--no-interaction] [-e|--env ENV] [--no-debug] [--] <command> ``` please help .
2018/05/27
[ "https://Stackoverflow.com/questions/50555587", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9541581/" ]
You have to enable [PDO](http://php.net/manual/en/book.pdo.php) extension. If you are on a Windows machine look in your `php.ini` file and uncomment `extension=php_pdo_mysql.dll`. The path to your `php.ini` file can be found by looking at your `phpinfo()`. Debian/Ubuntu PHP 5 `sudo apt-get install php5-mysql` PHP 7 `sudo apt-get install php7.0-mysql` You will then need to ensure the module is enabled: ``` sudo phpenmod pdo_mysql ``` Then restart Apache: ``` sudo service apache2 restart ```
Check if your php.ini file has the lines : ``` extension=pdo_mysql extension=pdo_pgsql extension=mysqli ```
15,437,866
How can I best check if a string input would be a valid java variable for coding? I'm sure I'm not the first one who is willing to do this. But maybe I'm missing the right keyword to find something useful. Best would probably be a RegEx, which checks that: * starts with a letter * can then contain digits, letters * can contain some special characters, like '\_' (which?) * may not contain a whitespace separator
2013/03/15
[ "https://Stackoverflow.com/questions/15437866", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1194415/" ]
``` public static boolean isValidJavaIdentifier(String s) { if (s.isEmpty()) { return false; } if (!Character.isJavaIdentifierStart(s.charAt(0))) { return false; } for (int i = 1; i < s.length(); i++) { if (!Character.isJavaIdentifierPart(s.charAt(i))) { return false; } } return true; } ``` EDIT: and, as @Joey indicates, you should also filter out keywords and reserved words.
Java 6+ ------- Use ```java import javax.lang.model.SourceVersion; boolean isValidVariableName(CharSequence name) { return SourceVersion.isIdentifier(name) && !SourceVersion.isKeyword(name); } ``` if you need to check whether a string is a valid Java variable name in the **latest** version of Java or ```java import javax.lang.model.SourceVersion; boolean isValidVariableNameInVersion(CharSequence name, SourceVersion version) { return SourceVersion.isIdentifier(name) && !SourceVersion.isKeyword(name, version); } ``` if you need to check whether a string is a valid Java variable name in a **specific** Java version. For example, [underscore became a reserved keyword starting from Java 9](https://bugs.openjdk.java.net/browse/JDK-8065599), so `isValidVariableNameInVersion("_", SourceVersion.RELEASE_9)` returns `false` while `isValidVariableNameInVersion("_", SourceVersion.RELEASE_8)` returns `true`. **How it works** [`SourceVersion.isIdentifier(CharSequence name)`](https://docs.oracle.com/javase/8/docs/api/javax/lang/model/SourceVersion.html#isIdentifier-java.lang.CharSequence-) checks whether or not name is a syntactically valid identifier (simple name) or keyword in the latest source version. [`!SourceVersion.isKeyword(name)`](https://docs.oracle.com/javase/8/docs/api/javax/lang/model/SourceVersion.html#isKeyword-java.lang.CharSequence-) returns false for keywords. As a result, `SourceVersion.isIdentifier(name) && !SourceVersion.isKeyword(name)` returns true for valid indetifiers and only for them. The same approach is used in the built-in method [`SourceVersion.isName(CharSequence name, SourceVersion version)`](https://docs.oracle.com/javase/8/docs/api/javax/lang/model/SourceVersion.html#isName-java.lang.CharSequence-) that checks whether name is a syntactically valid **qualified** name, which means that it will return `true` for strings like "apple.color": ```java public static boolean isName(CharSequence name, SourceVersion version) { String id = name.toString(); for(String s : id.split("\\.", -1)) { if (!isIdentifier(s) || isKeyword(s, version)) return false; } return true; } ``` **Test** ```java import org.junit.jupiter.api.Test; import javax.lang.model.SourceVersion; import static org.assertj.core.api.Assertions.assertThat; public class ValidVariableNameTest { boolean isValidVariableName(CharSequence name) { return isValidVariableNameInVersion(name, SourceVersion.RELEASE_8); } boolean isValidVariableNameInVersion(CharSequence name, SourceVersion version) { return SourceVersion.isIdentifier(name) && !SourceVersion.isKeyword(name, version); } @Test void variableNamesCanBeginWithLetters() { assertThat(isValidVariableName("test")).isTrue(); assertThat(isValidVariableName("e2")).isTrue(); assertThat(isValidVariableName("w")).isTrue(); assertThat(isValidVariableName("привет")).isTrue(); } @Test void variableNamesCanBeginWithDollarSign() { assertThat(isValidVariableName("$test")).isTrue(); assertThat(isValidVariableName("$e2")).isTrue(); assertThat(isValidVariableName("$w")).isTrue(); assertThat(isValidVariableName("$привет")).isTrue(); assertThat(isValidVariableName("$")).isTrue(); assertThat(isValidVariableName("$55")).isTrue(); } @Test void variableNamesCanBeginWithUnderscore() { assertThat(isValidVariableName("_test")).isTrue(); assertThat(isValidVariableName("_e2")).isTrue(); assertThat(isValidVariableName("_w")).isTrue(); assertThat(isValidVariableName("_привет")).isTrue(); assertThat(isValidVariableName("_55")).isTrue(); } @Test void variableNamesCannotContainCharactersThatAreNotLettersOrDigits() { assertThat(isValidVariableName("apple.color")).isFalse(); assertThat(isValidVariableName("my var")).isFalse(); assertThat(isValidVariableName(" ")).isFalse(); assertThat(isValidVariableName("apple%color")).isFalse(); assertThat(isValidVariableName("apple,color")).isFalse(); assertThat(isValidVariableName(",applecolor")).isFalse(); } @Test void variableNamesCannotStartWithDigit() { assertThat(isValidVariableName("2e")).isFalse(); assertThat(isValidVariableName("5")).isFalse(); assertThat(isValidVariableName("123test")).isFalse(); } @Test void differentSourceVersionsAreHandledCorrectly() { assertThat(isValidVariableNameInVersion("_", SourceVersion.RELEASE_9)).isFalse(); assertThat(isValidVariableNameInVersion("_", SourceVersion.RELEASE_8)).isTrue(); assertThat(isValidVariableNameInVersion("enum", SourceVersion.RELEASE_9)).isFalse(); assertThat(isValidVariableNameInVersion("enum", SourceVersion.RELEASE_4)).isTrue(); } @Test void keywordsCannotBeUsedAsVariableNames() { assertThat(isValidVariableName("strictfp")).isFalse(); assertThat(isValidVariableName("assert")).isFalse(); assertThat(isValidVariableName("enum")).isFalse(); // Modifiers assertThat(isValidVariableName("public")).isFalse(); assertThat(isValidVariableName("protected")).isFalse(); assertThat(isValidVariableName("private")).isFalse(); assertThat(isValidVariableName("abstract")).isFalse(); assertThat(isValidVariableName("static")).isFalse(); assertThat(isValidVariableName("final")).isFalse(); assertThat(isValidVariableName("transient")).isFalse(); assertThat(isValidVariableName("volatile")).isFalse(); assertThat(isValidVariableName("synchronized")).isFalse(); assertThat(isValidVariableName("native")).isFalse(); // Declarations assertThat(isValidVariableName("class")).isFalse(); assertThat(isValidVariableName("interface")).isFalse(); assertThat(isValidVariableName("extends")).isFalse(); assertThat(isValidVariableName("package")).isFalse(); assertThat(isValidVariableName("throws")).isFalse(); assertThat(isValidVariableName("implements")).isFalse(); // Primitive types and void assertThat(isValidVariableName("boolean")).isFalse(); assertThat(isValidVariableName("byte")).isFalse(); assertThat(isValidVariableName("char")).isFalse(); assertThat(isValidVariableName("short")).isFalse(); assertThat(isValidVariableName("int")).isFalse(); assertThat(isValidVariableName("long")).isFalse(); assertThat(isValidVariableName("float")).isFalse(); assertThat(isValidVariableName("double")).isFalse(); assertThat(isValidVariableName("void")).isFalse(); // Control flow assertThat(isValidVariableName("if")).isFalse(); assertThat(isValidVariableName("else")).isFalse(); assertThat(isValidVariableName("try")).isFalse(); assertThat(isValidVariableName("catch")).isFalse(); assertThat(isValidVariableName("finally")).isFalse(); assertThat(isValidVariableName("do")).isFalse(); assertThat(isValidVariableName("while")).isFalse(); assertThat(isValidVariableName("for")).isFalse(); assertThat(isValidVariableName("continue")).isFalse(); assertThat(isValidVariableName("switch")).isFalse(); assertThat(isValidVariableName("case")).isFalse(); assertThat(isValidVariableName("default")).isFalse(); assertThat(isValidVariableName("break")).isFalse(); assertThat(isValidVariableName("throw")).isFalse(); assertThat(isValidVariableName("return")).isFalse(); // Other keywords assertThat(isValidVariableName("this")).isFalse(); assertThat(isValidVariableName("new")).isFalse(); assertThat(isValidVariableName("super")).isFalse(); assertThat(isValidVariableName("import")).isFalse(); assertThat(isValidVariableName("instanceof")).isFalse(); // Reserved keywords assertThat(isValidVariableName("goto")).isFalse(); assertThat(isValidVariableName("const")).isFalse(); } @Test void literalsCannotBeUsedAsVariableNames() { assertThat(isValidVariableName("null")).isFalse(); assertThat(isValidVariableName("true")).isFalse(); assertThat(isValidVariableName("false")).isFalse(); } } ```
15,678,117
I am trying to use protobuf format in ServiceStack Webservices ( following the example at [ServiceStack: REST with ProtoBuf by Steven Hollidge](http://stevenhollidge.blogspot.in/2012/04/servicestack-rest-with-protobuf.html). I have added a Winform application to consume the webservice. The codes are given below. **HelloService.cs** ``` using System.Runtime.Serialization; using ProtoBuf; using ServiceStack.Demo.Rest; using ServiceStack.ServiceHost; using ServiceStack.ServiceInterface; namespace ServiceStack.Demo.WebService { [DataContract] public class Hello { [DataMember(Order = 1)] public string Name { get; set; } } [DataContract] public class HelloResponse { [DataMember(Order = 1)] public string Result { get; set; } } public class HelloService : RestServiceBase<Hello> { public override object OnGet(Hello request) { return new HelloResponse { Result = "Hello, " + request.Name }; } } } ``` **Global.asax.cs** ``` using System; using System.Web; using Funq; using ServiceStack.Demo.Rest; using ServiceStack.Demo.WebService; using ServiceStack.WebHost.Endpoints; namespace ServiceStack.Demo { public class AppHost : AppHostBase { public AppHost() : base("ServiceStack makes services easy!", typeof (AppHost).Assembly) { ServiceStack.Plugins.ProtoBuf.AppStart.Start(); } public override void Configure(Container container) { Routes .Add<Hello>("/hello") .Add<Hello>("/hello/{Name}"); } } public class Global : HttpApplication { protected void Application_Start(object sender, EventArgs e) { new AppHost().Init(); } } } ``` **Form1.cs** ``` using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using ServiceStack.ServiceClient; using ProtoBuf; using ServiceStack.Plugins.ProtoBuf; using System.Runtime.Serialization; using ServiceStack.ServiceClient.Web; namespace client { public partial class Form1 : Form { private ServiceClientBase _client; private const string Url = "http://localhost/servicestack.demo/servicestack/hello?format=x-protobuf"; public Form1() { InitializeComponent(); } private void Button1Click(object sender, EventArgs e) { this._client = new ProtoBufServiceClient(Url); var response = _client.Send<HelloResponse>(new Hello {Name = "ProtoBuf"}); label1.Text = response.Result; } public class Hello { public string Name { get; set; } } public class HelloResponse { public string Result { get; set; } } } } ``` I am getting `System.InvalidOperationException: Type is not expected, and no contract can be inferred: client.Form1+Hello` What am I doing wrong? Please suggest.....
2013/03/28
[ "https://Stackoverflow.com/questions/15678117", "https://Stackoverflow.com", "https://Stackoverflow.com/users/801562/" ]
It looks like you have your `Hello` class and your `HelloResponse` class declared twice. Once in **HelloService.cs** and again as inner classes in **Form.cs**. Removing the duplicates from your **Form.cs** file should allow your `ProtoBufServiceClient` to reference the correct classes/types.
Put your POCO classes in the same namespace, that should do it.
15,678,117
I am trying to use protobuf format in ServiceStack Webservices ( following the example at [ServiceStack: REST with ProtoBuf by Steven Hollidge](http://stevenhollidge.blogspot.in/2012/04/servicestack-rest-with-protobuf.html). I have added a Winform application to consume the webservice. The codes are given below. **HelloService.cs** ``` using System.Runtime.Serialization; using ProtoBuf; using ServiceStack.Demo.Rest; using ServiceStack.ServiceHost; using ServiceStack.ServiceInterface; namespace ServiceStack.Demo.WebService { [DataContract] public class Hello { [DataMember(Order = 1)] public string Name { get; set; } } [DataContract] public class HelloResponse { [DataMember(Order = 1)] public string Result { get; set; } } public class HelloService : RestServiceBase<Hello> { public override object OnGet(Hello request) { return new HelloResponse { Result = "Hello, " + request.Name }; } } } ``` **Global.asax.cs** ``` using System; using System.Web; using Funq; using ServiceStack.Demo.Rest; using ServiceStack.Demo.WebService; using ServiceStack.WebHost.Endpoints; namespace ServiceStack.Demo { public class AppHost : AppHostBase { public AppHost() : base("ServiceStack makes services easy!", typeof (AppHost).Assembly) { ServiceStack.Plugins.ProtoBuf.AppStart.Start(); } public override void Configure(Container container) { Routes .Add<Hello>("/hello") .Add<Hello>("/hello/{Name}"); } } public class Global : HttpApplication { protected void Application_Start(object sender, EventArgs e) { new AppHost().Init(); } } } ``` **Form1.cs** ``` using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using ServiceStack.ServiceClient; using ProtoBuf; using ServiceStack.Plugins.ProtoBuf; using System.Runtime.Serialization; using ServiceStack.ServiceClient.Web; namespace client { public partial class Form1 : Form { private ServiceClientBase _client; private const string Url = "http://localhost/servicestack.demo/servicestack/hello?format=x-protobuf"; public Form1() { InitializeComponent(); } private void Button1Click(object sender, EventArgs e) { this._client = new ProtoBufServiceClient(Url); var response = _client.Send<HelloResponse>(new Hello {Name = "ProtoBuf"}); label1.Text = response.Result; } public class Hello { public string Name { get; set; } } public class HelloResponse { public string Result { get; set; } } } } ``` I am getting `System.InvalidOperationException: Type is not expected, and no contract can be inferred: client.Form1+Hello` What am I doing wrong? Please suggest.....
2013/03/28
[ "https://Stackoverflow.com/questions/15678117", "https://Stackoverflow.com", "https://Stackoverflow.com/users/801562/" ]
I have updated the Form1.cs to the following and now it is working fine( refer to <http://upjnv.blogspot.in/> ``` using System; using System.Windows.Forms; using ServiceStack.Plugins.ProtoBuf; using System.Runtime.Serialization; using ServiceStack.ServiceClient.Web; namespace client { public partial class Form1 : Form { private ServiceClientBase _client; private const string Url = "http://localhost/servicestack.demo/servicestack/"; public Form1() { InitializeComponent(); } private void Button1Click(object sender, EventArgs e) { this._client = new ProtoBufServiceClient(Url); var response = _client.Send<HelloResponse>("GET","/hello",new Hello {Name = "ProtoBuf"}); label1.Text = response.Result; } } [DataContract] public class Hello { [DataMember(Order = 1)] public string Name { get; set; } } [DataContract] public class HelloResponse { [DataMember(Order = 1)] public string Result { get; set; } } } ```
Put your POCO classes in the same namespace, that should do it.
15,678,117
I am trying to use protobuf format in ServiceStack Webservices ( following the example at [ServiceStack: REST with ProtoBuf by Steven Hollidge](http://stevenhollidge.blogspot.in/2012/04/servicestack-rest-with-protobuf.html). I have added a Winform application to consume the webservice. The codes are given below. **HelloService.cs** ``` using System.Runtime.Serialization; using ProtoBuf; using ServiceStack.Demo.Rest; using ServiceStack.ServiceHost; using ServiceStack.ServiceInterface; namespace ServiceStack.Demo.WebService { [DataContract] public class Hello { [DataMember(Order = 1)] public string Name { get; set; } } [DataContract] public class HelloResponse { [DataMember(Order = 1)] public string Result { get; set; } } public class HelloService : RestServiceBase<Hello> { public override object OnGet(Hello request) { return new HelloResponse { Result = "Hello, " + request.Name }; } } } ``` **Global.asax.cs** ``` using System; using System.Web; using Funq; using ServiceStack.Demo.Rest; using ServiceStack.Demo.WebService; using ServiceStack.WebHost.Endpoints; namespace ServiceStack.Demo { public class AppHost : AppHostBase { public AppHost() : base("ServiceStack makes services easy!", typeof (AppHost).Assembly) { ServiceStack.Plugins.ProtoBuf.AppStart.Start(); } public override void Configure(Container container) { Routes .Add<Hello>("/hello") .Add<Hello>("/hello/{Name}"); } } public class Global : HttpApplication { protected void Application_Start(object sender, EventArgs e) { new AppHost().Init(); } } } ``` **Form1.cs** ``` using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using ServiceStack.ServiceClient; using ProtoBuf; using ServiceStack.Plugins.ProtoBuf; using System.Runtime.Serialization; using ServiceStack.ServiceClient.Web; namespace client { public partial class Form1 : Form { private ServiceClientBase _client; private const string Url = "http://localhost/servicestack.demo/servicestack/hello?format=x-protobuf"; public Form1() { InitializeComponent(); } private void Button1Click(object sender, EventArgs e) { this._client = new ProtoBufServiceClient(Url); var response = _client.Send<HelloResponse>(new Hello {Name = "ProtoBuf"}); label1.Text = response.Result; } public class Hello { public string Name { get; set; } } public class HelloResponse { public string Result { get; set; } } } } ``` I am getting `System.InvalidOperationException: Type is not expected, and no contract can be inferred: client.Form1+Hello` What am I doing wrong? Please suggest.....
2013/03/28
[ "https://Stackoverflow.com/questions/15678117", "https://Stackoverflow.com", "https://Stackoverflow.com/users/801562/" ]
It looks like you have your `Hello` class and your `HelloResponse` class declared twice. Once in **HelloService.cs** and again as inner classes in **Form.cs**. Removing the duplicates from your **Form.cs** file should allow your `ProtoBufServiceClient` to reference the correct classes/types.
I have updated the Form1.cs to the following and now it is working fine( refer to <http://upjnv.blogspot.in/> ``` using System; using System.Windows.Forms; using ServiceStack.Plugins.ProtoBuf; using System.Runtime.Serialization; using ServiceStack.ServiceClient.Web; namespace client { public partial class Form1 : Form { private ServiceClientBase _client; private const string Url = "http://localhost/servicestack.demo/servicestack/"; public Form1() { InitializeComponent(); } private void Button1Click(object sender, EventArgs e) { this._client = new ProtoBufServiceClient(Url); var response = _client.Send<HelloResponse>("GET","/hello",new Hello {Name = "ProtoBuf"}); label1.Text = response.Result; } } [DataContract] public class Hello { [DataMember(Order = 1)] public string Name { get; set; } } [DataContract] public class HelloResponse { [DataMember(Order = 1)] public string Result { get; set; } } } ```
62,400,506
I'm learning to use FastAPI, and I'm getting this error over and over again while implementing a simple API and I've not being able to figure out why ``` "detail": "There was an error parsing the body" ``` This happends me on this two endpoints: Full code: [Code Repository](https://github.com/rodrigoarenas456/Backend_Python/tree/develop/store) snippet: ``` app_v1 = FastAPI(root_path='/v1') # JWT Token request @app_v1.post('/token') async def login_access_token(form_data: OAuth2PasswordRequestForm = Depends()): jwt_user_dict = {"username": form_data.username, "password": form_data.password} jwt_user = JWTUser(**jwt_user_dict) user = authenticate_user(jwt_user) if user is None: return HTTP_401_UNAUTHORIZED jwt_token = create_jwt_token(user) return {"token": jwt_token} ``` request: [![enter image description here](https://i.stack.imgur.com/n3DOn.png)](https://i.stack.imgur.com/n3DOn.png) [![enter image description here](https://i.stack.imgur.com/kPhRt.png)](https://i.stack.imgur.com/kPhRt.png) ``` @app_v1.post("/user/photo") async def update_photo(response: Response, profile_photo: bytes = File(...)): response.headers['x-file-size'] = str(len(profile_photo)) response.set_cookie(key='cookie-api', value="test") return {"profile photo size": len(profile_photo)} ``` request: [![enter image description here](https://i.stack.imgur.com/3TC8V.png)](https://i.stack.imgur.com/3TC8V.png)
2020/06/16
[ "https://Stackoverflow.com/questions/62400506", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5495134/" ]
I acomplished to figure out, it was because when FastAPI was installed, it didn't install python-multipart, so with this package missing everything that needs multipart falls After installing it works fine Thanks
The problem with the first request is that you should be sending `username` and `password` in a `form-data`. Instead of `x-www-form-urlencoded`, use `form-data` and you should be fine. [![enter image description here](https://i.stack.imgur.com/DsGHB.png)](https://i.stack.imgur.com/DsGHB.png) I can't see the problem with the second one. Can you try using Swagger interface and see if the same happens there?
266,952
If I know what a field will be initialized to, should I initialize it in the field, constructor, or receive it as a parameter? I am asking about best practices. All three options effectively provide the same result. I am not considering what is happening behind the scenes, because I think it would be insignificant. This is a general question for curiosity's sake. I do not have a specific problem with this at the moment, although I have in the past. I will use an ArrayList in the following example, because it is a case where you know what it will be initialized to, and if you end up actually wanting to initialize it to another existing ArrayList, there is no harm by preinitializing it. Or is there? For example, where should I initialize an ArrayList? Initialized in Field: ``` import java.util.ArrayList; public class Initializer { private ArrayList<String> arrayList = new ArrayList<String>(); public void addString(String string) { arrayList.add(string); } } ``` Initialized in Constructor: ``` import java.util.ArrayList; public class Initializer { private ArrayList<String> arrayList; public Initializer() { arrayList = new ArrayList<String>(); } public void addString(String string) { arrayList.add(string); } } ``` Initialized as Parameter: ``` import java.util.ArrayList; public class Initializer { private ArrayList<String> arrayList; public Initializer(ArrayList arrayList) { this.arrayList = arrayList; } public void addString(String string) { arrayList.add(string); } } ```
2014/12/19
[ "https://softwareengineering.stackexchange.com/questions/266952", "https://softwareengineering.stackexchange.com", "https://softwareengineering.stackexchange.com/users/112298/" ]
Initializing as a parameter breaks encapsulation in that the caller can then do with the passed in list what it wants (clear at odd times). ``` ArrayList<String> list = new ArrayList<String>(); Initializer init = new Initializer(list); //do various thing list.clear(); //now the list in init is also empty while init may still expect it to be filled ``` For the other 2 options it depends on what you want to initialize with: For example a class that needs a thread-safe queue could use one of several implementations (linked list, circular buffer, etc.) The constructor can decide which one to use based on parameters or which constructor was called and even pass parameters to the constructor of the object. ``` public Initializer(boolean useLinked) { if(useLinked){ this.arrayList = new LinkedList<String>(); else this.arrayList = new ArrayList<String>(); } ``` If the implementation will always be the same then just initialize in the field or initializer block and mark it final. ``` public class Initializer { private final ArrayList<String> arrayList = new ArrayList<String>(); } ``` This prevents other methods from overwriting it accidentally.
> > If I know what a field will be initialized to > > > If you know that, then chances are very high that either your class won't be very reusable or you make the mistake of assuming that you will know how your class will be used now and in future - while actually missing some possible usecases. I can explain this in more detail if you provide more information about what the class is to do semantically. Usually it is best to go with Initialization by parameter (assuming that the argument will change and not always be an empty list, as stated above). This design is also called `depedency injection`. It has quite some advantages. E.g. one of them is a much better testability. You should also use Interfaces instead of accepting only concrete types. So you should go for: ``` //(...) private List<String> someList ; public Initializer(List someList ) { this.someList = someList ; } ``` And someone can then create a new Initializer by `new Initializer(new ArrayList())` OR he can do something like `new Initializer(new CopyOnWriteArrayList())` as this will be much more performant in some cases. The user of the class can decide best, what kind of list he wants to use. And you, as the class creater, don't care if it is an ArrayList or CopyOnWriteArrayList right? You just want to have a `List`-thing where you can add items in the same way.
60,108,515
I stuck with error = Cannot find a differ supporting object '[object Object]' of type 'object'. NgFor only supports binding to Iterables such as Arrays. Actually, I want to make Notification list and I don't know what mistake I made. I stuck with error = Cannot find a differ supporting object '[object Object]' of type 'object'. NgFor only supports binding to Iterables such as Arrays. Actually, I want to make Notification list and I don't know what mistake I made. HTML ``` <ng-container *ngIf="notificationModal"> <div class="side-panel__notif-container"> <div class="side-panel__notify-header"> <span class="side-panel__usr-profile-close" (click)="clkNotifcationPnl()"> <fa-icon [icon]="faClose"></fa-icon> </span> <span class="side-panel__usr-noti-hdr">Notifications</span><br> </div> <div class="side-panel__notify-body"> <div class="side-panel__user-notif-cont"> <div class="drop-content"> <ul class="mt-2 list-group notify-contents"> <li *ngFor="let items of notify"> <div class="col-md-3 col-sm-3 col-xs-3"> <div class="notify-img"> <span [ngStyle]="{'background-image': loadProfilePic()}" class="side-panel__user-notif-img fa"></span> </div> </div> <div class="col-md-9 col-sm-9 col-xs-9 pd-l0">{{items.notifyFromName}} <p>{{items.notifyMessage}}</p> <p class="time">{{items.notifyDate}}</p> </div> </li> </ul> </div> </div> </div> </div> </ng-container> ``` **Component** ``` public onClickUserNotif() { this.headerService.isLoading = true; return this.commonService.getNotificationList().subscribe((res) => { if (res['status'].code === 0) { this.headerService.isLoading = false; let notify = res['notification'] if(notify.length > 0) { this.notificationModal = true; console.log(notify); } } }); } ``` And this value come out when I `console.log(notify)` [![enter image description here](https://i.stack.imgur.com/M9m0h.png)](https://i.stack.imgur.com/M9m0h.png)
2020/02/07
[ "https://Stackoverflow.com/questions/60108515", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12022853/" ]
```js let notify = res['notification'] ``` ### That creates block level scope, the local scope will never reflect this value. Angular binds to local scope, not block level. So you need to bind a local variable outside of that function. ```js class ComponentName { notify: any[]; // ... onClickUserNotif() { // ... this.notify = res['notification']; } } ``` Edit: We know the following. ====================== * prior to my suggestion you didn't have a locally scoped `notify` * angular wont throw an error on a null value * creating the locally scoped `notify` didn't solve the issue. Then only solutions/issues that I can see is either: ==================================================== * You're looking at `HTML` that doesn't correspond to the `.ts` file you're working with, or * `res['notification']` is being mutated in your `commonService` and `notify` is receiving that change. ### Sidenote: * In your `ngOnInit` you're subscribing to the *same* service that you subscribe to in your other function. I don't see why you're resubscribing. * You use `takeWhile()` to try and mitigate active subscriptions, however you're only influencing the outer subscription. Not the inner subscription.
I'd advise you to play on a safe side, make sure you have this array at all times: ``` class ComponentName { notify: any[] = []; // assign an empty array // ... onClickUserNotif() { // ... this.notify = res['notification']; } } // In the template, use the ? to indicate that the might be no properties yet: <div class="col-md-9 col-sm-9 col-xs-9 pd-l0">{{items?.notifyFromName}} <p>{{items?.notifyMessage}}</p> <p class="time">{{items?.notifyDate}}</p> </div> ```
53,447,598
I have a dictionary created from JSON. I would like to access items in the dictionairy through arrays containing their keys. Visualised JSON: ``` { "name": "Chiel", "industry": { "IndustryName": "Computer Science", "company": { "companyName": "Apple", "address": { "streetName": "Apple Park Way", "streetNumber": "1" } } }, "hobby": { "hobbyName": "Music production", "genre": { "genreName": "Deep house", "genreYearOrigin": "1980" } } } ``` See the following code example: ``` #create dict jsonData = '{"name":"Chiel","industry":{"IndustryName":"Computer Science","company":{"companyName":"Apple","address":{"streetName":"Apple Park Way","streetNumber":"1"}}},"hobby":{"hobbyName":"Music production","genre":{"genreName":"Deep house","genreYearOrigin":"1980"}}}' dictionary = json.loads(jsonData) #Referencing dict for 'streetName', from array, hardcoded. companyElements = ["industry", "company", "address", "streetName"] print(dictionary[companyElements[0]][companyElements[1]][companyElements[2]][companyElements[3]]) #Referencing dict for 'genreName', from array, hardcoded. hobbyElements = ["hobby", "genre", "genreName"] print(dictionary[hobbyElements[0]][hobbyElements[1]][hobbyElements[2]]) ``` The problem is that accessing the dictionaries is being done hardcoded. In other words, there are numbers being used (0, 1, 2, 3). Is it possible to access the dictionairy through an array, but soft coded? So passing in an array (or another data structure) to the dict without making use of numbers? If so, how can one achieve this?
2018/11/23
[ "https://Stackoverflow.com/questions/53447598", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6381389/" ]
Here [are the details](https://youtu.be/GRn49ehm_pI), ``` 1. go to your desired NuGet package webpage. 2. on the right side **Download Package** option click it. 3. your package **.nupkg** file will be downloaded. 4. change its extension to .zip and extract it 5. go to lib and copy your package dll file from net or any netstandard folder. For [your unity project compatibility purposes][2] view this: ``` [![enter image description here](https://i.stack.imgur.com/rCUve.png)](https://i.stack.imgur.com/rCUve.png) ``` 6. open unity workspace and create plugin folder 7. paste your dll file here. ``` *Here is the [video](https://youtu.be/GRn49ehm_pI) guide, i have imported newtonsoft.json pacakge in unity*
You have to set up the downloaded nuget /is in packages folder/ plugins manually. Nuget doesn't know which plugin can use unity and how. You can set their parameters in inspector: editor, standalone ... x86,x64 ...
53,447,598
I have a dictionary created from JSON. I would like to access items in the dictionairy through arrays containing their keys. Visualised JSON: ``` { "name": "Chiel", "industry": { "IndustryName": "Computer Science", "company": { "companyName": "Apple", "address": { "streetName": "Apple Park Way", "streetNumber": "1" } } }, "hobby": { "hobbyName": "Music production", "genre": { "genreName": "Deep house", "genreYearOrigin": "1980" } } } ``` See the following code example: ``` #create dict jsonData = '{"name":"Chiel","industry":{"IndustryName":"Computer Science","company":{"companyName":"Apple","address":{"streetName":"Apple Park Way","streetNumber":"1"}}},"hobby":{"hobbyName":"Music production","genre":{"genreName":"Deep house","genreYearOrigin":"1980"}}}' dictionary = json.loads(jsonData) #Referencing dict for 'streetName', from array, hardcoded. companyElements = ["industry", "company", "address", "streetName"] print(dictionary[companyElements[0]][companyElements[1]][companyElements[2]][companyElements[3]]) #Referencing dict for 'genreName', from array, hardcoded. hobbyElements = ["hobby", "genre", "genreName"] print(dictionary[hobbyElements[0]][hobbyElements[1]][hobbyElements[2]]) ``` The problem is that accessing the dictionaries is being done hardcoded. In other words, there are numbers being used (0, 1, 2, 3). Is it possible to access the dictionairy through an array, but soft coded? So passing in an array (or another data structure) to the dict without making use of numbers? If so, how can one achieve this?
2018/11/23
[ "https://Stackoverflow.com/questions/53447598", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6381389/" ]
Just thought I'd add this in case it helps anyone I used the [Nuget for Unity](https://github.com/GlitchEnzo/NuGetForUnity) asset (free) to import a package (websocketsharp) and it was really easy and painless. The references in VS worked immediately as well The package you're trying to import naturally has to be compatible with Unity but that's the same even if you import it manually. So I'd recommend giving this a try
There is [NuGet2Unity](https://github.com/BrianPeek/NuGet2Unity) that allows to convert any Nuget package to a '.unitypackage'. I've used it to convert "SpecFlow" and i was able to import the resulting Unity Package. Check out their [Examples](https://github.com/BrianPeek/NuGet2Unity#example). It worked for me with: > > dotnet.exe run -n specflow --version 3.0.225 > > > *Note that you might need to skip dependecies that are deliverd by the NugetPackage which are already deliverd by unity itself.*
53,447,598
I have a dictionary created from JSON. I would like to access items in the dictionairy through arrays containing their keys. Visualised JSON: ``` { "name": "Chiel", "industry": { "IndustryName": "Computer Science", "company": { "companyName": "Apple", "address": { "streetName": "Apple Park Way", "streetNumber": "1" } } }, "hobby": { "hobbyName": "Music production", "genre": { "genreName": "Deep house", "genreYearOrigin": "1980" } } } ``` See the following code example: ``` #create dict jsonData = '{"name":"Chiel","industry":{"IndustryName":"Computer Science","company":{"companyName":"Apple","address":{"streetName":"Apple Park Way","streetNumber":"1"}}},"hobby":{"hobbyName":"Music production","genre":{"genreName":"Deep house","genreYearOrigin":"1980"}}}' dictionary = json.loads(jsonData) #Referencing dict for 'streetName', from array, hardcoded. companyElements = ["industry", "company", "address", "streetName"] print(dictionary[companyElements[0]][companyElements[1]][companyElements[2]][companyElements[3]]) #Referencing dict for 'genreName', from array, hardcoded. hobbyElements = ["hobby", "genre", "genreName"] print(dictionary[hobbyElements[0]][hobbyElements[1]][hobbyElements[2]]) ``` The problem is that accessing the dictionaries is being done hardcoded. In other words, there are numbers being used (0, 1, 2, 3). Is it possible to access the dictionairy through an array, but soft coded? So passing in an array (or another data structure) to the dict without making use of numbers? If so, how can one achieve this?
2018/11/23
[ "https://Stackoverflow.com/questions/53447598", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6381389/" ]
Just thought I'd add this in case it helps anyone I used the [Nuget for Unity](https://github.com/GlitchEnzo/NuGetForUnity) asset (free) to import a package (websocketsharp) and it was really easy and painless. The references in VS worked immediately as well The package you're trying to import naturally has to be compatible with Unity but that's the same even if you import it manually. So I'd recommend giving this a try
Use native Nuget (for packages which targets only one framework) ================================================================ Instead of downloading everything manually you can create a `nuget.config` and a `packages.nuget` file and place them in you project's root directory. `nuget.config`: ```xml <?xml version="1.0" encoding="utf-8"?> <configuration> <config> <!-- This makes Nuget to place the packages at ./Assets/Plugins --> <add key="repositoryPath" value="./Assets/Plugins" /> </config> <packageSources> <clear /> <!-- Delete packageSources from other nuget.configs --> <add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" /> </packageSources> </configuration> ``` `packages.nuget`: ```xml <?xml version="1.0" encoding="utf-8"?> <packages> <!-- targetFramework="netstandard2.0" makes nuget to unzip the netstandard2.0 version of the package--> <package id="PackageA" version="1.0.0" targetFramework="netstandard2.0" /> <package id="PackageADependsOnThis" version="1.0.0" targetFramework="netstandard2.0" /> <package id="PackageB" version="1.0.0" targetFramework="netstandard2.0" /> </packages> ``` Usage ----- To restore these packages open the project's root directory in your terminal and enter the following: ``` nuget restore -NoCache ``` You may want to omit `-NoCache` it prevents nuget from using the cache at `C:\Users\<username>\.nuget\packages`. This is useful if you use a private nuget feed and there are already packages in your cache which fits your desired packages names and versions but are from a different feed. The downside of this approach is that you will have both in `./Assets/Plugins` the netstandard2.0-Library and the Nuget package like so: [![Example Files in fileexplorer](https://i.stack.imgur.com/mTd2N.png)](https://i.stack.imgur.com/mTd2N.png) Nuget packages a usually not that big so that should not be a factor. Also note you this approach will not resolve package dependencies, you will have to list them in `packages.config` yourself. Edit: I noticed **another downside**: NugetPackages which target multiple frameworks, will be installed as well. This leads to an Unity-Error and need to delete these framework-installs yourself. See also -------- [nuget.config reference](https://learn.microsoft.com/en-us/nuget/reference/nuget-config-file)
53,447,598
I have a dictionary created from JSON. I would like to access items in the dictionairy through arrays containing their keys. Visualised JSON: ``` { "name": "Chiel", "industry": { "IndustryName": "Computer Science", "company": { "companyName": "Apple", "address": { "streetName": "Apple Park Way", "streetNumber": "1" } } }, "hobby": { "hobbyName": "Music production", "genre": { "genreName": "Deep house", "genreYearOrigin": "1980" } } } ``` See the following code example: ``` #create dict jsonData = '{"name":"Chiel","industry":{"IndustryName":"Computer Science","company":{"companyName":"Apple","address":{"streetName":"Apple Park Way","streetNumber":"1"}}},"hobby":{"hobbyName":"Music production","genre":{"genreName":"Deep house","genreYearOrigin":"1980"}}}' dictionary = json.loads(jsonData) #Referencing dict for 'streetName', from array, hardcoded. companyElements = ["industry", "company", "address", "streetName"] print(dictionary[companyElements[0]][companyElements[1]][companyElements[2]][companyElements[3]]) #Referencing dict for 'genreName', from array, hardcoded. hobbyElements = ["hobby", "genre", "genreName"] print(dictionary[hobbyElements[0]][hobbyElements[1]][hobbyElements[2]]) ``` The problem is that accessing the dictionaries is being done hardcoded. In other words, there are numbers being used (0, 1, 2, 3). Is it possible to access the dictionairy through an array, but soft coded? So passing in an array (or another data structure) to the dict without making use of numbers? If so, how can one achieve this?
2018/11/23
[ "https://Stackoverflow.com/questions/53447598", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6381389/" ]
Use native Nuget (for packages which targets only one framework) ================================================================ Instead of downloading everything manually you can create a `nuget.config` and a `packages.nuget` file and place them in you project's root directory. `nuget.config`: ```xml <?xml version="1.0" encoding="utf-8"?> <configuration> <config> <!-- This makes Nuget to place the packages at ./Assets/Plugins --> <add key="repositoryPath" value="./Assets/Plugins" /> </config> <packageSources> <clear /> <!-- Delete packageSources from other nuget.configs --> <add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" /> </packageSources> </configuration> ``` `packages.nuget`: ```xml <?xml version="1.0" encoding="utf-8"?> <packages> <!-- targetFramework="netstandard2.0" makes nuget to unzip the netstandard2.0 version of the package--> <package id="PackageA" version="1.0.0" targetFramework="netstandard2.0" /> <package id="PackageADependsOnThis" version="1.0.0" targetFramework="netstandard2.0" /> <package id="PackageB" version="1.0.0" targetFramework="netstandard2.0" /> </packages> ``` Usage ----- To restore these packages open the project's root directory in your terminal and enter the following: ``` nuget restore -NoCache ``` You may want to omit `-NoCache` it prevents nuget from using the cache at `C:\Users\<username>\.nuget\packages`. This is useful if you use a private nuget feed and there are already packages in your cache which fits your desired packages names and versions but are from a different feed. The downside of this approach is that you will have both in `./Assets/Plugins` the netstandard2.0-Library and the Nuget package like so: [![Example Files in fileexplorer](https://i.stack.imgur.com/mTd2N.png)](https://i.stack.imgur.com/mTd2N.png) Nuget packages a usually not that big so that should not be a factor. Also note you this approach will not resolve package dependencies, you will have to list them in `packages.config` yourself. Edit: I noticed **another downside**: NugetPackages which target multiple frameworks, will be installed as well. This leads to an Unity-Error and need to delete these framework-installs yourself. See also -------- [nuget.config reference](https://learn.microsoft.com/en-us/nuget/reference/nuget-config-file)
There is [NuGet2Unity](https://github.com/BrianPeek/NuGet2Unity) that allows to convert any Nuget package to a '.unitypackage'. I've used it to convert "SpecFlow" and i was able to import the resulting Unity Package. Check out their [Examples](https://github.com/BrianPeek/NuGet2Unity#example). It worked for me with: > > dotnet.exe run -n specflow --version 3.0.225 > > > *Note that you might need to skip dependecies that are deliverd by the NugetPackage which are already deliverd by unity itself.*
53,447,598
I have a dictionary created from JSON. I would like to access items in the dictionairy through arrays containing their keys. Visualised JSON: ``` { "name": "Chiel", "industry": { "IndustryName": "Computer Science", "company": { "companyName": "Apple", "address": { "streetName": "Apple Park Way", "streetNumber": "1" } } }, "hobby": { "hobbyName": "Music production", "genre": { "genreName": "Deep house", "genreYearOrigin": "1980" } } } ``` See the following code example: ``` #create dict jsonData = '{"name":"Chiel","industry":{"IndustryName":"Computer Science","company":{"companyName":"Apple","address":{"streetName":"Apple Park Way","streetNumber":"1"}}},"hobby":{"hobbyName":"Music production","genre":{"genreName":"Deep house","genreYearOrigin":"1980"}}}' dictionary = json.loads(jsonData) #Referencing dict for 'streetName', from array, hardcoded. companyElements = ["industry", "company", "address", "streetName"] print(dictionary[companyElements[0]][companyElements[1]][companyElements[2]][companyElements[3]]) #Referencing dict for 'genreName', from array, hardcoded. hobbyElements = ["hobby", "genre", "genreName"] print(dictionary[hobbyElements[0]][hobbyElements[1]][hobbyElements[2]]) ``` The problem is that accessing the dictionaries is being done hardcoded. In other words, there are numbers being used (0, 1, 2, 3). Is it possible to access the dictionairy through an array, but soft coded? So passing in an array (or another data structure) to the dict without making use of numbers? If so, how can one achieve this?
2018/11/23
[ "https://Stackoverflow.com/questions/53447598", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6381389/" ]
Here [are the details](https://youtu.be/GRn49ehm_pI), ``` 1. go to your desired NuGet package webpage. 2. on the right side **Download Package** option click it. 3. your package **.nupkg** file will be downloaded. 4. change its extension to .zip and extract it 5. go to lib and copy your package dll file from net or any netstandard folder. For [your unity project compatibility purposes][2] view this: ``` [![enter image description here](https://i.stack.imgur.com/rCUve.png)](https://i.stack.imgur.com/rCUve.png) ``` 6. open unity workspace and create plugin folder 7. paste your dll file here. ``` *Here is the [video](https://youtu.be/GRn49ehm_pI) guide, i have imported newtonsoft.json pacakge in unity*
You can use the native `dotnet restore` or `nuget restore` commands to populate an asset folder with the nuget packages. #### Get the packages Specify where to put the packages either on the command line or in a `nuget.config` file so that they will be included as assets in unity. ``` <?xml version="1.0" encoding="utf-8"?> <configuration> <config> <add key="globalPackagesFolder" value="./NuGetPackages" /> </config> </configuration> ``` This can go in the same folder as your dotnet solution, in which case you can restore the packages with `dotnet restore` or `nuget restore` in the solution folder. #### Configure which version is used in Unity In the Unity editor, find the dll files from the package [![Unity dll file from a nuget package](https://i.stack.imgur.com/u35Yu.png)](https://i.stack.imgur.com/u35Yu.png) Open the file in the inspector and disable it for platforms, or conditionally for build constraints. [![Unity dll inspector with all platforms disabled](https://i.stack.imgur.com/f5hRV.png)](https://i.stack.imgur.com/f5hRV.png) This gets saved into the `.dll.meta` files in the same directory as the `.dll`. You don't want them to be deleted so ... #### Configure source control to keep the `.dll.meta` files This `.gitignore` will exclude everything from the packages, but will keep the `.dll.meta` files that specify which version Unity uses. ``` **/NuGetPackages/** !**/NuGetPackages/**/ !**/NuGetPackages/**/*.dll.meta ```
53,447,598
I have a dictionary created from JSON. I would like to access items in the dictionairy through arrays containing their keys. Visualised JSON: ``` { "name": "Chiel", "industry": { "IndustryName": "Computer Science", "company": { "companyName": "Apple", "address": { "streetName": "Apple Park Way", "streetNumber": "1" } } }, "hobby": { "hobbyName": "Music production", "genre": { "genreName": "Deep house", "genreYearOrigin": "1980" } } } ``` See the following code example: ``` #create dict jsonData = '{"name":"Chiel","industry":{"IndustryName":"Computer Science","company":{"companyName":"Apple","address":{"streetName":"Apple Park Way","streetNumber":"1"}}},"hobby":{"hobbyName":"Music production","genre":{"genreName":"Deep house","genreYearOrigin":"1980"}}}' dictionary = json.loads(jsonData) #Referencing dict for 'streetName', from array, hardcoded. companyElements = ["industry", "company", "address", "streetName"] print(dictionary[companyElements[0]][companyElements[1]][companyElements[2]][companyElements[3]]) #Referencing dict for 'genreName', from array, hardcoded. hobbyElements = ["hobby", "genre", "genreName"] print(dictionary[hobbyElements[0]][hobbyElements[1]][hobbyElements[2]]) ``` The problem is that accessing the dictionaries is being done hardcoded. In other words, there are numbers being used (0, 1, 2, 3). Is it possible to access the dictionairy through an array, but soft coded? So passing in an array (or another data structure) to the dict without making use of numbers? If so, how can one achieve this?
2018/11/23
[ "https://Stackoverflow.com/questions/53447598", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6381389/" ]
You really don't wanna go down the path of configuring Unity to work with Nuget automatically. That article is rather old. With Unity 2018, you get a .net standard 2.0 compatibility level, which should be perfect for Nuget packages. Simply download the package using a separate VS project (as mentioned in the article), then take the netstandard20 version of the DLL and place it in your Unity project.
There is [NuGet2Unity](https://github.com/BrianPeek/NuGet2Unity) that allows to convert any Nuget package to a '.unitypackage'. I've used it to convert "SpecFlow" and i was able to import the resulting Unity Package. Check out their [Examples](https://github.com/BrianPeek/NuGet2Unity#example). It worked for me with: > > dotnet.exe run -n specflow --version 3.0.225 > > > *Note that you might need to skip dependecies that are deliverd by the NugetPackage which are already deliverd by unity itself.*
53,447,598
I have a dictionary created from JSON. I would like to access items in the dictionairy through arrays containing their keys. Visualised JSON: ``` { "name": "Chiel", "industry": { "IndustryName": "Computer Science", "company": { "companyName": "Apple", "address": { "streetName": "Apple Park Way", "streetNumber": "1" } } }, "hobby": { "hobbyName": "Music production", "genre": { "genreName": "Deep house", "genreYearOrigin": "1980" } } } ``` See the following code example: ``` #create dict jsonData = '{"name":"Chiel","industry":{"IndustryName":"Computer Science","company":{"companyName":"Apple","address":{"streetName":"Apple Park Way","streetNumber":"1"}}},"hobby":{"hobbyName":"Music production","genre":{"genreName":"Deep house","genreYearOrigin":"1980"}}}' dictionary = json.loads(jsonData) #Referencing dict for 'streetName', from array, hardcoded. companyElements = ["industry", "company", "address", "streetName"] print(dictionary[companyElements[0]][companyElements[1]][companyElements[2]][companyElements[3]]) #Referencing dict for 'genreName', from array, hardcoded. hobbyElements = ["hobby", "genre", "genreName"] print(dictionary[hobbyElements[0]][hobbyElements[1]][hobbyElements[2]]) ``` The problem is that accessing the dictionaries is being done hardcoded. In other words, there are numbers being used (0, 1, 2, 3). Is it possible to access the dictionairy through an array, but soft coded? So passing in an array (or another data structure) to the dict without making use of numbers? If so, how can one achieve this?
2018/11/23
[ "https://Stackoverflow.com/questions/53447598", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6381389/" ]
Just thought I'd add this in case it helps anyone I used the [Nuget for Unity](https://github.com/GlitchEnzo/NuGetForUnity) asset (free) to import a package (websocketsharp) and it was really easy and painless. The references in VS worked immediately as well The package you're trying to import naturally has to be compatible with Unity but that's the same even if you import it manually. So I'd recommend giving this a try
You have to set up the downloaded nuget /is in packages folder/ plugins manually. Nuget doesn't know which plugin can use unity and how. You can set their parameters in inspector: editor, standalone ... x86,x64 ...
53,447,598
I have a dictionary created from JSON. I would like to access items in the dictionairy through arrays containing their keys. Visualised JSON: ``` { "name": "Chiel", "industry": { "IndustryName": "Computer Science", "company": { "companyName": "Apple", "address": { "streetName": "Apple Park Way", "streetNumber": "1" } } }, "hobby": { "hobbyName": "Music production", "genre": { "genreName": "Deep house", "genreYearOrigin": "1980" } } } ``` See the following code example: ``` #create dict jsonData = '{"name":"Chiel","industry":{"IndustryName":"Computer Science","company":{"companyName":"Apple","address":{"streetName":"Apple Park Way","streetNumber":"1"}}},"hobby":{"hobbyName":"Music production","genre":{"genreName":"Deep house","genreYearOrigin":"1980"}}}' dictionary = json.loads(jsonData) #Referencing dict for 'streetName', from array, hardcoded. companyElements = ["industry", "company", "address", "streetName"] print(dictionary[companyElements[0]][companyElements[1]][companyElements[2]][companyElements[3]]) #Referencing dict for 'genreName', from array, hardcoded. hobbyElements = ["hobby", "genre", "genreName"] print(dictionary[hobbyElements[0]][hobbyElements[1]][hobbyElements[2]]) ``` The problem is that accessing the dictionaries is being done hardcoded. In other words, there are numbers being used (0, 1, 2, 3). Is it possible to access the dictionairy through an array, but soft coded? So passing in an array (or another data structure) to the dict without making use of numbers? If so, how can one achieve this?
2018/11/23
[ "https://Stackoverflow.com/questions/53447598", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6381389/" ]
Here [are the details](https://youtu.be/GRn49ehm_pI), ``` 1. go to your desired NuGet package webpage. 2. on the right side **Download Package** option click it. 3. your package **.nupkg** file will be downloaded. 4. change its extension to .zip and extract it 5. go to lib and copy your package dll file from net or any netstandard folder. For [your unity project compatibility purposes][2] view this: ``` [![enter image description here](https://i.stack.imgur.com/rCUve.png)](https://i.stack.imgur.com/rCUve.png) ``` 6. open unity workspace and create plugin folder 7. paste your dll file here. ``` *Here is the [video](https://youtu.be/GRn49ehm_pI) guide, i have imported newtonsoft.json pacakge in unity*
There is [NuGet2Unity](https://github.com/BrianPeek/NuGet2Unity) that allows to convert any Nuget package to a '.unitypackage'. I've used it to convert "SpecFlow" and i was able to import the resulting Unity Package. Check out their [Examples](https://github.com/BrianPeek/NuGet2Unity#example). It worked for me with: > > dotnet.exe run -n specflow --version 3.0.225 > > > *Note that you might need to skip dependecies that are deliverd by the NugetPackage which are already deliverd by unity itself.*
53,447,598
I have a dictionary created from JSON. I would like to access items in the dictionairy through arrays containing their keys. Visualised JSON: ``` { "name": "Chiel", "industry": { "IndustryName": "Computer Science", "company": { "companyName": "Apple", "address": { "streetName": "Apple Park Way", "streetNumber": "1" } } }, "hobby": { "hobbyName": "Music production", "genre": { "genreName": "Deep house", "genreYearOrigin": "1980" } } } ``` See the following code example: ``` #create dict jsonData = '{"name":"Chiel","industry":{"IndustryName":"Computer Science","company":{"companyName":"Apple","address":{"streetName":"Apple Park Way","streetNumber":"1"}}},"hobby":{"hobbyName":"Music production","genre":{"genreName":"Deep house","genreYearOrigin":"1980"}}}' dictionary = json.loads(jsonData) #Referencing dict for 'streetName', from array, hardcoded. companyElements = ["industry", "company", "address", "streetName"] print(dictionary[companyElements[0]][companyElements[1]][companyElements[2]][companyElements[3]]) #Referencing dict for 'genreName', from array, hardcoded. hobbyElements = ["hobby", "genre", "genreName"] print(dictionary[hobbyElements[0]][hobbyElements[1]][hobbyElements[2]]) ``` The problem is that accessing the dictionaries is being done hardcoded. In other words, there are numbers being used (0, 1, 2, 3). Is it possible to access the dictionairy through an array, but soft coded? So passing in an array (or another data structure) to the dict without making use of numbers? If so, how can one achieve this?
2018/11/23
[ "https://Stackoverflow.com/questions/53447598", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6381389/" ]
You really don't wanna go down the path of configuring Unity to work with Nuget automatically. That article is rather old. With Unity 2018, you get a .net standard 2.0 compatibility level, which should be perfect for Nuget packages. Simply download the package using a separate VS project (as mentioned in the article), then take the netstandard20 version of the DLL and place it in your Unity project.
Use native Nuget (for packages which targets only one framework) ================================================================ Instead of downloading everything manually you can create a `nuget.config` and a `packages.nuget` file and place them in you project's root directory. `nuget.config`: ```xml <?xml version="1.0" encoding="utf-8"?> <configuration> <config> <!-- This makes Nuget to place the packages at ./Assets/Plugins --> <add key="repositoryPath" value="./Assets/Plugins" /> </config> <packageSources> <clear /> <!-- Delete packageSources from other nuget.configs --> <add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" /> </packageSources> </configuration> ``` `packages.nuget`: ```xml <?xml version="1.0" encoding="utf-8"?> <packages> <!-- targetFramework="netstandard2.0" makes nuget to unzip the netstandard2.0 version of the package--> <package id="PackageA" version="1.0.0" targetFramework="netstandard2.0" /> <package id="PackageADependsOnThis" version="1.0.0" targetFramework="netstandard2.0" /> <package id="PackageB" version="1.0.0" targetFramework="netstandard2.0" /> </packages> ``` Usage ----- To restore these packages open the project's root directory in your terminal and enter the following: ``` nuget restore -NoCache ``` You may want to omit `-NoCache` it prevents nuget from using the cache at `C:\Users\<username>\.nuget\packages`. This is useful if you use a private nuget feed and there are already packages in your cache which fits your desired packages names and versions but are from a different feed. The downside of this approach is that you will have both in `./Assets/Plugins` the netstandard2.0-Library and the Nuget package like so: [![Example Files in fileexplorer](https://i.stack.imgur.com/mTd2N.png)](https://i.stack.imgur.com/mTd2N.png) Nuget packages a usually not that big so that should not be a factor. Also note you this approach will not resolve package dependencies, you will have to list them in `packages.config` yourself. Edit: I noticed **another downside**: NugetPackages which target multiple frameworks, will be installed as well. This leads to an Unity-Error and need to delete these framework-installs yourself. See also -------- [nuget.config reference](https://learn.microsoft.com/en-us/nuget/reference/nuget-config-file)
53,447,598
I have a dictionary created from JSON. I would like to access items in the dictionairy through arrays containing their keys. Visualised JSON: ``` { "name": "Chiel", "industry": { "IndustryName": "Computer Science", "company": { "companyName": "Apple", "address": { "streetName": "Apple Park Way", "streetNumber": "1" } } }, "hobby": { "hobbyName": "Music production", "genre": { "genreName": "Deep house", "genreYearOrigin": "1980" } } } ``` See the following code example: ``` #create dict jsonData = '{"name":"Chiel","industry":{"IndustryName":"Computer Science","company":{"companyName":"Apple","address":{"streetName":"Apple Park Way","streetNumber":"1"}}},"hobby":{"hobbyName":"Music production","genre":{"genreName":"Deep house","genreYearOrigin":"1980"}}}' dictionary = json.loads(jsonData) #Referencing dict for 'streetName', from array, hardcoded. companyElements = ["industry", "company", "address", "streetName"] print(dictionary[companyElements[0]][companyElements[1]][companyElements[2]][companyElements[3]]) #Referencing dict for 'genreName', from array, hardcoded. hobbyElements = ["hobby", "genre", "genreName"] print(dictionary[hobbyElements[0]][hobbyElements[1]][hobbyElements[2]]) ``` The problem is that accessing the dictionaries is being done hardcoded. In other words, there are numbers being used (0, 1, 2, 3). Is it possible to access the dictionairy through an array, but soft coded? So passing in an array (or another data structure) to the dict without making use of numbers? If so, how can one achieve this?
2018/11/23
[ "https://Stackoverflow.com/questions/53447598", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6381389/" ]
You can use the native `dotnet restore` or `nuget restore` commands to populate an asset folder with the nuget packages. #### Get the packages Specify where to put the packages either on the command line or in a `nuget.config` file so that they will be included as assets in unity. ``` <?xml version="1.0" encoding="utf-8"?> <configuration> <config> <add key="globalPackagesFolder" value="./NuGetPackages" /> </config> </configuration> ``` This can go in the same folder as your dotnet solution, in which case you can restore the packages with `dotnet restore` or `nuget restore` in the solution folder. #### Configure which version is used in Unity In the Unity editor, find the dll files from the package [![Unity dll file from a nuget package](https://i.stack.imgur.com/u35Yu.png)](https://i.stack.imgur.com/u35Yu.png) Open the file in the inspector and disable it for platforms, or conditionally for build constraints. [![Unity dll inspector with all platforms disabled](https://i.stack.imgur.com/f5hRV.png)](https://i.stack.imgur.com/f5hRV.png) This gets saved into the `.dll.meta` files in the same directory as the `.dll`. You don't want them to be deleted so ... #### Configure source control to keep the `.dll.meta` files This `.gitignore` will exclude everything from the packages, but will keep the `.dll.meta` files that specify which version Unity uses. ``` **/NuGetPackages/** !**/NuGetPackages/**/ !**/NuGetPackages/**/*.dll.meta ```
You have to set up the downloaded nuget /is in packages folder/ plugins manually. Nuget doesn't know which plugin can use unity and how. You can set their parameters in inspector: editor, standalone ... x86,x64 ...
24,530
Popper claims that falsifiability is a criterion of science (but not of meaningfulness). Scanning the original 1935 text (Logik der Forschung) it seems to me that he just refers to "Wissenschaft". Does he actually mean what English calls "Science" or the broader German sense in which the humanities and social sciences are "Geisteswissenschaften" and what we call Sciences (without a modifier) are "Naturwissenschaften"? In the English version (Logic of Scientific Discovery, 1955 or so) Popper just refers to "Science". In the German original he very occasionally does mention specifically Naturwissenschaften and sometimes modifies "wissenschaftlich" e.g. "empirisch-wissenschaftlich", but it is not clear to me whether he thinks of the demarcation criterion as applicable to all kinds of science or only to natural science. PS I described the question as semantics of the criterion - but actually I see that it is really about the semantics of the objects to which the criterion is to be applied.
2015/06/18
[ "https://philosophy.stackexchange.com/questions/24530", "https://philosophy.stackexchange.com", "https://philosophy.stackexchange.com/users/15024/" ]
Popper did accept social sciences as sciences proper, and even was more positive on them than many natural scientists. Here is from [Cibangu's Karl Popper and the Social Sciences](http://cdn.intechopen.com/pdfs-wm/39080.pdf):"*Popper understood the social sciences as sciences in the full sense of the word, a position that attempts to refute the widespread idea that the social sciences represent a weak form of science. Discussions of the scientific status of the social sciences (their methods, theories, and laws) are usually impaired by the common misunderstandings that authors entertain about physics and its laws.*" The difference is, according to Popper, that "*physical laws, or the “laws of nature”, are valid anywhere and always; for the physical world is ruled by a system of physical uniformities invariable throughout space and time. Sociological laws, however, or the laws of social life, differ in different places and periods... The method of the social sciences, like that of the natural sciences, consists in trying out tentative solutions to those problems from which our investigations start. Solutions are proposed and criticized. If a proposed solution is not open to objective criticism, then it is excluded as unscientific.*" See also explicit discussion of demarcation for social sciences, and its relation to his "open society", in chapter IV of Ratheesh's dissertation [Karl Popper's Falsification and its implication in Social Science](https://www.academia.edu/6407758/Karl_Popper_falsification_and_its_implication_in_social_science).
I agree that from *The Logic of Scientific Discovery* it is difficult to link Popper's demarcation criterion to the distinction between natural and social sciences. However, in [*Conjectures and Refutations*](https://poars1982.files.wordpress.com/2008/03/science-conjectures-and-refutations.pdf) Popper famously gives three examples of pseudo-science: Marx's theory of history, Freud's psychoanalysis and Adler's individual psychology. All these three examples belong to the social sciences. Also, Popper contrasts them with Einstein's general relativity theory, as a positive example of genuine science. All this clearly implies that, according to that essay of Popper's, the social sciences are to be judged by the same criterion of demarcation as the natural sciences.
46,092,268
Is there any way for the browser to "lock" the file after being selected by the `<input type="file" />`? Right now I can select a file, start some operations on it with JavaScript and in the meantime I can delete it from my disk, which results in errors in JavaScript code. **EDIT** The goal is to make sure the file cannot be deleted while I am working on it with JavaScript.
2017/09/07
[ "https://Stackoverflow.com/questions/46092268", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5033397/" ]
No there is no way. Simply because JS is a client side language, even with server side this wouldn't be possible because you can't interact with users computer. For this to happened you would need your desktop app that would take the file for example copy it and lock it. If this was to be implemented, this would have to be implemented in the browser. Edit addition: If you think about it why this isn't implemented in browsers already, maybe because what if you go offline while uploading what will happen to the file? Stay locked?
**Yes** : You can create a copy in memory, and use this instead of the file on user's disk. You will have to read its content first and to create a new File/Blob from there : ```js let theFile = null; inp.onchange = async function(e) { theFile = await saveBlob(inp.files[0]); btn.disabled = false; inp.disabled = true; } btn.onclick = e => { console.log(theFile); let reader = new FileReader(); // to prove it's really still there reader.onload = e => console.log(new Uint8Array(reader.result)); reader.onerror = e => console.log(e); reader.readAsArrayBuffer(theFile.slice(0, 4)); } function saveBlob(blob) { let reader = new FileReader(); return new Promise((res, rej) => { reader.onload = e => { if (blob instanceof File) { // tries to keep it as a File, but beware some implementations still have bugs res( new File([reader.result], blob.name, {type: blob.type}) ); } else { res( new Blob([reader.result], {type: blob.type}) ); } }; reader.onerror = rej; // already removed ??? reader.readAsArrayBuffer(blob); }); } ``` ```html <input type="file" id="inp"> <button id="btn" disabled>I did remove it from disk</button> ``` An alternative way would be to store it in indexedDB. Then, you can work with this copy and be sure that it will stay in memory, whatever the user does with the original file. If you need to keep it for longer than the document's life, you can create a blobURI (`URL.createObjectURL(theFile)`) that you'll be able to store in localStorage and retrieve in reload or redirection with `fetch(blobURI).then(r=>r.blob());`. And if you need it to survive for even longer (an hard refresh will kill the reference of the blobURI), then use indexedDB. --- **Edit** in response to [question's edit](https://stackoverflow.com/posts/46092268/revisions#reve4aadf1f-da2f-41f1-be3b-f5b4f9bf88d3). Obviously you won't be able to change file's permissions on user's disk, but you don't need to do it, since you can get a copy of it to work with.
51,938,699
Say, I have an async function that I want to call in a synchronous function. For example: ``` Future<int> foo() async { // do something return 109; } int bar() { var r = wait_for_future(foo()); return r; } ``` What I'm looking for is a possible implementation for `wait_for_future`. Can this even be done in Dart?
2018/08/20
[ "https://Stackoverflow.com/questions/51938699", "https://Stackoverflow.com", "https://Stackoverflow.com/users/363949/" ]
`params` is supposed to be a Javascript object with the `inv` property, which you have not provided as an argument to the function. ```js function myClickEvent(params) { var inv = $("#" + params["inv"]); inv.on("click", function () { console.log(inv+": clicked"); //$.ajax({ // url: params["route"], //contentType: "text/json", //success: function (result) { // history.pushState(null, null, params["route"]); // $("#content-wrapper").html(result); // inv.parent().siblings().removeClass("active"); // inv.parent().addClass("active"); // } // }); // return false; }); } ``` ```html <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <button onclick='myClickEvent({inv: "test"})'>Click me</button> <p/> <button id="test">Test</button> ```
That's because you are not passing anything to the function, you can test it this way `<button onclick='myClickEvent("value")'>Click me</button>` and then add `console.log(params)` in the first line of your function
51,938,699
Say, I have an async function that I want to call in a synchronous function. For example: ``` Future<int> foo() async { // do something return 109; } int bar() { var r = wait_for_future(foo()); return r; } ``` What I'm looking for is a possible implementation for `wait_for_future`. Can this even be done in Dart?
2018/08/20
[ "https://Stackoverflow.com/questions/51938699", "https://Stackoverflow.com", "https://Stackoverflow.com/users/363949/" ]
`params` is supposed to be a Javascript object with the `inv` property, which you have not provided as an argument to the function. ```js function myClickEvent(params) { var inv = $("#" + params["inv"]); inv.on("click", function () { console.log(inv+": clicked"); //$.ajax({ // url: params["route"], //contentType: "text/json", //success: function (result) { // history.pushState(null, null, params["route"]); // $("#content-wrapper").html(result); // inv.parent().siblings().removeClass("active"); // inv.parent().addClass("active"); // } // }); // return false; }); } ``` ```html <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <button onclick='myClickEvent({inv: "test"})'>Click me</button> <p/> <button id="test">Test</button> ```
You need to read a javascript tutorial, you are telling the button to execute on click the function myClickEvent() without parameters, and in the definition you are expecting a params param, this is not filled by itself, i would tell you to add the param but what you really need to do is not to use the onClick attribute in html and use instead addEventListener from script in the button element.
5,301,744
I need to get WADL file for RESTful service. I know that in case using jersey it's available as `http://localhost:8080/application.wadl`. But I use RESTeasy. Can I do the same in my framework case?
2011/03/14
[ "https://Stackoverflow.com/questions/5301744", "https://Stackoverflow.com", "https://Stackoverflow.com/users/608818/" ]
Latest versions: ================ Quoting [Chapter 49. RESTEasy WADL Support](http://docs.jboss.org/resteasy/docs/3.1.4.Final/userguide/html_single/index.html#WADL): > > Chapter 49. RESTEasy WADL Support > ================================= > > > [49.1. RESTEasy WADL Support for Servlet Container](http://docs.jboss.org/resteasy/docs/3.1.4.Final/userguide/html_single/index.html#d4e2321) > > [49.2. RESTEasy WADL support for Sun JDK HTTP Server](http://docs.jboss.org/resteasy/docs/3.1.4.Final/userguide/html_single/index.html#d4e2327) > > [49.3. RESTEasy WADL support for Netty Container](http://docs.jboss.org/resteasy/docs/3.1.4.Final/userguide/html_single/index.html#d4e2337) > > [49.4. RESTEasy WADL Support for Undertow Container](http://docs.jboss.org/resteasy/docs/3.1.4.Final/userguide/html_single/index.html#d4e2342) > > > RESTEasy has its own support to generate WADL for its resources, and it supports several different containers. The following text will show you how to use this feature in different containers. > > > ### 49.1. RESTEasy WADL Support for Servlet Container > > > RESTEasy WADL uses `ResteasyWadlServlet` to support servlet container. It can be registered into `web.xml` to enable WADL feature. Here is an example to show the usages of `ResteasyWadlServlet` in `web.xml`: > > > > ``` > <servlet> > <servlet-name>RESTEasy WADL</servlet-name> > <servlet-class>org.jboss.resteasy.wadl.ResteasyWadlServlet</servlet-class> > </servlet> > > <servlet-mapping> > <servlet-name>RESTEasy WADL</servlet-name> > <url-pattern>/application.xml</url-pattern> > </servlet-mapping> > > ``` > > The preceding configuration in `web.xml` shows how to enable > `ResteasyWadlServlet` and mapped it to `/application.xml`. And then the > WADL can be accessed from the configured URL: > > > > ``` > /application.xml > > ``` > > --- Workaround for Older versions ============================= There is a workaround: a maven plugin called `maven-wadl-plugin` by the jersey folks that also works to generate WADL for services coded using RESTEasy. Here's how to use it. 1. Add this to your `pom.xml`: ============================== ```xml <build> <plugins> <plugin> <groupId>com.sun.jersey.contribs</groupId> <artifactId>maven-wadl-plugin</artifactId> <version>1.17</version> <executions> <execution> <id>generate</id> <goals> <goal>generate</goal> </goals> <phase>${javadoc-phase}</phase> </execution> </executions> <configuration> <wadlFile>${project.build.outputDirectory}/application.wadl </wadlFile> <formatWadlFile>true</formatWadlFile> <baseUri>http://example.com:8080/rest</baseUri> <packagesResourceConfig> <param>com.example.rs.resource</param> </packagesResourceConfig> <wadlGenerators> <wadlGeneratorDescription> <className>com.sun.jersey.server.wadl.generators.WadlGeneratorApplicationDoc </className> <properties> <property> <name>applicationDocsFile</name> <value>${basedir}/src/main/doc/application-doc.xml</value> </property> </properties> </wadlGeneratorDescription> <wadlGeneratorDescription> <className>com.sun.jersey.server.wadl.generators.WadlGeneratorGrammarsSupport </className> <properties> <property> <name>grammarsFile</name> <value>${basedir}/src/main/doc/application-grammars.xml</value> </property> </properties> </wadlGeneratorDescription> </wadlGenerators> </configuration> </plugin> </plugins> </build> ``` Pay attention to the `baseUri` and `packagesResourceConfig` elements. You have to change them to reflect your project's configuration. You may also want to change the plugin's version (I used 1.17). 2. Create a /doc folder and add some files. =========================================== Create the `src/main/doc/` folder and create the two files below. File: **application-doc.xml** Content: ```xml <?xml version="1.0" encoding="UTF-8"?> <applicationDocs targetNamespace="http://wadl.dev.java.net/2009/02"> <doc xml:lang="en" title="A message in the WADL">This is added to the start of the generated application.wadl</doc> </applicationDocs> ``` File: **application-grammars.xml** Content: ```xml <?xml version="1.0" encoding="UTF-8" ?> <grammars xmlns="http://wadl.dev.java.net/2009/02" /> ``` 3. Run the maven command. ========================= Go to the project folder and run the following command: ``` $ mvn compile com.sun.jersey.contribs:maven-wadl-plugin:generate ``` The files `\target\classes\application.wadl` (the WADL itself) and `\target\classes\xsd0.xsd` (the schema of the resources - it's used by the application.wadl) should be generated. Edit and use them as you wish. PS.: Bear in mind that this is a very simple use of the maven-wadl-plugin. It can do a lot more. To know it better, please refer to the zip file in <http://search.maven.org/remotecontent?filepath=com/sun/jersey/samples/generate-wadl/1.12/generate-wadl-1.12-project.zip>
WADL generation in RESTeasy is a feature not yet implemented. If you want it go vote for it. <https://issues.jboss.org/browse/RESTEASY-166>
5,301,744
I need to get WADL file for RESTful service. I know that in case using jersey it's available as `http://localhost:8080/application.wadl`. But I use RESTeasy. Can I do the same in my framework case?
2011/03/14
[ "https://Stackoverflow.com/questions/5301744", "https://Stackoverflow.com", "https://Stackoverflow.com/users/608818/" ]
WADL generation in RESTeasy is a feature not yet implemented. If you want it go vote for it. <https://issues.jboss.org/browse/RESTEASY-166>
we can generate a wadl with the help of maven project with POM.XML <https://issues.jboss.org/browse/RESTEASY-166> check the comments here..!!
5,301,744
I need to get WADL file for RESTful service. I know that in case using jersey it's available as `http://localhost:8080/application.wadl`. But I use RESTeasy. Can I do the same in my framework case?
2011/03/14
[ "https://Stackoverflow.com/questions/5301744", "https://Stackoverflow.com", "https://Stackoverflow.com/users/608818/" ]
WADL generation in RESTeasy is a feature not yet implemented. If you want it go vote for it. <https://issues.jboss.org/browse/RESTEASY-166>
See [RESTEasy WADL Support](http://docs.jboss.org/resteasy/docs/3.1.0.Final/userguide/html/WADL.html) (3.1.0). The snipped below is copied from there ``` <servlet> <servlet-name>RESTEasy WADL</servlet-name> <servlet-class>org.jboss.resteasy.wadl.ResteasyWadlServlet</servlet-class> </servlet> <servlet-mapping> <servlet-name>RESTEasy WADL</servlet-name> <url-pattern>/application.xml</url-pattern> </servlet-mapping> ``` This uses the `ResteasyWadlServlet` and will make the WADL accessible at `/application.xml`. *Note*: Rex and Jaskirat have already mentioned previously that [RESTEASY-166](https://issues.jboss.org/browse/RESTEASY-166) was used to manage the implementation for this feature. It seems this was completed in 3.0.14.
5,301,744
I need to get WADL file for RESTful service. I know that in case using jersey it's available as `http://localhost:8080/application.wadl`. But I use RESTeasy. Can I do the same in my framework case?
2011/03/14
[ "https://Stackoverflow.com/questions/5301744", "https://Stackoverflow.com", "https://Stackoverflow.com/users/608818/" ]
Latest versions: ================ Quoting [Chapter 49. RESTEasy WADL Support](http://docs.jboss.org/resteasy/docs/3.1.4.Final/userguide/html_single/index.html#WADL): > > Chapter 49. RESTEasy WADL Support > ================================= > > > [49.1. RESTEasy WADL Support for Servlet Container](http://docs.jboss.org/resteasy/docs/3.1.4.Final/userguide/html_single/index.html#d4e2321) > > [49.2. RESTEasy WADL support for Sun JDK HTTP Server](http://docs.jboss.org/resteasy/docs/3.1.4.Final/userguide/html_single/index.html#d4e2327) > > [49.3. RESTEasy WADL support for Netty Container](http://docs.jboss.org/resteasy/docs/3.1.4.Final/userguide/html_single/index.html#d4e2337) > > [49.4. RESTEasy WADL Support for Undertow Container](http://docs.jboss.org/resteasy/docs/3.1.4.Final/userguide/html_single/index.html#d4e2342) > > > RESTEasy has its own support to generate WADL for its resources, and it supports several different containers. The following text will show you how to use this feature in different containers. > > > ### 49.1. RESTEasy WADL Support for Servlet Container > > > RESTEasy WADL uses `ResteasyWadlServlet` to support servlet container. It can be registered into `web.xml` to enable WADL feature. Here is an example to show the usages of `ResteasyWadlServlet` in `web.xml`: > > > > ``` > <servlet> > <servlet-name>RESTEasy WADL</servlet-name> > <servlet-class>org.jboss.resteasy.wadl.ResteasyWadlServlet</servlet-class> > </servlet> > > <servlet-mapping> > <servlet-name>RESTEasy WADL</servlet-name> > <url-pattern>/application.xml</url-pattern> > </servlet-mapping> > > ``` > > The preceding configuration in `web.xml` shows how to enable > `ResteasyWadlServlet` and mapped it to `/application.xml`. And then the > WADL can be accessed from the configured URL: > > > > ``` > /application.xml > > ``` > > --- Workaround for Older versions ============================= There is a workaround: a maven plugin called `maven-wadl-plugin` by the jersey folks that also works to generate WADL for services coded using RESTEasy. Here's how to use it. 1. Add this to your `pom.xml`: ============================== ```xml <build> <plugins> <plugin> <groupId>com.sun.jersey.contribs</groupId> <artifactId>maven-wadl-plugin</artifactId> <version>1.17</version> <executions> <execution> <id>generate</id> <goals> <goal>generate</goal> </goals> <phase>${javadoc-phase}</phase> </execution> </executions> <configuration> <wadlFile>${project.build.outputDirectory}/application.wadl </wadlFile> <formatWadlFile>true</formatWadlFile> <baseUri>http://example.com:8080/rest</baseUri> <packagesResourceConfig> <param>com.example.rs.resource</param> </packagesResourceConfig> <wadlGenerators> <wadlGeneratorDescription> <className>com.sun.jersey.server.wadl.generators.WadlGeneratorApplicationDoc </className> <properties> <property> <name>applicationDocsFile</name> <value>${basedir}/src/main/doc/application-doc.xml</value> </property> </properties> </wadlGeneratorDescription> <wadlGeneratorDescription> <className>com.sun.jersey.server.wadl.generators.WadlGeneratorGrammarsSupport </className> <properties> <property> <name>grammarsFile</name> <value>${basedir}/src/main/doc/application-grammars.xml</value> </property> </properties> </wadlGeneratorDescription> </wadlGenerators> </configuration> </plugin> </plugins> </build> ``` Pay attention to the `baseUri` and `packagesResourceConfig` elements. You have to change them to reflect your project's configuration. You may also want to change the plugin's version (I used 1.17). 2. Create a /doc folder and add some files. =========================================== Create the `src/main/doc/` folder and create the two files below. File: **application-doc.xml** Content: ```xml <?xml version="1.0" encoding="UTF-8"?> <applicationDocs targetNamespace="http://wadl.dev.java.net/2009/02"> <doc xml:lang="en" title="A message in the WADL">This is added to the start of the generated application.wadl</doc> </applicationDocs> ``` File: **application-grammars.xml** Content: ```xml <?xml version="1.0" encoding="UTF-8" ?> <grammars xmlns="http://wadl.dev.java.net/2009/02" /> ``` 3. Run the maven command. ========================= Go to the project folder and run the following command: ``` $ mvn compile com.sun.jersey.contribs:maven-wadl-plugin:generate ``` The files `\target\classes\application.wadl` (the WADL itself) and `\target\classes\xsd0.xsd` (the schema of the resources - it's used by the application.wadl) should be generated. Edit and use them as you wish. PS.: Bear in mind that this is a very simple use of the maven-wadl-plugin. It can do a lot more. To know it better, please refer to the zip file in <http://search.maven.org/remotecontent?filepath=com/sun/jersey/samples/generate-wadl/1.12/generate-wadl-1.12-project.zip>
we can generate a wadl with the help of maven project with POM.XML <https://issues.jboss.org/browse/RESTEASY-166> check the comments here..!!
5,301,744
I need to get WADL file for RESTful service. I know that in case using jersey it's available as `http://localhost:8080/application.wadl`. But I use RESTeasy. Can I do the same in my framework case?
2011/03/14
[ "https://Stackoverflow.com/questions/5301744", "https://Stackoverflow.com", "https://Stackoverflow.com/users/608818/" ]
Latest versions: ================ Quoting [Chapter 49. RESTEasy WADL Support](http://docs.jboss.org/resteasy/docs/3.1.4.Final/userguide/html_single/index.html#WADL): > > Chapter 49. RESTEasy WADL Support > ================================= > > > [49.1. RESTEasy WADL Support for Servlet Container](http://docs.jboss.org/resteasy/docs/3.1.4.Final/userguide/html_single/index.html#d4e2321) > > [49.2. RESTEasy WADL support for Sun JDK HTTP Server](http://docs.jboss.org/resteasy/docs/3.1.4.Final/userguide/html_single/index.html#d4e2327) > > [49.3. RESTEasy WADL support for Netty Container](http://docs.jboss.org/resteasy/docs/3.1.4.Final/userguide/html_single/index.html#d4e2337) > > [49.4. RESTEasy WADL Support for Undertow Container](http://docs.jboss.org/resteasy/docs/3.1.4.Final/userguide/html_single/index.html#d4e2342) > > > RESTEasy has its own support to generate WADL for its resources, and it supports several different containers. The following text will show you how to use this feature in different containers. > > > ### 49.1. RESTEasy WADL Support for Servlet Container > > > RESTEasy WADL uses `ResteasyWadlServlet` to support servlet container. It can be registered into `web.xml` to enable WADL feature. Here is an example to show the usages of `ResteasyWadlServlet` in `web.xml`: > > > > ``` > <servlet> > <servlet-name>RESTEasy WADL</servlet-name> > <servlet-class>org.jboss.resteasy.wadl.ResteasyWadlServlet</servlet-class> > </servlet> > > <servlet-mapping> > <servlet-name>RESTEasy WADL</servlet-name> > <url-pattern>/application.xml</url-pattern> > </servlet-mapping> > > ``` > > The preceding configuration in `web.xml` shows how to enable > `ResteasyWadlServlet` and mapped it to `/application.xml`. And then the > WADL can be accessed from the configured URL: > > > > ``` > /application.xml > > ``` > > --- Workaround for Older versions ============================= There is a workaround: a maven plugin called `maven-wadl-plugin` by the jersey folks that also works to generate WADL for services coded using RESTEasy. Here's how to use it. 1. Add this to your `pom.xml`: ============================== ```xml <build> <plugins> <plugin> <groupId>com.sun.jersey.contribs</groupId> <artifactId>maven-wadl-plugin</artifactId> <version>1.17</version> <executions> <execution> <id>generate</id> <goals> <goal>generate</goal> </goals> <phase>${javadoc-phase}</phase> </execution> </executions> <configuration> <wadlFile>${project.build.outputDirectory}/application.wadl </wadlFile> <formatWadlFile>true</formatWadlFile> <baseUri>http://example.com:8080/rest</baseUri> <packagesResourceConfig> <param>com.example.rs.resource</param> </packagesResourceConfig> <wadlGenerators> <wadlGeneratorDescription> <className>com.sun.jersey.server.wadl.generators.WadlGeneratorApplicationDoc </className> <properties> <property> <name>applicationDocsFile</name> <value>${basedir}/src/main/doc/application-doc.xml</value> </property> </properties> </wadlGeneratorDescription> <wadlGeneratorDescription> <className>com.sun.jersey.server.wadl.generators.WadlGeneratorGrammarsSupport </className> <properties> <property> <name>grammarsFile</name> <value>${basedir}/src/main/doc/application-grammars.xml</value> </property> </properties> </wadlGeneratorDescription> </wadlGenerators> </configuration> </plugin> </plugins> </build> ``` Pay attention to the `baseUri` and `packagesResourceConfig` elements. You have to change them to reflect your project's configuration. You may also want to change the plugin's version (I used 1.17). 2. Create a /doc folder and add some files. =========================================== Create the `src/main/doc/` folder and create the two files below. File: **application-doc.xml** Content: ```xml <?xml version="1.0" encoding="UTF-8"?> <applicationDocs targetNamespace="http://wadl.dev.java.net/2009/02"> <doc xml:lang="en" title="A message in the WADL">This is added to the start of the generated application.wadl</doc> </applicationDocs> ``` File: **application-grammars.xml** Content: ```xml <?xml version="1.0" encoding="UTF-8" ?> <grammars xmlns="http://wadl.dev.java.net/2009/02" /> ``` 3. Run the maven command. ========================= Go to the project folder and run the following command: ``` $ mvn compile com.sun.jersey.contribs:maven-wadl-plugin:generate ``` The files `\target\classes\application.wadl` (the WADL itself) and `\target\classes\xsd0.xsd` (the schema of the resources - it's used by the application.wadl) should be generated. Edit and use them as you wish. PS.: Bear in mind that this is a very simple use of the maven-wadl-plugin. It can do a lot more. To know it better, please refer to the zip file in <http://search.maven.org/remotecontent?filepath=com/sun/jersey/samples/generate-wadl/1.12/generate-wadl-1.12-project.zip>
See [RESTEasy WADL Support](http://docs.jboss.org/resteasy/docs/3.1.0.Final/userguide/html/WADL.html) (3.1.0). The snipped below is copied from there ``` <servlet> <servlet-name>RESTEasy WADL</servlet-name> <servlet-class>org.jboss.resteasy.wadl.ResteasyWadlServlet</servlet-class> </servlet> <servlet-mapping> <servlet-name>RESTEasy WADL</servlet-name> <url-pattern>/application.xml</url-pattern> </servlet-mapping> ``` This uses the `ResteasyWadlServlet` and will make the WADL accessible at `/application.xml`. *Note*: Rex and Jaskirat have already mentioned previously that [RESTEASY-166](https://issues.jboss.org/browse/RESTEASY-166) was used to manage the implementation for this feature. It seems this was completed in 3.0.14.
6,833,619
I've got a Visual Studio Setup Project that uses the **msiexec.exe** file to create an *Uninstall* item as outlined in [>> THIS <<](https://stackoverflow.com/questions/1356160) article on SO. The Installer does not run. When I launch the installer by double-clicking the *setup.exe* file, the "Please wait while setup launches" screen barely blips on the screen before I am confronted with my error. ![Error Code 2727](https://i.stack.imgur.com/q4DO9.png) The Text is (for search functions): > > The installer has encountered an unexpected error installing this package. This may indicate a problem with this package. The error code is 2727. > > > I have found a set of [MSI Error Codes](http://desktopengineer.com/msierrors), and Error Code 2727 translates to > > `The directory entry '[2]' does not exist in the Directory table`. > > > Could someone guide me towards fixing this? What should I do? **[UPDATE]** At the suggestion of [Cosmin Pirvu](https://stackoverflow.com/users/527987), I have created an error log for my installer. After looking it over, it appears my installation error could be the result of having a link to the *Not Installed* file **msiexec.exe** that I use in conjunction with my Project's `[ProductCode]` to create an *Uninstall* link. The log file shown below appears to indicate that my installation fails when the installer attempts to create a temporary file for **msiexec.exe**, then it has another failure when it tries to display the Error Icon. The file [>> install.log on Google Sites <<](http://sites.google.com/site/jp2code/home/list/install.log) is my Error Log file's output (Hint: just do a search for `Return value 3` to get to the errors). **[UPDATE 2]** I have an *Uninstall link* in the setup project that links back to the batch file `uninstall.bat` in my main project: ``` @echo off %windir%\system32\msiexec.exe /x %1 ``` The `Arguments` to the *Uninstall link* is only `[ProductCode]`, since the `/x` switch is hard coded into the batch file. **[Solution]:** The Visual Studio Installer was not creating a folder that had some required DLLs in it.
2011/07/26
[ "https://Stackoverflow.com/questions/6833619", "https://Stackoverflow.com", "https://Stackoverflow.com/users/153923/" ]
The first step should be creating an [installation log](https://stackoverflow.com/a/18755775/1115360) to see what triggers the error. From the log you posted, it seems like your MSI tries to use a directory which is not in Directory table. Are you using any merge modules or special custom actions? If so, try to determine if they try to use a directory from your package. You mentioned something about an uninstall shortcut. Can you give us more details?
Old question, I know - just wanted to add in some information that helped me with the Windows Installer project in Visual Studio 2015, in case anyone comes across this topic. I got the same error message, 2727. My issue was that I was including my source code into an "src" folder in the installation directory. When looking at the output files for the source, I noticed several files like this: \obj\Release\\TemporaryGeneratedFile\_5937a670-0e60-4077-877b-f7221da3dda1.cs Yes, it included that extra slash after Release. I had to add an exclusion (right click Source Files output -> ExcludeFilter) to exclude these files from installing. I added "\*Temporary\*" to exclude only these files. Maybe someone else can explain why these temporary files were generated, all I know is that this fixed the issue. Hopefully this will help someone else looking for this topic.
6,833,619
I've got a Visual Studio Setup Project that uses the **msiexec.exe** file to create an *Uninstall* item as outlined in [>> THIS <<](https://stackoverflow.com/questions/1356160) article on SO. The Installer does not run. When I launch the installer by double-clicking the *setup.exe* file, the "Please wait while setup launches" screen barely blips on the screen before I am confronted with my error. ![Error Code 2727](https://i.stack.imgur.com/q4DO9.png) The Text is (for search functions): > > The installer has encountered an unexpected error installing this package. This may indicate a problem with this package. The error code is 2727. > > > I have found a set of [MSI Error Codes](http://desktopengineer.com/msierrors), and Error Code 2727 translates to > > `The directory entry '[2]' does not exist in the Directory table`. > > > Could someone guide me towards fixing this? What should I do? **[UPDATE]** At the suggestion of [Cosmin Pirvu](https://stackoverflow.com/users/527987), I have created an error log for my installer. After looking it over, it appears my installation error could be the result of having a link to the *Not Installed* file **msiexec.exe** that I use in conjunction with my Project's `[ProductCode]` to create an *Uninstall* link. The log file shown below appears to indicate that my installation fails when the installer attempts to create a temporary file for **msiexec.exe**, then it has another failure when it tries to display the Error Icon. The file [>> install.log on Google Sites <<](http://sites.google.com/site/jp2code/home/list/install.log) is my Error Log file's output (Hint: just do a search for `Return value 3` to get to the errors). **[UPDATE 2]** I have an *Uninstall link* in the setup project that links back to the batch file `uninstall.bat` in my main project: ``` @echo off %windir%\system32\msiexec.exe /x %1 ``` The `Arguments` to the *Uninstall link* is only `[ProductCode]`, since the `/x` switch is hard coded into the batch file. **[Solution]:** The Visual Studio Installer was not creating a folder that had some required DLLs in it.
2011/07/26
[ "https://Stackoverflow.com/questions/6833619", "https://Stackoverflow.com", "https://Stackoverflow.com/users/153923/" ]
The first step should be creating an [installation log](https://stackoverflow.com/a/18755775/1115360) to see what triggers the error. From the log you posted, it seems like your MSI tries to use a directory which is not in Directory table. Are you using any merge modules or special custom actions? If so, try to determine if they try to use a directory from your package. You mentioned something about an uninstall shortcut. Can you give us more details?
If you remove a directory or directories from the Directory Table, This will cause an issue with other tables still using those directory variables.
6,833,619
I've got a Visual Studio Setup Project that uses the **msiexec.exe** file to create an *Uninstall* item as outlined in [>> THIS <<](https://stackoverflow.com/questions/1356160) article on SO. The Installer does not run. When I launch the installer by double-clicking the *setup.exe* file, the "Please wait while setup launches" screen barely blips on the screen before I am confronted with my error. ![Error Code 2727](https://i.stack.imgur.com/q4DO9.png) The Text is (for search functions): > > The installer has encountered an unexpected error installing this package. This may indicate a problem with this package. The error code is 2727. > > > I have found a set of [MSI Error Codes](http://desktopengineer.com/msierrors), and Error Code 2727 translates to > > `The directory entry '[2]' does not exist in the Directory table`. > > > Could someone guide me towards fixing this? What should I do? **[UPDATE]** At the suggestion of [Cosmin Pirvu](https://stackoverflow.com/users/527987), I have created an error log for my installer. After looking it over, it appears my installation error could be the result of having a link to the *Not Installed* file **msiexec.exe** that I use in conjunction with my Project's `[ProductCode]` to create an *Uninstall* link. The log file shown below appears to indicate that my installation fails when the installer attempts to create a temporary file for **msiexec.exe**, then it has another failure when it tries to display the Error Icon. The file [>> install.log on Google Sites <<](http://sites.google.com/site/jp2code/home/list/install.log) is my Error Log file's output (Hint: just do a search for `Return value 3` to get to the errors). **[UPDATE 2]** I have an *Uninstall link* in the setup project that links back to the batch file `uninstall.bat` in my main project: ``` @echo off %windir%\system32\msiexec.exe /x %1 ``` The `Arguments` to the *Uninstall link* is only `[ProductCode]`, since the `/x` switch is hard coded into the batch file. **[Solution]:** The Visual Studio Installer was not creating a folder that had some required DLLs in it.
2011/07/26
[ "https://Stackoverflow.com/questions/6833619", "https://Stackoverflow.com", "https://Stackoverflow.com/users/153923/" ]
The first step should be creating an [installation log](https://stackoverflow.com/a/18755775/1115360) to see what triggers the error. From the log you posted, it seems like your MSI tries to use a directory which is not in Directory table. Are you using any merge modules or special custom actions? If so, try to determine if they try to use a directory from your package. You mentioned something about an uninstall shortcut. Can you give us more details?
I know its a Old question, but like @Riccaforte I was having some trouble to fix this in Visual Studio 2015. What I did was just delete all my Source Files inside my Aplication Folder, and I don't know why, but it did the trick.
6,833,619
I've got a Visual Studio Setup Project that uses the **msiexec.exe** file to create an *Uninstall* item as outlined in [>> THIS <<](https://stackoverflow.com/questions/1356160) article on SO. The Installer does not run. When I launch the installer by double-clicking the *setup.exe* file, the "Please wait while setup launches" screen barely blips on the screen before I am confronted with my error. ![Error Code 2727](https://i.stack.imgur.com/q4DO9.png) The Text is (for search functions): > > The installer has encountered an unexpected error installing this package. This may indicate a problem with this package. The error code is 2727. > > > I have found a set of [MSI Error Codes](http://desktopengineer.com/msierrors), and Error Code 2727 translates to > > `The directory entry '[2]' does not exist in the Directory table`. > > > Could someone guide me towards fixing this? What should I do? **[UPDATE]** At the suggestion of [Cosmin Pirvu](https://stackoverflow.com/users/527987), I have created an error log for my installer. After looking it over, it appears my installation error could be the result of having a link to the *Not Installed* file **msiexec.exe** that I use in conjunction with my Project's `[ProductCode]` to create an *Uninstall* link. The log file shown below appears to indicate that my installation fails when the installer attempts to create a temporary file for **msiexec.exe**, then it has another failure when it tries to display the Error Icon. The file [>> install.log on Google Sites <<](http://sites.google.com/site/jp2code/home/list/install.log) is my Error Log file's output (Hint: just do a search for `Return value 3` to get to the errors). **[UPDATE 2]** I have an *Uninstall link* in the setup project that links back to the batch file `uninstall.bat` in my main project: ``` @echo off %windir%\system32\msiexec.exe /x %1 ``` The `Arguments` to the *Uninstall link* is only `[ProductCode]`, since the `/x` switch is hard coded into the batch file. **[Solution]:** The Visual Studio Installer was not creating a folder that had some required DLLs in it.
2011/07/26
[ "https://Stackoverflow.com/questions/6833619", "https://Stackoverflow.com", "https://Stackoverflow.com/users/153923/" ]
The first step should be creating an [installation log](https://stackoverflow.com/a/18755775/1115360) to see what triggers the error. From the log you posted, it seems like your MSI tries to use a directory which is not in Directory table. Are you using any merge modules or special custom actions? If so, try to determine if they try to use a directory from your package. You mentioned something about an uninstall shortcut. Can you give us more details?
My 2727 error message was the result of a \*.png file I had added as a link to my project. "Copy to Output Directory" was set to "Copy if newer". Somehow the Visual Studio Setup Project was not able to resolve the path to the \*.png file and added an invalid path to the installer. LessMSI helped to find the problem <https://lessmsi.activescott.com/> and removing the link in the project and adding the files in the installer project solved the problem. Hope someone finds this helpful regards
6,833,619
I've got a Visual Studio Setup Project that uses the **msiexec.exe** file to create an *Uninstall* item as outlined in [>> THIS <<](https://stackoverflow.com/questions/1356160) article on SO. The Installer does not run. When I launch the installer by double-clicking the *setup.exe* file, the "Please wait while setup launches" screen barely blips on the screen before I am confronted with my error. ![Error Code 2727](https://i.stack.imgur.com/q4DO9.png) The Text is (for search functions): > > The installer has encountered an unexpected error installing this package. This may indicate a problem with this package. The error code is 2727. > > > I have found a set of [MSI Error Codes](http://desktopengineer.com/msierrors), and Error Code 2727 translates to > > `The directory entry '[2]' does not exist in the Directory table`. > > > Could someone guide me towards fixing this? What should I do? **[UPDATE]** At the suggestion of [Cosmin Pirvu](https://stackoverflow.com/users/527987), I have created an error log for my installer. After looking it over, it appears my installation error could be the result of having a link to the *Not Installed* file **msiexec.exe** that I use in conjunction with my Project's `[ProductCode]` to create an *Uninstall* link. The log file shown below appears to indicate that my installation fails when the installer attempts to create a temporary file for **msiexec.exe**, then it has another failure when it tries to display the Error Icon. The file [>> install.log on Google Sites <<](http://sites.google.com/site/jp2code/home/list/install.log) is my Error Log file's output (Hint: just do a search for `Return value 3` to get to the errors). **[UPDATE 2]** I have an *Uninstall link* in the setup project that links back to the batch file `uninstall.bat` in my main project: ``` @echo off %windir%\system32\msiexec.exe /x %1 ``` The `Arguments` to the *Uninstall link* is only `[ProductCode]`, since the `/x` switch is hard coded into the batch file. **[Solution]:** The Visual Studio Installer was not creating a folder that had some required DLLs in it.
2011/07/26
[ "https://Stackoverflow.com/questions/6833619", "https://Stackoverflow.com", "https://Stackoverflow.com/users/153923/" ]
Old question, I know - just wanted to add in some information that helped me with the Windows Installer project in Visual Studio 2015, in case anyone comes across this topic. I got the same error message, 2727. My issue was that I was including my source code into an "src" folder in the installation directory. When looking at the output files for the source, I noticed several files like this: \obj\Release\\TemporaryGeneratedFile\_5937a670-0e60-4077-877b-f7221da3dda1.cs Yes, it included that extra slash after Release. I had to add an exclusion (right click Source Files output -> ExcludeFilter) to exclude these files from installing. I added "\*Temporary\*" to exclude only these files. Maybe someone else can explain why these temporary files were generated, all I know is that this fixed the issue. Hopefully this will help someone else looking for this topic.
If you remove a directory or directories from the Directory Table, This will cause an issue with other tables still using those directory variables.
6,833,619
I've got a Visual Studio Setup Project that uses the **msiexec.exe** file to create an *Uninstall* item as outlined in [>> THIS <<](https://stackoverflow.com/questions/1356160) article on SO. The Installer does not run. When I launch the installer by double-clicking the *setup.exe* file, the "Please wait while setup launches" screen barely blips on the screen before I am confronted with my error. ![Error Code 2727](https://i.stack.imgur.com/q4DO9.png) The Text is (for search functions): > > The installer has encountered an unexpected error installing this package. This may indicate a problem with this package. The error code is 2727. > > > I have found a set of [MSI Error Codes](http://desktopengineer.com/msierrors), and Error Code 2727 translates to > > `The directory entry '[2]' does not exist in the Directory table`. > > > Could someone guide me towards fixing this? What should I do? **[UPDATE]** At the suggestion of [Cosmin Pirvu](https://stackoverflow.com/users/527987), I have created an error log for my installer. After looking it over, it appears my installation error could be the result of having a link to the *Not Installed* file **msiexec.exe** that I use in conjunction with my Project's `[ProductCode]` to create an *Uninstall* link. The log file shown below appears to indicate that my installation fails when the installer attempts to create a temporary file for **msiexec.exe**, then it has another failure when it tries to display the Error Icon. The file [>> install.log on Google Sites <<](http://sites.google.com/site/jp2code/home/list/install.log) is my Error Log file's output (Hint: just do a search for `Return value 3` to get to the errors). **[UPDATE 2]** I have an *Uninstall link* in the setup project that links back to the batch file `uninstall.bat` in my main project: ``` @echo off %windir%\system32\msiexec.exe /x %1 ``` The `Arguments` to the *Uninstall link* is only `[ProductCode]`, since the `/x` switch is hard coded into the batch file. **[Solution]:** The Visual Studio Installer was not creating a folder that had some required DLLs in it.
2011/07/26
[ "https://Stackoverflow.com/questions/6833619", "https://Stackoverflow.com", "https://Stackoverflow.com/users/153923/" ]
Old question, I know - just wanted to add in some information that helped me with the Windows Installer project in Visual Studio 2015, in case anyone comes across this topic. I got the same error message, 2727. My issue was that I was including my source code into an "src" folder in the installation directory. When looking at the output files for the source, I noticed several files like this: \obj\Release\\TemporaryGeneratedFile\_5937a670-0e60-4077-877b-f7221da3dda1.cs Yes, it included that extra slash after Release. I had to add an exclusion (right click Source Files output -> ExcludeFilter) to exclude these files from installing. I added "\*Temporary\*" to exclude only these files. Maybe someone else can explain why these temporary files were generated, all I know is that this fixed the issue. Hopefully this will help someone else looking for this topic.
My 2727 error message was the result of a \*.png file I had added as a link to my project. "Copy to Output Directory" was set to "Copy if newer". Somehow the Visual Studio Setup Project was not able to resolve the path to the \*.png file and added an invalid path to the installer. LessMSI helped to find the problem <https://lessmsi.activescott.com/> and removing the link in the project and adding the files in the installer project solved the problem. Hope someone finds this helpful regards
6,833,619
I've got a Visual Studio Setup Project that uses the **msiexec.exe** file to create an *Uninstall* item as outlined in [>> THIS <<](https://stackoverflow.com/questions/1356160) article on SO. The Installer does not run. When I launch the installer by double-clicking the *setup.exe* file, the "Please wait while setup launches" screen barely blips on the screen before I am confronted with my error. ![Error Code 2727](https://i.stack.imgur.com/q4DO9.png) The Text is (for search functions): > > The installer has encountered an unexpected error installing this package. This may indicate a problem with this package. The error code is 2727. > > > I have found a set of [MSI Error Codes](http://desktopengineer.com/msierrors), and Error Code 2727 translates to > > `The directory entry '[2]' does not exist in the Directory table`. > > > Could someone guide me towards fixing this? What should I do? **[UPDATE]** At the suggestion of [Cosmin Pirvu](https://stackoverflow.com/users/527987), I have created an error log for my installer. After looking it over, it appears my installation error could be the result of having a link to the *Not Installed* file **msiexec.exe** that I use in conjunction with my Project's `[ProductCode]` to create an *Uninstall* link. The log file shown below appears to indicate that my installation fails when the installer attempts to create a temporary file for **msiexec.exe**, then it has another failure when it tries to display the Error Icon. The file [>> install.log on Google Sites <<](http://sites.google.com/site/jp2code/home/list/install.log) is my Error Log file's output (Hint: just do a search for `Return value 3` to get to the errors). **[UPDATE 2]** I have an *Uninstall link* in the setup project that links back to the batch file `uninstall.bat` in my main project: ``` @echo off %windir%\system32\msiexec.exe /x %1 ``` The `Arguments` to the *Uninstall link* is only `[ProductCode]`, since the `/x` switch is hard coded into the batch file. **[Solution]:** The Visual Studio Installer was not creating a folder that had some required DLLs in it.
2011/07/26
[ "https://Stackoverflow.com/questions/6833619", "https://Stackoverflow.com", "https://Stackoverflow.com/users/153923/" ]
I know its a Old question, but like @Riccaforte I was having some trouble to fix this in Visual Studio 2015. What I did was just delete all my Source Files inside my Aplication Folder, and I don't know why, but it did the trick.
If you remove a directory or directories from the Directory Table, This will cause an issue with other tables still using those directory variables.
6,833,619
I've got a Visual Studio Setup Project that uses the **msiexec.exe** file to create an *Uninstall* item as outlined in [>> THIS <<](https://stackoverflow.com/questions/1356160) article on SO. The Installer does not run. When I launch the installer by double-clicking the *setup.exe* file, the "Please wait while setup launches" screen barely blips on the screen before I am confronted with my error. ![Error Code 2727](https://i.stack.imgur.com/q4DO9.png) The Text is (for search functions): > > The installer has encountered an unexpected error installing this package. This may indicate a problem with this package. The error code is 2727. > > > I have found a set of [MSI Error Codes](http://desktopengineer.com/msierrors), and Error Code 2727 translates to > > `The directory entry '[2]' does not exist in the Directory table`. > > > Could someone guide me towards fixing this? What should I do? **[UPDATE]** At the suggestion of [Cosmin Pirvu](https://stackoverflow.com/users/527987), I have created an error log for my installer. After looking it over, it appears my installation error could be the result of having a link to the *Not Installed* file **msiexec.exe** that I use in conjunction with my Project's `[ProductCode]` to create an *Uninstall* link. The log file shown below appears to indicate that my installation fails when the installer attempts to create a temporary file for **msiexec.exe**, then it has another failure when it tries to display the Error Icon. The file [>> install.log on Google Sites <<](http://sites.google.com/site/jp2code/home/list/install.log) is my Error Log file's output (Hint: just do a search for `Return value 3` to get to the errors). **[UPDATE 2]** I have an *Uninstall link* in the setup project that links back to the batch file `uninstall.bat` in my main project: ``` @echo off %windir%\system32\msiexec.exe /x %1 ``` The `Arguments` to the *Uninstall link* is only `[ProductCode]`, since the `/x` switch is hard coded into the batch file. **[Solution]:** The Visual Studio Installer was not creating a folder that had some required DLLs in it.
2011/07/26
[ "https://Stackoverflow.com/questions/6833619", "https://Stackoverflow.com", "https://Stackoverflow.com/users/153923/" ]
If you remove a directory or directories from the Directory Table, This will cause an issue with other tables still using those directory variables.
My 2727 error message was the result of a \*.png file I had added as a link to my project. "Copy to Output Directory" was set to "Copy if newer". Somehow the Visual Studio Setup Project was not able to resolve the path to the \*.png file and added an invalid path to the installer. LessMSI helped to find the problem <https://lessmsi.activescott.com/> and removing the link in the project and adding the files in the installer project solved the problem. Hope someone finds this helpful regards
6,833,619
I've got a Visual Studio Setup Project that uses the **msiexec.exe** file to create an *Uninstall* item as outlined in [>> THIS <<](https://stackoverflow.com/questions/1356160) article on SO. The Installer does not run. When I launch the installer by double-clicking the *setup.exe* file, the "Please wait while setup launches" screen barely blips on the screen before I am confronted with my error. ![Error Code 2727](https://i.stack.imgur.com/q4DO9.png) The Text is (for search functions): > > The installer has encountered an unexpected error installing this package. This may indicate a problem with this package. The error code is 2727. > > > I have found a set of [MSI Error Codes](http://desktopengineer.com/msierrors), and Error Code 2727 translates to > > `The directory entry '[2]' does not exist in the Directory table`. > > > Could someone guide me towards fixing this? What should I do? **[UPDATE]** At the suggestion of [Cosmin Pirvu](https://stackoverflow.com/users/527987), I have created an error log for my installer. After looking it over, it appears my installation error could be the result of having a link to the *Not Installed* file **msiexec.exe** that I use in conjunction with my Project's `[ProductCode]` to create an *Uninstall* link. The log file shown below appears to indicate that my installation fails when the installer attempts to create a temporary file for **msiexec.exe**, then it has another failure when it tries to display the Error Icon. The file [>> install.log on Google Sites <<](http://sites.google.com/site/jp2code/home/list/install.log) is my Error Log file's output (Hint: just do a search for `Return value 3` to get to the errors). **[UPDATE 2]** I have an *Uninstall link* in the setup project that links back to the batch file `uninstall.bat` in my main project: ``` @echo off %windir%\system32\msiexec.exe /x %1 ``` The `Arguments` to the *Uninstall link* is only `[ProductCode]`, since the `/x` switch is hard coded into the batch file. **[Solution]:** The Visual Studio Installer was not creating a folder that had some required DLLs in it.
2011/07/26
[ "https://Stackoverflow.com/questions/6833619", "https://Stackoverflow.com", "https://Stackoverflow.com/users/153923/" ]
I know its a Old question, but like @Riccaforte I was having some trouble to fix this in Visual Studio 2015. What I did was just delete all my Source Files inside my Aplication Folder, and I don't know why, but it did the trick.
My 2727 error message was the result of a \*.png file I had added as a link to my project. "Copy to Output Directory" was set to "Copy if newer". Somehow the Visual Studio Setup Project was not able to resolve the path to the \*.png file and added an invalid path to the installer. LessMSI helped to find the problem <https://lessmsi.activescott.com/> and removing the link in the project and adding the files in the installer project solved the problem. Hope someone finds this helpful regards
1,281,654
This is the error I am getting: ``` Syntax error near 'online' in the full-text search condition '""online"*" and "and*" and ""text"*"'. ``` This is my stored procedure: ``` ALTER PROCEDURE dbo.StoredProcedure1 ( @text varchar(1000)=null ) AS SET NOCOUNT ON declare @whereclause varchar(1000) SET @whereclause = @text SELECT articles.ArticleID AS linkid, articles.abstract as descriptiontext, articles.title as title, 'article' as source, articles.releasedate as lasteditdate FROM articles WHERE CONTAINS(title, @whereclause) ORDER BY lasteditdate DESC, source ASC ``` This what i pass to SP: ``` string content = "\"online\" and \"text\""; ``` part of C# code: ``` using (SqlConnection cn = new SqlConnection(this.ConnectionString)) { SqlCommand cmd = new SqlCommand("StoredProcedure1", cn); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add("@text", SqlDbType.VarChar).Value = searchExpression; cn.Open(); ``` **UPDATE:** Strings that i try and errors that i get: ``` content = "online text"; Syntax error near 'text' in the full-text search condition 'online text'. content = "\"online\" and \"text\""; Syntax error near 'online' in the full-text search condition '""online"*" and "and*" and ""text"*"'. content = "\"online and text\""; Syntax error near 'online*' in the full-text search condition '""online*" and "and*" and "text"*"'. ```
2009/08/15
[ "https://Stackoverflow.com/questions/1281654", "https://Stackoverflow.com", "https://Stackoverflow.com/users/108440/" ]
From msdn: Specifies the text to search for in column\_name and the conditions for a match. is nvarchar. An implicit conversion occurs when another character data type is used as input. Because "parameter sniffing" does not work across conversion, use nvarchar for better performance. So i've changed everything to nvarchar: ``` cmd.Parameters.Add("@text", SqlDbType.NVarChar).Value = searchExpression; declare @whereclause nvarchar(1000) ```
Try this one in your c# code when adding parameter: ``` cmd.Parameters.Add("@text", searchExpression); ```
1,281,654
This is the error I am getting: ``` Syntax error near 'online' in the full-text search condition '""online"*" and "and*" and ""text"*"'. ``` This is my stored procedure: ``` ALTER PROCEDURE dbo.StoredProcedure1 ( @text varchar(1000)=null ) AS SET NOCOUNT ON declare @whereclause varchar(1000) SET @whereclause = @text SELECT articles.ArticleID AS linkid, articles.abstract as descriptiontext, articles.title as title, 'article' as source, articles.releasedate as lasteditdate FROM articles WHERE CONTAINS(title, @whereclause) ORDER BY lasteditdate DESC, source ASC ``` This what i pass to SP: ``` string content = "\"online\" and \"text\""; ``` part of C# code: ``` using (SqlConnection cn = new SqlConnection(this.ConnectionString)) { SqlCommand cmd = new SqlCommand("StoredProcedure1", cn); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add("@text", SqlDbType.VarChar).Value = searchExpression; cn.Open(); ``` **UPDATE:** Strings that i try and errors that i get: ``` content = "online text"; Syntax error near 'text' in the full-text search condition 'online text'. content = "\"online\" and \"text\""; Syntax error near 'online' in the full-text search condition '""online"*" and "and*" and ""text"*"'. content = "\"online and text\""; Syntax error near 'online*' in the full-text search condition '""online*" and "and*" and "text"*"'. ```
2009/08/15
[ "https://Stackoverflow.com/questions/1281654", "https://Stackoverflow.com", "https://Stackoverflow.com/users/108440/" ]
From msdn: Specifies the text to search for in column\_name and the conditions for a match. is nvarchar. An implicit conversion occurs when another character data type is used as input. Because "parameter sniffing" does not work across conversion, use nvarchar for better performance. So i've changed everything to nvarchar: ``` cmd.Parameters.Add("@text", SqlDbType.NVarChar).Value = searchExpression; declare @whereclause nvarchar(1000) ```
I think SQl uses % instead of \*
1,281,654
This is the error I am getting: ``` Syntax error near 'online' in the full-text search condition '""online"*" and "and*" and ""text"*"'. ``` This is my stored procedure: ``` ALTER PROCEDURE dbo.StoredProcedure1 ( @text varchar(1000)=null ) AS SET NOCOUNT ON declare @whereclause varchar(1000) SET @whereclause = @text SELECT articles.ArticleID AS linkid, articles.abstract as descriptiontext, articles.title as title, 'article' as source, articles.releasedate as lasteditdate FROM articles WHERE CONTAINS(title, @whereclause) ORDER BY lasteditdate DESC, source ASC ``` This what i pass to SP: ``` string content = "\"online\" and \"text\""; ``` part of C# code: ``` using (SqlConnection cn = new SqlConnection(this.ConnectionString)) { SqlCommand cmd = new SqlCommand("StoredProcedure1", cn); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add("@text", SqlDbType.VarChar).Value = searchExpression; cn.Open(); ``` **UPDATE:** Strings that i try and errors that i get: ``` content = "online text"; Syntax error near 'text' in the full-text search condition 'online text'. content = "\"online\" and \"text\""; Syntax error near 'online' in the full-text search condition '""online"*" and "and*" and ""text"*"'. content = "\"online and text\""; Syntax error near 'online*' in the full-text search condition '""online*" and "and*" and "text"*"'. ```
2009/08/15
[ "https://Stackoverflow.com/questions/1281654", "https://Stackoverflow.com", "https://Stackoverflow.com/users/108440/" ]
From msdn: Specifies the text to search for in column\_name and the conditions for a match. is nvarchar. An implicit conversion occurs when another character data type is used as input. Because "parameter sniffing" does not work across conversion, use nvarchar for better performance. So i've changed everything to nvarchar: ``` cmd.Parameters.Add("@text", SqlDbType.NVarChar).Value = searchExpression; declare @whereclause nvarchar(1000) ```
The problem is with the extra quotation marks. Instead of this: ``` string content = "\"online\" and \"text\""; ``` try this: ``` string content = "online and text"; ``` It will generate a correct condition: ``` '"online*" and "and*" and "text*"' ``` Also if accept user input and pass it directly into a query like this - you are really opening your application to SQL injection.
1,281,654
This is the error I am getting: ``` Syntax error near 'online' in the full-text search condition '""online"*" and "and*" and ""text"*"'. ``` This is my stored procedure: ``` ALTER PROCEDURE dbo.StoredProcedure1 ( @text varchar(1000)=null ) AS SET NOCOUNT ON declare @whereclause varchar(1000) SET @whereclause = @text SELECT articles.ArticleID AS linkid, articles.abstract as descriptiontext, articles.title as title, 'article' as source, articles.releasedate as lasteditdate FROM articles WHERE CONTAINS(title, @whereclause) ORDER BY lasteditdate DESC, source ASC ``` This what i pass to SP: ``` string content = "\"online\" and \"text\""; ``` part of C# code: ``` using (SqlConnection cn = new SqlConnection(this.ConnectionString)) { SqlCommand cmd = new SqlCommand("StoredProcedure1", cn); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add("@text", SqlDbType.VarChar).Value = searchExpression; cn.Open(); ``` **UPDATE:** Strings that i try and errors that i get: ``` content = "online text"; Syntax error near 'text' in the full-text search condition 'online text'. content = "\"online\" and \"text\""; Syntax error near 'online' in the full-text search condition '""online"*" and "and*" and ""text"*"'. content = "\"online and text\""; Syntax error near 'online*' in the full-text search condition '""online*" and "and*" and "text"*"'. ```
2009/08/15
[ "https://Stackoverflow.com/questions/1281654", "https://Stackoverflow.com", "https://Stackoverflow.com/users/108440/" ]
From msdn: Specifies the text to search for in column\_name and the conditions for a match. is nvarchar. An implicit conversion occurs when another character data type is used as input. Because "parameter sniffing" does not work across conversion, use nvarchar for better performance. So i've changed everything to nvarchar: ``` cmd.Parameters.Add("@text", SqlDbType.NVarChar).Value = searchExpression; declare @whereclause nvarchar(1000) ```
Not sure if it's significant, but your procedure is expecting varchar and your calling code is saying the parameter is SqlDbType.Char. I'm quite fond of DeriveParameters : ``` SqlCommand cmd = new SqlCommand("StoredProcedure1", cn); cmd.CommandType = CommandType.StoredProcedure; cn.Open() SqlCommandBuilder.DeriveParameters cmd; cmd.Parameters("@text").Value = searchExpression; ```
1,281,654
This is the error I am getting: ``` Syntax error near 'online' in the full-text search condition '""online"*" and "and*" and ""text"*"'. ``` This is my stored procedure: ``` ALTER PROCEDURE dbo.StoredProcedure1 ( @text varchar(1000)=null ) AS SET NOCOUNT ON declare @whereclause varchar(1000) SET @whereclause = @text SELECT articles.ArticleID AS linkid, articles.abstract as descriptiontext, articles.title as title, 'article' as source, articles.releasedate as lasteditdate FROM articles WHERE CONTAINS(title, @whereclause) ORDER BY lasteditdate DESC, source ASC ``` This what i pass to SP: ``` string content = "\"online\" and \"text\""; ``` part of C# code: ``` using (SqlConnection cn = new SqlConnection(this.ConnectionString)) { SqlCommand cmd = new SqlCommand("StoredProcedure1", cn); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add("@text", SqlDbType.VarChar).Value = searchExpression; cn.Open(); ``` **UPDATE:** Strings that i try and errors that i get: ``` content = "online text"; Syntax error near 'text' in the full-text search condition 'online text'. content = "\"online\" and \"text\""; Syntax error near 'online' in the full-text search condition '""online"*" and "and*" and ""text"*"'. content = "\"online and text\""; Syntax error near 'online*' in the full-text search condition '""online*" and "and*" and "text"*"'. ```
2009/08/15
[ "https://Stackoverflow.com/questions/1281654", "https://Stackoverflow.com", "https://Stackoverflow.com/users/108440/" ]
From msdn: Specifies the text to search for in column\_name and the conditions for a match. is nvarchar. An implicit conversion occurs when another character data type is used as input. Because "parameter sniffing" does not work across conversion, use nvarchar for better performance. So i've changed everything to nvarchar: ``` cmd.Parameters.Add("@text", SqlDbType.NVarChar).Value = searchExpression; declare @whereclause nvarchar(1000) ```
I use this method to remove slashes and then pass the resulting char array to sp. ``` public static char[] RemoveBackslash(string value) { char[] c = value.ToCharArray(); return Array.FindAll(c, val => val != 39).ToArray(); } string content = "'\"online\" and \"text\"'"; Sqlparam = new SqlParameter("@search", SqlDbType.NVarChar); Sqlparam.Value = RemoveBackslash(content); Sqlcomm.Parameters.Add(Sqlparam); ```
36,329,080
``` $st = $this->db->prepare("SELECT * FROM users WHERE id=? ORDER BY id ASC"); $st->execute(array($id)); if($st->rowCount() >= 1){ foreach ($st as $row) { echo $row["exp"]."+"; } } ``` So what I've tried is to echo `$row["exp"]."+";` to simply add in a loop, but it just print it out. How can I fix?
2016/03/31
[ "https://Stackoverflow.com/questions/36329080", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4929804/" ]
On the second run, T2 "wakes up too late" and T1 already incremented i to 10, so T2 will not enter the while loop. I think the first run is the weird one to be honest.
Suppose `T1 and T2` runs at the same time, during `t1.start();` and `t2.start()`, at this time `i = 0`, `T1` sleeps and `T2` sleeps, `T1` wakes and proceeds to check if i < 10, prints out 1-9, however `T2` wakes but still not run by the JVM, know that once a thread exits the sleep state does not necessary mean it will immediately run. Once `T2` runs, i is still 0, it checks if it is < 10, which it is so it prints out 0, it then amends the plus 1 however `i` has already changed value, and results in to 11. hence does not print anymore Second run, T1 finishes before T2 executes and i is already 10. There is no guarantees on when threads actually run.
36,329,080
``` $st = $this->db->prepare("SELECT * FROM users WHERE id=? ORDER BY id ASC"); $st->execute(array($id)); if($st->rowCount() >= 1){ foreach ($st as $row) { echo $row["exp"]."+"; } } ``` So what I've tried is to echo `$row["exp"]."+";` to simply add in a loop, but it just print it out. How can I fix?
2016/03/31
[ "https://Stackoverflow.com/questions/36329080", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4929804/" ]
In addition to [@Gunner](https://stackoverflow.com/users/5259945/gunner) and [@mel3kings](https://stackoverflow.com/users/2023728/mel3kings) Actually threads running parallel to each other and OS may allow one thread more time instead next one. Scenario 1; ``` loop Thread1 Thread2 t1 sleep sleep t2 started to loop started the loop t4 print 0 print 1 t5 print 2 print 3 t6 print 4 print 5 t7 print 6 print 7 t8 print 8 print 9 t9 print 10 exit to loop ``` Scenario 2 ``` loop Thread1 Thread2 t1 sleep sleep t2 started to loop t4 print 0 t5 print 1 t6 print 2 t7 print 3 t8 print 4 started loop t9 .................................. ``` Scenario 3 (Also possible) ``` loop Thread1 Thread2 t1 sleep sleep t2 started to loop started loop t3 print 0 send i to print t4 print 1 t5 print 2 t6 print 3 t7 print 4 t8 print 5 t9 print 6 t10 print 7 t11 print 8 t12 print 9 t13 exit print 0 (delay of console output may cause that) ``` Also there are other output scenarios. Anyway to see its details try below code with thread names and see which thread print each output ``` public class Th1 implements Runnable { private int i = 0; public void run() { String name = Thread.currentThread().getName(); try { Thread.sleep(1000); } catch (InterruptedException ex) { } while (i < 10) { System.out.println(name + ": " + i); i += 1; } } public static void main(String[] args) { Th1 t = new Th1(); Thread t1 = new Thread(t); Thread t2 = new Thread(t); t1.start(); t2.start(); } } ``` Output ``` Thread-1: 0 Thread-1: 1 Thread-1: 2 Thread-0: 0 //last zero may comes from here but print order is about console Thread-1: 3 Thread-1: 4 Thread-1: 5 Thread-1: 6 Thread-1: 7 Thread-1: 8 Thread-1: 9 ```
Suppose `T1 and T2` runs at the same time, during `t1.start();` and `t2.start()`, at this time `i = 0`, `T1` sleeps and `T2` sleeps, `T1` wakes and proceeds to check if i < 10, prints out 1-9, however `T2` wakes but still not run by the JVM, know that once a thread exits the sleep state does not necessary mean it will immediately run. Once `T2` runs, i is still 0, it checks if it is < 10, which it is so it prints out 0, it then amends the plus 1 however `i` has already changed value, and results in to 11. hence does not print anymore Second run, T1 finishes before T2 executes and i is already 10. There is no guarantees on when threads actually run.
36,329,080
``` $st = $this->db->prepare("SELECT * FROM users WHERE id=? ORDER BY id ASC"); $st->execute(array($id)); if($st->rowCount() >= 1){ foreach ($st as $row) { echo $row["exp"]."+"; } } ``` So what I've tried is to echo `$row["exp"]."+";` to simply add in a loop, but it just print it out. How can I fix?
2016/03/31
[ "https://Stackoverflow.com/questions/36329080", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4929804/" ]
In addition to [@Gunner](https://stackoverflow.com/users/5259945/gunner) and [@mel3kings](https://stackoverflow.com/users/2023728/mel3kings) Actually threads running parallel to each other and OS may allow one thread more time instead next one. Scenario 1; ``` loop Thread1 Thread2 t1 sleep sleep t2 started to loop started the loop t4 print 0 print 1 t5 print 2 print 3 t6 print 4 print 5 t7 print 6 print 7 t8 print 8 print 9 t9 print 10 exit to loop ``` Scenario 2 ``` loop Thread1 Thread2 t1 sleep sleep t2 started to loop t4 print 0 t5 print 1 t6 print 2 t7 print 3 t8 print 4 started loop t9 .................................. ``` Scenario 3 (Also possible) ``` loop Thread1 Thread2 t1 sleep sleep t2 started to loop started loop t3 print 0 send i to print t4 print 1 t5 print 2 t6 print 3 t7 print 4 t8 print 5 t9 print 6 t10 print 7 t11 print 8 t12 print 9 t13 exit print 0 (delay of console output may cause that) ``` Also there are other output scenarios. Anyway to see its details try below code with thread names and see which thread print each output ``` public class Th1 implements Runnable { private int i = 0; public void run() { String name = Thread.currentThread().getName(); try { Thread.sleep(1000); } catch (InterruptedException ex) { } while (i < 10) { System.out.println(name + ": " + i); i += 1; } } public static void main(String[] args) { Th1 t = new Th1(); Thread t1 = new Thread(t); Thread t2 = new Thread(t); t1.start(); t2.start(); } } ``` Output ``` Thread-1: 0 Thread-1: 1 Thread-1: 2 Thread-0: 0 //last zero may comes from here but print order is about console Thread-1: 3 Thread-1: 4 Thread-1: 5 Thread-1: 6 Thread-1: 7 Thread-1: 8 Thread-1: 9 ```
On the second run, T2 "wakes up too late" and T1 already incremented i to 10, so T2 will not enter the while loop. I think the first run is the weird one to be honest.
12,895,816
I'm currently working on a big project and I need to use `weak_ptr` instead of `shared_ptr`. Here is my problem. I have a class named House with an attribute: `vector<boost::shared_ptr<People>> my_people`. I want to modify this data member to be `vector<boost::weak_ptr<People>> my_people`. My getter was ``` vector<boost::shared_ptr<People>>& getPeople() const { return my_people; } ``` Normally, with a simple `weak_ptr` I can return `my_people.lock();` But I have a vector and I don't know how to do something like this: ``` vector<boost::shared_ptr<People>>& getPeople() const { for( vector<boost::weak_ptr<People>::iterator it = my_people.begin(); it != my_people.end(); ++it) { (*it).lock(); } return my_people; } ``` In other words, I want to return my vector of `weak_ptr` but as a vector of `shared_ptr`. Is it possible? Or do I have to return a vector of `weak_ptr` and use `lock()` everywhere I use them?
2012/10/15
[ "https://Stackoverflow.com/questions/12895816", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1747056/" ]
What about: ``` vector<boost::shared_ptr<People>> getPeople() const { vector<boost::shared_ptr<People>> res; for( vector<boost::weak_ptr<People>::iterator it = my_people.begin(); it != my_people.end(); ++it) res.push_back(it->lock()); return res; } ``` Also, you can filter out the null pointers, if you want. Of course, you cannot return a reference to a local variable so you have to return a copy. You may want to do instead: ``` void getPeople(vector<boost::shared_ptr<People>> &res) const { for( vector<boost::weak_ptr<People>::iterator it = my_people.begin(); it != my_people.end(); ++it) res.push_back(it->lock()); } ``` to avoid copying the return vector.
Note that `vector<weak_ptr<T> >` and `vector<shared_ptr<T> >` are two completely different types. However, you can write a function that accepts the former and returns the latter: ``` template<class Ptrs, class WeakPtrs> void lockWeakPtrs(const WeakPtrs &weakPtrs, Ptrs &ptrs) { BOOST_FOREACH (typename WeakPtrs::const_reference weakPtr, weakPtrs) { typename Ptrs::value_type ptr = weakPtr.lock(); if (ptr) // if you want to drop expired weak_ptr's ptrs.insert(ptrs.end(), ptr); } } ``` Call like this: `lockWeakPtrs(myWeakVector, mySharedVector);`
12,895,816
I'm currently working on a big project and I need to use `weak_ptr` instead of `shared_ptr`. Here is my problem. I have a class named House with an attribute: `vector<boost::shared_ptr<People>> my_people`. I want to modify this data member to be `vector<boost::weak_ptr<People>> my_people`. My getter was ``` vector<boost::shared_ptr<People>>& getPeople() const { return my_people; } ``` Normally, with a simple `weak_ptr` I can return `my_people.lock();` But I have a vector and I don't know how to do something like this: ``` vector<boost::shared_ptr<People>>& getPeople() const { for( vector<boost::weak_ptr<People>::iterator it = my_people.begin(); it != my_people.end(); ++it) { (*it).lock(); } return my_people; } ``` In other words, I want to return my vector of `weak_ptr` but as a vector of `shared_ptr`. Is it possible? Or do I have to return a vector of `weak_ptr` and use `lock()` everywhere I use them?
2012/10/15
[ "https://Stackoverflow.com/questions/12895816", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1747056/" ]
Your function is a reasonable start: ``` vector<boost::shared_ptr<People>>& getPeople() const { for( vector<boost::weak_ptr<People>::iterator it = my_people.begin(); it != my_people.end(); ++it) { (*it).lock(); } return my_people; } ``` But calling `(*it).lock()` just creates a `shared_ptr` and throws it away, it doesn't change the type of the vector elements, and you can't return the vector as a different type. You need to create a vector of the right type, fill it with the shared\_ptr objects, and return it: ``` vector<boost::shared_ptr<People>> getPeople() const { vector<boost::shared_ptr<People>> people(my_people.size()); std::transform(my_people.begin(), my_people.end(), people.begin(), boost::bind(&boost::weak_ptr<People>::lock, _1)); return people; } ``` This iterates over each element of `my_people`, calls `lock()` on it, and assigns the result to the corresponding element of `people`. If you know that `my_people` never contains expired pointers it's even easier: ``` vector<boost::shared_ptr<People>> getPeople() const { vector<boost::shared_ptr<People>> people(my_people.begin(), my_people.end()); return people; } ``` This fills the `people` vector by constructing each `shared_ptr` element from a `weak_ptr` element. The difference is that this version will throw an exception if a `weak_ptr` has expired because the `shared_ptr` constructor throws if passed an expired `weak_ptr`. The version using`transform` will put an empty `shared_ptr` in the vector if an expired weak\_ptr is transformed.
What about: ``` vector<boost::shared_ptr<People>> getPeople() const { vector<boost::shared_ptr<People>> res; for( vector<boost::weak_ptr<People>::iterator it = my_people.begin(); it != my_people.end(); ++it) res.push_back(it->lock()); return res; } ``` Also, you can filter out the null pointers, if you want. Of course, you cannot return a reference to a local variable so you have to return a copy. You may want to do instead: ``` void getPeople(vector<boost::shared_ptr<People>> &res) const { for( vector<boost::weak_ptr<People>::iterator it = my_people.begin(); it != my_people.end(); ++it) res.push_back(it->lock()); } ``` to avoid copying the return vector.
12,895,816
I'm currently working on a big project and I need to use `weak_ptr` instead of `shared_ptr`. Here is my problem. I have a class named House with an attribute: `vector<boost::shared_ptr<People>> my_people`. I want to modify this data member to be `vector<boost::weak_ptr<People>> my_people`. My getter was ``` vector<boost::shared_ptr<People>>& getPeople() const { return my_people; } ``` Normally, with a simple `weak_ptr` I can return `my_people.lock();` But I have a vector and I don't know how to do something like this: ``` vector<boost::shared_ptr<People>>& getPeople() const { for( vector<boost::weak_ptr<People>::iterator it = my_people.begin(); it != my_people.end(); ++it) { (*it).lock(); } return my_people; } ``` In other words, I want to return my vector of `weak_ptr` but as a vector of `shared_ptr`. Is it possible? Or do I have to return a vector of `weak_ptr` and use `lock()` everywhere I use them?
2012/10/15
[ "https://Stackoverflow.com/questions/12895816", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1747056/" ]
You could use **[std::transform](http://www.cplusplus.com/reference/algorithm/transform/)** ``` std::vector<std::shared_ptr<People>> temp; sharedTargetList.resize(my_people.size()); //transform into a shared_ptr vector std::transform(my_people.begin(), my_people.end(), temp.begin(), [](std::weak_ptr<People> weakPtr){ return weakPtr.lock(); } ); ```
What about: ``` vector<boost::shared_ptr<People>> getPeople() const { vector<boost::shared_ptr<People>> res; for( vector<boost::weak_ptr<People>::iterator it = my_people.begin(); it != my_people.end(); ++it) res.push_back(it->lock()); return res; } ``` Also, you can filter out the null pointers, if you want. Of course, you cannot return a reference to a local variable so you have to return a copy. You may want to do instead: ``` void getPeople(vector<boost::shared_ptr<People>> &res) const { for( vector<boost::weak_ptr<People>::iterator it = my_people.begin(); it != my_people.end(); ++it) res.push_back(it->lock()); } ``` to avoid copying the return vector.
12,895,816
I'm currently working on a big project and I need to use `weak_ptr` instead of `shared_ptr`. Here is my problem. I have a class named House with an attribute: `vector<boost::shared_ptr<People>> my_people`. I want to modify this data member to be `vector<boost::weak_ptr<People>> my_people`. My getter was ``` vector<boost::shared_ptr<People>>& getPeople() const { return my_people; } ``` Normally, with a simple `weak_ptr` I can return `my_people.lock();` But I have a vector and I don't know how to do something like this: ``` vector<boost::shared_ptr<People>>& getPeople() const { for( vector<boost::weak_ptr<People>::iterator it = my_people.begin(); it != my_people.end(); ++it) { (*it).lock(); } return my_people; } ``` In other words, I want to return my vector of `weak_ptr` but as a vector of `shared_ptr`. Is it possible? Or do I have to return a vector of `weak_ptr` and use `lock()` everywhere I use them?
2012/10/15
[ "https://Stackoverflow.com/questions/12895816", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1747056/" ]
Your function is a reasonable start: ``` vector<boost::shared_ptr<People>>& getPeople() const { for( vector<boost::weak_ptr<People>::iterator it = my_people.begin(); it != my_people.end(); ++it) { (*it).lock(); } return my_people; } ``` But calling `(*it).lock()` just creates a `shared_ptr` and throws it away, it doesn't change the type of the vector elements, and you can't return the vector as a different type. You need to create a vector of the right type, fill it with the shared\_ptr objects, and return it: ``` vector<boost::shared_ptr<People>> getPeople() const { vector<boost::shared_ptr<People>> people(my_people.size()); std::transform(my_people.begin(), my_people.end(), people.begin(), boost::bind(&boost::weak_ptr<People>::lock, _1)); return people; } ``` This iterates over each element of `my_people`, calls `lock()` on it, and assigns the result to the corresponding element of `people`. If you know that `my_people` never contains expired pointers it's even easier: ``` vector<boost::shared_ptr<People>> getPeople() const { vector<boost::shared_ptr<People>> people(my_people.begin(), my_people.end()); return people; } ``` This fills the `people` vector by constructing each `shared_ptr` element from a `weak_ptr` element. The difference is that this version will throw an exception if a `weak_ptr` has expired because the `shared_ptr` constructor throws if passed an expired `weak_ptr`. The version using`transform` will put an empty `shared_ptr` in the vector if an expired weak\_ptr is transformed.
Note that `vector<weak_ptr<T> >` and `vector<shared_ptr<T> >` are two completely different types. However, you can write a function that accepts the former and returns the latter: ``` template<class Ptrs, class WeakPtrs> void lockWeakPtrs(const WeakPtrs &weakPtrs, Ptrs &ptrs) { BOOST_FOREACH (typename WeakPtrs::const_reference weakPtr, weakPtrs) { typename Ptrs::value_type ptr = weakPtr.lock(); if (ptr) // if you want to drop expired weak_ptr's ptrs.insert(ptrs.end(), ptr); } } ``` Call like this: `lockWeakPtrs(myWeakVector, mySharedVector);`
12,895,816
I'm currently working on a big project and I need to use `weak_ptr` instead of `shared_ptr`. Here is my problem. I have a class named House with an attribute: `vector<boost::shared_ptr<People>> my_people`. I want to modify this data member to be `vector<boost::weak_ptr<People>> my_people`. My getter was ``` vector<boost::shared_ptr<People>>& getPeople() const { return my_people; } ``` Normally, with a simple `weak_ptr` I can return `my_people.lock();` But I have a vector and I don't know how to do something like this: ``` vector<boost::shared_ptr<People>>& getPeople() const { for( vector<boost::weak_ptr<People>::iterator it = my_people.begin(); it != my_people.end(); ++it) { (*it).lock(); } return my_people; } ``` In other words, I want to return my vector of `weak_ptr` but as a vector of `shared_ptr`. Is it possible? Or do I have to return a vector of `weak_ptr` and use `lock()` everywhere I use them?
2012/10/15
[ "https://Stackoverflow.com/questions/12895816", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1747056/" ]
You could use **[std::transform](http://www.cplusplus.com/reference/algorithm/transform/)** ``` std::vector<std::shared_ptr<People>> temp; sharedTargetList.resize(my_people.size()); //transform into a shared_ptr vector std::transform(my_people.begin(), my_people.end(), temp.begin(), [](std::weak_ptr<People> weakPtr){ return weakPtr.lock(); } ); ```
Note that `vector<weak_ptr<T> >` and `vector<shared_ptr<T> >` are two completely different types. However, you can write a function that accepts the former and returns the latter: ``` template<class Ptrs, class WeakPtrs> void lockWeakPtrs(const WeakPtrs &weakPtrs, Ptrs &ptrs) { BOOST_FOREACH (typename WeakPtrs::const_reference weakPtr, weakPtrs) { typename Ptrs::value_type ptr = weakPtr.lock(); if (ptr) // if you want to drop expired weak_ptr's ptrs.insert(ptrs.end(), ptr); } } ``` Call like this: `lockWeakPtrs(myWeakVector, mySharedVector);`
40,172
I often encounter this when I am helping out someone who is new to programming and learning it for the first time. I'm talking about really new newbies, still learning about OOness, constructing objects, method calls and stuff like that. Usually, they have the keyboard and I am just offering guidance. On the one hand, the autocomplete feature of the IDEs helps to give them feedback that they are doing it right and they quickly get to like and rely on it. On the other hand, I fear that early dependence on the IDE autocomplete would make them not really understand the concepts or be able to function if they one day find themselves only with a simple editor. Can anyone with more experience in this regard please share their opinion? Which is better for a newbie, autocomplete or manual typing? **Update** Thanks for the input everyone! Many answers seem to focus on the main use of autocomplete, like completing methods, providing methods lookup and documentation etc. But IDEs nowadays do a lot more like. * When creating an object of List type, an IDE autocompletes to new ArrayList on right hand side. It may not be immediately clear to a newbie why it cannot be new List, but hey it works, so they move on. * Filling method parameters based on local variables in context. * Performing object casts * Automatically adding 'import' or 'using' statements and much more. These are the kinds of things I mean. Remember I'm talking about people who are doing Programming 101, really just starting. I have watched the IDE do these things which they have no idea about, but they just carry on. One could argue that it helps them focus on program flow and getting the hang of things first before going in-depth and understanding the nuances of the language, but I'm not sure.
2011/01/26
[ "https://softwareengineering.stackexchange.com/questions/40172", "https://softwareengineering.stackexchange.com", "https://softwareengineering.stackexchange.com/users/1728/" ]
The issue with IDEs and development environments in general is not so much things like autocomplete as the use of templated solutions (file|new|project) where lots of "interesting" things have already been done for you and are, to varying degrees, hidden. For someone who, broadly, understands what's going on underneath the hood this is helpful - but for someone learning what they need is rather less. There's also the question of the time taken to fire up a heavyweight IDE... I think therefore that using something lighter in weight and being able to run up applications in which you have written every line of code yourself has considerable merit - especially as using a text editor and a compiler demonstrates the important point that you don't need an IDE etc to write software *but* that doesn't mean that I want to use a text editor for long and that does present challenges in terms of debug - you want to be able to do breakpoints and you want to be able to single step through code as this will make it easier to understand what's going on. Of course we can further confuse the issue by considering things like Python where you have a "live" command line... Good question, no single good answer - except that you want to make learning a progression and starting with a text editor and a compiler (or a command line interpreter) will allow you to focus on the basics of syntax and logic before you progress to more complex stuff which will be easier to do with a more powerful development environment.
In the beginning, it's hard enough to build something that works, so anything that helps the brand noobie the better. A new programmer is going to need someone more senior to get them to think about whether array bound lists or linked lists are going to be the better match for the problem at hand. They each have their strengths and weaknesses. Whether the newbie has an IDE, or they are browsing the API docs online, there isn't going to be any real difference between the code they create. While dealing with the pain of writing syntax errors can be a learning experience, there is too much to learn to worry about that at the very beginning. You don't learn to walk the tightrope by going straight to the high-wire without a net. You start by walking a rope that's inches off the ground. I'd venture to say that most of us work with an IDE, and some sort of build script (Visual Studio's build script is created by the IDE but it is there). Most of us do not build our classes by hand with a text editor, and then invoke the compiler by hand. Why should we impose that on a newbie who has far more to learn?
40,172
I often encounter this when I am helping out someone who is new to programming and learning it for the first time. I'm talking about really new newbies, still learning about OOness, constructing objects, method calls and stuff like that. Usually, they have the keyboard and I am just offering guidance. On the one hand, the autocomplete feature of the IDEs helps to give them feedback that they are doing it right and they quickly get to like and rely on it. On the other hand, I fear that early dependence on the IDE autocomplete would make them not really understand the concepts or be able to function if they one day find themselves only with a simple editor. Can anyone with more experience in this regard please share their opinion? Which is better for a newbie, autocomplete or manual typing? **Update** Thanks for the input everyone! Many answers seem to focus on the main use of autocomplete, like completing methods, providing methods lookup and documentation etc. But IDEs nowadays do a lot more like. * When creating an object of List type, an IDE autocompletes to new ArrayList on right hand side. It may not be immediately clear to a newbie why it cannot be new List, but hey it works, so they move on. * Filling method parameters based on local variables in context. * Performing object casts * Automatically adding 'import' or 'using' statements and much more. These are the kinds of things I mean. Remember I'm talking about people who are doing Programming 101, really just starting. I have watched the IDE do these things which they have no idea about, but they just carry on. One could argue that it helps them focus on program flow and getting the hang of things first before going in-depth and understanding the nuances of the language, but I'm not sure.
2011/01/26
[ "https://softwareengineering.stackexchange.com/questions/40172", "https://softwareengineering.stackexchange.com", "https://softwareengineering.stackexchange.com/users/1728/" ]
I think making use of the IDE helps in the learning process. Methods, properties, parameters, overloads and the like are discoverable. With the overwhelmingly huge libraries, Intellisense helps trickle down JIT knowledge. In today's coding environment, it is impossible to learn everything up front, and JIT learning is often the only practical way to quickly become productive. I understand that using an IDE can be a crutch if you use it blindly, but I think the benefits far outweigh the negatives. Using templates without understanding what's been pre-built for you, on the other hand, is more of an issue. I think those can be used as a learning tool if the developer takes the time to read through the templated code. But most people don't bother. It could be a great learning tool, though.
When we grow up as a child, we are not told that we must understand the intricate rules of the English language before we can speak. We are not told that we must fully understand the proper use of prepositions, conjunctions, and to avoid sentence fragments. We learn by doing. We learn through success and failure. An IDE with autocomplete helps the new programmer gain confidence by facilitating the creation of programs, while not struggling with remembering every myriad function of a vast multitude of libraries. If one were to truly extrapolate the view that autocomplete hurts the new programmer because it makes it too easy for them, then you could argue, that reference books shouldn't be used *while* programming, because the concepts within should be committed to memory first, as not having them memorized slows them down, and doesn't allow them to fully understand the concepts first. Autocomplete is a tool, it is used to make the programmer more productive. Just as with learning a language for the first time, after we gain confidence and a level of success with what we are learning, we then work to improve our knowledge.
40,172
I often encounter this when I am helping out someone who is new to programming and learning it for the first time. I'm talking about really new newbies, still learning about OOness, constructing objects, method calls and stuff like that. Usually, they have the keyboard and I am just offering guidance. On the one hand, the autocomplete feature of the IDEs helps to give them feedback that they are doing it right and they quickly get to like and rely on it. On the other hand, I fear that early dependence on the IDE autocomplete would make them not really understand the concepts or be able to function if they one day find themselves only with a simple editor. Can anyone with more experience in this regard please share their opinion? Which is better for a newbie, autocomplete or manual typing? **Update** Thanks for the input everyone! Many answers seem to focus on the main use of autocomplete, like completing methods, providing methods lookup and documentation etc. But IDEs nowadays do a lot more like. * When creating an object of List type, an IDE autocompletes to new ArrayList on right hand side. It may not be immediately clear to a newbie why it cannot be new List, but hey it works, so they move on. * Filling method parameters based on local variables in context. * Performing object casts * Automatically adding 'import' or 'using' statements and much more. These are the kinds of things I mean. Remember I'm talking about people who are doing Programming 101, really just starting. I have watched the IDE do these things which they have no idea about, but they just carry on. One could argue that it helps them focus on program flow and getting the hang of things first before going in-depth and understanding the nuances of the language, but I'm not sure.
2011/01/26
[ "https://softwareengineering.stackexchange.com/questions/40172", "https://softwareengineering.stackexchange.com", "https://softwareengineering.stackexchange.com/users/1728/" ]
Understanding the concepts and memorising dozens of hundreds of stupid library classes and methods are two completely different things. Intellisense helps to kick all that useless knowledge off from your mind completely, and the earlier you do it, the better. Leave more space for the useful concepts, don't waste your limited resources on APIs. To answer an updated portion of a question: little syntax details, files layout, compiler and linker invocation are also unimportant compared to the generic programming concepts. Once they're understood a newbie-no-more can go into a deeper understanding of how the low level stuff actually works. It is better to do it when you already know the basics, otherwise chances are you'll pick up a number of dangerous magical superstitions. For example, DrScheme IDE has a great track record in teaching programming, and its success is mainly due to its ability to help to concentrate on what is really important.
IMO, The IDEs will make you more productive. But for beginners it's generally not an good idea to start programming with IDE. Text editors like notepad++, notepad, etc. would be enough. Also, it is generally not considered as an good idea to start learning the programming with high-level language. I would suggest you to start with assembly language. This will taught you basics as well as patience.
40,172
I often encounter this when I am helping out someone who is new to programming and learning it for the first time. I'm talking about really new newbies, still learning about OOness, constructing objects, method calls and stuff like that. Usually, they have the keyboard and I am just offering guidance. On the one hand, the autocomplete feature of the IDEs helps to give them feedback that they are doing it right and they quickly get to like and rely on it. On the other hand, I fear that early dependence on the IDE autocomplete would make them not really understand the concepts or be able to function if they one day find themselves only with a simple editor. Can anyone with more experience in this regard please share their opinion? Which is better for a newbie, autocomplete or manual typing? **Update** Thanks for the input everyone! Many answers seem to focus on the main use of autocomplete, like completing methods, providing methods lookup and documentation etc. But IDEs nowadays do a lot more like. * When creating an object of List type, an IDE autocompletes to new ArrayList on right hand side. It may not be immediately clear to a newbie why it cannot be new List, but hey it works, so they move on. * Filling method parameters based on local variables in context. * Performing object casts * Automatically adding 'import' or 'using' statements and much more. These are the kinds of things I mean. Remember I'm talking about people who are doing Programming 101, really just starting. I have watched the IDE do these things which they have no idea about, but they just carry on. One could argue that it helps them focus on program flow and getting the hang of things first before going in-depth and understanding the nuances of the language, but I'm not sure.
2011/01/26
[ "https://softwareengineering.stackexchange.com/questions/40172", "https://softwareengineering.stackexchange.com", "https://softwareengineering.stackexchange.com/users/1728/" ]
Using autocomplete is not a bad thing at all. It is simply for speed, and for me would be a sign of someone starting to get a grip of the IDE and using it well. I don't understand how NOT using it would help them learn OO for example.
In the beginning, it's hard enough to build something that works, so anything that helps the brand noobie the better. A new programmer is going to need someone more senior to get them to think about whether array bound lists or linked lists are going to be the better match for the problem at hand. They each have their strengths and weaknesses. Whether the newbie has an IDE, or they are browsing the API docs online, there isn't going to be any real difference between the code they create. While dealing with the pain of writing syntax errors can be a learning experience, there is too much to learn to worry about that at the very beginning. You don't learn to walk the tightrope by going straight to the high-wire without a net. You start by walking a rope that's inches off the ground. I'd venture to say that most of us work with an IDE, and some sort of build script (Visual Studio's build script is created by the IDE but it is there). Most of us do not build our classes by hand with a text editor, and then invoke the compiler by hand. Why should we impose that on a newbie who has far more to learn?
40,172
I often encounter this when I am helping out someone who is new to programming and learning it for the first time. I'm talking about really new newbies, still learning about OOness, constructing objects, method calls and stuff like that. Usually, they have the keyboard and I am just offering guidance. On the one hand, the autocomplete feature of the IDEs helps to give them feedback that they are doing it right and they quickly get to like and rely on it. On the other hand, I fear that early dependence on the IDE autocomplete would make them not really understand the concepts or be able to function if they one day find themselves only with a simple editor. Can anyone with more experience in this regard please share their opinion? Which is better for a newbie, autocomplete or manual typing? **Update** Thanks for the input everyone! Many answers seem to focus on the main use of autocomplete, like completing methods, providing methods lookup and documentation etc. But IDEs nowadays do a lot more like. * When creating an object of List type, an IDE autocompletes to new ArrayList on right hand side. It may not be immediately clear to a newbie why it cannot be new List, but hey it works, so they move on. * Filling method parameters based on local variables in context. * Performing object casts * Automatically adding 'import' or 'using' statements and much more. These are the kinds of things I mean. Remember I'm talking about people who are doing Programming 101, really just starting. I have watched the IDE do these things which they have no idea about, but they just carry on. One could argue that it helps them focus on program flow and getting the hang of things first before going in-depth and understanding the nuances of the language, but I'm not sure.
2011/01/26
[ "https://softwareengineering.stackexchange.com/questions/40172", "https://softwareengineering.stackexchange.com", "https://softwareengineering.stackexchange.com/users/1728/" ]
Using autocomplete is not a bad thing at all. It is simply for speed, and for me would be a sign of someone starting to get a grip of the IDE and using it well. I don't understand how NOT using it would help them learn OO for example.
IMO, The IDEs will make you more productive. But for beginners it's generally not an good idea to start programming with IDE. Text editors like notepad++, notepad, etc. would be enough. Also, it is generally not considered as an good idea to start learning the programming with high-level language. I would suggest you to start with assembly language. This will taught you basics as well as patience.
40,172
I often encounter this when I am helping out someone who is new to programming and learning it for the first time. I'm talking about really new newbies, still learning about OOness, constructing objects, method calls and stuff like that. Usually, they have the keyboard and I am just offering guidance. On the one hand, the autocomplete feature of the IDEs helps to give them feedback that they are doing it right and they quickly get to like and rely on it. On the other hand, I fear that early dependence on the IDE autocomplete would make them not really understand the concepts or be able to function if they one day find themselves only with a simple editor. Can anyone with more experience in this regard please share their opinion? Which is better for a newbie, autocomplete or manual typing? **Update** Thanks for the input everyone! Many answers seem to focus on the main use of autocomplete, like completing methods, providing methods lookup and documentation etc. But IDEs nowadays do a lot more like. * When creating an object of List type, an IDE autocompletes to new ArrayList on right hand side. It may not be immediately clear to a newbie why it cannot be new List, but hey it works, so they move on. * Filling method parameters based on local variables in context. * Performing object casts * Automatically adding 'import' or 'using' statements and much more. These are the kinds of things I mean. Remember I'm talking about people who are doing Programming 101, really just starting. I have watched the IDE do these things which they have no idea about, but they just carry on. One could argue that it helps them focus on program flow and getting the hang of things first before going in-depth and understanding the nuances of the language, but I'm not sure.
2011/01/26
[ "https://softwareengineering.stackexchange.com/questions/40172", "https://softwareengineering.stackexchange.com", "https://softwareengineering.stackexchange.com/users/1728/" ]
Having taught and tutored students that are new to programming, I find that autocomplete/intellisense sometimes causes more harm than good. Yes, they can write a program using it. Yes it compiles and runs and might even do the thing we asked them to do. But they don't understand what they are doing. When they don't understand what is happening, it becomes less programming and more hacking a solution together to get marks. I found that happened a lot with students as what we asked them to do became harder, they just hacked until the got something working. This always became clear when the midterm came around and students were asked to write simple methods by hand...they couldn't. Yes autocomplete/intellisense helps us (professional developers) a lot b/c it speeds us up. We don't have to memorize all different methods and parameter lists, but at the same time we also can hazard a guess at what parameters a method is going to take b/c we have the experience with programming to know. Newbies don't. They will wait for their IDE to pull up a list of methods, they will scroll through that list until they find one that maybe is what they need, they will look at the parameters it needs and see if they have them to pass in....and at the end they will have hacked something together that they can hand in. And, at the end of the course when they got their pass, they would walk away from their programming class with a shallow victory, many never to take another CS class again b/c they didn't understand anything they did or why they did it.
Learning takes practice. Programming can be a very frustrating task when you have no clue what you can do nor how things work. It's impractical to, say, read many books on programming principles without writing a single line of code; one doesn't learn anything this way. Intellisense is very helpful at giving new programmers the help they need to keep programming, keep practicing, and thus learning. As was already said, learning specific APIs is not the same as learning programming principles. What will undoubtedly happen is that the new programmers will make mistakes (regardless of Intellisense), and how they choose to fix those mistakes is what will lead them to become good programmers or poor ones. If you're trying to teach someone how to program, I'd get them to use Intellisense and play around until they get stuck. That's when I'd try to build a foundation by teaching them the reason they got stuck.
40,172
I often encounter this when I am helping out someone who is new to programming and learning it for the first time. I'm talking about really new newbies, still learning about OOness, constructing objects, method calls and stuff like that. Usually, they have the keyboard and I am just offering guidance. On the one hand, the autocomplete feature of the IDEs helps to give them feedback that they are doing it right and they quickly get to like and rely on it. On the other hand, I fear that early dependence on the IDE autocomplete would make them not really understand the concepts or be able to function if they one day find themselves only with a simple editor. Can anyone with more experience in this regard please share their opinion? Which is better for a newbie, autocomplete or manual typing? **Update** Thanks for the input everyone! Many answers seem to focus on the main use of autocomplete, like completing methods, providing methods lookup and documentation etc. But IDEs nowadays do a lot more like. * When creating an object of List type, an IDE autocompletes to new ArrayList on right hand side. It may not be immediately clear to a newbie why it cannot be new List, but hey it works, so they move on. * Filling method parameters based on local variables in context. * Performing object casts * Automatically adding 'import' or 'using' statements and much more. These are the kinds of things I mean. Remember I'm talking about people who are doing Programming 101, really just starting. I have watched the IDE do these things which they have no idea about, but they just carry on. One could argue that it helps them focus on program flow and getting the hang of things first before going in-depth and understanding the nuances of the language, but I'm not sure.
2011/01/26
[ "https://softwareengineering.stackexchange.com/questions/40172", "https://softwareengineering.stackexchange.com", "https://softwareengineering.stackexchange.com/users/1728/" ]
I would be the first to say that IDEs are a boon to productivity, even if I often complain about their quirks. However, I learned BASIC, C, C++, Java, Python, Perl, PHP, and several other languages without anything more than a text highlighting editor and the compiler/interpreter for the language. I actually learned Java in Notepad! Learning an IDE propmotes "magic" - the idea that "it works; doesn't matter how." Abstraction is good; magic is bad. A programmer should know, or be able to find out, everything going on in a project. A good IDE is designed to take care of the bookeeping, not controlling the project. Properly used it is a great tool. But what craftsman starts out using a CNC router? I think that the way I learned (having to type everything and know the compiler well to build a project) has helped me immeasurably when I did finally start using IDEs. For instance, a Java project is not a little folder in Eclipse project, but a collection of classes in a package structure with some XML files for paths, configuration, and deployment. I would not want to build a large enterprise application without an IDE, but I can build small ones. That makes it easier to understand the structure of large ones, and when I want a specific behavior in the build, say, I know how javac works, so I can tweak the actual build prompt rather than trying to find that magical combination that doesn't exist in the build configuration. I also believe I have a deeper understanding of error messages and how to find and fix them. IDEs promote the feeling that since there aren't any red underlines, the code much be right. I would not teach using an IDE. I think that beginning projects are small enough that the arguments for managing complexity are moot. If you are teaching Java, for example, you can place all your classes in the same folder and `javac *.java`. You don't need an IDE for that! This argues for keeping projects small, little more than proof-of-concepts. Minimize the overhead, and concentrate on teaching the concept the students need. Bigger projects in which an IDE would be useful belong in either more advanced SE classes or dedicated projects. As for help with finding classes and API research, again, I believe this is moot if the projects are kept small. Again in Java, javadoc is very easy to read. No one can keep the whole API in there head anyway, and ther *will* be a time where you will need to research an API without the benefit of an IDE. Like, in other languages, or if remoting into a server where you can't open the IDE. Teach how to find documentation, not "press '.' and you can see what an object's methods are." Any programmer can learn an IDE, but knowing an IDE does not make you a good programmer. Black humor aside, "magic" is never a good word for a programmer to use.
Lots of other good answers so don't consider this a complete answer, but it is good for newbies as well as experienced users to see a complete picture of what functions they have at their disposal. In Delphi I can hit ctrl-j and I'll see a list of every single possible thing I could ever syntactically expect to work. I don't necessarily agree, but I have read arguments to the effect that programmers should not even look at private class members of objects that they use and in this way, auto-complete gives every user an instant API reference. Newer IDE's let users and language developers put meta-data in their intellisense which further enhances the ability to read and understand what the functions do, without reading the source (which is something that they shouldn't have to do anyway). Perhaps, it is best for newbies to actually read and understand everything they implement. But, maybe it would be a better question whether or not newbies should be allowed to include or import whatever namespaces or units they want without documenting why they are including it.
40,172
I often encounter this when I am helping out someone who is new to programming and learning it for the first time. I'm talking about really new newbies, still learning about OOness, constructing objects, method calls and stuff like that. Usually, they have the keyboard and I am just offering guidance. On the one hand, the autocomplete feature of the IDEs helps to give them feedback that they are doing it right and they quickly get to like and rely on it. On the other hand, I fear that early dependence on the IDE autocomplete would make them not really understand the concepts or be able to function if they one day find themselves only with a simple editor. Can anyone with more experience in this regard please share their opinion? Which is better for a newbie, autocomplete or manual typing? **Update** Thanks for the input everyone! Many answers seem to focus on the main use of autocomplete, like completing methods, providing methods lookup and documentation etc. But IDEs nowadays do a lot more like. * When creating an object of List type, an IDE autocompletes to new ArrayList on right hand side. It may not be immediately clear to a newbie why it cannot be new List, but hey it works, so they move on. * Filling method parameters based on local variables in context. * Performing object casts * Automatically adding 'import' or 'using' statements and much more. These are the kinds of things I mean. Remember I'm talking about people who are doing Programming 101, really just starting. I have watched the IDE do these things which they have no idea about, but they just carry on. One could argue that it helps them focus on program flow and getting the hang of things first before going in-depth and understanding the nuances of the language, but I'm not sure.
2011/01/26
[ "https://softwareengineering.stackexchange.com/questions/40172", "https://softwareengineering.stackexchange.com", "https://softwareengineering.stackexchange.com/users/1728/" ]
Understanding the concepts and memorising dozens of hundreds of stupid library classes and methods are two completely different things. Intellisense helps to kick all that useless knowledge off from your mind completely, and the earlier you do it, the better. Leave more space for the useful concepts, don't waste your limited resources on APIs. To answer an updated portion of a question: little syntax details, files layout, compiler and linker invocation are also unimportant compared to the generic programming concepts. Once they're understood a newbie-no-more can go into a deeper understanding of how the low level stuff actually works. It is better to do it when you already know the basics, otherwise chances are you'll pick up a number of dangerous magical superstitions. For example, DrScheme IDE has a great track record in teaching programming, and its success is mainly due to its ability to help to concentrate on what is really important.
Perhaps a *newbie* should simply be working on easier problems first. And no, those problems should not require or encourage the use of an IDE to complete the task. There's more to be gained long-term by understanding the basic concepts. The tools should come after. **No woodworking craftsman would jump straight to using a high horsepower surface planer without understanding the intricacies of both the type of wood and the hand plane first.** (Note: autocomplete and intellisense are two drastically different things). Intellisense, in itself, isn't bad. It's only bad when it is used a crutch to guess at functionality without reading or understanding the underlying documentation or implementation. Side point: If the language requires an IDE to code for you, the language is probably at the wrong level of abstraction for the problems that you're trying to solve.
40,172
I often encounter this when I am helping out someone who is new to programming and learning it for the first time. I'm talking about really new newbies, still learning about OOness, constructing objects, method calls and stuff like that. Usually, they have the keyboard and I am just offering guidance. On the one hand, the autocomplete feature of the IDEs helps to give them feedback that they are doing it right and they quickly get to like and rely on it. On the other hand, I fear that early dependence on the IDE autocomplete would make them not really understand the concepts or be able to function if they one day find themselves only with a simple editor. Can anyone with more experience in this regard please share their opinion? Which is better for a newbie, autocomplete or manual typing? **Update** Thanks for the input everyone! Many answers seem to focus on the main use of autocomplete, like completing methods, providing methods lookup and documentation etc. But IDEs nowadays do a lot more like. * When creating an object of List type, an IDE autocompletes to new ArrayList on right hand side. It may not be immediately clear to a newbie why it cannot be new List, but hey it works, so they move on. * Filling method parameters based on local variables in context. * Performing object casts * Automatically adding 'import' or 'using' statements and much more. These are the kinds of things I mean. Remember I'm talking about people who are doing Programming 101, really just starting. I have watched the IDE do these things which they have no idea about, but they just carry on. One could argue that it helps them focus on program flow and getting the hang of things first before going in-depth and understanding the nuances of the language, but I'm not sure.
2011/01/26
[ "https://softwareengineering.stackexchange.com/questions/40172", "https://softwareengineering.stackexchange.com", "https://softwareengineering.stackexchange.com/users/1728/" ]
In the beginning, it's hard enough to build something that works, so anything that helps the brand noobie the better. A new programmer is going to need someone more senior to get them to think about whether array bound lists or linked lists are going to be the better match for the problem at hand. They each have their strengths and weaknesses. Whether the newbie has an IDE, or they are browsing the API docs online, there isn't going to be any real difference between the code they create. While dealing with the pain of writing syntax errors can be a learning experience, there is too much to learn to worry about that at the very beginning. You don't learn to walk the tightrope by going straight to the high-wire without a net. You start by walking a rope that's inches off the ground. I'd venture to say that most of us work with an IDE, and some sort of build script (Visual Studio's build script is created by the IDE but it is there). Most of us do not build our classes by hand with a text editor, and then invoke the compiler by hand. Why should we impose that on a newbie who has far more to learn?
I have two thoughts on this. The first is that to truly learn something I believe you have to know what is really going on. And with how good IntelliSense has gotten, it can hide some of that to a new developer. For example, I had a web engineering class in college where we actually built our own web frameworks to build our final apps on top of. I came out of that class with that ability to adapt to almost any web framework because I had the understanding of what was underneath it all to begin with. Using an IDE isn't quite to that level but, the point is still there I believe. However, using an IDE can also do things such as opening up APIs to new developers. When I started coding seriously, the IDE I used help me tremendously because I would do things like type in an object, use the auto-complete to see what methods it had, and then research them using the docs available. This was all done within the IDE and was a great learning tool. So, yes, I believe it is OK to use one as long as you also take the time to understand what is going on. Just using an object cast without understanding why you had to to it is really bad but, if a new developer sees that you can use an object cast and then looks to see why I see nothing wrong.
40,172
I often encounter this when I am helping out someone who is new to programming and learning it for the first time. I'm talking about really new newbies, still learning about OOness, constructing objects, method calls and stuff like that. Usually, they have the keyboard and I am just offering guidance. On the one hand, the autocomplete feature of the IDEs helps to give them feedback that they are doing it right and they quickly get to like and rely on it. On the other hand, I fear that early dependence on the IDE autocomplete would make them not really understand the concepts or be able to function if they one day find themselves only with a simple editor. Can anyone with more experience in this regard please share their opinion? Which is better for a newbie, autocomplete or manual typing? **Update** Thanks for the input everyone! Many answers seem to focus on the main use of autocomplete, like completing methods, providing methods lookup and documentation etc. But IDEs nowadays do a lot more like. * When creating an object of List type, an IDE autocompletes to new ArrayList on right hand side. It may not be immediately clear to a newbie why it cannot be new List, but hey it works, so they move on. * Filling method parameters based on local variables in context. * Performing object casts * Automatically adding 'import' or 'using' statements and much more. These are the kinds of things I mean. Remember I'm talking about people who are doing Programming 101, really just starting. I have watched the IDE do these things which they have no idea about, but they just carry on. One could argue that it helps them focus on program flow and getting the hang of things first before going in-depth and understanding the nuances of the language, but I'm not sure.
2011/01/26
[ "https://softwareengineering.stackexchange.com/questions/40172", "https://softwareengineering.stackexchange.com", "https://softwareengineering.stackexchange.com/users/1728/" ]
I think making use of the IDE helps in the learning process. Methods, properties, parameters, overloads and the like are discoverable. With the overwhelmingly huge libraries, Intellisense helps trickle down JIT knowledge. In today's coding environment, it is impossible to learn everything up front, and JIT learning is often the only practical way to quickly become productive. I understand that using an IDE can be a crutch if you use it blindly, but I think the benefits far outweigh the negatives. Using templates without understanding what's been pre-built for you, on the other hand, is more of an issue. I think those can be used as a learning tool if the developer takes the time to read through the templated code. But most people don't bother. It could be a great learning tool, though.
The issue with IDEs and development environments in general is not so much things like autocomplete as the use of templated solutions (file|new|project) where lots of "interesting" things have already been done for you and are, to varying degrees, hidden. For someone who, broadly, understands what's going on underneath the hood this is helpful - but for someone learning what they need is rather less. There's also the question of the time taken to fire up a heavyweight IDE... I think therefore that using something lighter in weight and being able to run up applications in which you have written every line of code yourself has considerable merit - especially as using a text editor and a compiler demonstrates the important point that you don't need an IDE etc to write software *but* that doesn't mean that I want to use a text editor for long and that does present challenges in terms of debug - you want to be able to do breakpoints and you want to be able to single step through code as this will make it easier to understand what's going on. Of course we can further confuse the issue by considering things like Python where you have a "live" command line... Good question, no single good answer - except that you want to make learning a progression and starting with a text editor and a compiler (or a command line interpreter) will allow you to focus on the basics of syntax and logic before you progress to more complex stuff which will be easier to do with a more powerful development environment.
70,061,417
Is there any official method to use ORACLE Dark Mode?
2021/11/22
[ "https://Stackoverflow.com/questions/70061417", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15458291/" ]
Tools > Preferences > Code Editor > PL/SQL Syntax Colors. Here you can choose Twilight scheme.
No, there is no official method. There is a way to change it manually through, through editing a jar file. [Here is the full video if it helps you out.](https://www.youtube.com/watch?v=znGzJOgQmHk) By default you can only change the Syntax colors + background of the editor.
70,061,417
Is there any official method to use ORACLE Dark Mode?
2021/11/22
[ "https://Stackoverflow.com/questions/70061417", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15458291/" ]
No, there is no official method. There is a way to change it manually through, through editing a jar file. [Here is the full video if it helps you out.](https://www.youtube.com/watch?v=znGzJOgQmHk) By default you can only change the Syntax colors + background of the editor.
Try to do this ============== OS: Debian Linux ---------------- Desktop: Gnome 40 JDK: Open JDK 11 edit ~/.sqldeveloper/{version}/product.conf add (the system theme will be used): SetJavaHome /{path to open11jdk} AddVMOption -Dswing.defaultlaf=com.sun.java.swing.plaf.gtk.GTKLookAndFeel If you would like to use a different theme that is not set for the system: edit ~/.sqldeveloper/{version}/product.conf add (after the above changes): GTK\_THEME={theme name} export GTK\_THEME Windows 10: ----------- edit: {user}/AppData/Roaming/sqldeveloper/{version}/product.conf add: AddVMOption -Dswing.defaultlaf=com.sun.java.swing.plaf.windows.WindowsLookAndFeel Sqldeveloper will use the current default Windows 10 theme
70,061,417
Is there any official method to use ORACLE Dark Mode?
2021/11/22
[ "https://Stackoverflow.com/questions/70061417", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15458291/" ]
Tools > Preferences > Code Editor > PL/SQL Syntax Colors. Here you can choose Twilight scheme.
Try to do this ============== OS: Debian Linux ---------------- Desktop: Gnome 40 JDK: Open JDK 11 edit ~/.sqldeveloper/{version}/product.conf add (the system theme will be used): SetJavaHome /{path to open11jdk} AddVMOption -Dswing.defaultlaf=com.sun.java.swing.plaf.gtk.GTKLookAndFeel If you would like to use a different theme that is not set for the system: edit ~/.sqldeveloper/{version}/product.conf add (after the above changes): GTK\_THEME={theme name} export GTK\_THEME Windows 10: ----------- edit: {user}/AppData/Roaming/sqldeveloper/{version}/product.conf add: AddVMOption -Dswing.defaultlaf=com.sun.java.swing.plaf.windows.WindowsLookAndFeel Sqldeveloper will use the current default Windows 10 theme
4,146,414
HI all, i want to ask can i save an array in shared prefrence(Default Shared Prefrence)... if yes then pls help me to save the array in shared prefrence.. Any code would b great if available. thanks in advance.
2010/11/10
[ "https://Stackoverflow.com/questions/4146414", "https://Stackoverflow.com", "https://Stackoverflow.com/users/383597/" ]
You could write each element of your array using a different key... something like this (for Strings): ``` void storeArrayToPrefs(SharedPreferences prefs, String a[]) { SharedPreferences.Editor editor = prefs.edit(); for (int i=0 ; i<a.length ; i++) { editor.putString("key" + i, a[i]); } editor.commit(); } ```
I believe you can only get primitive data types from the SharedPreference class. See this on the dev guide: <http://developer.android.com/intl/de/reference/android/content/SharedPreferences.html> `GetBoolean`, `GetInt`, etc. Depending on what type of data you have, you may want to consider using a SQLite database. [See here for a tutorial.](http://www.reigndesign.com/blog/using-your-own-sqlite-database-in-android-applications/)
4,146,414
HI all, i want to ask can i save an array in shared prefrence(Default Shared Prefrence)... if yes then pls help me to save the array in shared prefrence.. Any code would b great if available. thanks in advance.
2010/11/10
[ "https://Stackoverflow.com/questions/4146414", "https://Stackoverflow.com", "https://Stackoverflow.com/users/383597/" ]
You could write each element of your array using a different key... something like this (for Strings): ``` void storeArrayToPrefs(SharedPreferences prefs, String a[]) { SharedPreferences.Editor editor = prefs.edit(); for (int i=0 ; i<a.length ; i++) { editor.putString("key" + i, a[i]); } editor.commit(); } ```
All the primitive data types like booleans, floats, ints, longs, and strings are supported. You can store all the values of the array in Key value format using a loop and later if you want to retrieve make use of HashMap.
4,146,414
HI all, i want to ask can i save an array in shared prefrence(Default Shared Prefrence)... if yes then pls help me to save the array in shared prefrence.. Any code would b great if available. thanks in advance.
2010/11/10
[ "https://Stackoverflow.com/questions/4146414", "https://Stackoverflow.com", "https://Stackoverflow.com/users/383597/" ]
I believe you can only get primitive data types from the SharedPreference class. See this on the dev guide: <http://developer.android.com/intl/de/reference/android/content/SharedPreferences.html> `GetBoolean`, `GetInt`, etc. Depending on what type of data you have, you may want to consider using a SQLite database. [See here for a tutorial.](http://www.reigndesign.com/blog/using-your-own-sqlite-database-in-android-applications/)
All the primitive data types like booleans, floats, ints, longs, and strings are supported. You can store all the values of the array in Key value format using a loop and later if you want to retrieve make use of HashMap.
281,088
Take for example [this question](https://meta.stackexchange.com/questions/281082/how-do-i-create-a-table-inside-a-list-using-markdown). It was closed as a duplicate of two other questions. However, the close message says: > > [![](https://i.stack.imgur.com/Kddmg.png)](https://i.stack.imgur.com/Kddmg.png) > > > Or, in words: > > This question was marked as an exact duplicate of **an existing question**. > > > (emphasis mine) In case of more than one duplicate target, think the message better say: > > This question was marked as an exact duplicate of existing questions. > > >
2016/07/09
[ "https://meta.stackexchange.com/questions/281088", "https://meta.stackexchange.com", "https://meta.stackexchange.com/users/152859/" ]
A few word changes should be implied for the close reason to end this confusion and the need for different close reasons. Maybe the close reason should include the fact questions can be marked duplicate of one or more questions: > > This question has been marked as an exact duplicate of one or more questions > > > To match this with the "The question already has an answer here" header, we can change the wording slightly to: > > This question already has an answer within the following questions: > > > or: > > This question already has one or more answers here: > > >
Well, you could argue about the *This question already has an answer here* since it can and most likely will have *multiple* answers. But I don't think that is the point. I think the point is: this question has already been asked and it already has an answer. Either of these questions is an exact match. So there are not many matching questions, no just one. The same is true for the answer: there can be multiple answers but it is only one answer that provides the most useful answer.
1,316,301
If $T(n)= T(n-1) + 2T(n-2)$ with $T(0)=0$ and $T(1) = 1$ What is $T(n)$ (in $Θ$–notation) in terms of $n$? I am trying to solve by substitution, but I am not sure if I am doing this right, as I get stuck. Can anybody tell me where to go from here? $T(n)= T(n-1) + 2T(n-2)$ $T(n-1)= T(n-2) + 2T(n-3)$ $T(n-2)= T(n-3) + 2T(n-4)$ $T(n)= T(n-k) + 2T(n-(k+1))$ Substitute $n$ for $k$ $T(n)= T(n-n) + 2T(n-(n+1))$ $T(n)= T(0) + 2T(1)$ I am not sure where to go from here to find $T(n)$ (in $Θ$–notation) in terms of $n$.
2015/06/07
[ "https://math.stackexchange.com/questions/1316301", "https://math.stackexchange.com", "https://math.stackexchange.com/users/232336/" ]
Generating functions for the win. Let $T(x) = \sum\_{n=0}^{\infty}T\_nx^n = \sum\_{n=1}^{\infty}T\_nx^n$, since $T\_0 = 0$. Then: $$\begin{split} T(x) &= x + \sum\_{n=2}^{\infty}T\_nx^n \\ &= x + \sum\_{n=2}^{\infty}(T\_{n-1} + 2T\_{n-2})x^n \\ &= x + \sum\_{n=2}^{\infty}T\_{n-1}x^n + \sum\_{n=2}^{\infty}2T\_{n-2}x^n \end{split}$$ Let's rewrite those sums. The first one: $$\begin{split} \sum\_{n=2}^{\infty}T\_{n-1}x^n &= x\sum\_{n=2}^{\infty}T\_{n-1}x^{n-1} \\ &= x\sum\_{n=1}^{\infty}T\_nx^n \\ &= xT(x) \end{split}$$ Likewise, the second sum works out to $2x^2T(x)$. Thus: $$T(x) = x + xT(x) + 2x^2T(x)$$ So: $$\begin{split} T(x) &= \frac{x}{1 -x - 2x^2} = \frac{x}{(1-2x)(1+x)} \\ &= \frac{\frac{1}{3}}{1-2x} + \frac{-\frac{1}{3}}{1+x} \\ &= \frac13\sum\_{n=0}^{\infty}2^nx^n - \frac13\sum\_{n=0}^{\infty}(-1)^nx^n \\ &= \sum\_{n=0}^{\infty}\left(\frac{2^n - (-1)^n}{3}\right)x^n \end{split}$$ Which gives us our recurrence: $T\_n = \left(\frac{2^n - (-1)^n}{3}\right) = \Theta(2^n)$
1. $\Theta$-notation is? 2. The difference equation provided is that which defines the Jacobsthal numbers. 3. The general method to define the Jacobsthal numbers is as follows. Let $T(n) = r^{n}$ in the difference equation $T\_{n+2} = T\_{n+1} + 2 T\_{n}$ to obtain $r^{2} - r - 2 = 0$ which yields the solutions $2r = 1 \pm 3 \in \{4, -2\}$ and leads to the general form $$T\_{n} = A \, 2^{n} + B (-1)^{n}$$. Using the values $T\_{0} = 0$ and $T\_{1} = 1$ then $$T\_{n} = \frac{2^{n} - (-1)^{n}}{3}$$
1,316,301
If $T(n)= T(n-1) + 2T(n-2)$ with $T(0)=0$ and $T(1) = 1$ What is $T(n)$ (in $Θ$–notation) in terms of $n$? I am trying to solve by substitution, but I am not sure if I am doing this right, as I get stuck. Can anybody tell me where to go from here? $T(n)= T(n-1) + 2T(n-2)$ $T(n-1)= T(n-2) + 2T(n-3)$ $T(n-2)= T(n-3) + 2T(n-4)$ $T(n)= T(n-k) + 2T(n-(k+1))$ Substitute $n$ for $k$ $T(n)= T(n-n) + 2T(n-(n+1))$ $T(n)= T(0) + 2T(1)$ I am not sure where to go from here to find $T(n)$ (in $Θ$–notation) in terms of $n$.
2015/06/07
[ "https://math.stackexchange.com/questions/1316301", "https://math.stackexchange.com", "https://math.stackexchange.com/users/232336/" ]
1. $\Theta$-notation is? 2. The difference equation provided is that which defines the Jacobsthal numbers. 3. The general method to define the Jacobsthal numbers is as follows. Let $T(n) = r^{n}$ in the difference equation $T\_{n+2} = T\_{n+1} + 2 T\_{n}$ to obtain $r^{2} - r - 2 = 0$ which yields the solutions $2r = 1 \pm 3 \in \{4, -2\}$ and leads to the general form $$T\_{n} = A \, 2^{n} + B (-1)^{n}$$. Using the values $T\_{0} = 0$ and $T\_{1} = 1$ then $$T\_{n} = \frac{2^{n} - (-1)^{n}}{3}$$
i thought $2^n$ at first from similarity to Fibonacci #s. from there it is just 2 trivial inductions to find for what $g(n)$ is $T(n)\in Θ(g(n)),$ because $T(n)\in Θ(g(n))$ when $T(n)\in O(g(n))$ and $T(n)\in$ (big omega)$(g(n))$, if i am not mistaken. And $T(n)\in O(g(n))$ when for some $c\in N,n\_0\in Z$, $T(n)\le cg(n),n\ge n\_0$. $T(n)\in $ (big omega)$(g(n))$ when for some $c\in N,n\_0\in Z$, $T(n)\ge cg(n),n\ge n\_0$. $c=1,n\_0=1$: base case: $T(1)=1\le 2^1$. Assume $T(n)\le (1)(2^n)$, $n\ge 1$. $T(n+1)=T(n)+2T(n-1)\le 2^n+2(2^{n-1})=2^n+2^n=2(2^n)=2^{n+1}$. so it holds by induction. similar proof for lower bound/big omega. if i am not mistaken $2^n\Leftrightarrow log\_2n$. $log\_2n$ is the inverse of $2^n$ as $2^n$ is one-to-one. *edit: this part is incorrect: so is also $Θ(log\_n)$.*
1,316,301
If $T(n)= T(n-1) + 2T(n-2)$ with $T(0)=0$ and $T(1) = 1$ What is $T(n)$ (in $Θ$–notation) in terms of $n$? I am trying to solve by substitution, but I am not sure if I am doing this right, as I get stuck. Can anybody tell me where to go from here? $T(n)= T(n-1) + 2T(n-2)$ $T(n-1)= T(n-2) + 2T(n-3)$ $T(n-2)= T(n-3) + 2T(n-4)$ $T(n)= T(n-k) + 2T(n-(k+1))$ Substitute $n$ for $k$ $T(n)= T(n-n) + 2T(n-(n+1))$ $T(n)= T(0) + 2T(1)$ I am not sure where to go from here to find $T(n)$ (in $Θ$–notation) in terms of $n$.
2015/06/07
[ "https://math.stackexchange.com/questions/1316301", "https://math.stackexchange.com", "https://math.stackexchange.com/users/232336/" ]
1. $\Theta$-notation is? 2. The difference equation provided is that which defines the Jacobsthal numbers. 3. The general method to define the Jacobsthal numbers is as follows. Let $T(n) = r^{n}$ in the difference equation $T\_{n+2} = T\_{n+1} + 2 T\_{n}$ to obtain $r^{2} - r - 2 = 0$ which yields the solutions $2r = 1 \pm 3 \in \{4, -2\}$ and leads to the general form $$T\_{n} = A \, 2^{n} + B (-1)^{n}$$. Using the values $T\_{0} = 0$ and $T\_{1} = 1$ then $$T\_{n} = \frac{2^{n} - (-1)^{n}}{3}$$
we have $$t\_n = t\_{n-1} + 2t\_{n-2}, t\_0 = 0, t\_1 = 2.$$ here are the first few numbers in the sequence: $$0, 2, 2, 6, 10, \cdots. $$ it looks like you can establish $$t\_n > 0 \text{ for all } n \ge 1$$ by induction. once we have that can we use $$t\_n \ge 2t\_{n-2} $$ to conclude that $t\_n = O(2^n)$ without solving the recurrence relation?
1,316,301
If $T(n)= T(n-1) + 2T(n-2)$ with $T(0)=0$ and $T(1) = 1$ What is $T(n)$ (in $Θ$–notation) in terms of $n$? I am trying to solve by substitution, but I am not sure if I am doing this right, as I get stuck. Can anybody tell me where to go from here? $T(n)= T(n-1) + 2T(n-2)$ $T(n-1)= T(n-2) + 2T(n-3)$ $T(n-2)= T(n-3) + 2T(n-4)$ $T(n)= T(n-k) + 2T(n-(k+1))$ Substitute $n$ for $k$ $T(n)= T(n-n) + 2T(n-(n+1))$ $T(n)= T(0) + 2T(1)$ I am not sure where to go from here to find $T(n)$ (in $Θ$–notation) in terms of $n$.
2015/06/07
[ "https://math.stackexchange.com/questions/1316301", "https://math.stackexchange.com", "https://math.stackexchange.com/users/232336/" ]
Generating functions for the win. Let $T(x) = \sum\_{n=0}^{\infty}T\_nx^n = \sum\_{n=1}^{\infty}T\_nx^n$, since $T\_0 = 0$. Then: $$\begin{split} T(x) &= x + \sum\_{n=2}^{\infty}T\_nx^n \\ &= x + \sum\_{n=2}^{\infty}(T\_{n-1} + 2T\_{n-2})x^n \\ &= x + \sum\_{n=2}^{\infty}T\_{n-1}x^n + \sum\_{n=2}^{\infty}2T\_{n-2}x^n \end{split}$$ Let's rewrite those sums. The first one: $$\begin{split} \sum\_{n=2}^{\infty}T\_{n-1}x^n &= x\sum\_{n=2}^{\infty}T\_{n-1}x^{n-1} \\ &= x\sum\_{n=1}^{\infty}T\_nx^n \\ &= xT(x) \end{split}$$ Likewise, the second sum works out to $2x^2T(x)$. Thus: $$T(x) = x + xT(x) + 2x^2T(x)$$ So: $$\begin{split} T(x) &= \frac{x}{1 -x - 2x^2} = \frac{x}{(1-2x)(1+x)} \\ &= \frac{\frac{1}{3}}{1-2x} + \frac{-\frac{1}{3}}{1+x} \\ &= \frac13\sum\_{n=0}^{\infty}2^nx^n - \frac13\sum\_{n=0}^{\infty}(-1)^nx^n \\ &= \sum\_{n=0}^{\infty}\left(\frac{2^n - (-1)^n}{3}\right)x^n \end{split}$$ Which gives us our recurrence: $T\_n = \left(\frac{2^n - (-1)^n}{3}\right) = \Theta(2^n)$
i thought $2^n$ at first from similarity to Fibonacci #s. from there it is just 2 trivial inductions to find for what $g(n)$ is $T(n)\in Θ(g(n)),$ because $T(n)\in Θ(g(n))$ when $T(n)\in O(g(n))$ and $T(n)\in$ (big omega)$(g(n))$, if i am not mistaken. And $T(n)\in O(g(n))$ when for some $c\in N,n\_0\in Z$, $T(n)\le cg(n),n\ge n\_0$. $T(n)\in $ (big omega)$(g(n))$ when for some $c\in N,n\_0\in Z$, $T(n)\ge cg(n),n\ge n\_0$. $c=1,n\_0=1$: base case: $T(1)=1\le 2^1$. Assume $T(n)\le (1)(2^n)$, $n\ge 1$. $T(n+1)=T(n)+2T(n-1)\le 2^n+2(2^{n-1})=2^n+2^n=2(2^n)=2^{n+1}$. so it holds by induction. similar proof for lower bound/big omega. if i am not mistaken $2^n\Leftrightarrow log\_2n$. $log\_2n$ is the inverse of $2^n$ as $2^n$ is one-to-one. *edit: this part is incorrect: so is also $Θ(log\_n)$.*
1,316,301
If $T(n)= T(n-1) + 2T(n-2)$ with $T(0)=0$ and $T(1) = 1$ What is $T(n)$ (in $Θ$–notation) in terms of $n$? I am trying to solve by substitution, but I am not sure if I am doing this right, as I get stuck. Can anybody tell me where to go from here? $T(n)= T(n-1) + 2T(n-2)$ $T(n-1)= T(n-2) + 2T(n-3)$ $T(n-2)= T(n-3) + 2T(n-4)$ $T(n)= T(n-k) + 2T(n-(k+1))$ Substitute $n$ for $k$ $T(n)= T(n-n) + 2T(n-(n+1))$ $T(n)= T(0) + 2T(1)$ I am not sure where to go from here to find $T(n)$ (in $Θ$–notation) in terms of $n$.
2015/06/07
[ "https://math.stackexchange.com/questions/1316301", "https://math.stackexchange.com", "https://math.stackexchange.com/users/232336/" ]
Generating functions for the win. Let $T(x) = \sum\_{n=0}^{\infty}T\_nx^n = \sum\_{n=1}^{\infty}T\_nx^n$, since $T\_0 = 0$. Then: $$\begin{split} T(x) &= x + \sum\_{n=2}^{\infty}T\_nx^n \\ &= x + \sum\_{n=2}^{\infty}(T\_{n-1} + 2T\_{n-2})x^n \\ &= x + \sum\_{n=2}^{\infty}T\_{n-1}x^n + \sum\_{n=2}^{\infty}2T\_{n-2}x^n \end{split}$$ Let's rewrite those sums. The first one: $$\begin{split} \sum\_{n=2}^{\infty}T\_{n-1}x^n &= x\sum\_{n=2}^{\infty}T\_{n-1}x^{n-1} \\ &= x\sum\_{n=1}^{\infty}T\_nx^n \\ &= xT(x) \end{split}$$ Likewise, the second sum works out to $2x^2T(x)$. Thus: $$T(x) = x + xT(x) + 2x^2T(x)$$ So: $$\begin{split} T(x) &= \frac{x}{1 -x - 2x^2} = \frac{x}{(1-2x)(1+x)} \\ &= \frac{\frac{1}{3}}{1-2x} + \frac{-\frac{1}{3}}{1+x} \\ &= \frac13\sum\_{n=0}^{\infty}2^nx^n - \frac13\sum\_{n=0}^{\infty}(-1)^nx^n \\ &= \sum\_{n=0}^{\infty}\left(\frac{2^n - (-1)^n}{3}\right)x^n \end{split}$$ Which gives us our recurrence: $T\_n = \left(\frac{2^n - (-1)^n}{3}\right) = \Theta(2^n)$
we have $$t\_n = t\_{n-1} + 2t\_{n-2}, t\_0 = 0, t\_1 = 2.$$ here are the first few numbers in the sequence: $$0, 2, 2, 6, 10, \cdots. $$ it looks like you can establish $$t\_n > 0 \text{ for all } n \ge 1$$ by induction. once we have that can we use $$t\_n \ge 2t\_{n-2} $$ to conclude that $t\_n = O(2^n)$ without solving the recurrence relation?
1,316,301
If $T(n)= T(n-1) + 2T(n-2)$ with $T(0)=0$ and $T(1) = 1$ What is $T(n)$ (in $Θ$–notation) in terms of $n$? I am trying to solve by substitution, but I am not sure if I am doing this right, as I get stuck. Can anybody tell me where to go from here? $T(n)= T(n-1) + 2T(n-2)$ $T(n-1)= T(n-2) + 2T(n-3)$ $T(n-2)= T(n-3) + 2T(n-4)$ $T(n)= T(n-k) + 2T(n-(k+1))$ Substitute $n$ for $k$ $T(n)= T(n-n) + 2T(n-(n+1))$ $T(n)= T(0) + 2T(1)$ I am not sure where to go from here to find $T(n)$ (in $Θ$–notation) in terms of $n$.
2015/06/07
[ "https://math.stackexchange.com/questions/1316301", "https://math.stackexchange.com", "https://math.stackexchange.com/users/232336/" ]
we have $$t\_n = t\_{n-1} + 2t\_{n-2}, t\_0 = 0, t\_1 = 2.$$ here are the first few numbers in the sequence: $$0, 2, 2, 6, 10, \cdots. $$ it looks like you can establish $$t\_n > 0 \text{ for all } n \ge 1$$ by induction. once we have that can we use $$t\_n \ge 2t\_{n-2} $$ to conclude that $t\_n = O(2^n)$ without solving the recurrence relation?
i thought $2^n$ at first from similarity to Fibonacci #s. from there it is just 2 trivial inductions to find for what $g(n)$ is $T(n)\in Θ(g(n)),$ because $T(n)\in Θ(g(n))$ when $T(n)\in O(g(n))$ and $T(n)\in$ (big omega)$(g(n))$, if i am not mistaken. And $T(n)\in O(g(n))$ when for some $c\in N,n\_0\in Z$, $T(n)\le cg(n),n\ge n\_0$. $T(n)\in $ (big omega)$(g(n))$ when for some $c\in N,n\_0\in Z$, $T(n)\ge cg(n),n\ge n\_0$. $c=1,n\_0=1$: base case: $T(1)=1\le 2^1$. Assume $T(n)\le (1)(2^n)$, $n\ge 1$. $T(n+1)=T(n)+2T(n-1)\le 2^n+2(2^{n-1})=2^n+2^n=2(2^n)=2^{n+1}$. so it holds by induction. similar proof for lower bound/big omega. if i am not mistaken $2^n\Leftrightarrow log\_2n$. $log\_2n$ is the inverse of $2^n$ as $2^n$ is one-to-one. *edit: this part is incorrect: so is also $Θ(log\_n)$.*
1,104,923
If I work from home using windows remote desktop, my work computers would have the screen on. People at work can see my screen, what I am seeing, typing, etc. How do I disable that? i.e. I can see my screen at home, but not show that in work/remote computer. I am using Citrix, it downloads an ica file. I think under the hood it still uses windows remote desktop application, how do I find out whether I am actually using Windows Remote Deskop? I use windows 8 at home and windows 7 at work.
2016/07/25
[ "https://superuser.com/questions/1104923", "https://superuser.com", "https://superuser.com/users/108157/" ]
If you are using the Windows built-in "Remote Desktop" application (`mstsc.exe`) then when you remotely connect in the remote computer will automatically "lock" so no-one can see the screen or what you're doing. They just get presented with the usual "Press Ctrl + Alt + Delete to unlock this computer".
You can simply switch the power off (at the screen) whenever you are leaving the office.
24,520,243
I'm looking right at the file I want to download in my current directory. wget wants a FULL url, I don't know what the full url is. im in directory /usr/local/lib/ and want to download php.ini. I am using putty to log into my web server, and when i say donwload i want to download it from the web server to my pc
2014/07/01
[ "https://Stackoverflow.com/questions/24520243", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1397417/" ]
in the spirit of @Wayne Piekarski answer, I've [created a repository](https://bitbucket.org/nu-art-public/android-google-libs) that stores the project as you will need it for developing in Eclipse, clone it -> add it as an Android Library -> DONE! Lets keep it simple :) ==== UPDATE ==== And if you still encounter the WearableActivity... simply replace it with another Activity of you choice.
Maven? ------ AndroidSDK uses their very own repository. After download copy all from ``` C:\Program Files (x86)\Android\android-sdk\extras\google\m2repository\ ``` To your repository. So this can be resolved: ``` <dependencies> <dependency> <groupId>com.google.android.wearable</groupId> <artifactId>wearable</artifactId> <version>1.0.0</version> <!-- or whatever --> </dependency> </dependencies> ``` And you will get your ``` [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------ [INFO] Total time: 1.148 s [INFO] Finished at: 2016-10-23T09:10:12+02:00 [INFO] Final Memory: 16M/15381M [INFO] ------------------------------------------------------------------------ ```
24,520,243
I'm looking right at the file I want to download in my current directory. wget wants a FULL url, I don't know what the full url is. im in directory /usr/local/lib/ and want to download php.ini. I am using putty to log into my web server, and when i say donwload i want to download it from the web server to my pc
2014/07/01
[ "https://Stackoverflow.com/questions/24520243", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1397417/" ]
Create a wearable module with Android Studio 4.0 and ended-up with the exact same issue! And it's 2020, 6 years later LOL. Followed this guide to add the missing bits and pieces: <https://developer.android.com/training/wearables/apps/creating> Basically my project builde.gradle didn't have those: ``` maven { url "https://maven.google.com" } ``` And this is module's gradle: ``` implementation 'com.google.android.support:wearable:2.8.0' ``` Once added, every checked properly. PS: the maven is not even needed. Only missing implementation which clearly shows the wizard fails to create a valid module.
In your Android SDK Manager, go to tools > manage add-on sites > user defined sites > new: <https://dl-ssl.google.com/android/repository/addon-play-services-5.xml> Make sure you have the following (this is what I have) 1) Android SDK Tools v 23 (23.0.1 just came out) 2) Android SDK Platform-tools v 20 3) Android SDK Build-tools v 20 4) Android 4.4W (API 20) 5) Android Support Repository 6) Android Support Library 7) Everything else up to date Resources: <http://developer.android.com/preview/google-play-services-wear.html> <http://developer.android.com/training/wearables/apps/creating.html>
24,520,243
I'm looking right at the file I want to download in my current directory. wget wants a FULL url, I don't know what the full url is. im in directory /usr/local/lib/ and want to download php.ini. I am using putty to log into my web server, and when i say donwload i want to download it from the web server to my pc
2014/07/01
[ "https://Stackoverflow.com/questions/24520243", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1397417/" ]
The best way to get started with Android Wear is to use the latest Android Studio 0.8.1 or later, and it makes adding the support libraries to your code a lot easier. But it is possible to still use Eclipse, and I'll explain how to do it ... Since the SDK was just released for Android Wear, you need to firstly make sure you follow these instructions to get everything up to date: <http://developer.android.com/preview/google-play-services-wear.html> Here are the steps you need to do to fix your problem: 1. Start SDK Manager. 2. Update the Android SDK Tools and Platform-tools to versions 23 and 20 respectively. 3. Click Tools > Manage Add-on Sites > User Defined Sites. 4. Click New, enter <https://dl-ssl.google.com/android/repository/addon-play-services-5.xml> into the text field, and click OK. 5. Click Close. You should now see lots of packages that need to be downloaded. You need to download "SDK Platform" under "Android 4.4W (API 20) 6. The most important part is to download the "Google Repository" package under "Extras". 7. Step 6 will produce a directory called $SDK/extras/google/m2repository/com/google/android/support/wearable/1.0.0 and in there will be a wearable-1.0.0.aar file 8. Unzip the wearable-1.0.0.aar file, and it will produce a classes.jar file 9. If you unzip -v classes.jar you will see that it contains android/support/wearable/view/WatchViewStuff.class, which is what you were looking for! 10. Copy this classes.jar file to your project's libs directory, rename it to something like wearable-classes.jar 11. Right click on the libs directory in Eclipse, which will refresh your project and you should see wearable-classes.jar 12. Clean and rebuild your project. These steps might seem complicated in having to deal with the .aar file ... It is a lot easier when working with Android Studio, since you can just add a gradle rule that does all these steps for you automatically: ``` dependencies { compile "com.google.android.support:wearable:1.0.+" } ```
In your Android SDK Manager, go to tools > manage add-on sites > user defined sites > new: <https://dl-ssl.google.com/android/repository/addon-play-services-5.xml> Make sure you have the following (this is what I have) 1) Android SDK Tools v 23 (23.0.1 just came out) 2) Android SDK Platform-tools v 20 3) Android SDK Build-tools v 20 4) Android 4.4W (API 20) 5) Android Support Repository 6) Android Support Library 7) Everything else up to date Resources: <http://developer.android.com/preview/google-play-services-wear.html> <http://developer.android.com/training/wearables/apps/creating.html>
24,520,243
I'm looking right at the file I want to download in my current directory. wget wants a FULL url, I don't know what the full url is. im in directory /usr/local/lib/ and want to download php.ini. I am using putty to log into my web server, and when i say donwload i want to download it from the web server to my pc
2014/07/01
[ "https://Stackoverflow.com/questions/24520243", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1397417/" ]
The best way to get started with Android Wear is to use the latest Android Studio 0.8.1 or later, and it makes adding the support libraries to your code a lot easier. But it is possible to still use Eclipse, and I'll explain how to do it ... Since the SDK was just released for Android Wear, you need to firstly make sure you follow these instructions to get everything up to date: <http://developer.android.com/preview/google-play-services-wear.html> Here are the steps you need to do to fix your problem: 1. Start SDK Manager. 2. Update the Android SDK Tools and Platform-tools to versions 23 and 20 respectively. 3. Click Tools > Manage Add-on Sites > User Defined Sites. 4. Click New, enter <https://dl-ssl.google.com/android/repository/addon-play-services-5.xml> into the text field, and click OK. 5. Click Close. You should now see lots of packages that need to be downloaded. You need to download "SDK Platform" under "Android 4.4W (API 20) 6. The most important part is to download the "Google Repository" package under "Extras". 7. Step 6 will produce a directory called $SDK/extras/google/m2repository/com/google/android/support/wearable/1.0.0 and in there will be a wearable-1.0.0.aar file 8. Unzip the wearable-1.0.0.aar file, and it will produce a classes.jar file 9. If you unzip -v classes.jar you will see that it contains android/support/wearable/view/WatchViewStuff.class, which is what you were looking for! 10. Copy this classes.jar file to your project's libs directory, rename it to something like wearable-classes.jar 11. Right click on the libs directory in Eclipse, which will refresh your project and you should see wearable-classes.jar 12. Clean and rebuild your project. These steps might seem complicated in having to deal with the .aar file ... It is a lot easier when working with Android Studio, since you can just add a gradle rule that does all these steps for you automatically: ``` dependencies { compile "com.google.android.support:wearable:1.0.+" } ```
in the spirit of @Wayne Piekarski answer, I've [created a repository](https://bitbucket.org/nu-art-public/android-google-libs) that stores the project as you will need it for developing in Eclipse, clone it -> add it as an Android Library -> DONE! Lets keep it simple :) ==== UPDATE ==== And if you still encounter the WearableActivity... simply replace it with another Activity of you choice.
24,520,243
I'm looking right at the file I want to download in my current directory. wget wants a FULL url, I don't know what the full url is. im in directory /usr/local/lib/ and want to download php.ini. I am using putty to log into my web server, and when i say donwload i want to download it from the web server to my pc
2014/07/01
[ "https://Stackoverflow.com/questions/24520243", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1397417/" ]
in the spirit of @Wayne Piekarski answer, I've [created a repository](https://bitbucket.org/nu-art-public/android-google-libs) that stores the project as you will need it for developing in Eclipse, clone it -> add it as an Android Library -> DONE! Lets keep it simple :) ==== UPDATE ==== And if you still encounter the WearableActivity... simply replace it with another Activity of you choice.
In your Android SDK Manager, go to tools > manage add-on sites > user defined sites > new: <https://dl-ssl.google.com/android/repository/addon-play-services-5.xml> Make sure you have the following (this is what I have) 1) Android SDK Tools v 23 (23.0.1 just came out) 2) Android SDK Platform-tools v 20 3) Android SDK Build-tools v 20 4) Android 4.4W (API 20) 5) Android Support Repository 6) Android Support Library 7) Everything else up to date Resources: <http://developer.android.com/preview/google-play-services-wear.html> <http://developer.android.com/training/wearables/apps/creating.html>
24,520,243
I'm looking right at the file I want to download in my current directory. wget wants a FULL url, I don't know what the full url is. im in directory /usr/local/lib/ and want to download php.ini. I am using putty to log into my web server, and when i say donwload i want to download it from the web server to my pc
2014/07/01
[ "https://Stackoverflow.com/questions/24520243", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1397417/" ]
in the spirit of @Wayne Piekarski answer, I've [created a repository](https://bitbucket.org/nu-art-public/android-google-libs) that stores the project as you will need it for developing in Eclipse, clone it -> add it as an Android Library -> DONE! Lets keep it simple :) ==== UPDATE ==== And if you still encounter the WearableActivity... simply replace it with another Activity of you choice.
The instructions detailed at the link below were very helpful for my Eclipse setup. <https://medium.com/@tangtungai/how-to-develop-and-package-android-wear-app-using-eclipse-ef1b34126a5d>
24,520,243
I'm looking right at the file I want to download in my current directory. wget wants a FULL url, I don't know what the full url is. im in directory /usr/local/lib/ and want to download php.ini. I am using putty to log into my web server, and when i say donwload i want to download it from the web server to my pc
2014/07/01
[ "https://Stackoverflow.com/questions/24520243", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1397417/" ]
Create a wearable module with Android Studio 4.0 and ended-up with the exact same issue! And it's 2020, 6 years later LOL. Followed this guide to add the missing bits and pieces: <https://developer.android.com/training/wearables/apps/creating> Basically my project builde.gradle didn't have those: ``` maven { url "https://maven.google.com" } ``` And this is module's gradle: ``` implementation 'com.google.android.support:wearable:2.8.0' ``` Once added, every checked properly. PS: the maven is not even needed. Only missing implementation which clearly shows the wizard fails to create a valid module.
Maven? ------ AndroidSDK uses their very own repository. After download copy all from ``` C:\Program Files (x86)\Android\android-sdk\extras\google\m2repository\ ``` To your repository. So this can be resolved: ``` <dependencies> <dependency> <groupId>com.google.android.wearable</groupId> <artifactId>wearable</artifactId> <version>1.0.0</version> <!-- or whatever --> </dependency> </dependencies> ``` And you will get your ``` [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------ [INFO] Total time: 1.148 s [INFO] Finished at: 2016-10-23T09:10:12+02:00 [INFO] Final Memory: 16M/15381M [INFO] ------------------------------------------------------------------------ ```