qid
int64
1
74.7M
question
stringlengths
0
58.3k
date
stringlengths
10
10
metadata
list
response_j
stringlengths
2
48.3k
response_k
stringlengths
2
40.5k
9,035,548
I'm currently writing a REST service within a Symfony2 application. This is (roughly) how one of my controllers look like: ``` /** * @Route("/account", defaults={"_format" = "json"}) */ class AccountController extends APIController { /** * @Route("/") * @Method("get") */ public function listAction() { // process something here and return JSON-encoded response } } ``` This works all fine - i.e. if some problem pops up and I throw a `HTTPException`, the correct `error.json.twig` from Symfony2's TwigBundle is used and renders the HTTP error as JSON. However, this is not true for the violation of route requirements, of which `@Method("get")` is one. If I for example throw a `POST` or `PUT` against the above URL, I still get the correct HTTP status code back, but rendered with the wrong content-type (text/html instead of application/json). I'm very much interested to let the complete API return JSON responses and nothing else - the question is: How do I achieve that? Do I have to omit route requirements alltogether and check the requirements myself (and then eventually throw my own `HTTPException`s)?
2012/01/27
[ "https://Stackoverflow.com/questions/9035548", "https://Stackoverflow.com", "https://Stackoverflow.com/users/305532/" ]
A prototype is a declaration, but a declaration not always is a prototype. If you don't specify the parameters, then that's only a declaration and not a prototype. That means the compiler won't reject a call to that function complaining it wasn't declared, but won't be able to check if the parameters passed are correct (as it would if you had a prototype).
A function prototype is a function declaration that specifies the number and types of parameters. ``` T foo(); // non-prototype declaration T foo(int, char *); // prototype declaration T foo(int a, char *b); // prototype declaration ```
9,035,548
I'm currently writing a REST service within a Symfony2 application. This is (roughly) how one of my controllers look like: ``` /** * @Route("/account", defaults={"_format" = "json"}) */ class AccountController extends APIController { /** * @Route("/") * @Method("get") */ public function listAction() { // process something here and return JSON-encoded response } } ``` This works all fine - i.e. if some problem pops up and I throw a `HTTPException`, the correct `error.json.twig` from Symfony2's TwigBundle is used and renders the HTTP error as JSON. However, this is not true for the violation of route requirements, of which `@Method("get")` is one. If I for example throw a `POST` or `PUT` against the above URL, I still get the correct HTTP status code back, but rendered with the wrong content-type (text/html instead of application/json). I'm very much interested to let the complete API return JSON responses and nothing else - the question is: How do I achieve that? Do I have to omit route requirements alltogether and check the requirements myself (and then eventually throw my own `HTTPException`s)?
2012/01/27
[ "https://Stackoverflow.com/questions/9035548", "https://Stackoverflow.com", "https://Stackoverflow.com/users/305532/" ]
A prototype is a declaration, but a declaration not always is a prototype. If you don't specify the parameters, then that's only a declaration and not a prototype. That means the compiler won't reject a call to that function complaining it wasn't declared, but won't be able to check if the parameters passed are correct (as it would if you had a prototype).
The prototype tells the compiler hey there is a function that looks like this and this is its name `int getanint()`. When you use that function the compiler puts the code calls that function and leaves a place to insert the address to the code that defines what that function does. So in File Header A; ``` int getanint(); ``` IN main.c ``` int main(...) { getanint(); } ``` when you compile main.c it has no idea what getanint does or even where it is the created .o file is incomplete and is not enough to create an actually program. remember that the compiler operates on a single file that file can be very large because of the #include directives but they create a single file. When you complie A.cpp ``` int getanint() { return 4; } ``` You now have the code for getanint in an object file. To actually make a program you have to get main.o and A.o together and have the definitions of the functions inserted into the appropriate places. That is the job of the linker.
20,573,269
I'm using Titanium Studio and Titanium SDK. In this case I'm developing for Android but I have an installation on OSX too. When using Alloy, I can specify ``` <Label class="header" id="someId">Week 50</Label> ``` and then specify the colors,fonts etc in the TSS file like this ``` ".header": { color: "blue" } ``` However when I use the SDK version: ``` var l = Ti.UI.createLabel({class:"header", text:"sometext"}); ``` The color from the TSS file isnt picked up??? What am I doing wrong. Isn't 'class' a valid property? (I cant seem to find it in the docs).
2013/12/13
[ "https://Stackoverflow.com/questions/20573269", "https://Stackoverflow.com", "https://Stackoverflow.com/users/587238/" ]
Alloy style are applied automatically to views created through xml. If you want to keep that effect while you are creating objects inside controller you have to use [$.UI.create()](http://docs.appcelerator.com/titanium/latest/#!/api/Alloy.Controller.UI-method-create) method instead of Titanium API. In your case your code will look like this: ``` var l = $.UI.create('Label', { title: "sometext", classes: ["header"], }); ``` For more read [Dynamic Styles guide](http://docs.appcelerator.com/titanium/latest/#!/guide/Dynamic_Styles). It's not very well documented and some parts of it were unclear for me when I read it but it's good starting point to experiment with the code and learn Alloy behaviour.
Encountered you question while I was searching for something similar. The chosen answer was unfortunately not the solution I was looking for, since I was writing a commonJS and needed the same this. If you are writing a commonJS (but still under an Alloy project) you can use the following solution: ``` var l = Alloy.UI.create("index", "Label", { title: "sometext", classes: ["header"], }); ``` Where `"index"` is what being generated by Alloy from you `app.tss` file.
5,796
I went all in with one other player still to act. He threw his cards on the table face up got my reaction then said I call. Is this legal or is his hand folded?
2015/03/28
[ "https://poker.stackexchange.com/questions/5796", "https://poker.stackexchange.com", "https://poker.stackexchange.com/users/3181/" ]
Yes, you might be 80% against a random hand, but unless he really is just gambling on his last hand (how can you know?) his likely range will significantly lower your odds. For example: You're getting pot odds of 42%. Your card odds are around 18% if he's only ever shoving AA in this spot, around 23% if he's shoving AA or KK, and 50% if he's shoving AA, KK or QQ. If you think he can do it with AK suited, cards odds improve to 52%. **The argument for laying down:** A nitty player might only shove AA or KK in this particular spot so laying down might well be profitable. Either way against most players you're never averaging 80% and you're a dog to a lot of players who might only make such a large 4 bet with AA or KK. **The argument for a call**: Using the same calcs as above, if you yourself are three betting a lot, or are likely to three bet with a wide range, villain might play QQ and a suited AK this way to end the pot there and then- he has blockers which might make this a profitable play for him. Similarly if he is a bad player, or a loose player who thinks he can get you to call with lower pairs or AKs might shove a wider range still. Then, there are scenarios where he is almost outright bluffing with 89 suited and using his tight table image to his advantage. These factors mean you should probably be calling against most players and against most opponents this is a +EV play. A lot of players will just snap call with KK regardless and, while not optimal, this will be a profitable play. There will, however, be some players against whom calling here is not a +EV play. If you can spot these players and make these folds, you can certainly increase your profitability at the table. The fact that you folded KK in this spot seems to me that you read him as a player who is too nitty to be making this play with anything less than AA or KK, so this may well have been a good fold long-term and certainly isn't horrible play.
Unless you think your opponent only ever does this move with AA, you're likely to be at least a 70-80% favourite to win the hand. Maybe not the bet to be making with your entire net worth, but with a portion of your poker bank on the table, I'd call this every time. Of course you're not going to win 100% of the time (and it hurts when you do lose - especially when your opponent has some random junk and gets lucky), but in the long run this call is going to be profitable.
5,796
I went all in with one other player still to act. He threw his cards on the table face up got my reaction then said I call. Is this legal or is his hand folded?
2015/03/28
[ "https://poker.stackexchange.com/questions/5796", "https://poker.stackexchange.com", "https://poker.stackexchange.com/users/3181/" ]
Unless you think your opponent only ever does this move with AA, you're likely to be at least a 70-80% favourite to win the hand. Maybe not the bet to be making with your entire net worth, but with a portion of your poker bank on the table, I'd call this every time. Of course you're not going to win 100% of the time (and it hurts when you do lose - especially when your opponent has some random junk and gets lucky), but in the long run this call is going to be profitable.
The only way that was a good lay down is if you are 100% sure he had AA. From your perceptive if you will fold to an all in with anything less than AA then you will be exploited. If villain only pushes with AA then villain will be exploited. Even if villain only plays AA, KK, and QQ here you should call as you are 50%. Look at the hand. Villain made an initial raise of just over the pot behind two limpers. This is basically never a stone cold bluff as there are too many players to get through. TT+ in front of villain should have come in for raise so about all we can do is put villain on TT+. A suited connector would likely have just called. Hero re-raise. That puts your range above villain. You are on JJ+ if not QQ+. When it gets back to villain if they are on TT+ they should / could push with their entire range. They think AA KK is ahead and they think TT is behind. If villain had AA or KK they would not quickly go in - that indicates they want a fold. They hope a push will fold out JJ or QQ. To me you should have raised with JJ+ and the only hand you can consider folding is JJ. I would probably even call here with JJ to balance my range and villain could just be totally out of line. Now if the two limpers called your $36 and villain pushed then it is fair to put him on AA or KK but could be doing it with QQ. I still think that is a close call. In summary mathematically and GTO it is a call.
5,796
I went all in with one other player still to act. He threw his cards on the table face up got my reaction then said I call. Is this legal or is his hand folded?
2015/03/28
[ "https://poker.stackexchange.com/questions/5796", "https://poker.stackexchange.com", "https://poker.stackexchange.com/users/3181/" ]
Yes, you might be 80% against a random hand, but unless he really is just gambling on his last hand (how can you know?) his likely range will significantly lower your odds. For example: You're getting pot odds of 42%. Your card odds are around 18% if he's only ever shoving AA in this spot, around 23% if he's shoving AA or KK, and 50% if he's shoving AA, KK or QQ. If you think he can do it with AK suited, cards odds improve to 52%. **The argument for laying down:** A nitty player might only shove AA or KK in this particular spot so laying down might well be profitable. Either way against most players you're never averaging 80% and you're a dog to a lot of players who might only make such a large 4 bet with AA or KK. **The argument for a call**: Using the same calcs as above, if you yourself are three betting a lot, or are likely to three bet with a wide range, villain might play QQ and a suited AK this way to end the pot there and then- he has blockers which might make this a profitable play for him. Similarly if he is a bad player, or a loose player who thinks he can get you to call with lower pairs or AKs might shove a wider range still. Then, there are scenarios where he is almost outright bluffing with 89 suited and using his tight table image to his advantage. These factors mean you should probably be calling against most players and against most opponents this is a +EV play. A lot of players will just snap call with KK regardless and, while not optimal, this will be a profitable play. There will, however, be some players against whom calling here is not a +EV play. If you can spot these players and make these folds, you can certainly increase your profitability at the table. The fact that you folded KK in this spot seems to me that you read him as a player who is too nitty to be making this play with anything less than AA or KK, so this may well have been a good fold long-term and certainly isn't horrible play.
The only way that was a good lay down is if you are 100% sure he had AA. From your perceptive if you will fold to an all in with anything less than AA then you will be exploited. If villain only pushes with AA then villain will be exploited. Even if villain only plays AA, KK, and QQ here you should call as you are 50%. Look at the hand. Villain made an initial raise of just over the pot behind two limpers. This is basically never a stone cold bluff as there are too many players to get through. TT+ in front of villain should have come in for raise so about all we can do is put villain on TT+. A suited connector would likely have just called. Hero re-raise. That puts your range above villain. You are on JJ+ if not QQ+. When it gets back to villain if they are on TT+ they should / could push with their entire range. They think AA KK is ahead and they think TT is behind. If villain had AA or KK they would not quickly go in - that indicates they want a fold. They hope a push will fold out JJ or QQ. To me you should have raised with JJ+ and the only hand you can consider folding is JJ. I would probably even call here with JJ to balance my range and villain could just be totally out of line. Now if the two limpers called your $36 and villain pushed then it is fair to put him on AA or KK but could be doing it with QQ. I still think that is a close call. In summary mathematically and GTO it is a call.
29,575
Now that Windows 7 Enterprise is available for VLK Users to download, I would like to check it out. The only thing holding me back is that I am an application developer (currently developing on a Windows Server 2008 installation) and the most useful thing I use is Hyper-V to create VMs of the systems I would like to test on. Is it possible to run Hyper-V under Windows 7 Enterprise? Or am I stuck with Windows Server 2008?
2009/08/25
[ "https://superuser.com/questions/29575", "https://superuser.com", "https://superuser.com/users/6893/" ]
Unfortunately that seems to be the case: > > System requirements / Specifications > > > * An x64-based processor running an x64 version of Windows Server 2008 > Standard, Windows Server 2008 > Enterprise or Windows Server 2008 > Datacenter. > > > [Hyper-V System Requirements and Specifications](http://en.wikipedia.org/wiki/Hyper-V#System_requirements_.2F_Specifications) --- Credits to [Diago](https://superuser.com/users/3981/diago): The alternative to Hyper-V for Windows 7 is Virtual PC for Windows 7 available [here](http://www.microsoft.com/windows/virtual-pc/download.aspx). It is currently in RC but will be available soon. It also requires hardware assisted virtualization to work. If you want 64-Bit VM's however you will have to load Windows Server 2008 and load Hyper-V since Virtual PC does not support this. For 64-Bit [VirtualBox](http://www.virtualbox.org) or [VMware](http://www.vmware.com/) are good options.
Windows 7 runs fine on Hyper-V, Hyper-V does not run on Windows 7. As other people have said, you can use Microsoft Virtual PC or Vmware Workstation along with a whole load of other VM software.
29,575
Now that Windows 7 Enterprise is available for VLK Users to download, I would like to check it out. The only thing holding me back is that I am an application developer (currently developing on a Windows Server 2008 installation) and the most useful thing I use is Hyper-V to create VMs of the systems I would like to test on. Is it possible to run Hyper-V under Windows 7 Enterprise? Or am I stuck with Windows Server 2008?
2009/08/25
[ "https://superuser.com/questions/29575", "https://superuser.com", "https://superuser.com/users/6893/" ]
Unfortunately that seems to be the case: > > System requirements / Specifications > > > * An x64-based processor running an x64 version of Windows Server 2008 > Standard, Windows Server 2008 > Enterprise or Windows Server 2008 > Datacenter. > > > [Hyper-V System Requirements and Specifications](http://en.wikipedia.org/wiki/Hyper-V#System_requirements_.2F_Specifications) --- Credits to [Diago](https://superuser.com/users/3981/diago): The alternative to Hyper-V for Windows 7 is Virtual PC for Windows 7 available [here](http://www.microsoft.com/windows/virtual-pc/download.aspx). It is currently in RC but will be available soon. It also requires hardware assisted virtualization to work. If you want 64-Bit VM's however you will have to load Windows Server 2008 and load Hyper-V since Virtual PC does not support this. For 64-Bit [VirtualBox](http://www.virtualbox.org) or [VMware](http://www.vmware.com/) are good options.
You are stuck with Windows Server 2008 if you have to use Hyper-V. You can always switch to another virtualization software like VMware or VirtualPC or you can wait until Server 2008 R2 is released, which is the server version of Windows 7.
29,575
Now that Windows 7 Enterprise is available for VLK Users to download, I would like to check it out. The only thing holding me back is that I am an application developer (currently developing on a Windows Server 2008 installation) and the most useful thing I use is Hyper-V to create VMs of the systems I would like to test on. Is it possible to run Hyper-V under Windows 7 Enterprise? Or am I stuck with Windows Server 2008?
2009/08/25
[ "https://superuser.com/questions/29575", "https://superuser.com", "https://superuser.com/users/6893/" ]
Windows 7 runs fine on Hyper-V, Hyper-V does not run on Windows 7. As other people have said, you can use Microsoft Virtual PC or Vmware Workstation along with a whole load of other VM software.
You are stuck with Windows Server 2008 if you have to use Hyper-V. You can always switch to another virtualization software like VMware or VirtualPC or you can wait until Server 2008 R2 is released, which is the server version of Windows 7.
68,160,846
I have created a 2 level nested Mat-Table grid in Angular in which it can expand multiple rows at a time. On each row click from the parent grid it calls an API and loads the data for the inner grid. When I click on the first row, it fetches the data as expected. [![First row data](https://i.stack.imgur.com/0tIL5.png)](https://i.stack.imgur.com/0tIL5.png) But when I click on the second row, it fetches the data for the second row as expected, but the value of the 1st inner row also becomes the same as the second one. The datasource value of the 1st row is overridden by the second one. [![Data of mat-table](https://i.stack.imgur.com/pPIJc.png)](https://i.stack.imgur.com/pPIJc.png) I tried making `dataSource` an array of `dataSource[i]`, using the `index`, but I was unable to. I have [a working StackBlitz for my issue](https://stackblitz.com/edit/angular-nested-mat-table-triplenested-wsnkyh?file=app%2Ftable-expandable-rows-example.html). Can anyone help me on this? Thanks in advance.
2021/06/28
[ "https://Stackoverflow.com/questions/68160846", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15084216/" ]
The problem is that inner userDatasource is getting overridden everytime you make an api call to get new data for the row. Here is one of the solution: Whenever you make a call to fetch inner datasource data, assign the data to element ``` getProjectDetails(element: any) { //console.log(element); this.tableService.getInnerData(element.Id).subscribe(res => { if (res.length == 0) { element['innerDatasource'] = new MatTableDataSource(); } else { console.log(res); element['innerDatasource'] = new MatTableDataSource(res); } }); } ``` Then in the html, use that value ``` <table mat-table [dataSource]="element.innerDatasource" multiTemplateDataRows matSort> ``` Working stackblitz link: <https://stackblitz.com/edit/angular-nested-mat-table-triplenested-bpvhfr?file=app%2Ftable-expandable-rows-example.html>
Complementary the answer of Drhasti, another option is allow **only show one** "detail" at time. In this case, you change the .html to only show one For this, you can declare a variable "elementExpanded" ``` elementExpanded:any; ``` Then you change the `*ngIf` ``` <div class="example-element-detail" [@detailExpand]="element==elementExpanded" *ngIf="element==elementExpanded"> ... </div> ``` And the `(click)` in your mat-row ``` <tr mat-row *matRowDef="let element; columns: columnsToDisplay;" [class.example-element-row]="element.addresses?.length" [class.example-expanded-row]="element==elementExpanded" (click)="elementExpanded = elementExpanded==element?null:element"> </tr> ```
35,799,905
I recently upgraded our SQL Server from 2005 to 2014 (linked server) and I am noticing that one of the stored procedures which calls the exec command to execute a stored procedure on the upgraded linked server is failing with the error > > Could not find server 'server name' in sys.servers.Verify that the correct server name was specified. If necessary, execute the stored procedure sp\_addlinkedserver to add the server to sys.servers. > > > The issue is that the linked server exists and I have done tests to ensure I can query the tables from the linked server. Here are the checks I did to see if the linked server is configured correctly. ``` - select name from sys.servers -- > Lists the linked server - select top 10 * from linkedserver.database.dbo.table --> Gets top 10 records - exec linkedserver.database.dbo.storedproc --> Executes the stored procedure (I created a test stored procedure on the linked server and I can execute it) ``` However the one that is failing with the error is below ``` exec linkedserver.database.dbo.failing_storedprocedure @id,'load ','v2',@file_name, @list_id = @listid output; ``` I've recreated the linked server and RPC is enabled.I've granted execute permission on the stored procedure. I can select records and execute other stored procedures on the linked server but the above exec is failing(it worked before the upgrade).Is there a syntax difference between SQL Server 2005 and SQL Server 2014 that is causing this to fail?
2016/03/04
[ "https://Stackoverflow.com/questions/35799905", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4681341/" ]
I figured out the issue. The linked server was created correctly. However, after the server was upgraded and switched the server name in `sys.servers` still had the old server name. I had to drop the old server name and add the new server name to `sys.servers` on the new server ``` sp_dropserver 'Server_A' GO sp_addserver 'Server',local GO ```
I had the problem due to an extra space in the name of the linked server. "SERVER1, 1234" instead of "SERVER1,1234"
35,799,905
I recently upgraded our SQL Server from 2005 to 2014 (linked server) and I am noticing that one of the stored procedures which calls the exec command to execute a stored procedure on the upgraded linked server is failing with the error > > Could not find server 'server name' in sys.servers.Verify that the correct server name was specified. If necessary, execute the stored procedure sp\_addlinkedserver to add the server to sys.servers. > > > The issue is that the linked server exists and I have done tests to ensure I can query the tables from the linked server. Here are the checks I did to see if the linked server is configured correctly. ``` - select name from sys.servers -- > Lists the linked server - select top 10 * from linkedserver.database.dbo.table --> Gets top 10 records - exec linkedserver.database.dbo.storedproc --> Executes the stored procedure (I created a test stored procedure on the linked server and I can execute it) ``` However the one that is failing with the error is below ``` exec linkedserver.database.dbo.failing_storedprocedure @id,'load ','v2',@file_name, @list_id = @listid output; ``` I've recreated the linked server and RPC is enabled.I've granted execute permission on the stored procedure. I can select records and execute other stored procedures on the linked server but the above exec is failing(it worked before the upgrade).Is there a syntax difference between SQL Server 2005 and SQL Server 2014 that is causing this to fail?
2016/03/04
[ "https://Stackoverflow.com/questions/35799905", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4681341/" ]
At first check out that your linked server is in the list by this query ``` select name from sys.servers ``` If it not exists then try to add to the linked server ``` EXEC sp_addlinkedserver @server = 'SERVER_NAME' --or may be server ip address ``` After that login to that linked server by ``` EXEC sp_addlinkedsrvlogin 'SERVER_NAME' ,'false' ,NULL ,'USER_NAME' ,'PASSWORD' ``` Then you can do whatever you want ,treat it like your local server ``` exec [SERVER_NAME].[DATABASE_NAME].dbo.SP_NAME @sample_parameter ``` Finally you can drop that server from linked server list by ``` sp_dropserver 'SERVER_NAME', 'droplogins' ``` If it will help you then please upvote.
I had the problem due to an extra space in the name of the linked server. "SERVER1, 1234" instead of "SERVER1,1234"
2,437,271
I did a [git on the com.android.music](http://android.git.kernel.org/?p=platform/packages/apps/Music.git) app and then created a project in eclipse from existing code. I chose 2.1 as the sdk target but I am getting errors trying to compile. Is the music app referencing code that is not part of the 2.1 sdk? Can someone list the steps for how to compile in eclipse? `Description Resource Path Location Type ArrayListCursor cannot be resolved to a type PlaylistBrowserActivity.java Music/src/com/android/music line 529 Java Problem MediaFile cannot be resolved AlbumBrowserActivity.java`
2010/03/13
[ "https://Stackoverflow.com/questions/2437271", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16340/" ]
> > Is the music app referencing code that > is not part of the 2.1 sdk? > > > Absolutely. Most of the built-in apps for Android were created before there was an SDK. You will not be able to build them in isolation from the rest of the firmware without substantial work. Work which, BTW, would be welcome contributions back to the Android open source project, if you were so inclined... :-)
Check the applications manifest file. It will contain an attribute stating which version of the SDK the application was built with.
60,245,358
Background: Excel worksheet as front end to an Access database. Excel contains VBA code and uses ADODB to move values into and out of the tables in Access. One column is a composite value which describes a complex priority relationship. One digit for priority level (1-6), one letter for more granular level (A-C), and a type of project (Safety, Security, Enviro, etc.) The values look like "2B - Maint.", "2A - ProcCntl" I need to sort the results of a select \* query in different ways. Sometimes with the typical Alpha sort which would list 1A values before 1B before 4C. Other times I need to sort all the Safety as a group, Maint. as another, etc. A simple alpha sort on the project type doesn't work because the manager wants a specific order. I am using the Switch function to assign the order. I have found a couple of ways to make this work in Access but they all ask for a parameter value when I run the query. Entering a blank value gets the desired result. Moving the query into the VBA of Excel returns an error complaining of an empty parameter. Here is one of the "working" queries: > > SELECT \*, Mid([Priority],6,2) AS ProjClass, > Switch(ProjClass="Sa",1,ProjClass="En",2,ProjClass="Se",3,ProjClass="6S",4,ProjClass="Qu",5,ProjClass="Pr",6,ProjClass="Ma",7,ProjClass="Bu",8) > AS [FirstSort] > > > FROM tblProjects > > > ORDER BY [FirstSort] ASC, [Priority] ASC; > > > When I run this through the VBA I get > > Run-time error "No value given for one or more required parameters." > > > When I run it in Access a "Enter Parameter Value" dialog opens asking for FirstSort. I click through and see the result is correctly sorted. The root question: Why is Access seeing FirstSort as a parameter and not a field name? I think I need to understand that before I can fix the VBA issue.
2020/02/16
[ "https://Stackoverflow.com/questions/60245358", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12697019/" ]
Try this: ``` var event=this.addAlert; const dialogOptions: JQueryUI.DialogOptions = { width: "50%", height: "auto", buttons: { "Subscribe": function (e) { event("Yes"); //this.addAlert("Yes"); jQuery(this).dialog("close"); }, "No Thanks": function (e) { console.log("moo"); event("no"); jQuery(this).dialog("close"); }, "Ask me later": function (e) { //this.addAlert("Ask Me Later"); jQuery(this).dialog("close"); } } }; ```
This worked answered at [sharepoint spfx forum](https://sharepoint.stackexchange.com/questions/276286/spfx-jquery-dialog-button-click-does-not-find-public-function/276292?noredirect=1#comment293902_276292) ``` public onDialogButtonClick(status: string, e): void { this.addAlert(status); jQuery('.dialog', this.domElement).dialog("close"); } public render(): void { this.domElement.innerHTML = AlertTemplate.templateHtml; const dialogOptions: JQueryUI.DialogOptions = { width: "50%", height: "auto", buttons: { "Subscribe": this.onDialogButtonClick.bind(this, "Subscribe"), "No Thanks": this.onDialogButtonClick.bind(this, "No Thanks"), "Ask me later": this.onDialogButtonClick.bind(this, "Ask me later") } }; jQuery('.dialog', this.domElement).dialog(dialogOptions); jQuery(".ui-dialog-titlebar").hide(); } ```
16,770,454
I have a problem on my script, i would like to know : How to remove a class if the content of an element (such as div, img, etc) is equal to another content of another element (such as div, img, etc) ? Thanks for your answer
2013/05/27
[ "https://Stackoverflow.com/questions/16770454", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2424470/" ]
This i a grouping issue. The "normal" solution with xslt-1.0 is **muenchian grouping** (e.g look to [this](http://www.jenitennison.com/xslt/grouping/muenchian.html)). Therefor add a key to your xslt for your grouping condition: ``` <xsl:key name="kUniqueC" match="C" use="concat(Name,'|', Age, '|', Sex)"/> ``` Loop over groups: ``` <xsl:for-each select="//C[ generate-id() = generate-id(key('kUniqueC', concat(Name,'|', Age, '|', Sex))[1]) ]" > ``` Try this: ``` <xsl:template match="@* | node()"> <xsl:copy> <xsl:apply-templates select="@* | node()"/> </xsl:copy> </xsl:template> <xsl:template match="/"> <xsl:for-each select="//C[ generate-id() = generate-id(key('kUniqueC', concat(Name,'|', Age, '|', Sex))[1]) ]" > <xsl:apply-templates select="." /> </xsl:for-each> </xsl:template> ``` Output: ``` <C> <Name>John</Name> <Age>21</Age> <Sex>Male</Sex> </C><C> <Name>John</Name> <Age>50</Age> <Sex>Male</Sex> </C> ```
Is this what you're looking for? ``` <xsl:template match="A/B"> <xsl:for-each select="C"> <xsl:if test="not(following-sibling::C[Name = current()/Name and Age = current()/Age and Sex = current()/Sex])"> <xsl:value-of select="Name" />, <xsl:value-of select="Age" /> </xsl:if> </xsl:for-each> </xsl:template> ``` This will output Name, Age for the first 2 C nodes.
16,770,454
I have a problem on my script, i would like to know : How to remove a class if the content of an element (such as div, img, etc) is equal to another content of another element (such as div, img, etc) ? Thanks for your answer
2013/05/27
[ "https://Stackoverflow.com/questions/16770454", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2424470/" ]
Is this what you're looking for? ``` <xsl:template match="A/B"> <xsl:for-each select="C"> <xsl:if test="not(following-sibling::C[Name = current()/Name and Age = current()/Age and Sex = current()/Sex])"> <xsl:value-of select="Name" />, <xsl:value-of select="Age" /> </xsl:if> </xsl:for-each> </xsl:template> ``` This will output Name, Age for the first 2 C nodes.
``` <?xml version="1.0" encoding="ISO-8859-1"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="/"> <div> <xsl:for-each select="A/B/C"> <xsl:variable name="name" select="Name"/> <xsl:variable name="age" select="Age"/> <xsl:variable name="sex" select="Sex"/> <xsl:variable name="numEntries" select="count(//C[Name=$name][Age=$age][Sex=$sex])"/> <xsl:variable name="i" select="position()" /> <xsl:choose> <xsl:when test="$numEntries=1"> <p><xsl:value-of select="Name" /></p> <p><xsl:value-of select="Age" /></p> <p><xsl:value-of select="Sex" /></p> </xsl:when> <xsl:when test="$i &gt; $numEntries"> <p><xsl:value-of select="Name" /></p> <p><xsl:value-of select="Age" /></p> <p><xsl:value-of select="Sex" /></p> </xsl:when> </xsl:choose> </xsl:for-each> </div> </xsl:template> </xsl:stylesheet> ```
16,770,454
I have a problem on my script, i would like to know : How to remove a class if the content of an element (such as div, img, etc) is equal to another content of another element (such as div, img, etc) ? Thanks for your answer
2013/05/27
[ "https://Stackoverflow.com/questions/16770454", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2424470/" ]
This i a grouping issue. The "normal" solution with xslt-1.0 is **muenchian grouping** (e.g look to [this](http://www.jenitennison.com/xslt/grouping/muenchian.html)). Therefor add a key to your xslt for your grouping condition: ``` <xsl:key name="kUniqueC" match="C" use="concat(Name,'|', Age, '|', Sex)"/> ``` Loop over groups: ``` <xsl:for-each select="//C[ generate-id() = generate-id(key('kUniqueC', concat(Name,'|', Age, '|', Sex))[1]) ]" > ``` Try this: ``` <xsl:template match="@* | node()"> <xsl:copy> <xsl:apply-templates select="@* | node()"/> </xsl:copy> </xsl:template> <xsl:template match="/"> <xsl:for-each select="//C[ generate-id() = generate-id(key('kUniqueC', concat(Name,'|', Age, '|', Sex))[1]) ]" > <xsl:apply-templates select="." /> </xsl:for-each> </xsl:template> ``` Output: ``` <C> <Name>John</Name> <Age>21</Age> <Sex>Male</Sex> </C><C> <Name>John</Name> <Age>50</Age> <Sex>Male</Sex> </C> ```
``` <?xml version="1.0" encoding="ISO-8859-1"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="/"> <div> <xsl:for-each select="A/B/C"> <xsl:variable name="name" select="Name"/> <xsl:variable name="age" select="Age"/> <xsl:variable name="sex" select="Sex"/> <xsl:variable name="numEntries" select="count(//C[Name=$name][Age=$age][Sex=$sex])"/> <xsl:variable name="i" select="position()" /> <xsl:choose> <xsl:when test="$numEntries=1"> <p><xsl:value-of select="Name" /></p> <p><xsl:value-of select="Age" /></p> <p><xsl:value-of select="Sex" /></p> </xsl:when> <xsl:when test="$i &gt; $numEntries"> <p><xsl:value-of select="Name" /></p> <p><xsl:value-of select="Age" /></p> <p><xsl:value-of select="Sex" /></p> </xsl:when> </xsl:choose> </xsl:for-each> </div> </xsl:template> </xsl:stylesheet> ```
1,596,140
I have this code below to populate my UITableView on the fly. I have to display two kind of cells: a regular cell with a background image and a cell with a regular background image, plus a label and a button. if Indexpath.row is less than a control variable, then regular cells are drawn. If not, cells with buttons and labels are drawn. this is the code ``` - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *MyIdentifier = @"MyIdentifier"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:MyIdentifier]; if (cell == nil) { cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:MyIdentifier] autorelease]; } UIImage *imageU; if (indexPath.row < controlVariable) { imageU = [[[UIImage alloc]initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:[NSString stringWithFormat: @"table%d", indexPath.row] ofType:@"jpg"]] autorelease]; cell.imageView.image = imageU; } else { imageU = [[[UIImage alloc]initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:[NSString stringWithFormat: @"table-pg%d",numberX] ofType:@"jpg"]] autorelease]; cell.imageView.image = imageU; NSString * myString = [NSString stringWithFormat: @"pago%d", numberX]; UILabel * myLabel = [[UILabel alloc] initWithFrame:CGRectMake(5.0, 49.0, 200.0, 22.0)]; [myLabel setTextAlignment:UITextAlignmentLeft]; [myLabel setBackgroundColor:[UIColor blueColor]]; [myLabel setClipsToBounds:YES]; [myLabel setFont:[UIFont systemFontOfSize:14.0]]; [myLabel setTextColor:[UIColor blackColor]]; [myLabel setText: myString]; [myLabel setAlpha:0.6]; [cell addSubview: myLabel]; [myLabel release]; UIButton *buyButton = [[UIButton alloc] initWithFrame:CGRectMake( 220, 4, 100, 35)]; buyButton.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter; buyButton.contentHorizontalAlignment = UIControlContentHorizontalAlignmentCenter; [buyButton setTitle:NSLocalizedString(@"buyKey", @"") forState:UIControlStateNormal]; [buyButton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal]; buyButton.titleLabel.font = [UIFont boldSystemFontOfSize:14]; UIImage *newImage = [[[[UIImage alloc]initWithContentsOfFile:[[NSBundle mainBundle] pathForResource: @"whiteButton" ofType:@"png"]] autorelease] stretchableImageWithLeftCapWidth:12.0f topCapHeight:0.0f]; [buyButton setBackgroundImage:newImage forState:UIControlStateNormal]; [buyButton addTarget:self action:@selector(comprar:) forControlEvents:UIControlEventTouchDown]; buyButton.backgroundColor = [UIColor clearColor]; [buyButton setTag:indexPath.row]; [cell addSubview:buyButton]; [buyButton release]; } return cell; } ``` The problem with this code is: when I scroll the UITableView down and reach the division between regular cells and cells with buttons and labels, I see it is rendering correctly, but if I go up after going deep down, I see the buttons and labels being added to cells that were not supposed to have them. From this point forward, all cells contains buttons and labels... It is like the cells are not releasing its contents before drawing. It is like labels and buttons are being added on top of other buttons and labels already on the cell. Cells are not releasing its contents before drawing again. How to solve that? thanks for any help. NOTE: I see barely no difference after making the changes suggested by the two first answers. Now, not all cells are wrong, just some. They change every time I scroll down the table and return to the beginning of the table.
2009/10/20
[ "https://Stackoverflow.com/questions/1596140", "https://Stackoverflow.com", "https://Stackoverflow.com/users/316469/" ]
You should use a separate `reuseIdentifier` for each cell 'type' that you are using. In this case, you'll want to use two. You'll also want to create/add the `UILabel` and `UIButton` when you get a dequeue *miss* and not for every run through.. In pseudocode: ``` UILabel * lbl; UIButton * btn; cell = [table dequeueReusableCellWithIdentifier:correctIdentifier]; if (cell == nil) { cell = ...; // alloc cell lbl = ...; lbl.tag = kTagLabel; [cell addSubView:lbl]; btn = ...; btn.tag = kTagButton; [cell addSubView:btn]; } else { lbl = (UILabel*)[cell viewWithTag:kTagLabel]; btn = (UIButton*)[cell viewWithTag:kTagButton]; } //... now set the text/image appropriately. ``` Otherwise, you create a label and button each time the cell is dequeued from the table. Scrolling up and down will cause lots of labels and buttons to be created that never get released.
You should use two different reuseIdentifiers; one for cells with just images, and one for cells with images and buttons. The problem is that your one cell type is being reused, but its content is not (nor should it be) cleared out when it's dequeued.
59,545,790
I have hundreds of rows in a string that look like this: ``` filler|filler|scrape this text|and this text|sometimes this to|filler|filler ``` Is it possible to select only the text after the 2nd | and before the last 2 |s?
2019/12/31
[ "https://Stackoverflow.com/questions/59545790", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1467996/" ]
Since you are on 2016, string\_split() would be an option, but there is no GTD of the order. That said, consider a little XML **Example** ``` Declare @YourTable Table ([ID] int,[SomeCol] varchar(150)) Insert Into @YourTable Values (1,'filler|filler|scrape this text|and this text|sometimes this to|filler|filler') Select A.ID ,B.Pos3 ,B.Pos4 ,B.Pos5 From @YourTable A Cross Apply ( Select Pos1 = ltrim(rtrim(xDim.value('/x[1]','varchar(max)'))) ,Pos2 = ltrim(rtrim(xDim.value('/x[2]','varchar(max)'))) ,Pos3 = ltrim(rtrim(xDim.value('/x[3]','varchar(max)'))) ,Pos4 = ltrim(rtrim(xDim.value('/x[4]','varchar(max)'))) ,Pos5 = ltrim(rtrim(xDim.value('/x[5]','varchar(max)'))) ,Pos6 = ltrim(rtrim(xDim.value('/x[6]','varchar(max)'))) ,Pos7 = ltrim(rtrim(xDim.value('/x[7]','varchar(max)'))) From ( values (cast('<x>' + replace((Select replace(SomeCol,'|','§§Split§§') as [*] For XML Path('')),'§§Split§§','</x><x>')+'</x>' as xml))) A(xDim) ) B ``` **Returns** ``` ID Pos3 Pos4 Pos5 1 scrape this text and this text sometimes this to ```
JSON-based approach is also an option here. You need to transform the input text into a valid JSON array and get each array item with `JSON_VALUE()` by index (0-based). Table: ``` CREATE TABLE Data ( TextData nvarchar(max) ) INSERT INTO Data (TextData) VALUES (N'filler|filler|scrape this text|and this text|sometimes this to|filler|filler') ``` Statement: ``` SELECT JSON_VALUE(CONCAT(N'["', REPLACE(d.TextData, N'|', N'","'), N'"]'), '$[2]') AS Text3, JSON_VALUE(CONCAT(N'["', REPLACE(d.TextData, N'|', N'","'), N'"]'), '$[3]') AS Text4, JSON_VALUE(CONCAT(N'["', REPLACE(d.TextData, N'|', N'","'), N'"]'), '$[4]') AS Text5 FROM Data d ``` Result: ``` ----------------------------------------------------- Text3 Text4 Text5 ----------------------------------------------------- scrape this text and this text sometimes this to ```
112,599
Is it possible to use SFTP on Linux and restrict a user account to ONE directory such that no other directory listing can be obtained? Yes, I must use SFTP, FTP is only used by people that love getting hacked. For instance I want someone to modify files in /var/www/code/ but I don't want them to be able modify anything else. I don't even want them to see the contents /tmp/. (I will accept a "quick and dirty" solution, as long as it is **secure**.)
2010/02/13
[ "https://serverfault.com/questions/112599", "https://serverfault.com", "https://serverfault.com/users/30776/" ]
From sshd\_config man-page: ``` ChrootDirectory Specifies a path to chroot(2) to after authentication. This path, and all its components, must be root-owned directories that are not writable by any other user or group. After the chroot, sshd(8) changes the working directory to the user's home directo- ry. The path may contain the following tokens that are expanded at runtime once the connecting user has been authenticated: %% is replaced by a literal '%', %h is replaced by the home directory of the user being authenticated, and %u is replaced by the user- name of that user. The ChrootDirectory must contain the necessary files and directo- ries to support the user's session. For an interactive session this requires at least a shell, typically sh(1), and basic /dev nodes such as null(4), zero(4), stdin(4), stdout(4), stderr(4), arandom(4) and tty(4) devices. For file transfer sessions using ``sftp'', no additional configuration of the environment is nec- essary if the in-process sftp server is used, though sessions which use logging do require /dev/log inside the chroot directory (see sftp-server(8) for details). The default is not to chroot(2). ```
SFTP is NOT a feature-rich solution comparable to an FTP server like vsftpd. It doesn't support chroots; which is what you are looking for. FTPS (not SFTP) would be the best solution since it supports encryption, chroots, etc. vsftpd supports this and it's easy to setup. In addition be sure to take advantage of the pam\_listfile module to explicitly state which users are allowed to login via ftps.
112,599
Is it possible to use SFTP on Linux and restrict a user account to ONE directory such that no other directory listing can be obtained? Yes, I must use SFTP, FTP is only used by people that love getting hacked. For instance I want someone to modify files in /var/www/code/ but I don't want them to be able modify anything else. I don't even want them to see the contents /tmp/. (I will accept a "quick and dirty" solution, as long as it is **secure**.)
2010/02/13
[ "https://serverfault.com/questions/112599", "https://serverfault.com", "https://serverfault.com/users/30776/" ]
Another alternative could also be to replace their shell with MySecureShell which gives you features such as Chroot, Bandwidth limiting, Connection limiting, etc.. etc.. <http://mysecureshell.sourceforge.net/> Using it in a webhosting environment at the moment and must say it's worked out quite nicely.
SFTP is NOT a feature-rich solution comparable to an FTP server like vsftpd. It doesn't support chroots; which is what you are looking for. FTPS (not SFTP) would be the best solution since it supports encryption, chroots, etc. vsftpd supports this and it's easy to setup. In addition be sure to take advantage of the pam\_listfile module to explicitly state which users are allowed to login via ftps.
112,599
Is it possible to use SFTP on Linux and restrict a user account to ONE directory such that no other directory listing can be obtained? Yes, I must use SFTP, FTP is only used by people that love getting hacked. For instance I want someone to modify files in /var/www/code/ but I don't want them to be able modify anything else. I don't even want them to see the contents /tmp/. (I will accept a "quick and dirty" solution, as long as it is **secure**.)
2010/02/13
[ "https://serverfault.com/questions/112599", "https://serverfault.com", "https://serverfault.com/users/30776/" ]
From sshd\_config man-page: ``` ChrootDirectory Specifies a path to chroot(2) to after authentication. This path, and all its components, must be root-owned directories that are not writable by any other user or group. After the chroot, sshd(8) changes the working directory to the user's home directo- ry. The path may contain the following tokens that are expanded at runtime once the connecting user has been authenticated: %% is replaced by a literal '%', %h is replaced by the home directory of the user being authenticated, and %u is replaced by the user- name of that user. The ChrootDirectory must contain the necessary files and directo- ries to support the user's session. For an interactive session this requires at least a shell, typically sh(1), and basic /dev nodes such as null(4), zero(4), stdin(4), stdout(4), stderr(4), arandom(4) and tty(4) devices. For file transfer sessions using ``sftp'', no additional configuration of the environment is nec- essary if the in-process sftp server is used, though sessions which use logging do require /dev/log inside the chroot directory (see sftp-server(8) for details). The default is not to chroot(2). ```
Another alternative could also be to replace their shell with MySecureShell which gives you features such as Chroot, Bandwidth limiting, Connection limiting, etc.. etc.. <http://mysecureshell.sourceforge.net/> Using it in a webhosting environment at the moment and must say it's worked out quite nicely.
112,599
Is it possible to use SFTP on Linux and restrict a user account to ONE directory such that no other directory listing can be obtained? Yes, I must use SFTP, FTP is only used by people that love getting hacked. For instance I want someone to modify files in /var/www/code/ but I don't want them to be able modify anything else. I don't even want them to see the contents /tmp/. (I will accept a "quick and dirty" solution, as long as it is **secure**.)
2010/02/13
[ "https://serverfault.com/questions/112599", "https://serverfault.com", "https://serverfault.com/users/30776/" ]
From sshd\_config man-page: ``` ChrootDirectory Specifies a path to chroot(2) to after authentication. This path, and all its components, must be root-owned directories that are not writable by any other user or group. After the chroot, sshd(8) changes the working directory to the user's home directo- ry. The path may contain the following tokens that are expanded at runtime once the connecting user has been authenticated: %% is replaced by a literal '%', %h is replaced by the home directory of the user being authenticated, and %u is replaced by the user- name of that user. The ChrootDirectory must contain the necessary files and directo- ries to support the user's session. For an interactive session this requires at least a shell, typically sh(1), and basic /dev nodes such as null(4), zero(4), stdin(4), stdout(4), stderr(4), arandom(4) and tty(4) devices. For file transfer sessions using ``sftp'', no additional configuration of the environment is nec- essary if the in-process sftp server is used, though sessions which use logging do require /dev/log inside the chroot directory (see sftp-server(8) for details). The default is not to chroot(2). ```
<http://pizzashack.org/rssh/> lets you set up restricted ssh so that only SFTP/SCP are run; it also helps setting up the chroot. As CarpeNoctem points out, FTPS sometimes is a better solution. ssh, SFTP, scp are very "low-level", FTPS (like the unsafe FTP) are normally higher-level (virtual directories, virtual users, etc.). I think for the scenario you describe, both approaches would work.
112,599
Is it possible to use SFTP on Linux and restrict a user account to ONE directory such that no other directory listing can be obtained? Yes, I must use SFTP, FTP is only used by people that love getting hacked. For instance I want someone to modify files in /var/www/code/ but I don't want them to be able modify anything else. I don't even want them to see the contents /tmp/. (I will accept a "quick and dirty" solution, as long as it is **secure**.)
2010/02/13
[ "https://serverfault.com/questions/112599", "https://serverfault.com", "https://serverfault.com/users/30776/" ]
From sshd\_config man-page: ``` ChrootDirectory Specifies a path to chroot(2) to after authentication. This path, and all its components, must be root-owned directories that are not writable by any other user or group. After the chroot, sshd(8) changes the working directory to the user's home directo- ry. The path may contain the following tokens that are expanded at runtime once the connecting user has been authenticated: %% is replaced by a literal '%', %h is replaced by the home directory of the user being authenticated, and %u is replaced by the user- name of that user. The ChrootDirectory must contain the necessary files and directo- ries to support the user's session. For an interactive session this requires at least a shell, typically sh(1), and basic /dev nodes such as null(4), zero(4), stdin(4), stdout(4), stderr(4), arandom(4) and tty(4) devices. For file transfer sessions using ``sftp'', no additional configuration of the environment is nec- essary if the in-process sftp server is used, though sessions which use logging do require /dev/log inside the chroot directory (see sftp-server(8) for details). The default is not to chroot(2). ```
I'd use this config: <http://www.debian-administration.org/articles/590> Then, for the chroot functionality: <http://www.howtoforge.com/chrooted-ssh-sftp-tutorial-debian-lenny>
112,599
Is it possible to use SFTP on Linux and restrict a user account to ONE directory such that no other directory listing can be obtained? Yes, I must use SFTP, FTP is only used by people that love getting hacked. For instance I want someone to modify files in /var/www/code/ but I don't want them to be able modify anything else. I don't even want them to see the contents /tmp/. (I will accept a "quick and dirty" solution, as long as it is **secure**.)
2010/02/13
[ "https://serverfault.com/questions/112599", "https://serverfault.com", "https://serverfault.com/users/30776/" ]
Another alternative could also be to replace their shell with MySecureShell which gives you features such as Chroot, Bandwidth limiting, Connection limiting, etc.. etc.. <http://mysecureshell.sourceforge.net/> Using it in a webhosting environment at the moment and must say it's worked out quite nicely.
<http://pizzashack.org/rssh/> lets you set up restricted ssh so that only SFTP/SCP are run; it also helps setting up the chroot. As CarpeNoctem points out, FTPS sometimes is a better solution. ssh, SFTP, scp are very "low-level", FTPS (like the unsafe FTP) are normally higher-level (virtual directories, virtual users, etc.). I think for the scenario you describe, both approaches would work.
112,599
Is it possible to use SFTP on Linux and restrict a user account to ONE directory such that no other directory listing can be obtained? Yes, I must use SFTP, FTP is only used by people that love getting hacked. For instance I want someone to modify files in /var/www/code/ but I don't want them to be able modify anything else. I don't even want them to see the contents /tmp/. (I will accept a "quick and dirty" solution, as long as it is **secure**.)
2010/02/13
[ "https://serverfault.com/questions/112599", "https://serverfault.com", "https://serverfault.com/users/30776/" ]
Another alternative could also be to replace their shell with MySecureShell which gives you features such as Chroot, Bandwidth limiting, Connection limiting, etc.. etc.. <http://mysecureshell.sourceforge.net/> Using it in a webhosting environment at the moment and must say it's worked out quite nicely.
I'd use this config: <http://www.debian-administration.org/articles/590> Then, for the chroot functionality: <http://www.howtoforge.com/chrooted-ssh-sftp-tutorial-debian-lenny>
32,655,317
I've read been reading StackOverflow posts for the last 30 minutes and none of them work. Maybe there is a server setup that is preventing this from working? I just want to remove index.php from whatever URL is typed in. For example, `www.mysite.com/blah/blah/index.php` would become `www.mysite.com/blah/blah/`. `www.mysite.com/index.php` would become `www.mysite.com/`. I've read at least 10 posts and tried each one, but it ALWAYS just redirects to the root. Here is the current code I'm using that looks like it should work: ``` Options +FollowSymLinks Options +Indexes <IfModule mod_rewrite.c> RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ /index.php?/$1 [L] </IfModule> ``` Instead of just removing index.php from the URL, it redirects to the root of the site.
2015/09/18
[ "https://Stackoverflow.com/questions/32655317", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2211053/" ]
I think this is what you are looking for: ``` RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)/?$ $1/index.php [L,QSA] ```
``` <IfModule mod_rewrite.c> RewriteEngine On RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /(.*)index\.php($|\ |\?) RewriteRule ^ /%1 [R=301,L] </IfModule> ```
49,186
I have a shapefile whose features I can filter by specifying a where clause in the query dialogue. F.x. I have a field named 'city\_name' and by stating 'city\_name = "London"' in the where clause only London is displayed. What I would like to do now is to fetch all values in 'city\_name' from the attribute table. Something like that: ``` select distinct city_name from [attribute table] ``` I found several tools in QGIS apparently dealing with SQL and I also had a quick look at the different Plugins. But I fail at connecting to a database or the table name ... what database or which table in that case? In the end I want to export the result list and use it for further processing. I am using QGIS 1.8.
2013/01/27
[ "https://gis.stackexchange.com/questions/49186", "https://gis.stackexchange.com", "https://gis.stackexchange.com/users/14532/" ]
**Update answer (QGIS Version >= 2.14)** [Since QGIS 2.14](http://www.qgis.org/en/site/forusers/visualchangelog214/index.html#feature-virtual-layers), you can use run SQL statements on any loaded vector layer using [Virtual layers](http://docs.qgis.org/2.14/en/docs/user_manual/working_with_vector/virtual_layers.html?highlight=virtual%20layers). 1. Having the layer loaded in QGIS, go to **Layer > Add Layer > Add/Edit Virtual Layer**; 2. In the Create virtual layer dialog, enter you SQL statement in the Query field. Something like: SELECT DISTINCT city\_name FROM layer\_name 3. For geometry set No Geometry 4. Click Ok and a table will load in QGIS with the desired unique values. Note: this table will be updated if new values are added to the city\_name column. **Legacy answer (QGIS Version < 2.14)** You have a few choices to do what you ask. 1. Import your shapefile in a Spatialite or Postgis database, and then you can query your table using complete SQL statements; 2. Use the Dissolve tool (Vector > Geoprocessing Tools > Dissolve), to dissolve your shapefiles using the field "city\_name". Although is an strange method, the dbf file of the resulting shapefile will provide the list you need; 3. Take a look at [group stats plugin (1.6)](http://plugins.qgis.org/plugins/GroupStats/), you can use "city\_name" as classification field, and press calculate. It will calculate some stats about each city, you can then copy the result and extract the city list. --- I have just noticed that, in the **Vector > Analysis Tools**, there is a **List unique Values** tool that is precisely what one needs for this task. So easy... no workarounds and no need for Plugins.
Try including something like: ``` where city_name is NOT NULL or not equal to NULL ```
49,186
I have a shapefile whose features I can filter by specifying a where clause in the query dialogue. F.x. I have a field named 'city\_name' and by stating 'city\_name = "London"' in the where clause only London is displayed. What I would like to do now is to fetch all values in 'city\_name' from the attribute table. Something like that: ``` select distinct city_name from [attribute table] ``` I found several tools in QGIS apparently dealing with SQL and I also had a quick look at the different Plugins. But I fail at connecting to a database or the table name ... what database or which table in that case? In the end I want to export the result list and use it for further processing. I am using QGIS 1.8.
2013/01/27
[ "https://gis.stackexchange.com/questions/49186", "https://gis.stackexchange.com", "https://gis.stackexchange.com/users/14532/" ]
Try including something like: ``` where city_name is NOT NULL or not equal to NULL ```
Use query builder in QGIS, go to city name field in fields in query builder. Go to values, add all. Delete any nulls. Build a script similar to city name = "london" and city name = "paris" until you have the complete list of names and run the script. Now all city names are selected. You can export selected as a shape file and import into a postgresql database. To use a postgresql backend to QGIS install a postgresql stack with geoserver, postgresql, and a postgis enabled databse in postgresql. You will need to connect QGIS to the server. Play around a bit and you will figure it out.
49,186
I have a shapefile whose features I can filter by specifying a where clause in the query dialogue. F.x. I have a field named 'city\_name' and by stating 'city\_name = "London"' in the where clause only London is displayed. What I would like to do now is to fetch all values in 'city\_name' from the attribute table. Something like that: ``` select distinct city_name from [attribute table] ``` I found several tools in QGIS apparently dealing with SQL and I also had a quick look at the different Plugins. But I fail at connecting to a database or the table name ... what database or which table in that case? In the end I want to export the result list and use it for further processing. I am using QGIS 1.8.
2013/01/27
[ "https://gis.stackexchange.com/questions/49186", "https://gis.stackexchange.com", "https://gis.stackexchange.com/users/14532/" ]
Use the QGIS DB Manager and access your shapefile via 'virtual layers' You can then use the SQL window and write your query: [![enter image description here](https://i.stack.imgur.com/5ydzP.png)](https://i.stack.imgur.com/5ydzP.png)
Try including something like: ``` where city_name is NOT NULL or not equal to NULL ```
49,186
I have a shapefile whose features I can filter by specifying a where clause in the query dialogue. F.x. I have a field named 'city\_name' and by stating 'city\_name = "London"' in the where clause only London is displayed. What I would like to do now is to fetch all values in 'city\_name' from the attribute table. Something like that: ``` select distinct city_name from [attribute table] ``` I found several tools in QGIS apparently dealing with SQL and I also had a quick look at the different Plugins. But I fail at connecting to a database or the table name ... what database or which table in that case? In the end I want to export the result list and use it for further processing. I am using QGIS 1.8.
2013/01/27
[ "https://gis.stackexchange.com/questions/49186", "https://gis.stackexchange.com", "https://gis.stackexchange.com/users/14532/" ]
QGIS now has a tool that will list unique values in one or more fields in a layer. "This algorithm generates a report with information about the unique values found in a given attribute (or attributes) of a vector layer." Can be found in main menu Vector> Analysis Tools> List Unique Values. Generates a table with unique values.
Try including something like: ``` where city_name is NOT NULL or not equal to NULL ```
49,186
I have a shapefile whose features I can filter by specifying a where clause in the query dialogue. F.x. I have a field named 'city\_name' and by stating 'city\_name = "London"' in the where clause only London is displayed. What I would like to do now is to fetch all values in 'city\_name' from the attribute table. Something like that: ``` select distinct city_name from [attribute table] ``` I found several tools in QGIS apparently dealing with SQL and I also had a quick look at the different Plugins. But I fail at connecting to a database or the table name ... what database or which table in that case? In the end I want to export the result list and use it for further processing. I am using QGIS 1.8.
2013/01/27
[ "https://gis.stackexchange.com/questions/49186", "https://gis.stackexchange.com", "https://gis.stackexchange.com/users/14532/" ]
**Update answer (QGIS Version >= 2.14)** [Since QGIS 2.14](http://www.qgis.org/en/site/forusers/visualchangelog214/index.html#feature-virtual-layers), you can use run SQL statements on any loaded vector layer using [Virtual layers](http://docs.qgis.org/2.14/en/docs/user_manual/working_with_vector/virtual_layers.html?highlight=virtual%20layers). 1. Having the layer loaded in QGIS, go to **Layer > Add Layer > Add/Edit Virtual Layer**; 2. In the Create virtual layer dialog, enter you SQL statement in the Query field. Something like: SELECT DISTINCT city\_name FROM layer\_name 3. For geometry set No Geometry 4. Click Ok and a table will load in QGIS with the desired unique values. Note: this table will be updated if new values are added to the city\_name column. **Legacy answer (QGIS Version < 2.14)** You have a few choices to do what you ask. 1. Import your shapefile in a Spatialite or Postgis database, and then you can query your table using complete SQL statements; 2. Use the Dissolve tool (Vector > Geoprocessing Tools > Dissolve), to dissolve your shapefiles using the field "city\_name". Although is an strange method, the dbf file of the resulting shapefile will provide the list you need; 3. Take a look at [group stats plugin (1.6)](http://plugins.qgis.org/plugins/GroupStats/), you can use "city\_name" as classification field, and press calculate. It will calculate some stats about each city, you can then copy the result and extract the city list. --- I have just noticed that, in the **Vector > Analysis Tools**, there is a **List unique Values** tool that is precisely what one needs for this task. So easy... no workarounds and no need for Plugins.
Use query builder in QGIS, go to city name field in fields in query builder. Go to values, add all. Delete any nulls. Build a script similar to city name = "london" and city name = "paris" until you have the complete list of names and run the script. Now all city names are selected. You can export selected as a shape file and import into a postgresql database. To use a postgresql backend to QGIS install a postgresql stack with geoserver, postgresql, and a postgis enabled databse in postgresql. You will need to connect QGIS to the server. Play around a bit and you will figure it out.
49,186
I have a shapefile whose features I can filter by specifying a where clause in the query dialogue. F.x. I have a field named 'city\_name' and by stating 'city\_name = "London"' in the where clause only London is displayed. What I would like to do now is to fetch all values in 'city\_name' from the attribute table. Something like that: ``` select distinct city_name from [attribute table] ``` I found several tools in QGIS apparently dealing with SQL and I also had a quick look at the different Plugins. But I fail at connecting to a database or the table name ... what database or which table in that case? In the end I want to export the result list and use it for further processing. I am using QGIS 1.8.
2013/01/27
[ "https://gis.stackexchange.com/questions/49186", "https://gis.stackexchange.com", "https://gis.stackexchange.com/users/14532/" ]
**Update answer (QGIS Version >= 2.14)** [Since QGIS 2.14](http://www.qgis.org/en/site/forusers/visualchangelog214/index.html#feature-virtual-layers), you can use run SQL statements on any loaded vector layer using [Virtual layers](http://docs.qgis.org/2.14/en/docs/user_manual/working_with_vector/virtual_layers.html?highlight=virtual%20layers). 1. Having the layer loaded in QGIS, go to **Layer > Add Layer > Add/Edit Virtual Layer**; 2. In the Create virtual layer dialog, enter you SQL statement in the Query field. Something like: SELECT DISTINCT city\_name FROM layer\_name 3. For geometry set No Geometry 4. Click Ok and a table will load in QGIS with the desired unique values. Note: this table will be updated if new values are added to the city\_name column. **Legacy answer (QGIS Version < 2.14)** You have a few choices to do what you ask. 1. Import your shapefile in a Spatialite or Postgis database, and then you can query your table using complete SQL statements; 2. Use the Dissolve tool (Vector > Geoprocessing Tools > Dissolve), to dissolve your shapefiles using the field "city\_name". Although is an strange method, the dbf file of the resulting shapefile will provide the list you need; 3. Take a look at [group stats plugin (1.6)](http://plugins.qgis.org/plugins/GroupStats/), you can use "city\_name" as classification field, and press calculate. It will calculate some stats about each city, you can then copy the result and extract the city list. --- I have just noticed that, in the **Vector > Analysis Tools**, there is a **List unique Values** tool that is precisely what one needs for this task. So easy... no workarounds and no need for Plugins.
Use the QGIS DB Manager and access your shapefile via 'virtual layers' You can then use the SQL window and write your query: [![enter image description here](https://i.stack.imgur.com/5ydzP.png)](https://i.stack.imgur.com/5ydzP.png)
49,186
I have a shapefile whose features I can filter by specifying a where clause in the query dialogue. F.x. I have a field named 'city\_name' and by stating 'city\_name = "London"' in the where clause only London is displayed. What I would like to do now is to fetch all values in 'city\_name' from the attribute table. Something like that: ``` select distinct city_name from [attribute table] ``` I found several tools in QGIS apparently dealing with SQL and I also had a quick look at the different Plugins. But I fail at connecting to a database or the table name ... what database or which table in that case? In the end I want to export the result list and use it for further processing. I am using QGIS 1.8.
2013/01/27
[ "https://gis.stackexchange.com/questions/49186", "https://gis.stackexchange.com", "https://gis.stackexchange.com/users/14532/" ]
**Update answer (QGIS Version >= 2.14)** [Since QGIS 2.14](http://www.qgis.org/en/site/forusers/visualchangelog214/index.html#feature-virtual-layers), you can use run SQL statements on any loaded vector layer using [Virtual layers](http://docs.qgis.org/2.14/en/docs/user_manual/working_with_vector/virtual_layers.html?highlight=virtual%20layers). 1. Having the layer loaded in QGIS, go to **Layer > Add Layer > Add/Edit Virtual Layer**; 2. In the Create virtual layer dialog, enter you SQL statement in the Query field. Something like: SELECT DISTINCT city\_name FROM layer\_name 3. For geometry set No Geometry 4. Click Ok and a table will load in QGIS with the desired unique values. Note: this table will be updated if new values are added to the city\_name column. **Legacy answer (QGIS Version < 2.14)** You have a few choices to do what you ask. 1. Import your shapefile in a Spatialite or Postgis database, and then you can query your table using complete SQL statements; 2. Use the Dissolve tool (Vector > Geoprocessing Tools > Dissolve), to dissolve your shapefiles using the field "city\_name". Although is an strange method, the dbf file of the resulting shapefile will provide the list you need; 3. Take a look at [group stats plugin (1.6)](http://plugins.qgis.org/plugins/GroupStats/), you can use "city\_name" as classification field, and press calculate. It will calculate some stats about each city, you can then copy the result and extract the city list. --- I have just noticed that, in the **Vector > Analysis Tools**, there is a **List unique Values** tool that is precisely what one needs for this task. So easy... no workarounds and no need for Plugins.
QGIS now has a tool that will list unique values in one or more fields in a layer. "This algorithm generates a report with information about the unique values found in a given attribute (or attributes) of a vector layer." Can be found in main menu Vector> Analysis Tools> List Unique Values. Generates a table with unique values.
49,186
I have a shapefile whose features I can filter by specifying a where clause in the query dialogue. F.x. I have a field named 'city\_name' and by stating 'city\_name = "London"' in the where clause only London is displayed. What I would like to do now is to fetch all values in 'city\_name' from the attribute table. Something like that: ``` select distinct city_name from [attribute table] ``` I found several tools in QGIS apparently dealing with SQL and I also had a quick look at the different Plugins. But I fail at connecting to a database or the table name ... what database or which table in that case? In the end I want to export the result list and use it for further processing. I am using QGIS 1.8.
2013/01/27
[ "https://gis.stackexchange.com/questions/49186", "https://gis.stackexchange.com", "https://gis.stackexchange.com/users/14532/" ]
Use the QGIS DB Manager and access your shapefile via 'virtual layers' You can then use the SQL window and write your query: [![enter image description here](https://i.stack.imgur.com/5ydzP.png)](https://i.stack.imgur.com/5ydzP.png)
Use query builder in QGIS, go to city name field in fields in query builder. Go to values, add all. Delete any nulls. Build a script similar to city name = "london" and city name = "paris" until you have the complete list of names and run the script. Now all city names are selected. You can export selected as a shape file and import into a postgresql database. To use a postgresql backend to QGIS install a postgresql stack with geoserver, postgresql, and a postgis enabled databse in postgresql. You will need to connect QGIS to the server. Play around a bit and you will figure it out.
49,186
I have a shapefile whose features I can filter by specifying a where clause in the query dialogue. F.x. I have a field named 'city\_name' and by stating 'city\_name = "London"' in the where clause only London is displayed. What I would like to do now is to fetch all values in 'city\_name' from the attribute table. Something like that: ``` select distinct city_name from [attribute table] ``` I found several tools in QGIS apparently dealing with SQL and I also had a quick look at the different Plugins. But I fail at connecting to a database or the table name ... what database or which table in that case? In the end I want to export the result list and use it for further processing. I am using QGIS 1.8.
2013/01/27
[ "https://gis.stackexchange.com/questions/49186", "https://gis.stackexchange.com", "https://gis.stackexchange.com/users/14532/" ]
QGIS now has a tool that will list unique values in one or more fields in a layer. "This algorithm generates a report with information about the unique values found in a given attribute (or attributes) of a vector layer." Can be found in main menu Vector> Analysis Tools> List Unique Values. Generates a table with unique values.
Use query builder in QGIS, go to city name field in fields in query builder. Go to values, add all. Delete any nulls. Build a script similar to city name = "london" and city name = "paris" until you have the complete list of names and run the script. Now all city names are selected. You can export selected as a shape file and import into a postgresql database. To use a postgresql backend to QGIS install a postgresql stack with geoserver, postgresql, and a postgis enabled databse in postgresql. You will need to connect QGIS to the server. Play around a bit and you will figure it out.
49,186
I have a shapefile whose features I can filter by specifying a where clause in the query dialogue. F.x. I have a field named 'city\_name' and by stating 'city\_name = "London"' in the where clause only London is displayed. What I would like to do now is to fetch all values in 'city\_name' from the attribute table. Something like that: ``` select distinct city_name from [attribute table] ``` I found several tools in QGIS apparently dealing with SQL and I also had a quick look at the different Plugins. But I fail at connecting to a database or the table name ... what database or which table in that case? In the end I want to export the result list and use it for further processing. I am using QGIS 1.8.
2013/01/27
[ "https://gis.stackexchange.com/questions/49186", "https://gis.stackexchange.com", "https://gis.stackexchange.com/users/14532/" ]
QGIS now has a tool that will list unique values in one or more fields in a layer. "This algorithm generates a report with information about the unique values found in a given attribute (or attributes) of a vector layer." Can be found in main menu Vector> Analysis Tools> List Unique Values. Generates a table with unique values.
Use the QGIS DB Manager and access your shapefile via 'virtual layers' You can then use the SQL window and write your query: [![enter image description here](https://i.stack.imgur.com/5ydzP.png)](https://i.stack.imgur.com/5ydzP.png)
14,699,155
One thing I found unintuitive about GCDAsyncSocket's didReadData callback is that it doesn't get call again unless you issue another readData. Why is it designed this way? Is it correct to expect the user of the library to initiate another read call in order to get a callback or is this a design flaw? e.g. ``` - (void)socket:(GCDAsyncSocket *)sock didAcceptNewSocket:(GCDAsyncSocket *)newSocket { ... // initiate the first read self.socket = newSocket; [self.socket readDataWithTimeout:-1 tag:0]; } - (void)socket:(GCDAsyncSocket *)sock didReadData:(NSData *)data withTag:(long)tag { // do what you need with the data... // read again, or didReadData won't get called! [self.socket readDataWithTimeout:-1 tag:0]; } ```
2013/02/05
[ "https://Stackoverflow.com/questions/14699155", "https://Stackoverflow.com", "https://Stackoverflow.com/users/66814/" ]
Why is it designed that way? As long as you're only ever using *readDataWithTimeout:tag:* it may seem more intuitive to just have the delegate method called whenever some new data has arrived. But *readDataWithTimeout:tag:* isn't the the only way to read data with GCDAsyncSocket. There are also e.g. *readDataToLength:withTimeout:tag:* and *readDataToData:withTimeout:tag:* Both of these methods call the delegate at specific points in the incoming data, and you might want to call different ones at different points in your processing. For example, if you were handling a stream format where there was a CRLF delimited header followed by a variable length body whose length was provided in the header then you might want to alternate between calls of *readDataToData:withTimeout:tag:* to read the header whose delimiter you know, and then *readDataToLength:withTimeout:tag:* to read the body whose length you have pulled from the header.
That is correct; you are expected to continue the read loop in the delegate method.
14,699,155
One thing I found unintuitive about GCDAsyncSocket's didReadData callback is that it doesn't get call again unless you issue another readData. Why is it designed this way? Is it correct to expect the user of the library to initiate another read call in order to get a callback or is this a design flaw? e.g. ``` - (void)socket:(GCDAsyncSocket *)sock didAcceptNewSocket:(GCDAsyncSocket *)newSocket { ... // initiate the first read self.socket = newSocket; [self.socket readDataWithTimeout:-1 tag:0]; } - (void)socket:(GCDAsyncSocket *)sock didReadData:(NSData *)data withTag:(long)tag { // do what you need with the data... // read again, or didReadData won't get called! [self.socket readDataWithTimeout:-1 tag:0]; } ```
2013/02/05
[ "https://Stackoverflow.com/questions/14699155", "https://Stackoverflow.com", "https://Stackoverflow.com/users/66814/" ]
That is correct; you are expected to continue the read loop in the delegate method.
Expanding on what Simon Jenkins said: ``` - (void)socket:(GCDAsyncSocket *)sock didWriteDataWithTag:(long)tag { // This method is executed on the socketQueue (not the main thread) switch (tag) { case CHECK_STAUTS: [sock readDataToData:[GCDAsyncSocket ZeroData] withTimeout:READ_TIMEOUT tag:CHECK_STAUTS]; break; default: break; } } - (void)socket:(GCDAsyncSocket *)sock didReadData:(NSData *)data withTag:(long)tag { // This method is executed on the socketQueue (not the main thread) dispatch_async(dispatch_get_main_queue(), ^{ @autoreleasepool { if (tag == CHECK_STAUTS) { //TODO: parse the msg to find the length. NSString *msg = [[NSString alloc] initWithData:data encoding:NSASCIIStringEncoding]; [serverSocket readDataToLength:LENGTH_BODY withTimeout:-1 tag:CHECK_STAUTS_BODY]; } else if (tag == CHECK_STAUTS_BODY) { //TODO: parse the msg to the body content NSString *msg = [[NSString alloc] initWithData:data encoding:NSASCIIStringEncoding]; } } }); // Echo message back to client //[sock writeData:data withTimeout:-1 tag:ECHO_MSG]; } ```
14,699,155
One thing I found unintuitive about GCDAsyncSocket's didReadData callback is that it doesn't get call again unless you issue another readData. Why is it designed this way? Is it correct to expect the user of the library to initiate another read call in order to get a callback or is this a design flaw? e.g. ``` - (void)socket:(GCDAsyncSocket *)sock didAcceptNewSocket:(GCDAsyncSocket *)newSocket { ... // initiate the first read self.socket = newSocket; [self.socket readDataWithTimeout:-1 tag:0]; } - (void)socket:(GCDAsyncSocket *)sock didReadData:(NSData *)data withTag:(long)tag { // do what you need with the data... // read again, or didReadData won't get called! [self.socket readDataWithTimeout:-1 tag:0]; } ```
2013/02/05
[ "https://Stackoverflow.com/questions/14699155", "https://Stackoverflow.com", "https://Stackoverflow.com/users/66814/" ]
Why is it designed that way? As long as you're only ever using *readDataWithTimeout:tag:* it may seem more intuitive to just have the delegate method called whenever some new data has arrived. But *readDataWithTimeout:tag:* isn't the the only way to read data with GCDAsyncSocket. There are also e.g. *readDataToLength:withTimeout:tag:* and *readDataToData:withTimeout:tag:* Both of these methods call the delegate at specific points in the incoming data, and you might want to call different ones at different points in your processing. For example, if you were handling a stream format where there was a CRLF delimited header followed by a variable length body whose length was provided in the header then you might want to alternate between calls of *readDataToData:withTimeout:tag:* to read the header whose delimiter you know, and then *readDataToLength:withTimeout:tag:* to read the body whose length you have pulled from the header.
Expanding on what Simon Jenkins said: ``` - (void)socket:(GCDAsyncSocket *)sock didWriteDataWithTag:(long)tag { // This method is executed on the socketQueue (not the main thread) switch (tag) { case CHECK_STAUTS: [sock readDataToData:[GCDAsyncSocket ZeroData] withTimeout:READ_TIMEOUT tag:CHECK_STAUTS]; break; default: break; } } - (void)socket:(GCDAsyncSocket *)sock didReadData:(NSData *)data withTag:(long)tag { // This method is executed on the socketQueue (not the main thread) dispatch_async(dispatch_get_main_queue(), ^{ @autoreleasepool { if (tag == CHECK_STAUTS) { //TODO: parse the msg to find the length. NSString *msg = [[NSString alloc] initWithData:data encoding:NSASCIIStringEncoding]; [serverSocket readDataToLength:LENGTH_BODY withTimeout:-1 tag:CHECK_STAUTS_BODY]; } else if (tag == CHECK_STAUTS_BODY) { //TODO: parse the msg to the body content NSString *msg = [[NSString alloc] initWithData:data encoding:NSASCIIStringEncoding]; } } }); // Echo message back to client //[sock writeData:data withTimeout:-1 tag:ECHO_MSG]; } ```
59,174,408
I want a text that flashes with a clock's seconds. This [Link](https://stackoverflow.com/questions/27533244/how-to-make-a-flashing-text-box-in-tkinter) was helpful, but couldn't solve my problem. Below is my little working code: ``` from tkinter import * from datetime import datetime import datetime as dt import time def change_color(): curtime='' newtime = time.strftime('%H:%M:%S') if newtime != curtime: curtime = dt.date.today().strftime("%B")[:3]+", "+dt.datetime.now().strftime("%d")+"\n"+newtime clock.config(text=curtime) clock.after(200, change_color) flash_colours=('black', 'red') for i in range(0, len(flash_colours)): print("{0}".format(flash_colours[i])) flashing_text.config(foreground="{0}".format(flash_colours[i])) root = Tk() clock = Label(root, text="clock") clock.pack() flashing_text = Label(root, text="Flashing text") flashing_text.pack() change_color() root.mainloop() ``` This line of code: `print("{0}".format(flash_colours[i]))` prints the alternating colors on the console as the function calls itself every 200s. But the flashing\_text Label's text foreground doesn't change colors. Does anybody have a solution to this problem? Thanks! Please forgive my bad coding.
2019/12/04
[ "https://Stackoverflow.com/questions/59174408", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8454718/" ]
Although you have changed the color of the `flashing_text` in the for loop twice, but the tkinter event handler (`mainloop()`) can only process the changes when it takes back the control after `change_color()` completed. So you can only see the `flashing_text` in red (the last color change). To achieve the goal, you need to change the color once in the `change_color()`. Below is a modified `change_color()`: ``` def change_color(color_idx=0, pasttime=None): newtime = time.strftime('%H:%M:%S') if newtime != pasttime: curtime = dt.date.today().strftime("%B")[:3]+", "+dt.datetime.now().strftime("%d")+"\n"+newtime clock.config(text=curtime) flash_colors = ('black', 'red') flashing_text.config(foreground=flash_colors[color_idx]) clock.after(200, change_color, 1-color_idx, newtime) ```
I would add it to a class so you can share your variables from each callback. So something like this. ``` from tkinter import * from datetime import datetime import datetime as dt import time class Clock: def __init__(self, colors): self.root = Tk() self.clock = Label(self.root, text="clock") self.clock.pack() self.flashing_text = Label(self.root, text="Flashing text") self.flashing_text.pack() self.curtime = time.strftime('%H:%M:%S') self.flash_colours = colors self.current_colour = 0 self.change_color() self.root.mainloop() def change_color(self): self.newtime = time.strftime('%H:%M:%S') if self.newtime != self.curtime: if not self.current_colour: self.current_colour = 1 else: self.current_colour = 0 self.curtime = time.strftime('%H:%M:%S') self.flashing_text.config(foreground="{0}".format(self.flash_colours[self.current_colour])) self.clock.config(text=self.curtime) self.clock.after(200, self.change_color) if __name__ == '__main__': clock = Clock(('black', 'red')) ```
62,703,242
I am trying to get SonarQube for python up and running in centos. I have downloaded this version : sonarqube-8.3.1.34397.zip. I have installed java 11. **java -version** ``` openjdk version "11.0.7" 2020-04-14 LTS OpenJDK Runtime Environment 18.9 (build 11.0.7+10-LTS) OpenJDK 64-Bit Server VM 18.9 (build 11.0.7+10-LTS, mixed mode, sharing) ``` **conf/wrapper.conf** ``` wrapper.java.command=/usr/lib/jvm/java-11-openjdk-11.0.7.10-4.el7_8.x86_64/bin/java ``` Running **./bin/linux-x86-64/sonar.sh console** as Root user, I get following error ``` Running SonarQube... wrapper | --> Wrapper Started as Console wrapper | Launching a JVM... jvm 1 | Wrapper (Version 3.2.3) http://wrapper.tanukisoftware.org jvm 1 | Copyright 1999-2006 Tanuki Software, Inc. All Rights Reserved. jvm 1 | jvm 1 | 2020.07.03 00:19:28 INFO app[][o.s.a.AppFileSystem] Cleaning or creating temp directory /opt/sonarqube/temp jvm 1 | 2020.07.03 00:19:28 INFO app[][o.s.a.es.EsSettings] Elasticsearch listening on /127.0.0.1:9001 jvm 1 | 2020.07.03 00:19:29 INFO app[][o.s.a.ProcessLauncherImpl] Launch process[[key='es', ipcIndex=1, logFilenamePrefix=es]] from [/opt/sonarqube/elasticsearch]: /opt/sonarqube/elasticsearch/bin/elasticsearch jvm 1 | 2020.07.03 00:19:29 INFO app[][o.s.a.SchedulerImpl] Waiting for Elasticsearch to be up and running jvm 1 | OpenJDK 64-Bit Server VM warning: Option UseConcMarkSweepGC was deprecated in version 9.0 and will likely be removed in a future release. jvm 1 | 2020.07.03 00:19:29 INFO app[][o.e.p.PluginsService] no modules loaded jvm 1 | 2020.07.03 00:19:29 INFO app[][o.e.p.PluginsService] loaded plugin [org.elasticsearch.transport.Netty4Plugin] jvm 1 | 2020.07.03 00:19:31 WARN app[][o.s.a.p.AbstractManagedProcess] Process exited with exit value [es]: 1 jvm 1 | 2020.07.03 00:19:31 INFO app[][o.s.a.SchedulerImpl] Process[es] is stopped jvm 1 | 2020.07.03 00:19:31 INFO app[][o.s.a.SchedulerImpl] SonarQube is stopped wrapper | <-- Wrapper Stopped ``` Running **./bin/linux-x86-64/sonar.sh console** as normal user, I get following error ``` Running SonarQube... wrapper | --> Wrapper Started as Console wrapper | Launching a JVM... jvm 1 | Wrapper (Version 3.2.3) http://wrapper.tanukisoftware.org jvm 1 | Copyright 1999-2006 Tanuki Software, Inc. All Rights Reserved. jvm 1 | jvm 1 | 2020.07.03 00:20:45 INFO app[][o.s.a.AppFileSystem] Cleaning or creating temp directory /opt/sonarqube/temp jvm 1 | 2020.07.03 00:20:45 ERROR app[][o.s.application.App] Startup failure jvm 1 | java.lang.IllegalArgumentException: Unable to create shared memory : jvm 1 | at org.sonar.process.sharedmemoryfile.AllProcessesCommands.<init>(AllProcessesCommands.java:103) jvm 1 | at org.sonar.application.AppFileSystem.reset(AppFileSystem.java:63) jvm 1 | at org.sonar.application.App.start(App.java:63) jvm 1 | at org.sonar.application.App.main(App.java:98) jvm 1 | at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) jvm 1 | at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) jvm 1 | at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) jvm 1 | at java.base/java.lang.reflect.Method.invoke(Method.java:566) jvm 1 | at org.tanukisoftware.wrapper.WrapperSimpleApp.run(WrapperSimpleApp.java:240) jvm 1 | at java.base/java.lang.Thread.run(Thread.java:834) jvm 1 | Caused by: java.io.FileNotFoundException: /opt/sonarqube/temp/sharedmemory (Permission denied) jvm 1 | at java.base/java.io.RandomAccessFile.open0(Native Method) jvm 1 | at java.base/java.io.RandomAccessFile.open(RandomAccessFile.java:345) jvm 1 | at java.base/java.io.RandomAccessFile.<init>(RandomAccessFile.java:259) jvm 1 | at java.base/java.io.RandomAccessFile.<init>(RandomAccessFile.java:214) jvm 1 | at org.sonar.process.sharedmemoryfile.AllProcessesCommands.<init>(AllProcessesCommands.java:100) jvm 1 | ... 9 common frames omitted wrapper | <-- Wrapper Stopped ``` Output of sonar.log file ``` --> Wrapper Started as Console Launching a JVM... Wrapper (Version 3.2.3) http://wrapper.tanukisoftware.org Copyright 1999-2006 Tanuki Software, Inc. All Rights Reserved. WrapperSimpleApp: Encountered an error running main: java.lang.IllegalStateException: SonarQube requires Java 11 to run java.lang.IllegalStateException: SonarQube requires Java 11 to run at com.google.common.base.Preconditions.checkState(Preconditions.java:508) at org.sonar.application.App.checkJavaVersion(App.java:94) at org.sonar.application.App.start(App.java:57) at org.sonar.application.App.main(App.java:98) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.tanukisoftware.wrapper.WrapperSimpleApp.run(WrapperSimpleApp.java:240) at java.lang.Thread.run(Thread.java:748) <-- Wrapper Stopped --> Wrapper Started as Console Launching a JVM... Wrapper (Version 3.2.3) http://wrapper.tanukisoftware.org Copyright 1999-2006 Tanuki Software, Inc. All Rights Reserved. WrapperSimpleApp: Encountered an error running main: java.lang.IllegalStateException: SonarQube requires Java 11 to run java.lang.IllegalStateException: SonarQube requires Java 11 to run at com.google.common.base.Preconditions.checkState(Preconditions.java:508) at org.sonar.application.App.checkJavaVersion(App.java:94) at org.sonar.application.App.start(App.java:57) at org.sonar.application.App.main(App.java:98) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.tanukisoftware.wrapper.WrapperSimpleApp.run(WrapperSimpleApp.java:240) at java.lang.Thread.run(Thread.java:748) <-- Wrapper Stopped --> Wrapper Started as Console Launching a JVM... Wrapper (Version 3.2.3) http://wrapper.tanukisoftware.org Copyright 1999-2006 Tanuki Software, Inc. All Rights Reserved. 2020.07.02 23:40:34 INFO app[][o.s.a.AppFileSystem] Cleaning or creating temp directory /opt/sonarqube/temp 2020.07.02 23:40:34 INFO app[][o.s.a.es.EsSettings] Elasticsearch listening on /127.0.0.1:9001 2020.07.02 23:40:34 INFO app[][o.s.a.ProcessLauncherImpl] Launch process[[key='es', ipcIndex=1, logFilenamePrefix=es]] from [/opt/sonarqube/elasticsearch]: /opt/sonarqube/elasticsearch/bin/elasticsearch 2020.07.02 23:40:34 INFO app[][o.s.a.SchedulerImpl] Waiting for Elasticsearch to be up and running OpenJDK 64-Bit Server VM warning: Option UseConcMarkSweepGC was deprecated in version 9.0 and will likely be removed in a future release. 2020.07.02 23:40:35 INFO app[][o.e.p.PluginsService] no modules loaded 2020.07.02 23:40:35 INFO app[][o.e.p.PluginsService] loaded plugin [org.elasticsearch.transport.Netty4Plugin] 2020.07.02 23:40:38 WARN app[][o.s.a.p.AbstractManagedProcess] Process exited with exit value [es]: 1 2020.07.02 23:40:38 INFO app[][o.s.a.SchedulerImpl] Process[es] is stopped 2020.07.02 23:40:38 INFO app[][o.s.a.SchedulerImpl] SonarQube is stopped <-- Wrapper Stopped --> Wrapper Started as Console Launching a JVM... Wrapper (Version 3.2.3) http://wrapper.tanukisoftware.org Copyright 1999-2006 Tanuki Software, Inc. All Rights Reserved. 2020.07.02 23:57:56 INFO app[][o.s.a.AppFileSystem] Cleaning or creating temp directory /opt/sonarqube/temp 2020.07.02 23:57:56 INFO app[][o.s.a.es.EsSettings] Elasticsearch listening on /127.0.0.1:9001 2020.07.02 23:57:56 INFO app[][o.s.a.ProcessLauncherImpl] Launch process[[key='es', ipcIndex=1, logFilenamePrefix=es]] from [/opt/sonarqube/elasticsearch]: /opt/sonarqube/elasticsearch/bin/elasticsearch 2020.07.02 23:57:57 INFO app[][o.s.a.SchedulerImpl] Waiting for Elasticsearch to be up and running OpenJDK 64-Bit Server VM warning: Option UseConcMarkSweepGC was deprecated in version 9.0 and will likely be removed in a future release. 2020.07.02 23:57:57 INFO app[][o.e.p.PluginsService] no modules loaded 2020.07.02 23:57:57 INFO app[][o.e.p.PluginsService] loaded plugin [org.elasticsearch.transport.Netty4Plugin] 2020.07.02 23:58:00 WARN app[][o.s.a.p.AbstractManagedProcess] Process exited with exit value [es]: 1 2020.07.02 23:58:00 INFO app[][o.s.a.SchedulerImpl] Process[es] is stopped 2020.07.02 23:58:00 INFO app[][o.s.a.SchedulerImpl] SonarQube is stopped <-- Wrapper Stopped --> Wrapper Started as Console Launching a JVM... Wrapper (Version 3.2.3) http://wrapper.tanukisoftware.org Copyright 1999-2006 Tanuki Software, Inc. All Rights Reserved. 2020.07.03 00:08:31 INFO app[][o.s.a.AppFileSystem] Cleaning or creating temp directory /opt/sonarqube/temp 2020.07.03 00:08:31 INFO app[][o.s.a.es.EsSettings] Elasticsearch listening on /127.0.0.1:9001 2020.07.03 00:08:31 INFO app[][o.s.a.ProcessLauncherImpl] Launch process[[key='es', ipcIndex=1, logFilenamePrefix=es]] from [/opt/sonarqube/elasticsearch]: /opt/sonarqube/elasticsearch/bin/elasticsearch 2020.07.03 00:08:31 INFO app[][o.s.a.SchedulerImpl] Waiting for Elasticsearch to be up and running OpenJDK 64-Bit Server VM warning: Option UseConcMarkSweepGC was deprecated in version 9.0 and will likely be removed in a future release. 2020.07.03 00:08:32 INFO app[][o.e.p.PluginsService] no modules loaded 2020.07.03 00:08:32 INFO app[][o.e.p.PluginsService] loaded plugin [org.elasticsearch.transport.Netty4Plugin] 2020.07.03 00:08:34 WARN app[][o.s.a.p.AbstractManagedProcess] Process exited with exit value [es]: 1 2020.07.03 00:08:34 INFO app[][o.s.a.SchedulerImpl] Process[es] is stopped 2020.07.03 00:08:34 INFO app[][o.s.a.SchedulerImpl] SonarQube is stopped <-- Wrapper Stopped --> Wrapper Started as Console Launching a JVM... Wrapper (Version 3.2.3) http://wrapper.tanukisoftware.org Copyright 1999-2006 Tanuki Software, Inc. All Rights Reserved. 2020.07.03 00:13:22 INFO app[][o.s.a.AppFileSystem] Cleaning or creating temp directory /opt/sonarqube/temp 2020.07.03 00:13:22 INFO app[][o.s.a.es.EsSettings] Elasticsearch listening on /127.0.0.1:9001 2020.07.03 00:13:22 INFO app[][o.s.a.ProcessLauncherImpl] Launch process[[key='es', ipcIndex=1, logFilenamePrefix=es]] from [/opt/sonarqube/elasticsearch]: /opt/sonarqube/elasticsearch/bin/elasticsearch 2020.07.03 00:13:22 INFO app[][o.s.a.SchedulerImpl] Waiting for Elasticsearch to be up and running OpenJDK 64-Bit Server VM warning: Option UseConcMarkSweepGC was deprecated in version 9.0 and will likely be removed in a future release. 2020.07.03 00:13:23 INFO app[][o.e.p.PluginsService] no modules loaded 2020.07.03 00:13:23 INFO app[][o.e.p.PluginsService] loaded plugin [org.elasticsearch.transport.Netty4Plugin] 2020.07.03 00:13:25 WARN app[][o.s.a.p.AbstractManagedProcess] Process exited with exit value [es]: 1 2020.07.03 00:13:25 INFO app[][o.s.a.SchedulerImpl] Process[es] is stopped 2020.07.03 00:13:25 INFO app[][o.s.a.SchedulerImpl] SonarQube is stopped <-- Wrapper Stopped --> Wrapper Started as Daemon Launching a JVM... Wrapper (Version 3.2.3) http://wrapper.tanukisoftware.org Copyright 1999-2006 Tanuki Software, Inc. All Rights Reserved. 2020.07.03 00:13:33 INFO app[][o.s.a.AppFileSystem] Cleaning or creating temp directory /opt/sonarqube/temp 2020.07.03 00:13:33 INFO app[][o.s.a.es.EsSettings] Elasticsearch listening on /127.0.0.1:9001 2020.07.03 00:13:33 INFO app[][o.s.a.ProcessLauncherImpl] Launch process[[key='es', ipcIndex=1, logFilenamePrefix=es]] from [/opt/sonarqube/elasticsearch]: /opt/sonarqube/elasticsearch/bin/elasticsearch 2020.07.03 00:13:33 INFO app[][o.s.a.SchedulerImpl] Waiting for Elasticsearch to be up and running OpenJDK 64-Bit Server VM warning: Option UseConcMarkSweepGC was deprecated in version 9.0 and will likely be removed in a future release. 2020.07.03 00:13:34 INFO app[][o.e.p.PluginsService] no modules loaded 2020.07.03 00:13:34 INFO app[][o.e.p.PluginsService] loaded plugin [org.elasticsearch.transport.Netty4Plugin] 2020.07.03 00:13:36 WARN app[][o.s.a.p.AbstractManagedProcess] Process exited with exit value [es]: 1 2020.07.03 00:13:36 INFO app[][o.s.a.SchedulerImpl] Process[es] is stopped 2020.07.03 00:13:36 INFO app[][o.s.a.SchedulerImpl] SonarQube is stopped <-- Wrapper Stopped --> Wrapper Started as Daemon Launching a JVM... Wrapper (Version 3.2.3) http://wrapper.tanukisoftware.org Copyright 1999-2006 Tanuki Software, Inc. All Rights Reserved. 2020.07.03 00:13:48 INFO app[][o.s.a.AppFileSystem] Cleaning or creating temp directory /opt/sonarqube/temp 2020.07.03 00:13:48 INFO app[][o.s.a.es.EsSettings] Elasticsearch listening on /127.0.0.1:9001 2020.07.03 00:13:48 INFO app[][o.s.a.ProcessLauncherImpl] Launch process[[key='es', ipcIndex=1, logFilenamePrefix=es]] from [/opt/sonarqube/elasticsearch]: /opt/sonarqube/elasticsearch/bin/elasticsearch 2020.07.03 00:13:48 INFO app[][o.s.a.SchedulerImpl] Waiting for Elasticsearch to be up and running OpenJDK 64-Bit Server VM warning: Option UseConcMarkSweepGC was deprecated in version 9.0 and will likely be removed in a future release. 2020.07.03 00:13:48 INFO app[][o.e.p.PluginsService] no modules loaded 2020.07.03 00:13:48 INFO app[][o.e.p.PluginsService] loaded plugin [org.elasticsearch.transport.Netty4Plugin] 2020.07.03 00:13:50 WARN app[][o.s.a.p.AbstractManagedProcess] Process exited with exit value [es]: 1 2020.07.03 00:13:50 INFO app[][o.s.a.SchedulerImpl] Process[es] is stopped 2020.07.03 00:13:50 INFO app[][o.s.a.SchedulerImpl] SonarQube is stopped <-- Wrapper Stopped --> Wrapper Started as Console Launching a JVM... Wrapper (Version 3.2.3) http://wrapper.tanukisoftware.org Copyright 1999-2006 Tanuki Software, Inc. All Rights Reserved. 2020.07.03 00:14:03 INFO app[][o.s.a.AppFileSystem] Cleaning or creating temp directory /opt/sonarqube/temp 2020.07.03 00:14:03 INFO app[][o.s.a.es.EsSettings] Elasticsearch listening on /127.0.0.1:9001 2020.07.03 00:14:03 INFO app[][o.s.a.ProcessLauncherImpl] Launch process[[key='es', ipcIndex=1, logFilenamePrefix=es]] from [/opt/sonarqube/elasticsearch]: /opt/sonarqube/elasticsearch/bin/elasticsearch 2020.07.03 00:14:03 INFO app[][o.s.a.SchedulerImpl] Waiting for Elasticsearch to be up and running OpenJDK 64-Bit Server VM warning: Option UseConcMarkSweepGC was deprecated in version 9.0 and will likely be removed in a future release. 2020.07.03 00:14:04 INFO app[][o.e.p.PluginsService] no modules loaded 2020.07.03 00:14:04 INFO app[][o.e.p.PluginsService] loaded plugin [org.elasticsearch.transport.Netty4Plugin] 2020.07.03 00:14:06 WARN app[][o.s.a.p.AbstractManagedProcess] Process exited with exit value [es]: 1 2020.07.03 00:14:06 INFO app[][o.s.a.SchedulerImpl] Process[es] is stopped 2020.07.03 00:14:06 INFO app[][o.s.a.SchedulerImpl] SonarQube is stopped <-- Wrapper Stopped --> Wrapper Started as Console Launching a JVM... Wrapper (Version 3.2.3) http://wrapper.tanukisoftware.org Copyright 1999-2006 Tanuki Software, Inc. All Rights Reserved. 2020.07.03 00:19:28 INFO app[][o.s.a.AppFileSystem] Cleaning or creating temp directory /opt/sonarqube/temp 2020.07.03 00:19:28 INFO app[][o.s.a.es.EsSettings] Elasticsearch listening on /127.0.0.1:9001 2020.07.03 00:19:29 INFO app[][o.s.a.ProcessLauncherImpl] Launch process[[key='es', ipcIndex=1, logFilenamePrefix=es]] from [/opt/sonarqube/elasticsearch]: /opt/sonarqube/elasticsearch/bin/elasticsearch 2020.07.03 00:19:29 INFO app[][o.s.a.SchedulerImpl] Waiting for Elasticsearch to be up and running OpenJDK 64-Bit Server VM warning: Option UseConcMarkSweepGC was deprecated in version 9.0 and will likely be removed in a future release. 2020.07.03 00:19:29 INFO app[][o.e.p.PluginsService] no modules loaded 2020.07.03 00:19:29 INFO app[][o.e.p.PluginsService] loaded plugin [org.elasticsearch.transport.Netty4Plugin] 2020.07.03 00:19:31 WARN app[][o.s.a.p.AbstractManagedProcess] Process exited with exit value [es]: 1 2020.07.03 00:19:31 INFO app[][o.s.a.SchedulerImpl] Process[es] is stopped 2020.07.03 00:19:31 INFO app[][o.s.a.SchedulerImpl] SonarQube is stopped <-- Wrapper Stopped ```
2020/07/02
[ "https://Stackoverflow.com/questions/62703242", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8700970/" ]
For SonarQube to install from zip, you need to create a dedicated user which have access to your Java 11 installation and as well all the files of SonarQube installation directory. Then start your SonarQube server with that user. Do not use root user to start the SonarQube server. Here is the link to documentation, where SonarQube has mentioned this: <https://docs.sonarqube.org/8.3/setup/install-server/> Here is the guide to help you with Installation: 1. <https://devopscube.com/setup-and-configure-sonarqube-on-linux/> 2. <https://docs.sonarqube.org/8.3/setup/get-started-2-minutes/>
I'm using docker and I had the same problem. I needed to include this code: ``` USER root chmod -R 777 /opt/sonarqube ``` Then everything worked out.
63,226,696
I want to load view on menu-item click in same page where menu did not disappear like this. [![enter image description here](https://i.stack.imgur.com/lFO1p.png)](https://i.stack.imgur.com/lFO1p.png) But, In my case It disappears, Like this. [![enter image description here](https://i.stack.imgur.com/8TzBw.png)](https://i.stack.imgur.com/8TzBw.png) Code in MainLayout .java is : ``` package com.packagename.myapp; import com.vaadin.flow.component.AttachEvent; import com.vaadin.flow.component.Component; import com.vaadin.flow.component.Key; import com.vaadin.flow.component.KeyModifier; import com.vaadin.flow.component.applayout.AppLayout; import com.vaadin.flow.component.applayout.DrawerToggle; import com.vaadin.flow.component.button.Button; import com.vaadin.flow.component.button.ButtonVariant; import com.vaadin.flow.component.charts.model.Navigator; import com.vaadin.flow.component.dependency.CssImport; import com.vaadin.flow.component.html.Label; import com.vaadin.flow.component.html.Span; import com.vaadin.flow.component.icon.Icon; import com.vaadin.flow.component.icon.VaadinIcon; import com.vaadin.flow.component.orderedlayout.FlexComponent.Alignment; import com.vaadin.flow.component.orderedlayout.HorizontalLayout; import com.vaadin.flow.component.orderedlayout.VerticalLayout; import com.vaadin.flow.router.Route; import com.vaadin.flow.router.RouteConfiguration; import com.vaadin.flow.router.RouterLayout; import com.vaadin.flow.router.RouterLink; import com.vaadin.flow.server.PWA; import com.vaadin.flow.theme.Theme; import com.vaadin.flow.theme.lumo.Lumo; import sun.jvm.hotspot.debugger.cdbg.AccessControl; /** * The main layout. Contains the navigation menu. */ @Theme(value = Lumo.class) @Route("") @PWA(name = "Project Base for Vaadin", shortName = "Project Base", enableInstallPrompt = false) @CssImport("./styles/shared-styles.css") @CssImport(value = "./styles/menu-buttons.css", themeFor = "vaadin-button") public class MainLayout extends AppLayout implements RouterLayout { public MainLayout() { final DrawerToggle drawerToggle = new DrawerToggle(); drawerToggle.addClassName("menu-toggle"); addToNavbar(drawerToggle); VerticalLayout layout = new VerticalLayout(); layout.setDefaultHorizontalComponentAlignment(Alignment.CENTER); layout.setClassName("Menu-header"); final HorizontalLayout top = new HorizontalLayout(); top.setDefaultVerticalComponentAlignment(Alignment.CENTER); top.setClassName("menu-header"); final Label title = new Label("Menu Application"); top.add(title); addToNavbar(top); addToDrawer(createMenuLink(HomeView.class, HomeView.VIEW_NAME, VaadinIcon.EDIT.create())); addToDrawer(createMenuLink(MainView.class, MainView.VIEW_NAME, VaadinIcon.INFO_CIRCLE.create())); } private RouterLink createMenuLink(Class<? extends Component> viewClass, String caption, Icon icon) { final RouterLink routerLink = new RouterLink(null, viewClass); routerLink.setClassName("menu-button"); routerLink.add(icon); routerLink.add(new Span(caption)); icon.setSize("24px"); return routerLink; } private Button createMenuButton(String caption, Icon icon) { final Button routerButton = new Button(caption); routerButton.setClassName("menu-button"); routerButton.addThemeVariants(ButtonVariant.LUMO_TERTIARY_INLINE); routerButton.setIcon(icon); icon.setSize("24px"); return routerButton; } } ``` Code int MainView.java is: ``` package com.packagename.myapp; import com.vaadin.flow.component.Key; import com.vaadin.flow.component.button.Button; import com.vaadin.flow.component.button.ButtonVariant; import com.vaadin.flow.component.dependency.CssImport; import com.vaadin.flow.component.notification.Notification; import com.vaadin.flow.component.orderedlayout.VerticalLayout; import com.vaadin.flow.component.textfield.TextField; import com.vaadin.flow.router.Route; import com.vaadin.flow.server.PWA; @Route("main-view") public class MainView extends VerticalLayout { public static final String VIEW_NAME = "Main"; public MainView() { TextField textField = new TextField("Your name"); textField.addThemeName("bordered"); GreetService greetService = new GreetService(); Button button = new Button("Say hello", e -> Notification.show(greetService.greet(textField.getValue()))); button.addThemeVariants(ButtonVariant.LUMO_PRIMARY); button.addClickShortcut(Key.ENTER); addClassName("centered-content"); add(textField, button); } } ``` Code in HomeView.java is: ``` package com.packagename.myapp; import com.vaadin.flow.component.Key; import com.vaadin.flow.component.button.Button; import com.vaadin.flow.component.button.ButtonVariant; import com.vaadin.flow.component.dependency.CssImport; import com.vaadin.flow.component.html.Span; import com.vaadin.flow.component.icon.VaadinIcon; import com.vaadin.flow.component.notification.Notification; import com.vaadin.flow.component.orderedlayout.VerticalLayout; import com.vaadin.flow.component.textfield.TextField; import com.vaadin.flow.router.Route; import com.vaadin.flow.server.PWA; import com.vaadin.flow.server.Version; @Route("home-view") public class HomeView extends VerticalLayout { public static final String VIEW_NAME = "Home"; public HomeView() { add(VaadinIcon.INFO_CIRCLE.create()); add(new Span(" This application is using Vaadin version " + Version.getFullVersion() + ".")); setSizeFull(); setJustifyContentMode(JustifyContentMode.CENTER); setAlignItems(Alignment.CENTER); } } ``` I want to load GUI of menu-item in same page. How can I do this? Help me please, How can I Fix this issue.
2020/08/03
[ "https://Stackoverflow.com/questions/63226696", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10412853/" ]
You need to specify in which `RouterLayout` it should be shown. For the `HomeView` the route-annotation would be ``` @Route(value = "home-view", layout = MainLayout.class) ```
You can download an example project from <https://start.vaadin.com/> and take example from there on how to do it. In your case, you have your views set up to routes, but there is no connection between it and the main layout. The `@Route` annotation should define the parameter `layout` to tell the system it should be rendered within another layout, like for example this: HomeView.java ``` @Route(value = "home-view", layout = MainLayout.class) ``` The `MainLayout` should not have a route in itself as it should not be accessible with no content as a view. Parent layout should always implement `RouterLayout`, but as you are already extending `AppLayout`, that's already taken care of. More documentation on it can be found at <https://vaadin.com/docs/v14/flow/routing/tutorial-router-layout.html>.
74,645,690
I'm trying to build a basic game-like program where I need to rearrange a given matrix but vertically. In this case, I only have 0s and 1s. 0 being lighter objects and 1 being heavier. When the function runs, all the 1s should fall down vertically and the zeros go up vertically as well. It needs to have the exact number of 0s and 1s as the original matrix. Example: -If I give the following matrix: ``` [1,0,1,1,0,1,0], [0,0,0,1,0,0,0], [1,0,1,1,1,1,1], [0,1,1,0,1,1,0], [1,1,0,1,0,0,1] ``` It should rearrange it to: ``` [0,0,0,0,0,0,0], [0,0,0,1,0,0,0], [1,0,1,1,0,1,0], [1,1,1,1,1,1,1], [1,1,1,1,1,1,1] ``` Any help or suggestions will be highly appreciated.
2022/12/01
[ "https://Stackoverflow.com/questions/74645690", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15062354/" ]
Consider using numpy for your matrices. You can then use [`np.sort`](https://numpy.org/doc/stable/reference/generated/numpy.sort.html) to do what you want: ```py np.sort(matrix, axis=0) ```
If you didn't want to use numpy (though you should), you could do: ``` from collections import Counter test = [[1,0,1,1,0,1,0], [0,0,0,1,0,0,0], [1,0,1,1,1,1,1], [0,1,1,0,1,1,0], [1,1,0,1,0,0,1] ] new_version = [[] for _ in test] # create an empty list to append data to for count, item in enumerate(test[0]): # go through the length of one of the list of lists for their length # assuming that all lists are of equal length frequency = Counter([x[count] for x in test]) # get frequency count for the column for count_inside, item_inside in enumerate(test): # to add the values depending on their frequency distribution in the column value = 0 if 0 in frequency and count_inside < frequency[0] else 1 new_version[count_inside].append(value) print(new_version) ```
74,645,690
I'm trying to build a basic game-like program where I need to rearrange a given matrix but vertically. In this case, I only have 0s and 1s. 0 being lighter objects and 1 being heavier. When the function runs, all the 1s should fall down vertically and the zeros go up vertically as well. It needs to have the exact number of 0s and 1s as the original matrix. Example: -If I give the following matrix: ``` [1,0,1,1,0,1,0], [0,0,0,1,0,0,0], [1,0,1,1,1,1,1], [0,1,1,0,1,1,0], [1,1,0,1,0,0,1] ``` It should rearrange it to: ``` [0,0,0,0,0,0,0], [0,0,0,1,0,0,0], [1,0,1,1,0,1,0], [1,1,1,1,1,1,1], [1,1,1,1,1,1,1] ``` Any help or suggestions will be highly appreciated.
2022/12/01
[ "https://Stackoverflow.com/questions/74645690", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15062354/" ]
Not as readable as the numpy approach, but if you want to use the list-approach you could 1. Transpose the matrix by using the `zip(*matrix)` approach. 2. Sort the resulting rows (which are columns of the original matrix) 3. Transpose back. You can do it in one line: ``` [row for row in zip(*[sorted(column) for column in zip(*matrix)])] ```
If you didn't want to use numpy (though you should), you could do: ``` from collections import Counter test = [[1,0,1,1,0,1,0], [0,0,0,1,0,0,0], [1,0,1,1,1,1,1], [0,1,1,0,1,1,0], [1,1,0,1,0,0,1] ] new_version = [[] for _ in test] # create an empty list to append data to for count, item in enumerate(test[0]): # go through the length of one of the list of lists for their length # assuming that all lists are of equal length frequency = Counter([x[count] for x in test]) # get frequency count for the column for count_inside, item_inside in enumerate(test): # to add the values depending on their frequency distribution in the column value = 0 if 0 in frequency and count_inside < frequency[0] else 1 new_version[count_inside].append(value) print(new_version) ```
11,413,922
I found `@Rule` annotation in `jUnit` for better handling of exception. Is there a way to check error code ? Currently my code looks like (without @Rule): ``` @Test public void checkNullObject() { MyClass myClass= null; try { MyCustomClass.get(null); // it throws custom exception when null is passed } catch (CustomException e) { // error code is error.reason.null Assert.assertSame("error.reason.null", e.getInformationCode()); } } ``` But with use of `@Rule`, I am doing following : ``` @Rule public ExpectedException exception = ExpectedException.none(); @Test public void checkNullObject() throws CustomException { exception.expect(CustomException .class); exception.expectMessage("Input object is null."); MyClass myClass= null; MyCustomClass.get(null); } ``` But, I want to do something like below: ``` @Rule public ExpectedException exception = ExpectedException.none(); @Test public void checkNullObject() throws CustomException { exception.expect(CustomException .class); //currently below line is not legal. But I need to check errorcode. exception.errorCode("error.reason.null"); MyClass myClass= null; MyCustomClass.get(null); } ```
2012/07/10
[ "https://Stackoverflow.com/questions/11413922", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1392956/" ]
You can use a custom matcher on the rule with the `expect(Matcher<?> matcher)` method. For example: ``` public class ErrorCodeMatcher extends BaseMatcher<CustomException> { private final String expectedCode; public ErrorCodeMatcher(String expectedCode) { this.expectedCode = expectedCode; } @Override public boolean matches(Object item) { CustomException e = (CustomException)item; return expectedCode.equals(e.getInformationCode()); } } ``` and in the test: ``` exception.expect(new ErrorCodeMatcher("error.reason.null")); ```
You can also see how the `expect(Matcher<?> matcher)` has been used within [ExpectedException.java source](https://github.com/KentBeck/junit/blob/master/src/main/java/org/junit/rules/ExpectedException.java) ``` private Matcher<Throwable> hasMessage(final Matcher<String> matcher) { return new TypeSafeMatcher<Throwable>() { @Override public boolean matchesSafely(Throwable item) { return matcher.matches(item.getMessage()); } }; } public void expectMessage(Matcher<String> matcher) { expect(hasMessage(matcher)); } ```
64,554,258
I want to update the likes' value with 1. My MongoDB structure is as follows . ``` {"_id":{"$oid":"5f980a66c4b0d52950bdf907"}, "course_id":"5002", "lecture_id":"451", "__v":0, "created_at":{"$date":"2020-10-27T11:54:14.842Z"}, "message":[ { "_id":{"$oid":"5f980a84c4b0d52950bdf90a"}, "from":{ "userId":"68819","name":"Developer IIRS", "avatar":"https://api.adorable.io/avatars/285/811753.png" }, "content":"ok", "likes":0, "parent_id":null, "created_at":{"$date":"2020-10-27T11:54:44.388Z"} } ] } ``` Here is my code to update value of **likes** ``` router.post('/:lectureId/:courseId/:id', function(req, res, next) { let query = { lecture_id: req.params.lectureId, course_id: req.params.courseId }; let update = { $push: { message: { _id: req.params.id,likes: 1 } } } var options = { new: true } console.log('Liked', query) Chat.update(query, update, function(err, result) { if (err) { //res.send(err); console.log('err',err ); return err; } res.json(result); }) }); ``` Its basically adding new document. I am stuck here how can i do this.
2020/10/27
[ "https://Stackoverflow.com/questions/64554258", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14084660/" ]
``` "lecture_id": "451", "course_id": "5002" }, { $inc: { "message.$[elem].likes": 1 } }, { new: true, arrayFilters: [ { "elem._id": "5f980a84c4b0d52950bdf90a" } ] })``` ```
Here is the mongo query. ``` db.collection.update({ "lecture_id": "451", "course_id": "5002", "message._id": "5f980a84c4b0d52950bdf91a" }, { "$inc": { "message.$.likes": 1 } }) ``` Try it here [Mongo Playground](https://mongoplayground.net/p/YXcH6Nd53fu) Not an expert in nodejs. Below update statement may work for you. `let update = { $inc: { "message.$.likes": 1 } }`
40,397,524
I'm very new to Laravel, and am having trouble understanding queries in Eloquent. I have two models - Laptop and Location. Suppose I want to query all the laptops belonging to a location that has a 'stock' value of 1. In SQL this would be a left join, but how do I do this in Eloquent? I've already added the relationships to the two models, so the Laptop model has a 'location' method, but where do I go from there?
2016/11/03
[ "https://Stackoverflow.com/questions/40397524", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5847182/" ]
If you have data that is stored in row-major order (that is, your data is an array of rows, rather than columns, of data), you must keep track of the columns to print. This is a typical way to receive data from a MySQL database. You can do this by looking at your first row, using `$columns = array_keys($row)`, or simply hard-code the column keys if they are known in advance like I have done in the following example. ``` <?php $data = [ [ "name" => "Alice", "email" => "[email protected]", "home_address" => "Alice Lane 61" ], [ "name" => "Bob", "age" => 16, "home_address" => "Bob St. 42" ] ]; $columns = [ "name", "age", "email", "home_address" ]; ?> <html> <body> <table> <tr> <?php foreach($columns as $column) { ?> <th><?php echo $column; ?></th> <?php } ?> </tr> <?php foreach ($data as $row) { ?> <tr> <?php foreach($columns as $column) { ?> <td> <?php if (isset($row[$column])) { echo $row[$column]; } else { echo "N/A"; } ?> </td> <?php } // end $column foreach ?> </tr> <?php } // end $row foreach ?> </table> </body> </html> ``` Note that not all rows have the same columns here. This is handled in the if-statement in the table. This example outputs: ```html <html> <body> <table> <tr> <th>name</th> <th>age</th> <th>email</th> <th>home_address</th> </tr> <tr> <td>Alice </td> <td>N/A </td> <td>[email protected] </td> <td>Alice Lane 61 </td> </tr> <tr> <td>Bob </td> <td>16 </td> <td>N/A </td> <td>Bob St. 42 </td> </tr> </table> </body> </html> ```
This will get you started ``` <table> <thead> <tr> <th>Row One</th> <th>Row Two</th> </tr> </thead> <tbody> <?php foreach( $array as $key ) { ?> <tr> <td><?php echo $key[ 'rowOne' ]; ?></td> <td><?php echo $key[ 'rowTwo' ]; ?></td> </tr> <?php } ?> </tbody> </table> ``` You loop through each row in your array and echo out the information you need. You really need to do some PHP tutorials and you will understand how to loop arrays.
5,412,005
UPDATE: After a bit of testing I've determined the file itself isnt being created, at least according to the file.exists check anyway. Any ideas? Hi I'm trying to serialize an arraylist when my app is exited and read it back when its resumed. It doesnt seem to be creating the file. Here is my code. ``` protected void onPause() { super.onPause(); if(!myArrayList.isEmpty()) { final String FILENAME = "myfile.bin"; try{ FileOutputStream fos; fos = openFileOutput(FILENAME, Context.MODE_PRIVATE); //FileOutputStream fileStream = new FileOutputStream(FILENAME); ObjectOutputStream os = new ObjectOutputStream(fos); os.writeObject(myArrayList); os.flush(); os.close(); } catch (FileNotFoundException e) { e.printStackTrace(); }catch(IOException e){ e.printStackTrace(); } catch (ClassNotFoundException e) { e.printStackTrace(); } } } @SuppressWarnings("unchecked") @Override protected void onResume() { super.onResume(); File file = new File("myfile.bin"); if(file.exists()){ final String FILENAME="myfile.bin"; try{ FileInputStream fileStream = new FileInputStream(FILENAME); ObjectInputStream os = new ObjectInputStream(fileStream); myArrayList = (ArrayList<MyObject>)os.readObject(); os.close(); } catch (FileNotFoundException e) { e.printStackTrace(); }catch(IOException e){ e.printStackTrace(); } } } ``` Any ideas? My MyObject class implements serializable.
2011/03/23
[ "https://Stackoverflow.com/questions/5412005", "https://Stackoverflow.com", "https://Stackoverflow.com/users/646478/" ]
Got it to work by changing `FileInputStream fileStream = new FileInputStream(FILENAME)` to `FileInputStream fileStream= openFileInput(FILENAME)`.
``` os.writeObject(myArrayList); os.flush(); os.close(); ``` Try os.close() immediately after writeObject, it should call flush() anyways.
62,315,770
I'm struggling with live charts. I'm using WPF. I want to build a bar chart that displays the number of members in a Karate Club by belt color. One of my learning projects. Following their docs: <https://lvcharts.net/App/examples/v1/wpf/Basic%20Column> I am getting an error in xaml: d:DataContext="{d:DesignInstance local:Charts}" 'The name "Charts" does not exist in namespace "clr-namespace:KarateClub" ' and LabelFormatter="{Binding Formatter}" 'Method Formatter not found in type Charts' If I remove the DataContext code the graph displays but it doesn't use any of my values. I must be missing how to link the XAML code to the C# code...? Have I got the class/namespace path wrong? My XAML Code: ``` <UserControl x:Class="KarateClub.Charts" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:local="clr-namespace:KarateClub" xmlns:lvc="clr-namespace:LiveCharts.Wpf;assembly=LiveCharts.Wpf" mc:Ignorable="d" d:DesignHeight="400" d:DesignWidth="1000" d:DataContext="{d:DesignInstance local:Charts}" > <Grid Background="White" Width="1000" Height="550"> <Grid Background="White" Margin="33,45,239,170"> <lvc:CartesianChart Series="{Binding SeriesCollection}" LegendLocation="Left"> <lvc:CartesianChart.AxisX> <lvc:Axis Title="Belts" Labels="{Binding Labels}"></lvc:Axis> </lvc:CartesianChart.AxisX> <lvc:CartesianChart.AxisY> <lvc:Axis Title="Members" LabelFormatter="{Binding Formatter}"></lvc:Axis> </lvc:CartesianChart.AxisY> </lvc:CartesianChart> </Grid> </Grid> </UserControl> ``` My C# Code: ``` using System; using System.Windows.Controls; using LiveCharts; using LiveCharts.Wpf; namespace KarateClub { public partial class Charts : UserControl { public SeriesCollection SeriesCollection { get; set; } public string[] Labels { get; set; } public Func<double, string> Formatter { get; set; } public Charts() { InitializeComponent(); SeriesCollection = new SeriesCollection { new ColumnSeries { Title = "2020", Values = new ChartValues<double> { 1, 5, 3, 5, 7, 3, 9, 2, 3 } } }; Labels = new[] { "White", "Yellow", "Orange", "Green", "Blue", "Purple", "Brown", "Red", "Black" }; Formatter = value => value.ToString("N"); DataContext = this; } } } ```
2020/06/11
[ "https://Stackoverflow.com/questions/62315770", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6611979/" ]
You are currently using a design-time instance of `Charts`, which is generated by the designer. This instance is auto-generated and doesn't contain any data. This is the default behavior, which is controlled by the `IsDesignTimeCreatable` property of the markup extension `DesignInstanceExtension`. By default `IsDesignTimeCreatable` returns `false`, which directs the designer to create a fake instance using reflection (bypassing any constructor). To use a design-time instance of the specified type which is properly constructed, you have to set this property explicitly to `true`: ``` <UserControl x:Class="KarateClub.Charts" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:local="clr-namespace:KarateClub" d:DataContext="{d:DesignInstance local:Charts, IsDesignTimeCreatable=True}" > ... </UserControl> ``` Now the designer will create an instance using the constructor instead of using reflection. Apparently this Blend design-time attributes are not well documented. To learn more see [Microsoft Docs: Design-Time Attributes in the Silverlight Designer](https://learn.microsoft.com/en-us/previous-versions/windows/silverlight/dotnet-windows-silverlight/ff602277%28v%3Dvs.95%29)
The example you are following does not say `d:DataContext="{d:DesignInstance local:Charts}"`. it says `d:DataContext="{d:DesignInstance local:BasicColumn}"`.
59,730,379
Below is the MapperInterface.php I'm trying to figure out how to add an if-else statement into the const. mapping array. Something like so: ``` if (LIN02 == “VN”) o Treat LIN03 as the SKU · else if (LIN04 == “VN”) o Treat LIN05 as the SKU ``` --- ``` <?php declare(strict_types=1); namespace Direct\OrderUpdate\Api; use Direct\OrderUpdate\Api\OrderUpdateInterface; /** * Interface MapperInterface * Translates parsed edi file data to a \Direct\OrderUpdate\Api\OrderUpdateInterface * @package Direct\OrderUpdate\Api */ interface MapperInterface { /** * Mapping array formatted as MAPPING[segemntId][elemntId] => methodNameToProcessTheValueOfElement * @var array */ const MAPPING = [ 'DTM' => ['DTM02' => 'processCreatedAt'], // shipment.created_at 'PRF' => ['PRF01' => 'processIncrementId'], // order.increment_id 'LIN' => ['LIN05' => 'processSku'], // shipment.items.sku 'SN1' => ['SN102' => 'processQty'], // shipment.items.qty 'REF' => ['REF02' => 'processTrack'] // shipment.tracks.track_number, shipment.tracks.carrier_code ]; /** * Mapping for carrier codes * @var array */ const CARRIER_CODES_MAPPING = ['FED' => 'fedex']; /** * @return array */ public function getMapping(): array; /** * @param array $segments * @return OrderUpdateInterface */ public function map(array $segments): OrderUpdateInterface; } ``` I hope that makes sense. Not sure if there is a better way to go about it but ultimately I need more than 1 "LIN" segmentId. Maybe add a new function and use this condition? ***NEW FILE*** ANSWER \*\*\* ``` <?php declare(strict_types=1); namespace Direct\OrderUpdate\Api; use Direct\OrderUpdate\Api\OrderUpdateInterface; /** * Abstract Mapper * Translates parsed edi file data to a \Direct\OrderUpdate\Api\OrderUpdateInterface * @package Direct\OrderUpdate\Api */ abstract class AbstractMapper{ // Here we add all the methods from our interface as abstract public abstract function getMapping(): array; public abstract function map(array $segments): OrderUpdateInterface; // The const here will behave the same as in the interface const CARRIER_CODES_MAPPING = ['FED' => 'fedex']; // We will set our default mapping - notice these are private to disable access from outside private const MAPPING = ['LIN' => [ 'LIN02' => 'VN', 'LIN01' => 'processSku'], 'PRF' => ['PRF01' => 'processIncrementId'], 'DTM' => ['DTM02' => 'processCreatedAt'], 'SN1' => ['SN102' => 'processQty'], 'REF' => ['REF02' => 'processTrack']]; private $mapToProcess = []; // When we initiate this class we modify our $mapping member according to our new logic function __construct() { $this->mapToProcess = self::MAPPING; // init as if ($this->mapToProcess['LIN']['LIN02'] == 'VN') $this->mapToProcess['LIN']['LIN03'] = 'processSku'; else if ($this->mapToProcess['LIN']['LIN04'] == 'VN') $this->mapToProcess['LIN']['LIN05'] = 'processSku'; } // We use this method to get our process and don't directly use the map public function getProcess($segemntId, $elemntId) { return $this->mapToProcess[$segemntId][$elemntId]; } } class Obj extends AbstractMapper { // notice that as interface it need to implement all the abstract methods public function getMapping() : array { return [$this->getMapping()]; } public function map() : array { return [$this->map()]; } } ``` --- ``` class Obj extends AbstractMapper { // notice that as interface it need to implement all the abstract methods public function getMapping() : array { return [$this->getMapping()]; } public function map() : array { return [$this->map()]; } } ```
2020/01/14
[ "https://Stackoverflow.com/questions/59730379", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5890687/" ]
As you can see [here](https://stackoverflow.com/questions/6455877/can-you-undefine-or-change-a-constant-in-php/6455902) - **const variable cannot be change or hold logic**. Notice that interface cannot hold logic as well - so you cannot do that in your interface. I think the better solution for your issue is to use a [abstract class](https://www.php.net/manual/en/language.oop5.abstract.php). I will be the same as your interface (you can see the discussion about the different [here](https://stackoverflow.com/questions/1913098/what-is-the-difference-between-an-interface-and-abstract-class) but I think it will be the same for your needs). I would recommend to create abstract class as this: ``` abstract class AbstractMapper{ // here add all the method from your interface as abstract public abstract function getMapping(): array; public abstract function map(array $segments): OrderUpdateInterface; // the const here will behave the same as in the interface const CARRIER_CODES_MAPPING = ['FED' => 'fedex']; // set your default mapping - notice those are private to disable access from outside private const MAPPING = ['LIN' => [ 'LIN02' => 'NV', 'LIN01' => 'processSku'], 'PRF' => [ 'PRF01' => 'processIncrementId']]; private $mapToProcess = []; // when initiate this class modify your $mapping member according your logic function __construct() { $this->mapToProcess = self::MAPPING; // init as if ($this->mapToProcess['LIN']['LIN02'] == 'NV') $this->mapToProcess['LIN']['LIN03'] = 'processSku'; else if ($this->mapToProcess['LIN']['LIN04'] == 'NV') $this->mapToProcess['LIN']['LIN05'] = 'processSku'; } // use method to get your process and don't use directly the map public function getProcess($segemntId, $elemntId) { return $this->mapToProcess[$segemntId][$elemntId]; } } ``` Now you can declare object that inherited as: ``` class Obj extends AbstractMapper { // notice that as interface it need to implement all the abstract methods public function getMapping() : array { return []; } } ``` Example for use is: ``` $obj = New Obj(); print_r($obj->getProcess('LIN', 'LIN01')); ``` Note that it seems that your logic is not changing so I put new variable and set it during the construct. If you want you can dump it and just modify the return value of the `getProcess` function - put all the logic there. Another option is to make the `$mapToProcess` public and access it directly but I guess better programing is to use the getter method. Hope that helps!
You can't add an if-else statement inside the constant definition. The closest to what you are looking for is probably this: ``` const A = 1; const B = 2; // Value of C is somewhat "more dynamic" and depends on values of other constants const C = self::A == 1 ? self::A + self::B : 0; // MAPPING array inherits "more dynamic" properties of C const MAPPING = [ self::A, self::B, self::C, ]; ``` Will output: ``` 0 => 1 1 => 2 2 => 3 ``` In other words, you will need to break your array apart into separate constants, then do all conditional defines, then construct the final MAPPING array from resulting constant values.
3,649,177
I have a method that I want to be enqueued to the UI thread message pump. How is this done in actionscript? Basically I am looking for the equivalent of System.Windows.Deployment.Current.Dispatcher.BeginInvoke() in actionscript.
2010/09/06
[ "https://Stackoverflow.com/questions/3649177", "https://Stackoverflow.com", "https://Stackoverflow.com/users/147530/" ]
It hides the navUrl property of the base class. See [new Modifier](http://msdn.microsoft.com/en-us/library/435f1dw2.aspx). As mentioned in that MSDN entry, you can access the "hidden" property with fully qualified names: `BaseClass.navUrl`. Abuse of either can result in massive confusion and possible insanity (i.e. broken code).
`new` is hiding the property. It might be like this in your code: ``` class base1 { public virtual string navUrl { get; set; } } class derived : base1 { public new string navUrl { get; set; } } ``` Here in the derived class, the `navUrl` property is hiding the base class property.
3,649,177
I have a method that I want to be enqueued to the UI thread message pump. How is this done in actionscript? Basically I am looking for the equivalent of System.Windows.Deployment.Current.Dispatcher.BeginInvoke() in actionscript.
2010/09/06
[ "https://Stackoverflow.com/questions/3649177", "https://Stackoverflow.com", "https://Stackoverflow.com/users/147530/" ]
It hides the navUrl property of the base class. See [new Modifier](http://msdn.microsoft.com/en-us/library/435f1dw2.aspx). As mentioned in that MSDN entry, you can access the "hidden" property with fully qualified names: `BaseClass.navUrl`. Abuse of either can result in massive confusion and possible insanity (i.e. broken code).
Some times referred to as `Shadowing` or **[method hiding](http://msdn.microsoft.com/en-us/library/aa691135%28VS.71%29.aspx)**; The method called depends on the type of the reference at the point the call is made. [This might](http://www.akadia.com/services/dotnet_polymorphism.html) help.
3,649,177
I have a method that I want to be enqueued to the UI thread message pump. How is this done in actionscript? Basically I am looking for the equivalent of System.Windows.Deployment.Current.Dispatcher.BeginInvoke() in actionscript.
2010/09/06
[ "https://Stackoverflow.com/questions/3649177", "https://Stackoverflow.com", "https://Stackoverflow.com/users/147530/" ]
It hides the navUrl property of the base class. See [new Modifier](http://msdn.microsoft.com/en-us/library/435f1dw2.aspx). As mentioned in that MSDN entry, you can access the "hidden" property with fully qualified names: `BaseClass.navUrl`. Abuse of either can result in massive confusion and possible insanity (i.e. broken code).
This is also documented [here](http://msdn.microsoft.com/en-us/library/ms173152(VS.80).aspx). Code snippet from msdn. ``` public class BaseClass { public void DoWork() { } public int WorkField; public int WorkProperty { get { return 0; } } } public class DerivedClass : BaseClass { public new void DoWork() { } public new int WorkField; public new int WorkProperty { get { return 0; } } } DerivedClass B = new DerivedClass(); B.WorkProperty; // Calls the new property. BaseClass A = (BaseClass)B; A.WorkProperty; // Calls the old property. ```
3,649,177
I have a method that I want to be enqueued to the UI thread message pump. How is this done in actionscript? Basically I am looking for the equivalent of System.Windows.Deployment.Current.Dispatcher.BeginInvoke() in actionscript.
2010/09/06
[ "https://Stackoverflow.com/questions/3649177", "https://Stackoverflow.com", "https://Stackoverflow.com/users/147530/" ]
It hides the navUrl property of the base class. See [new Modifier](http://msdn.microsoft.com/en-us/library/435f1dw2.aspx). As mentioned in that MSDN entry, you can access the "hidden" property with fully qualified names: `BaseClass.navUrl`. Abuse of either can result in massive confusion and possible insanity (i.e. broken code).
<https://msdn.microsoft.com/en-us/library/435f1dw2.aspx> Look at the first example here, it gives a pretty good idea of how the `new` keyword can be used to mask base class variables
3,649,177
I have a method that I want to be enqueued to the UI thread message pump. How is this done in actionscript? Basically I am looking for the equivalent of System.Windows.Deployment.Current.Dispatcher.BeginInvoke() in actionscript.
2010/09/06
[ "https://Stackoverflow.com/questions/3649177", "https://Stackoverflow.com", "https://Stackoverflow.com/users/147530/" ]
`new` is hiding the property. It might be like this in your code: ``` class base1 { public virtual string navUrl { get; set; } } class derived : base1 { public new string navUrl { get; set; } } ``` Here in the derived class, the `navUrl` property is hiding the base class property.
Some times referred to as `Shadowing` or **[method hiding](http://msdn.microsoft.com/en-us/library/aa691135%28VS.71%29.aspx)**; The method called depends on the type of the reference at the point the call is made. [This might](http://www.akadia.com/services/dotnet_polymorphism.html) help.
3,649,177
I have a method that I want to be enqueued to the UI thread message pump. How is this done in actionscript? Basically I am looking for the equivalent of System.Windows.Deployment.Current.Dispatcher.BeginInvoke() in actionscript.
2010/09/06
[ "https://Stackoverflow.com/questions/3649177", "https://Stackoverflow.com", "https://Stackoverflow.com/users/147530/" ]
`new` is hiding the property. It might be like this in your code: ``` class base1 { public virtual string navUrl { get; set; } } class derived : base1 { public new string navUrl { get; set; } } ``` Here in the derived class, the `navUrl` property is hiding the base class property.
This is also documented [here](http://msdn.microsoft.com/en-us/library/ms173152(VS.80).aspx). Code snippet from msdn. ``` public class BaseClass { public void DoWork() { } public int WorkField; public int WorkProperty { get { return 0; } } } public class DerivedClass : BaseClass { public new void DoWork() { } public new int WorkField; public new int WorkProperty { get { return 0; } } } DerivedClass B = new DerivedClass(); B.WorkProperty; // Calls the new property. BaseClass A = (BaseClass)B; A.WorkProperty; // Calls the old property. ```
3,649,177
I have a method that I want to be enqueued to the UI thread message pump. How is this done in actionscript? Basically I am looking for the equivalent of System.Windows.Deployment.Current.Dispatcher.BeginInvoke() in actionscript.
2010/09/06
[ "https://Stackoverflow.com/questions/3649177", "https://Stackoverflow.com", "https://Stackoverflow.com/users/147530/" ]
`new` is hiding the property. It might be like this in your code: ``` class base1 { public virtual string navUrl { get; set; } } class derived : base1 { public new string navUrl { get; set; } } ``` Here in the derived class, the `navUrl` property is hiding the base class property.
<https://msdn.microsoft.com/en-us/library/435f1dw2.aspx> Look at the first example here, it gives a pretty good idea of how the `new` keyword can be used to mask base class variables
3,649,177
I have a method that I want to be enqueued to the UI thread message pump. How is this done in actionscript? Basically I am looking for the equivalent of System.Windows.Deployment.Current.Dispatcher.BeginInvoke() in actionscript.
2010/09/06
[ "https://Stackoverflow.com/questions/3649177", "https://Stackoverflow.com", "https://Stackoverflow.com/users/147530/" ]
This is also documented [here](http://msdn.microsoft.com/en-us/library/ms173152(VS.80).aspx). Code snippet from msdn. ``` public class BaseClass { public void DoWork() { } public int WorkField; public int WorkProperty { get { return 0; } } } public class DerivedClass : BaseClass { public new void DoWork() { } public new int WorkField; public new int WorkProperty { get { return 0; } } } DerivedClass B = new DerivedClass(); B.WorkProperty; // Calls the new property. BaseClass A = (BaseClass)B; A.WorkProperty; // Calls the old property. ```
Some times referred to as `Shadowing` or **[method hiding](http://msdn.microsoft.com/en-us/library/aa691135%28VS.71%29.aspx)**; The method called depends on the type of the reference at the point the call is made. [This might](http://www.akadia.com/services/dotnet_polymorphism.html) help.
3,649,177
I have a method that I want to be enqueued to the UI thread message pump. How is this done in actionscript? Basically I am looking for the equivalent of System.Windows.Deployment.Current.Dispatcher.BeginInvoke() in actionscript.
2010/09/06
[ "https://Stackoverflow.com/questions/3649177", "https://Stackoverflow.com", "https://Stackoverflow.com/users/147530/" ]
Some times referred to as `Shadowing` or **[method hiding](http://msdn.microsoft.com/en-us/library/aa691135%28VS.71%29.aspx)**; The method called depends on the type of the reference at the point the call is made. [This might](http://www.akadia.com/services/dotnet_polymorphism.html) help.
<https://msdn.microsoft.com/en-us/library/435f1dw2.aspx> Look at the first example here, it gives a pretty good idea of how the `new` keyword can be used to mask base class variables
3,649,177
I have a method that I want to be enqueued to the UI thread message pump. How is this done in actionscript? Basically I am looking for the equivalent of System.Windows.Deployment.Current.Dispatcher.BeginInvoke() in actionscript.
2010/09/06
[ "https://Stackoverflow.com/questions/3649177", "https://Stackoverflow.com", "https://Stackoverflow.com/users/147530/" ]
This is also documented [here](http://msdn.microsoft.com/en-us/library/ms173152(VS.80).aspx). Code snippet from msdn. ``` public class BaseClass { public void DoWork() { } public int WorkField; public int WorkProperty { get { return 0; } } } public class DerivedClass : BaseClass { public new void DoWork() { } public new int WorkField; public new int WorkProperty { get { return 0; } } } DerivedClass B = new DerivedClass(); B.WorkProperty; // Calls the new property. BaseClass A = (BaseClass)B; A.WorkProperty; // Calls the old property. ```
<https://msdn.microsoft.com/en-us/library/435f1dw2.aspx> Look at the first example here, it gives a pretty good idea of how the `new` keyword can be used to mask base class variables
38,267,254
I have an XML document like this: ``` <parent> <child>hello world</child> </parent> ``` I want to apply two different transformations: * From "hello world" to "hello guys" (using the replace function) * From "hello guys" to "HELLO GUYS" (using the translation funciont) For this reason, my XSLT stylesheet i something like this: ``` <xsl:template match="@*|node()"> <xsl:copy> <xsl:apply-templates select="@*|node()"/> </xsl:copy> </xsl:template> <!-- First Transformation --> <xsl:template match="text()" > <xsl:value-of select="replace(. , 'world', 'guys')"/> </xsl:template> <!-- Second Transformation --> <xsl:template match="text()"> <xsl:value-of select="translate(., 'abcdefghijklmnopqrstuvwxyz', 'ABCDEFGHIJKLMNOPQRSTUVWXYZ')" /> </xsl:template> ``` The output is: ``` <parent> <child>HELLO WORLD</child> </parent> ``` You can notice that I get HELLO WORLD and not HELLO GUYS... I think that I can solve this problem making the replace function inside the translate function. Unfortunatelly I need to have this two operation well separated (for this reason I used two different template element). How can I achive this?
2016/07/08
[ "https://Stackoverflow.com/questions/38267254", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5553962/" ]
If you do a `foreach` loop and use the *loop variable* inside a lambda expression you capture it. Unfortunately the variable is scoped incorrectly (at least in older versions of C#, this [changes with C# 5](https://blogs.msdn.microsoft.com/ericlippert/2009/11/12/closing-over-the-loop-variable-considered-harmful/) (thanks, Mafii)). So you need to do something like: ``` foreach (ModuleType mod in modules) { // New variable that is locally scoped. var type = mod; _navBarButtons.Add(new NavButton(mod.ToString(), new RelayCommand<ModuleType>(param => ButtonExecute(type)), type)); } ```
Regarding the solution H.B. posted: not sure why it was not working with lambda functions, why the ButtonExecute was not being execute when the button was pressed. And also i don't understand the logic of defining a lambda function like 'foo => ButtonExecute(foo)' when foo is empty and being passed to the function. But anyway... This is what i did and is working: **Model** ``` <ItemsControl Name="NavButtonsItemsControl" ItemsSource="{Binding NavBarButtons}"> <ItemsControl.ItemsPanel> <ItemsPanelTemplate> <StackPanel Orientation="Horizontal" /> </ItemsPanelTemplate> </ItemsControl.ItemsPanel> <ItemsControl.ItemTemplate> <DataTemplate> <Button Content="{Binding ButtonContent}" CommandParameter="{Binding ButtonModuleType}" Command="{Binding ButtonCommand}"/> </DataTemplate> </ItemsControl.ItemTemplate> </ItemsControl> ``` **ViewModel** (check the rest of the code in my initial question) ``` ......... _navBarButtons.Add(new NavButton(mod.ToString(), new RelayCommand<ModuleType>(ButtonExecute), type)); ......... private void ButtonExecute(ModuleType state) { WriteToLog("Command with parameter " + state.ToString()); } ``` You can make this more generic by using Object instead of ModuleType. And the solution, instead of using a lambda function, is defining a CommandParameter binding in the button and getting that value as the parameter in the execute function. I don't think that binding is explicitly defined, that's why i was having a hard time understanding how the value was reaching 'ButtonExecute', but following the steps in [Dominik Schmidt tutorial](http://www.dominikschmidt.net/2010/12/net-c-mvvm-relaycommand-with-parameters/) it worked.
13,901,255
About 2 weeks ago, I lost the ability to debug JavaScript. I have Windows 8 Pro, IE 10 and Visual Studio 2012 with all updates installed. Until that time, I had no issues - now it does it on every project. The message I get is... "No Source Available. The current code thread is not currently running code or the call stack could not be obtained" Any suggestions as to how I get my JavaScript debugger back? I have already tried do a repair and a re-install with no success. Thanks in advance for any help.
2012/12/16
[ "https://Stackoverflow.com/questions/13901255", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1256085/" ]
I kept playing and removed KB2781514, did a repair on VS2012 and got the JavaScript debugger back - all seems to now work, but I'm really afraid to install that update. I also turned off automatic updates and will make sure that I set a restore point before adding most any future update.
I have had this same problem with VS2010 and VS2012 on WIN7 + IE10 CTP back in December last year. I hoped this problem was solved in the RTM version of IE10, today I found out it was not (and probably because it's not a IE10 problem). Checkout my answer in the link below, maybe it's working for you as well. [VS2010 and IE10 Attaching the Script debugger to process iexplore.exe failed](https://stackoverflow.com/questions/13421797/vs2010-and-ie10-attaching-the-script-debugger-to-process-iexplore-exe-failed/15373837#15373837)
13,901,255
About 2 weeks ago, I lost the ability to debug JavaScript. I have Windows 8 Pro, IE 10 and Visual Studio 2012 with all updates installed. Until that time, I had no issues - now it does it on every project. The message I get is... "No Source Available. The current code thread is not currently running code or the call stack could not be obtained" Any suggestions as to how I get my JavaScript debugger back? I have already tried do a repair and a re-install with no success. Thanks in advance for any help.
2012/12/16
[ "https://Stackoverflow.com/questions/13901255", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1256085/" ]
I had the same problem using VS 2012 after installing IE 10 on Win 7 64bit. I tried several things including "fixing" VS, uninstalling/reinstalling IE10. I couldn't get VS to be set breakpoints in javascript for anything. What finally worked was in VS 2012 I clicked on the "Play" toolbar button (little green arrow pointing right) and had two items listed for Internet Explorer, one being the default. At the bottom of the drop down from that button, I selected "Browse With" which brought up a dialogue box which let me delete one of the two IE's. I also selected Chrome and then back to IE which may have had an impact. In any case, after doing that, everything is working again.
I kept playing and removed KB2781514, did a repair on VS2012 and got the JavaScript debugger back - all seems to now work, but I'm really afraid to install that update. I also turned off automatic updates and will make sure that I set a restore point before adding most any future update.
13,901,255
About 2 weeks ago, I lost the ability to debug JavaScript. I have Windows 8 Pro, IE 10 and Visual Studio 2012 with all updates installed. Until that time, I had no issues - now it does it on every project. The message I get is... "No Source Available. The current code thread is not currently running code or the call stack could not be obtained" Any suggestions as to how I get my JavaScript debugger back? I have already tried do a repair and a re-install with no success. Thanks in advance for any help.
2012/12/16
[ "https://Stackoverflow.com/questions/13901255", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1256085/" ]
I kept playing and removed KB2781514, did a repair on VS2012 and got the JavaScript debugger back - all seems to now work, but I'm really afraid to install that update. I also turned off automatic updates and will make sure that I set a restore point before adding most any future update.
I have the same error with Windows8 + IE10 + VS2012 Update 1, but today I was update vs2012 with Update 2 and the problem is solved. [VS2012 Update 2 here](http://www.microsoft.com/visualstudio/esn/downloads#d-visual-studio-2012-update)
13,901,255
About 2 weeks ago, I lost the ability to debug JavaScript. I have Windows 8 Pro, IE 10 and Visual Studio 2012 with all updates installed. Until that time, I had no issues - now it does it on every project. The message I get is... "No Source Available. The current code thread is not currently running code or the call stack could not be obtained" Any suggestions as to how I get my JavaScript debugger back? I have already tried do a repair and a re-install with no success. Thanks in advance for any help.
2012/12/16
[ "https://Stackoverflow.com/questions/13901255", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1256085/" ]
I had the same problem using VS 2012 after installing IE 10 on Win 7 64bit. I tried several things including "fixing" VS, uninstalling/reinstalling IE10. I couldn't get VS to be set breakpoints in javascript for anything. What finally worked was in VS 2012 I clicked on the "Play" toolbar button (little green arrow pointing right) and had two items listed for Internet Explorer, one being the default. At the bottom of the drop down from that button, I selected "Browse With" which brought up a dialogue box which let me delete one of the two IE's. I also selected Chrome and then back to IE which may have had an impact. In any case, after doing that, everything is working again.
I have had this same problem with VS2010 and VS2012 on WIN7 + IE10 CTP back in December last year. I hoped this problem was solved in the RTM version of IE10, today I found out it was not (and probably because it's not a IE10 problem). Checkout my answer in the link below, maybe it's working for you as well. [VS2010 and IE10 Attaching the Script debugger to process iexplore.exe failed](https://stackoverflow.com/questions/13421797/vs2010-and-ie10-attaching-the-script-debugger-to-process-iexplore-exe-failed/15373837#15373837)
13,901,255
About 2 weeks ago, I lost the ability to debug JavaScript. I have Windows 8 Pro, IE 10 and Visual Studio 2012 with all updates installed. Until that time, I had no issues - now it does it on every project. The message I get is... "No Source Available. The current code thread is not currently running code or the call stack could not be obtained" Any suggestions as to how I get my JavaScript debugger back? I have already tried do a repair and a re-install with no success. Thanks in advance for any help.
2012/12/16
[ "https://Stackoverflow.com/questions/13901255", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1256085/" ]
Try the solution form this post - [VS2010 and IE10 Attaching the Script debugger to process iexplore.exe failed](https://stackoverflow.com/questions/13421797/vs2010-and-ie10-attaching-the-script-debugger-to-process-iexplore-exe-failed/15168080#15168080) * Close IE * In elevated cmd prompt run this command: regsvr32.exe "%ProgramFiles(x86)%\Common Files\Microsoft Shared\VS7Debug\msdbg2.dll" or %ProgramFiles% on a 32-bit OS Restart VS & IE. I restarted the machine to be sure.
I have had this same problem with VS2010 and VS2012 on WIN7 + IE10 CTP back in December last year. I hoped this problem was solved in the RTM version of IE10, today I found out it was not (and probably because it's not a IE10 problem). Checkout my answer in the link below, maybe it's working for you as well. [VS2010 and IE10 Attaching the Script debugger to process iexplore.exe failed](https://stackoverflow.com/questions/13421797/vs2010-and-ie10-attaching-the-script-debugger-to-process-iexplore-exe-failed/15373837#15373837)
13,901,255
About 2 weeks ago, I lost the ability to debug JavaScript. I have Windows 8 Pro, IE 10 and Visual Studio 2012 with all updates installed. Until that time, I had no issues - now it does it on every project. The message I get is... "No Source Available. The current code thread is not currently running code or the call stack could not be obtained" Any suggestions as to how I get my JavaScript debugger back? I have already tried do a repair and a re-install with no success. Thanks in advance for any help.
2012/12/16
[ "https://Stackoverflow.com/questions/13901255", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1256085/" ]
I had the same problem using VS 2012 after installing IE 10 on Win 7 64bit. I tried several things including "fixing" VS, uninstalling/reinstalling IE10. I couldn't get VS to be set breakpoints in javascript for anything. What finally worked was in VS 2012 I clicked on the "Play" toolbar button (little green arrow pointing right) and had two items listed for Internet Explorer, one being the default. At the bottom of the drop down from that button, I selected "Browse With" which brought up a dialogue box which let me delete one of the two IE's. I also selected Chrome and then back to IE which may have had an impact. In any case, after doing that, everything is working again.
Try the solution form this post - [VS2010 and IE10 Attaching the Script debugger to process iexplore.exe failed](https://stackoverflow.com/questions/13421797/vs2010-and-ie10-attaching-the-script-debugger-to-process-iexplore-exe-failed/15168080#15168080) * Close IE * In elevated cmd prompt run this command: regsvr32.exe "%ProgramFiles(x86)%\Common Files\Microsoft Shared\VS7Debug\msdbg2.dll" or %ProgramFiles% on a 32-bit OS Restart VS & IE. I restarted the machine to be sure.
13,901,255
About 2 weeks ago, I lost the ability to debug JavaScript. I have Windows 8 Pro, IE 10 and Visual Studio 2012 with all updates installed. Until that time, I had no issues - now it does it on every project. The message I get is... "No Source Available. The current code thread is not currently running code or the call stack could not be obtained" Any suggestions as to how I get my JavaScript debugger back? I have already tried do a repair and a re-install with no success. Thanks in advance for any help.
2012/12/16
[ "https://Stackoverflow.com/questions/13901255", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1256085/" ]
I had the same problem using VS 2012 after installing IE 10 on Win 7 64bit. I tried several things including "fixing" VS, uninstalling/reinstalling IE10. I couldn't get VS to be set breakpoints in javascript for anything. What finally worked was in VS 2012 I clicked on the "Play" toolbar button (little green arrow pointing right) and had two items listed for Internet Explorer, one being the default. At the bottom of the drop down from that button, I selected "Browse With" which brought up a dialogue box which let me delete one of the two IE's. I also selected Chrome and then back to IE which may have had an impact. In any case, after doing that, everything is working again.
I have the same error with Windows8 + IE10 + VS2012 Update 1, but today I was update vs2012 with Update 2 and the problem is solved. [VS2012 Update 2 here](http://www.microsoft.com/visualstudio/esn/downloads#d-visual-studio-2012-update)
13,901,255
About 2 weeks ago, I lost the ability to debug JavaScript. I have Windows 8 Pro, IE 10 and Visual Studio 2012 with all updates installed. Until that time, I had no issues - now it does it on every project. The message I get is... "No Source Available. The current code thread is not currently running code or the call stack could not be obtained" Any suggestions as to how I get my JavaScript debugger back? I have already tried do a repair and a re-install with no success. Thanks in advance for any help.
2012/12/16
[ "https://Stackoverflow.com/questions/13901255", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1256085/" ]
Try the solution form this post - [VS2010 and IE10 Attaching the Script debugger to process iexplore.exe failed](https://stackoverflow.com/questions/13421797/vs2010-and-ie10-attaching-the-script-debugger-to-process-iexplore-exe-failed/15168080#15168080) * Close IE * In elevated cmd prompt run this command: regsvr32.exe "%ProgramFiles(x86)%\Common Files\Microsoft Shared\VS7Debug\msdbg2.dll" or %ProgramFiles% on a 32-bit OS Restart VS & IE. I restarted the machine to be sure.
I have the same error with Windows8 + IE10 + VS2012 Update 1, but today I was update vs2012 with Update 2 and the problem is solved. [VS2012 Update 2 here](http://www.microsoft.com/visualstudio/esn/downloads#d-visual-studio-2012-update)
784,182
I've been working in ASP.NET for several years now (since the 1.0 days!), but I've never been formally instructed. I'm fully capable of doing pretty much anything I want and I've built several production-level, data-driven sites, including one that does over a million in sales a year (according to the owner). But I'm starting to get the feeling that the holes in my knowlege are dragging my productivity down. I read a lot and try to learn wherever I can to try to stay up with all the new technologies, but sometimes I just don't get it, and I think it's because of my lack of formal training. Does anyone have any ideas on the best way to fill in these gaps without having to rehash the fundamentals? Thanks
2009/04/24
[ "https://Stackoverflow.com/questions/784182", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7173/" ]
I can absolutely identify. I've been programming since 1997 and really don't have any formal training to speak of. With regards to ASP.NET, everything I've learned has been through open code (Community Server, BlogEngine.NET, the other ASP.NET Starter Kits), books, LearnVisualStudio.net, and constantly being thrown in the fire. I have a MASSIVE inferiority complex as I'm always wondering "did I do this the smart way or the inexperienced way". All I know is that my customers are happy, the errors that occur are few and are fixed quickly, and I keep getting work. Luckily I have a passion for my work and that's what drives me to keep improving (slow though it may be). If you're a "people person" then I think user group meetings are a great resource. I'm a bit of an introvert and unless someone who's smart reaches across and shakes my hand, I pretty much rely on the speaker's presentation to teach me something new. Probably not the best way to go and also probably why I don't go that much. But again, I would stress the open projects, especially Community Server.
Seek out people better than you and learn from them. Take some classes or join a user group.
784,182
I've been working in ASP.NET for several years now (since the 1.0 days!), but I've never been formally instructed. I'm fully capable of doing pretty much anything I want and I've built several production-level, data-driven sites, including one that does over a million in sales a year (according to the owner). But I'm starting to get the feeling that the holes in my knowlege are dragging my productivity down. I read a lot and try to learn wherever I can to try to stay up with all the new technologies, but sometimes I just don't get it, and I think it's because of my lack of formal training. Does anyone have any ideas on the best way to fill in these gaps without having to rehash the fundamentals? Thanks
2009/04/24
[ "https://Stackoverflow.com/questions/784182", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7173/" ]
I can absolutely identify. I've been programming since 1997 and really don't have any formal training to speak of. With regards to ASP.NET, everything I've learned has been through open code (Community Server, BlogEngine.NET, the other ASP.NET Starter Kits), books, LearnVisualStudio.net, and constantly being thrown in the fire. I have a MASSIVE inferiority complex as I'm always wondering "did I do this the smart way or the inexperienced way". All I know is that my customers are happy, the errors that occur are few and are fixed quickly, and I keep getting work. Luckily I have a passion for my work and that's what drives me to keep improving (slow though it may be). If you're a "people person" then I think user group meetings are a great resource. I'm a bit of an introvert and unless someone who's smart reaches across and shakes my hand, I pretty much rely on the speaker's presentation to teach me something new. Probably not the best way to go and also probably why I don't go that much. But again, I would stress the open projects, especially Community Server.
If you are looking at conferences, consider finding a local [Code Camp](http://www.google.com/search?q=code+camp). These conferences are often very low key, but have excellent information content. They involve local presenters and attendees so you can build up your contacts and a set of people you can run things past when you need help. In addition, you might want to find (or start) a local .NET group where you can learn together. These can be hard to get off the ground, but when done well can be an excellent source of community learning.
784,182
I've been working in ASP.NET for several years now (since the 1.0 days!), but I've never been formally instructed. I'm fully capable of doing pretty much anything I want and I've built several production-level, data-driven sites, including one that does over a million in sales a year (according to the owner). But I'm starting to get the feeling that the holes in my knowlege are dragging my productivity down. I read a lot and try to learn wherever I can to try to stay up with all the new technologies, but sometimes I just don't get it, and I think it's because of my lack of formal training. Does anyone have any ideas on the best way to fill in these gaps without having to rehash the fundamentals? Thanks
2009/04/24
[ "https://Stackoverflow.com/questions/784182", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7173/" ]
I'm in the same boat; been a .Net developer for 6 years. While I do have a CS degree, I don't have any formal training in ASP.Net; I learn it on the job as projects come up. I found the best way to figure out what to learn is to keep your eye on .Net developer blogs. Some I follow: David Hayden <http://www.davidhayden.com/blog.aspx> CodingHorror.com (you might be familiar with it ;-) Scott Hanselman <http://www.hanselman.com/blog/> Usually from reading their blogs, I pick up on what the latest .Net solutions that are out there and point me in the direction of new tech I should look into further. Overall though, I can only give you the advice I give junior devs at my company; realize you can't possibly be expected to know everything but always be eager to learn. Good luck!
Seek out people better than you and learn from them. Take some classes or join a user group.
784,182
I've been working in ASP.NET for several years now (since the 1.0 days!), but I've never been formally instructed. I'm fully capable of doing pretty much anything I want and I've built several production-level, data-driven sites, including one that does over a million in sales a year (according to the owner). But I'm starting to get the feeling that the holes in my knowlege are dragging my productivity down. I read a lot and try to learn wherever I can to try to stay up with all the new technologies, but sometimes I just don't get it, and I think it's because of my lack of formal training. Does anyone have any ideas on the best way to fill in these gaps without having to rehash the fundamentals? Thanks
2009/04/24
[ "https://Stackoverflow.com/questions/784182", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7173/" ]
I'll probably get some -1's for this, but as a fellow ASP.NET developer I don't think you really need to learn ALL that the framework has to offer. The reason I say that is that over the years my LACK of knowledge of all the cute little conveniences of ASP.NET has caused me to write better performing and more robust web apps for Windows. Balanced design patterns (separation of concerns) WITHOUT OVERDOING IT will make more of a "better" ASP.NET web app than using all of the controls and tools that come with the framework. Case in point is the ajax stuff you get with ASP.NET, and also data binding. Since ASP.NET was late in the game with Ajax, I started off with my own ajax wrapper (based on an early ajax book) and then moving to jQuery. My co-workers all swear by the UpdatePanels and 3rd party controls, and quite often the user experience ends up worse and more confusing than a regular post back (and then we have to inject javascript to make it perform better and more seemlessly). As far as data binding, I've yet to find a canned control (from Microsoft or any 3rd party) that handles 2-way binding better than the framework [Rick Strahl](http://www.west-wind.com/Weblog/) came up with back in the 1.1 days. We built a framework on top of a paper and some base classes he released, and I've yet to see something that I think handles data binding any better in ASP.NET (well...besides WPF/Silverlight...those frameworks really nailed it IMO). So, to me, the path to upgrading your ASP.NET skills is to come up with some good ways to separate your business logic into logical components in the cleanest possible way, and learn the hell out of C# and JavaScript (and/or a JS wrapper library like jQuery). For me, coming from a LAMP background before learning ASP.NET, I absolutely love C# and Visual Studio, but I'm not such a huge fan of the high level ASP.NET controls.
This is a pretty broad question, and hard to address. I perceive myself in a similar space to you, so I guess I can elaborate on what I've been focusing on to improve as a developer which might be of some help. I mostly write business and commerce related web apps, and my focus has been on a developing a solid understanding of separation of concerns, domain driven design, and enterprise design patterns. Some books on general software design which I found revelatory were Code Complete by Steve McConnell and Head First Design Patterns by Freeman & Freeman. I read SO, [Code Better](http://codebetter.com/), [DDD Step by Step](http://dddstepbystep.com/), and a number of other blogs regularly. Dissect well written code from others, and learn from them. Learn from your peers. If you're in a stifling work environment that doesn't give you the opportunity to grow as a developer, consider looking for a new job. Learn a new language in a completely different framework - I've been teaching myself Ruby on Rails at home and it has given me an interesting perspective on the ASP.NET work that I do commercially. Given that you're an ASP.NET web developer, learning MVC.NET will certainly help you to think about front-end development in a new, refreshing way.
784,182
I've been working in ASP.NET for several years now (since the 1.0 days!), but I've never been formally instructed. I'm fully capable of doing pretty much anything I want and I've built several production-level, data-driven sites, including one that does over a million in sales a year (according to the owner). But I'm starting to get the feeling that the holes in my knowlege are dragging my productivity down. I read a lot and try to learn wherever I can to try to stay up with all the new technologies, but sometimes I just don't get it, and I think it's because of my lack of formal training. Does anyone have any ideas on the best way to fill in these gaps without having to rehash the fundamentals? Thanks
2009/04/24
[ "https://Stackoverflow.com/questions/784182", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7173/" ]
1) Read the Code of popular Open Source Projects. There are a few that have some really good practices in place. I recommend checking out [BlogEngine.NET](http://www.dotnetblogengine.net/). Also if you're more ambitious, I'd suggest looking at the code for [ASP.NET MVC 1.0](http://aspnet.codeplex.com/Wiki/View.aspx?title=MVC). 2) Sometimes you need to "get back to the basics" when you've been working with a particular framework since a much earlier version. In this case, it can be really useful to pick up a book that covers some of the newer features. Here's a good book that shows of some of the new features in C# 3.0: [C# 3.0 Design Patterns](https://rads.stackoverflow.com/amzn/click/com/059652773X) 3) It may seem odd, but reading up on other languages/platforms (such as Ruby on Rails) will help you in the way you design your classes and code by taking tips of the good and bad of different platforms and combining them. 4) Read some books on general best practices and development methodologies. Some of these books I recommend are: [The Pragmatic Programmer: From Journeyman to Master](https://rads.stackoverflow.com/amzn/click/com/020161622X) [Practices of an Agile Developer: Working in the Real World](https://rads.stackoverflow.com/amzn/click/com/097451408X) [Code Complete: A Practical Handbook of Software Construction](https://rads.stackoverflow.com/amzn/click/com/0735619670)
I can absolutely identify. I've been programming since 1997 and really don't have any formal training to speak of. With regards to ASP.NET, everything I've learned has been through open code (Community Server, BlogEngine.NET, the other ASP.NET Starter Kits), books, LearnVisualStudio.net, and constantly being thrown in the fire. I have a MASSIVE inferiority complex as I'm always wondering "did I do this the smart way or the inexperienced way". All I know is that my customers are happy, the errors that occur are few and are fixed quickly, and I keep getting work. Luckily I have a passion for my work and that's what drives me to keep improving (slow though it may be). If you're a "people person" then I think user group meetings are a great resource. I'm a bit of an introvert and unless someone who's smart reaches across and shakes my hand, I pretty much rely on the speaker's presentation to teach me something new. Probably not the best way to go and also probably why I don't go that much. But again, I would stress the open projects, especially Community Server.
784,182
I've been working in ASP.NET for several years now (since the 1.0 days!), but I've never been formally instructed. I'm fully capable of doing pretty much anything I want and I've built several production-level, data-driven sites, including one that does over a million in sales a year (according to the owner). But I'm starting to get the feeling that the holes in my knowlege are dragging my productivity down. I read a lot and try to learn wherever I can to try to stay up with all the new technologies, but sometimes I just don't get it, and I think it's because of my lack of formal training. Does anyone have any ideas on the best way to fill in these gaps without having to rehash the fundamentals? Thanks
2009/04/24
[ "https://Stackoverflow.com/questions/784182", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7173/" ]
Look for interesting ways to break your established patters - even at a loss of productivity. Otherwise, it sounds like you are already in a pretty good spot. You can deliver on current requirements and sound like you can pick up new tricks when needed. Really, the best way to learn new techniques is to work on a different project - even if that means changing jobs. If you have relevant and continuous experience since 2001, you should be able to pick your projects. I've been coding PHP on a current project and it's been an interesting break from webforms. If anything, I'm getting good perspective on both models and really looking forward to doing some work in MVC.
If you can afford the money and time (or can get your company to pay for it), take a course at [DevelopMentor](http://www.develop.com/). They have courses across the country and all year round. They are generally a week long and are in depth.
784,182
I've been working in ASP.NET for several years now (since the 1.0 days!), but I've never been formally instructed. I'm fully capable of doing pretty much anything I want and I've built several production-level, data-driven sites, including one that does over a million in sales a year (according to the owner). But I'm starting to get the feeling that the holes in my knowlege are dragging my productivity down. I read a lot and try to learn wherever I can to try to stay up with all the new technologies, but sometimes I just don't get it, and I think it's because of my lack of formal training. Does anyone have any ideas on the best way to fill in these gaps without having to rehash the fundamentals? Thanks
2009/04/24
[ "https://Stackoverflow.com/questions/784182", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7173/" ]
1) Read the Code of popular Open Source Projects. There are a few that have some really good practices in place. I recommend checking out [BlogEngine.NET](http://www.dotnetblogengine.net/). Also if you're more ambitious, I'd suggest looking at the code for [ASP.NET MVC 1.0](http://aspnet.codeplex.com/Wiki/View.aspx?title=MVC). 2) Sometimes you need to "get back to the basics" when you've been working with a particular framework since a much earlier version. In this case, it can be really useful to pick up a book that covers some of the newer features. Here's a good book that shows of some of the new features in C# 3.0: [C# 3.0 Design Patterns](https://rads.stackoverflow.com/amzn/click/com/059652773X) 3) It may seem odd, but reading up on other languages/platforms (such as Ruby on Rails) will help you in the way you design your classes and code by taking tips of the good and bad of different platforms and combining them. 4) Read some books on general best practices and development methodologies. Some of these books I recommend are: [The Pragmatic Programmer: From Journeyman to Master](https://rads.stackoverflow.com/amzn/click/com/020161622X) [Practices of an Agile Developer: Working in the Real World](https://rads.stackoverflow.com/amzn/click/com/097451408X) [Code Complete: A Practical Handbook of Software Construction](https://rads.stackoverflow.com/amzn/click/com/0735619670)
If you are looking at conferences, consider finding a local [Code Camp](http://www.google.com/search?q=code+camp). These conferences are often very low key, but have excellent information content. They involve local presenters and attendees so you can build up your contacts and a set of people you can run things past when you need help. In addition, you might want to find (or start) a local .NET group where you can learn together. These can be hard to get off the ground, but when done well can be an excellent source of community learning.
784,182
I've been working in ASP.NET for several years now (since the 1.0 days!), but I've never been formally instructed. I'm fully capable of doing pretty much anything I want and I've built several production-level, data-driven sites, including one that does over a million in sales a year (according to the owner). But I'm starting to get the feeling that the holes in my knowlege are dragging my productivity down. I read a lot and try to learn wherever I can to try to stay up with all the new technologies, but sometimes I just don't get it, and I think it's because of my lack of formal training. Does anyone have any ideas on the best way to fill in these gaps without having to rehash the fundamentals? Thanks
2009/04/24
[ "https://Stackoverflow.com/questions/784182", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7173/" ]
Look for interesting ways to break your established patters - even at a loss of productivity. Otherwise, it sounds like you are already in a pretty good spot. You can deliver on current requirements and sound like you can pick up new tricks when needed. Really, the best way to learn new techniques is to work on a different project - even if that means changing jobs. If you have relevant and continuous experience since 2001, you should be able to pick your projects. I've been coding PHP on a current project and it's been an interesting break from webforms. If anything, I'm getting good perspective on both models and really looking forward to doing some work in MVC.
This is a pretty broad question, and hard to address. I perceive myself in a similar space to you, so I guess I can elaborate on what I've been focusing on to improve as a developer which might be of some help. I mostly write business and commerce related web apps, and my focus has been on a developing a solid understanding of separation of concerns, domain driven design, and enterprise design patterns. Some books on general software design which I found revelatory were Code Complete by Steve McConnell and Head First Design Patterns by Freeman & Freeman. I read SO, [Code Better](http://codebetter.com/), [DDD Step by Step](http://dddstepbystep.com/), and a number of other blogs regularly. Dissect well written code from others, and learn from them. Learn from your peers. If you're in a stifling work environment that doesn't give you the opportunity to grow as a developer, consider looking for a new job. Learn a new language in a completely different framework - I've been teaching myself Ruby on Rails at home and it has given me an interesting perspective on the ASP.NET work that I do commercially. Given that you're an ASP.NET web developer, learning MVC.NET will certainly help you to think about front-end development in a new, refreshing way.
784,182
I've been working in ASP.NET for several years now (since the 1.0 days!), but I've never been formally instructed. I'm fully capable of doing pretty much anything I want and I've built several production-level, data-driven sites, including one that does over a million in sales a year (according to the owner). But I'm starting to get the feeling that the holes in my knowlege are dragging my productivity down. I read a lot and try to learn wherever I can to try to stay up with all the new technologies, but sometimes I just don't get it, and I think it's because of my lack of formal training. Does anyone have any ideas on the best way to fill in these gaps without having to rehash the fundamentals? Thanks
2009/04/24
[ "https://Stackoverflow.com/questions/784182", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7173/" ]
Seek out people better than you and learn from them. Take some classes or join a user group.
If you can afford the money and time (or can get your company to pay for it), take a course at [DevelopMentor](http://www.develop.com/). They have courses across the country and all year round. They are generally a week long and are in depth.
784,182
I've been working in ASP.NET for several years now (since the 1.0 days!), but I've never been formally instructed. I'm fully capable of doing pretty much anything I want and I've built several production-level, data-driven sites, including one that does over a million in sales a year (according to the owner). But I'm starting to get the feeling that the holes in my knowlege are dragging my productivity down. I read a lot and try to learn wherever I can to try to stay up with all the new technologies, but sometimes I just don't get it, and I think it's because of my lack of formal training. Does anyone have any ideas on the best way to fill in these gaps without having to rehash the fundamentals? Thanks
2009/04/24
[ "https://Stackoverflow.com/questions/784182", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7173/" ]
1) Read the Code of popular Open Source Projects. There are a few that have some really good practices in place. I recommend checking out [BlogEngine.NET](http://www.dotnetblogengine.net/). Also if you're more ambitious, I'd suggest looking at the code for [ASP.NET MVC 1.0](http://aspnet.codeplex.com/Wiki/View.aspx?title=MVC). 2) Sometimes you need to "get back to the basics" when you've been working with a particular framework since a much earlier version. In this case, it can be really useful to pick up a book that covers some of the newer features. Here's a good book that shows of some of the new features in C# 3.0: [C# 3.0 Design Patterns](https://rads.stackoverflow.com/amzn/click/com/059652773X) 3) It may seem odd, but reading up on other languages/platforms (such as Ruby on Rails) will help you in the way you design your classes and code by taking tips of the good and bad of different platforms and combining them. 4) Read some books on general best practices and development methodologies. Some of these books I recommend are: [The Pragmatic Programmer: From Journeyman to Master](https://rads.stackoverflow.com/amzn/click/com/020161622X) [Practices of an Agile Developer: Working in the Real World](https://rads.stackoverflow.com/amzn/click/com/097451408X) [Code Complete: A Practical Handbook of Software Construction](https://rads.stackoverflow.com/amzn/click/com/0735619670)
This is a pretty broad question, and hard to address. I perceive myself in a similar space to you, so I guess I can elaborate on what I've been focusing on to improve as a developer which might be of some help. I mostly write business and commerce related web apps, and my focus has been on a developing a solid understanding of separation of concerns, domain driven design, and enterprise design patterns. Some books on general software design which I found revelatory were Code Complete by Steve McConnell and Head First Design Patterns by Freeman & Freeman. I read SO, [Code Better](http://codebetter.com/), [DDD Step by Step](http://dddstepbystep.com/), and a number of other blogs regularly. Dissect well written code from others, and learn from them. Learn from your peers. If you're in a stifling work environment that doesn't give you the opportunity to grow as a developer, consider looking for a new job. Learn a new language in a completely different framework - I've been teaching myself Ruby on Rails at home and it has given me an interesting perspective on the ASP.NET work that I do commercially. Given that you're an ASP.NET web developer, learning MVC.NET will certainly help you to think about front-end development in a new, refreshing way.
36,829,899
I was getting "HTTP 403 error Microsoft Edge can’t get to this page", while launching an application from IIS in Windows 10. Please suggest a solution for this. thanks
2016/04/24
[ "https://Stackoverflow.com/questions/36829899", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2168525/" ]
If all permissions are set and even though your website shows 403 forbidden, most likely the default page is not set for your website. With IIS, you can configure the default document as follows. 1. Connect to IIS. 2. Expand the sites and select the desired website. 3. From right hand side feature view, click on Default Document. 4. Set your desire default page and save the settings. While you browse any website, IIS searches for the default page to be displayed. If the first default document is not available, IIS will look for the next default page from the list. When IIS is unable to find any match and directory listing is enabled for that particular website, IIS will show you the list of folders. If directory listing is disabled, IIS will return an HTTP Error 403 - Forbidden message to the browser.
If an empty application gives you a 403 I can think of two immediate reasons. 1. The permissions are wrong. You might need to give the application pool user (`IIS AppPool\NAMEOFAPPPOOL` with recommended configuration) read permission to the directory. 2. You don't have any content. If you try to access a directory in IIS you will get a 403. Add a file and try to access that directly, or a `Default.aspx` or `index.html` file to the directory you're trying to access.
17,294,253
I am working on a Symfony 1.4 project. I need to make a PDF download link for a (yet to be) generated voucher and I have to say, I am a bit confused. I already have the HTML/CSS for the voucher, I created the download button in the right view, but I don't know where to go from there.
2013/06/25
[ "https://Stackoverflow.com/questions/17294253", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1225630/" ]
After try lots of options, the best and easiest for us has been add those lines in stylesheet.css: ``` .zoomLens { display: none !important; } .zoomContainer { display: none !important; } ``` Thanks!!!
The right solution should be in `catalog/view/theme/default/template/product/product.tpl` find ```js <script type="text/javascript"><!-- $(document).ready(function() { $('.colorbox').colorbox({ overlayClose: true, opacity: 0.5, rel: "colorbox" }); }); //--></script> ``` (should start at line 335) and change it to: ```js <script type="text/javascript"><!-- /*$(document).ready(function() { $('.colorbox').colorbox({ overlayClose: true, opacity: 0.5, rel: "colorbox" }); });*/ //--></script> ``` Thus simply comment whole colorbox feature initialization...
5,307,741
I have a site with a short url domain with an A record pointing to the main site (it's a pain to change this so I'd rather not). I have special logic that needs to run when the application is accessed from the short URL. Right now, I have Apache set up with a RewriteRule to do a 301 to the main site when you hit the short URL, but if I try to access the referrer or any sort of headers they seem to be gone. I can get around this by appending a query parameter, but I'd rather not muddy up the URL as well. Any ideas on how to set some piece of data within Apache that I can access in my Rails app to tell if the request was a result of accessing the short URL?
2011/03/15
[ "https://Stackoverflow.com/questions/5307741", "https://Stackoverflow.com", "https://Stackoverflow.com/users/145492/" ]
Title\_Authors is a look up two things join at a time project results and continue chaining ``` DataClasses1DataContext db = new DataClasses1DataContext(); var queryresults = from a in db.Authors join ba in db.Title_Authors on a.Au_ID equals ba.Au_ID into idAuthor from c in idAuthor join t in db.Titles on c.ISBN equals t.ISBN select new { Author = a.Author1,Title= t.Title1 }; foreach (var item in queryresults) { MessageBox.Show(item.Author); MessageBox.Show(item.Title); return; } ```
You can use LINQ Method Syntax to join on multiple columns. It's an example here, ``` var query = mTABLE_1.Join( // mTABLE_1 is a List<TABLE_1> mTABLE_1, t1 => new { ColA = t1.ColumnA, ColB = t1.ColumnB, ColC = t1.ColumnC }, t2 => new { ColA = t2.ColumnA, ColB = t2.ColumnB, ColC = t2.ColumnC }, (t1, t2) => new { t1, t2 }).Join( mTABLE_1, t1t2 => new { ColA = t1t2.t2.ColumnA, ColB = t1t2.t2.ColumnB, ColC = t1t2.t2.ColumnC }, t3 => new { ColA = t3.ColumnA, ColB = t3.ColumnB, ColC = t3.ColumnC }, (t1t2, t3) => new { t1 = t1t2.t1, t2 = t1t2.t2, t3 = t3 }); ``` **Note:** The compiler converts query syntax into method syntax at compile time.
5,307,741
I have a site with a short url domain with an A record pointing to the main site (it's a pain to change this so I'd rather not). I have special logic that needs to run when the application is accessed from the short URL. Right now, I have Apache set up with a RewriteRule to do a 301 to the main site when you hit the short URL, but if I try to access the referrer or any sort of headers they seem to be gone. I can get around this by appending a query parameter, but I'd rather not muddy up the URL as well. Any ideas on how to set some piece of data within Apache that I can access in my Rails app to tell if the request was a result of accessing the short URL?
2011/03/15
[ "https://Stackoverflow.com/questions/5307741", "https://Stackoverflow.com", "https://Stackoverflow.com/users/145492/" ]
U can also use : ``` var query = from t1 in myTABLE1List join t2 in myTABLE1List on new { ColA=t1.ColumnA, ColB=t1.ColumnB } equals new { ColA=t2.ColumnA, ColB=t2.ColumnB } join t3 in myTABLE1List on new {ColC=t2.ColumnA, ColD=t2.ColumnB } equals new { ColC=t3.ColumnA, ColD=t3.ColumnB } ```
The A and B alias must line up with Hrco and Position code from e table and t table - Hrco and Position Code combinations in the "equal new" filter. This will save you time because I kept getting "Not in scope on the left side" compile errors because I thought the filter was e.Hrco, t.Hrco pairing for the filter. ``` select * from table1 e join table2 t on e.Hrco=t.Hrco and e.PositionCode=t.PositionCode Notice the association of the columns to the labels A and B. The As equal and the Bs equal filter. IList<MyView> list = await (from e in _dbContext.table1 join t in _dbContext.table2 on new { A= e.Hrco, B= e.PositionCode } equals new {A= t.Hrco,B=t.PositionCode } where e.XMan == employeeNumber select new MyView { Employee=e.Employee, LastName=e.LastName, FirstName=e.FirstName, Title=t.JobTitle ).ToListAsync<MyView>(); ```
5,307,741
I have a site with a short url domain with an A record pointing to the main site (it's a pain to change this so I'd rather not). I have special logic that needs to run when the application is accessed from the short URL. Right now, I have Apache set up with a RewriteRule to do a 301 to the main site when you hit the short URL, but if I try to access the referrer or any sort of headers they seem to be gone. I can get around this by appending a query parameter, but I'd rather not muddy up the URL as well. Any ideas on how to set some piece of data within Apache that I can access in my Rails app to tell if the request was a result of accessing the short URL?
2011/03/15
[ "https://Stackoverflow.com/questions/5307741", "https://Stackoverflow.com", "https://Stackoverflow.com/users/145492/" ]
In LINQ2SQL you seldom need to join explicitly when using inner joins. If you have proper foreign key relationships in your database you will automatically get a relation in the LINQ designer (if not you can create a relation manually in the designer, although you should really have proper relations in your database) ![parent-child relation](https://i.stack.imgur.com/3flvg.png) Then you can just access related tables with the "dot-notation" ``` var q = from child in context.Childs where child.Parent.col2 == 4 select new { childCol1 = child.col1, parentCol1 = child.Parent.col1, }; ``` will generate the query ``` SELECT [t0].[col1] AS [childCol1], [t1].[col1] AS [parentCol1] FROM [dbo].[Child] AS [t0] INNER JOIN [dbo].[Parent] AS [t1] ON ([t1].[col1] = [t0].[col1]) AND ([t1].[col2] = [t0].[col2]) WHERE [t1].[col2] = @p0 -- @p0: Input Int (Size = -1; Prec = 0; Scale = 0) [4] -- Context: SqlProvider(Sql2008) Model: AttributedMetaModel Build: 4.0.30319.1 ``` In my opinion this is much more readable and lets you concentrate on your special conditions and not the actual mechanics of the join. **Edit** This is of course only applicable when you want to join in the line with our database model. If you want to join "outside the model" you need to resort to manual joins as in the [answer](https://stackoverflow.com/questions/5307731/linq-to-sql-multiple-joins-on-multiple-columns-is-this-possible/5307742#5307742) from [Quintin Robinson](https://stackoverflow.com/users/12707/quintin-robinson)
I would like to give another example in which multiple (3) joins are used. ``` DataClasses1DataContext ctx = new DataClasses1DataContext(); var Owners = ctx.OwnerMasters; var Category = ctx.CategoryMasters; var Status = ctx.StatusMasters; var Tasks = ctx.TaskMasters; var xyz = from t in Tasks join c in Category on t.TaskCategory equals c.CategoryID join s in Status on t.TaskStatus equals s.StatusID join o in Owners on t.TaskOwner equals o.OwnerID select new { t.TaskID, t.TaskShortDescription, c.CategoryName, s.StatusName, o.OwnerName }; ```
5,307,741
I have a site with a short url domain with an A record pointing to the main site (it's a pain to change this so I'd rather not). I have special logic that needs to run when the application is accessed from the short URL. Right now, I have Apache set up with a RewriteRule to do a 301 to the main site when you hit the short URL, but if I try to access the referrer or any sort of headers they seem to be gone. I can get around this by appending a query parameter, but I'd rather not muddy up the URL as well. Any ideas on how to set some piece of data within Apache that I can access in my Rails app to tell if the request was a result of accessing the short URL?
2011/03/15
[ "https://Stackoverflow.com/questions/5307741", "https://Stackoverflow.com", "https://Stackoverflow.com/users/145492/" ]
In LINQ2SQL you seldom need to join explicitly when using inner joins. If you have proper foreign key relationships in your database you will automatically get a relation in the LINQ designer (if not you can create a relation manually in the designer, although you should really have proper relations in your database) ![parent-child relation](https://i.stack.imgur.com/3flvg.png) Then you can just access related tables with the "dot-notation" ``` var q = from child in context.Childs where child.Parent.col2 == 4 select new { childCol1 = child.col1, parentCol1 = child.Parent.col1, }; ``` will generate the query ``` SELECT [t0].[col1] AS [childCol1], [t1].[col1] AS [parentCol1] FROM [dbo].[Child] AS [t0] INNER JOIN [dbo].[Parent] AS [t1] ON ([t1].[col1] = [t0].[col1]) AND ([t1].[col2] = [t0].[col2]) WHERE [t1].[col2] = @p0 -- @p0: Input Int (Size = -1; Prec = 0; Scale = 0) [4] -- Context: SqlProvider(Sql2008) Model: AttributedMetaModel Build: 4.0.30319.1 ``` In my opinion this is much more readable and lets you concentrate on your special conditions and not the actual mechanics of the join. **Edit** This is of course only applicable when you want to join in the line with our database model. If you want to join "outside the model" you need to resort to manual joins as in the [answer](https://stackoverflow.com/questions/5307731/linq-to-sql-multiple-joins-on-multiple-columns-is-this-possible/5307742#5307742) from [Quintin Robinson](https://stackoverflow.com/users/12707/quintin-robinson)
You can use LINQ Method Syntax to join on multiple columns. It's an example here, ``` var query = mTABLE_1.Join( // mTABLE_1 is a List<TABLE_1> mTABLE_1, t1 => new { ColA = t1.ColumnA, ColB = t1.ColumnB, ColC = t1.ColumnC }, t2 => new { ColA = t2.ColumnA, ColB = t2.ColumnB, ColC = t2.ColumnC }, (t1, t2) => new { t1, t2 }).Join( mTABLE_1, t1t2 => new { ColA = t1t2.t2.ColumnA, ColB = t1t2.t2.ColumnB, ColC = t1t2.t2.ColumnC }, t3 => new { ColA = t3.ColumnA, ColB = t3.ColumnB, ColC = t3.ColumnC }, (t1t2, t3) => new { t1 = t1t2.t1, t2 = t1t2.t2, t3 = t3 }); ``` **Note:** The compiler converts query syntax into method syntax at compile time.
5,307,741
I have a site with a short url domain with an A record pointing to the main site (it's a pain to change this so I'd rather not). I have special logic that needs to run when the application is accessed from the short URL. Right now, I have Apache set up with a RewriteRule to do a 301 to the main site when you hit the short URL, but if I try to access the referrer or any sort of headers they seem to be gone. I can get around this by appending a query parameter, but I'd rather not muddy up the URL as well. Any ideas on how to set some piece of data within Apache that I can access in my Rails app to tell if the request was a result of accessing the short URL?
2011/03/15
[ "https://Stackoverflow.com/questions/5307741", "https://Stackoverflow.com", "https://Stackoverflow.com/users/145492/" ]
Title\_Authors is a look up two things join at a time project results and continue chaining ``` DataClasses1DataContext db = new DataClasses1DataContext(); var queryresults = from a in db.Authors join ba in db.Title_Authors on a.Au_ID equals ba.Au_ID into idAuthor from c in idAuthor join t in db.Titles on c.ISBN equals t.ISBN select new { Author = a.Author1,Title= t.Title1 }; foreach (var item in queryresults) { MessageBox.Show(item.Author); MessageBox.Show(item.Title); return; } ```
I would like to give another example in which multiple (3) joins are used. ``` DataClasses1DataContext ctx = new DataClasses1DataContext(); var Owners = ctx.OwnerMasters; var Category = ctx.CategoryMasters; var Status = ctx.StatusMasters; var Tasks = ctx.TaskMasters; var xyz = from t in Tasks join c in Category on t.TaskCategory equals c.CategoryID join s in Status on t.TaskStatus equals s.StatusID join o in Owners on t.TaskOwner equals o.OwnerID select new { t.TaskID, t.TaskShortDescription, c.CategoryName, s.StatusName, o.OwnerName }; ```
5,307,741
I have a site with a short url domain with an A record pointing to the main site (it's a pain to change this so I'd rather not). I have special logic that needs to run when the application is accessed from the short URL. Right now, I have Apache set up with a RewriteRule to do a 301 to the main site when you hit the short URL, but if I try to access the referrer or any sort of headers they seem to be gone. I can get around this by appending a query parameter, but I'd rather not muddy up the URL as well. Any ideas on how to set some piece of data within Apache that I can access in my Rails app to tell if the request was a result of accessing the short URL?
2011/03/15
[ "https://Stackoverflow.com/questions/5307741", "https://Stackoverflow.com", "https://Stackoverflow.com/users/145492/" ]
Joining on multiple columns in Linq to SQL is a little different. ``` var query = from t1 in myTABLE1List // List<TABLE_1> join t2 in myTABLE1List on new { t1.ColumnA, t1.ColumnB } equals new { t2.ColumnA, t2.ColumnB } ... ``` You have to take advantage of anonymous types and compose a type for the multiple columns you wish to compare against. This seems confusing at first but once you get acquainted with the way the SQL is composed from the expressions it will make a lot more sense, under the covers this will generate the type of join you are looking for. **EDIT** Adding example for second join based on comment. ``` var query = from t1 in myTABLE1List // List<TABLE_1> join t2 in myTABLE1List on new { A = t1.ColumnA, B = t1.ColumnB } equals new { A = t2.ColumnA, B = t2.ColumnB } join t3 in myTABLE1List on new { A = t2.ColumnA, B = t2.ColumnB } equals new { A = t3.ColumnA, B = t3.ColumnB } ... ```
You can use LINQ Method Syntax to join on multiple columns. It's an example here, ``` var query = mTABLE_1.Join( // mTABLE_1 is a List<TABLE_1> mTABLE_1, t1 => new { ColA = t1.ColumnA, ColB = t1.ColumnB, ColC = t1.ColumnC }, t2 => new { ColA = t2.ColumnA, ColB = t2.ColumnB, ColC = t2.ColumnC }, (t1, t2) => new { t1, t2 }).Join( mTABLE_1, t1t2 => new { ColA = t1t2.t2.ColumnA, ColB = t1t2.t2.ColumnB, ColC = t1t2.t2.ColumnC }, t3 => new { ColA = t3.ColumnA, ColB = t3.ColumnB, ColC = t3.ColumnC }, (t1t2, t3) => new { t1 = t1t2.t1, t2 = t1t2.t2, t3 = t3 }); ``` **Note:** The compiler converts query syntax into method syntax at compile time.
5,307,741
I have a site with a short url domain with an A record pointing to the main site (it's a pain to change this so I'd rather not). I have special logic that needs to run when the application is accessed from the short URL. Right now, I have Apache set up with a RewriteRule to do a 301 to the main site when you hit the short URL, but if I try to access the referrer or any sort of headers they seem to be gone. I can get around this by appending a query parameter, but I'd rather not muddy up the URL as well. Any ideas on how to set some piece of data within Apache that I can access in my Rails app to tell if the request was a result of accessing the short URL?
2011/03/15
[ "https://Stackoverflow.com/questions/5307741", "https://Stackoverflow.com", "https://Stackoverflow.com/users/145492/" ]
Joining on multiple columns in Linq to SQL is a little different. ``` var query = from t1 in myTABLE1List // List<TABLE_1> join t2 in myTABLE1List on new { t1.ColumnA, t1.ColumnB } equals new { t2.ColumnA, t2.ColumnB } ... ``` You have to take advantage of anonymous types and compose a type for the multiple columns you wish to compare against. This seems confusing at first but once you get acquainted with the way the SQL is composed from the expressions it will make a lot more sense, under the covers this will generate the type of join you are looking for. **EDIT** Adding example for second join based on comment. ``` var query = from t1 in myTABLE1List // List<TABLE_1> join t2 in myTABLE1List on new { A = t1.ColumnA, B = t1.ColumnB } equals new { A = t2.ColumnA, B = t2.ColumnB } join t3 in myTABLE1List on new { A = t2.ColumnA, B = t2.ColumnB } equals new { A = t3.ColumnA, B = t3.ColumnB } ... ```
Title\_Authors is a look up two things join at a time project results and continue chaining ``` DataClasses1DataContext db = new DataClasses1DataContext(); var queryresults = from a in db.Authors join ba in db.Title_Authors on a.Au_ID equals ba.Au_ID into idAuthor from c in idAuthor join t in db.Titles on c.ISBN equals t.ISBN select new { Author = a.Author1,Title= t.Title1 }; foreach (var item in queryresults) { MessageBox.Show(item.Author); MessageBox.Show(item.Title); return; } ```
5,307,741
I have a site with a short url domain with an A record pointing to the main site (it's a pain to change this so I'd rather not). I have special logic that needs to run when the application is accessed from the short URL. Right now, I have Apache set up with a RewriteRule to do a 301 to the main site when you hit the short URL, but if I try to access the referrer or any sort of headers they seem to be gone. I can get around this by appending a query parameter, but I'd rather not muddy up the URL as well. Any ideas on how to set some piece of data within Apache that I can access in my Rails app to tell if the request was a result of accessing the short URL?
2011/03/15
[ "https://Stackoverflow.com/questions/5307741", "https://Stackoverflow.com", "https://Stackoverflow.com/users/145492/" ]
In LINQ2SQL you seldom need to join explicitly when using inner joins. If you have proper foreign key relationships in your database you will automatically get a relation in the LINQ designer (if not you can create a relation manually in the designer, although you should really have proper relations in your database) ![parent-child relation](https://i.stack.imgur.com/3flvg.png) Then you can just access related tables with the "dot-notation" ``` var q = from child in context.Childs where child.Parent.col2 == 4 select new { childCol1 = child.col1, parentCol1 = child.Parent.col1, }; ``` will generate the query ``` SELECT [t0].[col1] AS [childCol1], [t1].[col1] AS [parentCol1] FROM [dbo].[Child] AS [t0] INNER JOIN [dbo].[Parent] AS [t1] ON ([t1].[col1] = [t0].[col1]) AND ([t1].[col2] = [t0].[col2]) WHERE [t1].[col2] = @p0 -- @p0: Input Int (Size = -1; Prec = 0; Scale = 0) [4] -- Context: SqlProvider(Sql2008) Model: AttributedMetaModel Build: 4.0.30319.1 ``` In my opinion this is much more readable and lets you concentrate on your special conditions and not the actual mechanics of the join. **Edit** This is of course only applicable when you want to join in the line with our database model. If you want to join "outside the model" you need to resort to manual joins as in the [answer](https://stackoverflow.com/questions/5307731/linq-to-sql-multiple-joins-on-multiple-columns-is-this-possible/5307742#5307742) from [Quintin Robinson](https://stackoverflow.com/users/12707/quintin-robinson)
You can also join if the number of columns are not same in both tables and can map static value to table column ``` from t1 in Table1 join t2 in Table2 on new {X = t1.Column1, Y = 0 } on new {X = t2.Column1, Y = t2.Column2 } select new {t1, t2} ```
5,307,741
I have a site with a short url domain with an A record pointing to the main site (it's a pain to change this so I'd rather not). I have special logic that needs to run when the application is accessed from the short URL. Right now, I have Apache set up with a RewriteRule to do a 301 to the main site when you hit the short URL, but if I try to access the referrer or any sort of headers they seem to be gone. I can get around this by appending a query parameter, but I'd rather not muddy up the URL as well. Any ideas on how to set some piece of data within Apache that I can access in my Rails app to tell if the request was a result of accessing the short URL?
2011/03/15
[ "https://Stackoverflow.com/questions/5307741", "https://Stackoverflow.com", "https://Stackoverflow.com/users/145492/" ]
Joining on multiple columns in Linq to SQL is a little different. ``` var query = from t1 in myTABLE1List // List<TABLE_1> join t2 in myTABLE1List on new { t1.ColumnA, t1.ColumnB } equals new { t2.ColumnA, t2.ColumnB } ... ``` You have to take advantage of anonymous types and compose a type for the multiple columns you wish to compare against. This seems confusing at first but once you get acquainted with the way the SQL is composed from the expressions it will make a lot more sense, under the covers this will generate the type of join you are looking for. **EDIT** Adding example for second join based on comment. ``` var query = from t1 in myTABLE1List // List<TABLE_1> join t2 in myTABLE1List on new { A = t1.ColumnA, B = t1.ColumnB } equals new { A = t2.ColumnA, B = t2.ColumnB } join t3 in myTABLE1List on new { A = t2.ColumnA, B = t2.ColumnB } equals new { A = t3.ColumnA, B = t3.ColumnB } ... ```
You can also join if the number of columns are not same in both tables and can map static value to table column ``` from t1 in Table1 join t2 in Table2 on new {X = t1.Column1, Y = 0 } on new {X = t2.Column1, Y = t2.Column2 } select new {t1, t2} ```
5,307,741
I have a site with a short url domain with an A record pointing to the main site (it's a pain to change this so I'd rather not). I have special logic that needs to run when the application is accessed from the short URL. Right now, I have Apache set up with a RewriteRule to do a 301 to the main site when you hit the short URL, but if I try to access the referrer or any sort of headers they seem to be gone. I can get around this by appending a query parameter, but I'd rather not muddy up the URL as well. Any ideas on how to set some piece of data within Apache that I can access in my Rails app to tell if the request was a result of accessing the short URL?
2011/03/15
[ "https://Stackoverflow.com/questions/5307741", "https://Stackoverflow.com", "https://Stackoverflow.com/users/145492/" ]
Title\_Authors is a look up two things join at a time project results and continue chaining ``` DataClasses1DataContext db = new DataClasses1DataContext(); var queryresults = from a in db.Authors join ba in db.Title_Authors on a.Au_ID equals ba.Au_ID into idAuthor from c in idAuthor join t in db.Titles on c.ISBN equals t.ISBN select new { Author = a.Author1,Title= t.Title1 }; foreach (var item in queryresults) { MessageBox.Show(item.Author); MessageBox.Show(item.Title); return; } ```
You can also join if the number of columns are not same in both tables and can map static value to table column ``` from t1 in Table1 join t2 in Table2 on new {X = t1.Column1, Y = 0 } on new {X = t2.Column1, Y = t2.Column2 } select new {t1, t2} ```
62,735,626
I have a list of student names and courses they chose. ``` StudentName CourseName Age John 3 16 Dean 2 17 Lisa 1 18 King 3 19 Lisa 2 17 John 2 16 John 2 12 Lisa 1 15 ``` 1. For student with same name, I want to do a value\_count for different courses e.g., John, course 3 (1), course 2(2) 2. Use the highest frequency as the course code e.g. John, Course 2 (2 has the highest frequency) Lisa Course 1 (1 has the highest frequency) Is it possible to do it with Python pandas instead of using a for loop? Expected Output is: ``` Student Name / Course Name John 2 Dean 2 Lisa 1 King 3 ``` (The tricky part is Lisa and John. Lisa and John both correspond with multiple course number, we select the most appeared course number in this case)
2020/07/05
[ "https://Stackoverflow.com/questions/62735626", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
The stable baselines site claims they do not support tf2.X yet. So that might be your problem Try the following, ```py pip install tensorflow==1.14.0 pip install stable-baselines[mpi]==2.10.0 ``` They seem to work together for me to this day(Sept 4th, 2020). I know this might be a little late but I found your question now and decided to answer it as best as I could. Good luck!
If you are looking specifically for a TF2 version of Stable Baselines, check one of these (experimental) forks: * <https://github.com/sophiagu/stable-baselines-tf2> * <https://github.com/Stable-Baselines-Team/stable-baselines-tf2> Alternatively, try **Stable Baselines 3** (currently in beta), which is based on **PyTorch** instead of Tensorflow and is intended to replace the current TF1-based SB2 version: * <https://github.com/DLR-RM/stable-baselines3>
62,735,626
I have a list of student names and courses they chose. ``` StudentName CourseName Age John 3 16 Dean 2 17 Lisa 1 18 King 3 19 Lisa 2 17 John 2 16 John 2 12 Lisa 1 15 ``` 1. For student with same name, I want to do a value\_count for different courses e.g., John, course 3 (1), course 2(2) 2. Use the highest frequency as the course code e.g. John, Course 2 (2 has the highest frequency) Lisa Course 1 (1 has the highest frequency) Is it possible to do it with Python pandas instead of using a for loop? Expected Output is: ``` Student Name / Course Name John 2 Dean 2 Lisa 1 King 3 ``` (The tricky part is Lisa and John. Lisa and John both correspond with multiple course number, we select the most appeared course number in this case)
2020/07/05
[ "https://Stackoverflow.com/questions/62735626", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
The stable baselines site claims they do not support tf2.X yet. So that might be your problem Try the following, ```py pip install tensorflow==1.14.0 pip install stable-baselines[mpi]==2.10.0 ``` They seem to work together for me to this day(Sept 4th, 2020). I know this might be a little late but I found your question now and decided to answer it as best as I could. Good luck!
`import stable_baselines` doesn't work. `import stable_baselines3` works. --- For installing Stable-baselines, you can use * `conda install -c conda-forge stable-baselines3` if you use Anaconda * `pip install stable-baselines` if you want to install using PIP
62,735,626
I have a list of student names and courses they chose. ``` StudentName CourseName Age John 3 16 Dean 2 17 Lisa 1 18 King 3 19 Lisa 2 17 John 2 16 John 2 12 Lisa 1 15 ``` 1. For student with same name, I want to do a value\_count for different courses e.g., John, course 3 (1), course 2(2) 2. Use the highest frequency as the course code e.g. John, Course 2 (2 has the highest frequency) Lisa Course 1 (1 has the highest frequency) Is it possible to do it with Python pandas instead of using a for loop? Expected Output is: ``` Student Name / Course Name John 2 Dean 2 Lisa 1 King 3 ``` (The tricky part is Lisa and John. Lisa and John both correspond with multiple course number, we select the most appeared course number in this case)
2020/07/05
[ "https://Stackoverflow.com/questions/62735626", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
If you are looking specifically for a TF2 version of Stable Baselines, check one of these (experimental) forks: * <https://github.com/sophiagu/stable-baselines-tf2> * <https://github.com/Stable-Baselines-Team/stable-baselines-tf2> Alternatively, try **Stable Baselines 3** (currently in beta), which is based on **PyTorch** instead of Tensorflow and is intended to replace the current TF1-based SB2 version: * <https://github.com/DLR-RM/stable-baselines3>
`import stable_baselines` doesn't work. `import stable_baselines3` works. --- For installing Stable-baselines, you can use * `conda install -c conda-forge stable-baselines3` if you use Anaconda * `pip install stable-baselines` if you want to install using PIP
41,232,005
How to do below on single line? After line is executed value of **$b is null** ``` $b = ([System.Collections.Generic.Dictionary[string,object]]::new()).Add("dd",$null) ``` or ``` [System.Collections.Generic.Dictionary[string,object]]::new()).Add("dd",$null) -eq $null True ```
2016/12/19
[ "https://Stackoverflow.com/questions/41232005", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1807374/" ]
``` ($b = [System.Collections.Generic.Dictionary[string,object]]::new()).Add("dd",$null) ```
Try [hash tables](https://msdn.microsoft.com/en-us/powershell/reference/5.0/microsoft.powershell.core/about/about_hash_tables) instead of .NET dictionaries. These are `System.Collections.Hashtable` objects that store key-value pairs. In PowerShell, you can use the operator `@{}` to create a hash table, and can quickly initialize one with several values on a single line. You'll effectively get the same behavior with a hash table as you would a dictionary, except perhaps some performance differences and more noticably -- the lack of strong typing of your values. **Simple demo:** ``` PS C:> @{ "dd" = $null } Name Value ---- ----- dd ``` **To convert from a hash table to a dictionary in PowerShell in a single line:** ``` $dictionary = New-Object 'System.Collections.Generic.Dictionary[String,object]'; (@{ "dd" = $null }).Keys | % { $dictionary.Add($_, $hashtable.Item($_)) } ```
147,256
Is there a way to **get disabled products programmatically in Magento 2** ?
2016/11/24
[ "https://magento.stackexchange.com/questions/147256", "https://magento.stackexchange.com", "https://magento.stackexchange.com/users/43576/" ]
You can try with: ``` /** @var \Magento\Catalog\Model\ResourceModel\Product\CollectionFactory $_productCollectionFactory **/ $this->_productCollectionFactory->create() ->addAttributeToSelect('*') ->addAttributeToFilter('status', \Magento\Catalog\Model\Product\Attribute\Source\Status::STATUS_DISABLED); ``` Need to inject `\Magento\Catalog\Model\ResourceModel\Product\CollectionFactory $_productCollectionFactory` in your constructor.
It's best practice to use the Service Contracts Layer (see here: [Magento 2: what are the benefits of using service contracts?](https://magento.stackexchange.com/q/115398/2380)) ``` protected $_productRepository; protected $_searchCriteriaBuilder; public function __construct( \Magento\Catalog\Api\ProductRepositoryInterface $productRepository, \Magento\Framework\Api\SearchCriteriaBuilder $searchCriteriaBuilder ) { $this->_productRepository = $productRepository; $this->_searchCriteriaBuilder = $searchCriteriaBuilder; } ``` Then in your code you can do: ``` $searchCriteria = $this->_searchCriteriaBuilder->addFilter('status', \Magento\Catalog\Model\Product\Attribute\Source\Status::STATUS_DISABLED, 'eq')->create(); $searchResults = $this->_productRepository->getList($searchCriteria); $disabledProducts = $searchResults->getItems(); ```
43,134,850
I have a Solution in Visual Studio 2017 and one of the Projects is an ASP.NET Web Forms application. How can I rename the Project? I changed the name in the .sln file but within the IDE it is still showing the old name. The folder name matches the required name.
2017/03/31
[ "https://Stackoverflow.com/questions/43134850", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3304189/" ]
In Visual Studio Enterprise 2013, right click en Solution and search in contextual menu the option "Rename", there put you new solution name [solution rename](https://i.stack.imgur.com/ODDgg.jpg)
Thanks for the response. I had already tried editing the .sln file but it made no difference. I finally found the problem was in the applicationhost.config file. Once I edited that the new name appeared.
156,121
I was writing a letter of application for a university. I wanted to start my letter by writing: > > I am writing this letter to express my interest in becoming part... > > > and then I got confused. I am not sure how the last part of that sentence should be. > > * ...in becoming part... > * ...to become part... > > > What is the semantic difference between the two variants?
2014/03/07
[ "https://english.stackexchange.com/questions/156121", "https://english.stackexchange.com", "https://english.stackexchange.com/users/63710/" ]
As John Lawler notes in a comment, > > *Interest(ed)* takes prepositional phrases with *in*, which can have gerund clauses as objects (*He's interested in logographic pyrology*, *his interest in pyrographic logology*), but they don't take infinitive clauses (*\*He's interested to leave now*, *\*his interest to leave now*) > > > This means "interest in becoming" is the appropriate choice. Similar examples: > > I am interested in becoming part of... > > > Allow me to express my interest in becoming part of... > > > I am interested in leaving at 5 o' clock. > > > More information on [gerunds](http://en.wikipedia.org/wiki/Gerunds) can be found at Wikipedia.
Often, the K.I.S.S. principle is useful, and you could go with simple present and infinitives: > > I write this letter to express my interest to become part of ... > > > However, the use of simple-present tense - although technically correct - is [fast fading](https://books.google.com/ngrams/graph?content=I%20write%20to%20you,%20I%20am%20writing%20to%20you&year_start=1800&year_end=2000&corpus=15&smoothing=3&share=&direct_url=t1;,I%20write%20to%20you;,c0;.t1;,I%20am%20writing%20to%20you;,c0). Best to retain the present perfect: > > I am writing this letter to express my interest in becoming part of ... > > > But if this is the problem you are having in writing your application letter, perhaps first put a mind to issues of [tone](https://owl.english.purdue.edu/owl/resource/652/1/).
1,209,941
If $M, N$ are finite dimensional vector spaces with same dimension, then if $M$ is subset of $N$, then $M=N$. I think i need to show that both vector spaces are spanned by the same bases in order to do this or to prove $N$ is subset of $M$? But i am not sure how to do this. Thanks
2015/03/28
[ "https://math.stackexchange.com/questions/1209941", "https://math.stackexchange.com", "https://math.stackexchange.com/users/225132/" ]
Let me reformulate the problem: > > If $M$ is a (finite dimensional) subspace of a finite dimensional vector space $N$ and $\dim M=\dim N$, then $M=N$. > > > The clause that $M$ is finite dimensional is redundant, but it's not important, as you have it in your assignment. Suppose $M\ne N$ and let $v\in N$, $v\notin M$. If $\{v\_1,\dots,v\_n\}$ is a basis for $M$, then $\{v\_1,\dots,v\_n,v\}$ is a linearly independent set in $N$: this is impossible, because a linearly independent sets in $N$ has at most $n=\dim N=\dim M$ elements.
Hint: Let $\;B:=\{m\_1,...,m\_k\}\;$ be a basis of $\;M\;$ . Then $\;B\;$ is a linearly independent set of $\;N\;$ as $\;M\le N\;$ . But we're also given $\;k=\dim M=\dim N\;$ , so...complete here.