qid
int64
1
74.7M
question
stringlengths
0
58.3k
date
stringlengths
10
10
metadata
sequence
response_j
stringlengths
2
48.3k
response_k
stringlengths
2
40.5k
12,529,023
I have a `<textarea>` in HTML. When I put cursor in it, it's not starting from the beginning, but is blinking in middle. ### HTML ``` <TD width="21%"> <textarea class="txtarea" style="height:30px;" rows="3" name="Text" Id="Text" value=""> </textarea> </TD> ``` ### CSS ``` .txtarea{ border-right: #646464 ; border-top: #646464; border-left: #646464; border-bottom: #646464; width:100%; background: #ffffcc; } ```
2012/09/21
[ "https://Stackoverflow.com/questions/12529023", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1495475/" ]
``` <textarea class="txtarea" style="height:30px;" rows="3" name="Text" Id="Text" value=""> </textarea> ``` What you have is a space between `<textarea>` and `</textarea>` tags.
Textarea's opening and closing tag must be in same line because Whatever in between textarea tag it will considered as "value" of textarea. Now for below code placeholder will also shown as expected. ``` <textarea placeholder="Enter text here" class="txtarea" style="height:30px;" rows="3" name="Text" id="text" ></textarea> ```
17,842,296
I have the following excel table: ``` StartDate YTDActual 1/1/2013 100 2/1/2013 200 3/1/2013 99 4/1/2013 33 5/1/2013 45 6/1/2013 0 7/1/2013 0 ``` Is there a formula that returns, for each StartDate, the associated value in YTDActual, if it is different than 0, otherwise it would return the last YTDActual value different than 0 in the previous rows. So, basically the formula would produce the following values in the NewValue column: ``` StartDate NewValue 1/1/2013 100 2/1/2013 200 3/1/2013 99 4/1/2013 33 5/1/2013 45 6/1/2013 45 7/1/2013 45 ``` Note that in Jun & Jul the values are 45 because May had the last non-zero YTDActual value 45. Thanks Update: Just a clarification, the second table goes onto another sheet, they are not side by side.
2013/07/24
[ "https://Stackoverflow.com/questions/17842296", "https://Stackoverflow.com", "https://Stackoverflow.com/users/832783/" ]
This would do it: ``` Col A Col B Col C StartDate YTDActual NewValue 1/1/2013 100 =if(B2<>0,B2,C1) ... ``` Then just drag down the formula in Column C
If your dates start at A2 and YTD Actual amounts start at B2 try this formula for C2 copied down `=LOOKUP(2,1/(B$2:B2<>0),B$2:B2)` that will give you the required results
17,842,296
I have the following excel table: ``` StartDate YTDActual 1/1/2013 100 2/1/2013 200 3/1/2013 99 4/1/2013 33 5/1/2013 45 6/1/2013 0 7/1/2013 0 ``` Is there a formula that returns, for each StartDate, the associated value in YTDActual, if it is different than 0, otherwise it would return the last YTDActual value different than 0 in the previous rows. So, basically the formula would produce the following values in the NewValue column: ``` StartDate NewValue 1/1/2013 100 2/1/2013 200 3/1/2013 99 4/1/2013 33 5/1/2013 45 6/1/2013 45 7/1/2013 45 ``` Note that in Jun & Jul the values are 45 because May had the last non-zero YTDActual value 45. Thanks Update: Just a clarification, the second table goes onto another sheet, they are not side by side.
2013/07/24
[ "https://Stackoverflow.com/questions/17842296", "https://Stackoverflow.com", "https://Stackoverflow.com/users/832783/" ]
If your dates start at A2 and YTD Actual amounts start at B2 try this formula for C2 copied down `=LOOKUP(2,1/(B$2:B2<>0),B$2:B2)` that will give you the required results
Is the new data going in a column next to YTDActual? What I am getting at here is does it need to reference the date or could it just be a column C with: ``` =if(B2=0,C1,B2) ``` This would return B2 if not zero or otherwise the cell above it, this could be entered in cell C2 then dragged down to cover the other cells. If this does not work to have the new data in the columns next to column B above then I think you may struggle to do this without VBA. The problem that you will have is that you cannot create loops, so if a value is zero, you can check for another value, but this may also be zero and so on.
17,842,296
I have the following excel table: ``` StartDate YTDActual 1/1/2013 100 2/1/2013 200 3/1/2013 99 4/1/2013 33 5/1/2013 45 6/1/2013 0 7/1/2013 0 ``` Is there a formula that returns, for each StartDate, the associated value in YTDActual, if it is different than 0, otherwise it would return the last YTDActual value different than 0 in the previous rows. So, basically the formula would produce the following values in the NewValue column: ``` StartDate NewValue 1/1/2013 100 2/1/2013 200 3/1/2013 99 4/1/2013 33 5/1/2013 45 6/1/2013 45 7/1/2013 45 ``` Note that in Jun & Jul the values are 45 because May had the last non-zero YTDActual value 45. Thanks Update: Just a clarification, the second table goes onto another sheet, they are not side by side.
2013/07/24
[ "https://Stackoverflow.com/questions/17842296", "https://Stackoverflow.com", "https://Stackoverflow.com/users/832783/" ]
If your dates start at A2 and YTD Actual amounts start at B2 try this formula for C2 copied down `=LOOKUP(2,1/(B$2:B2<>0),B$2:B2)` that will give you the required results
I ended up using this formula for the NewValue column: ``` =IF(INDEX(Availability[YTDActual], MATCH(B2, Availability[StartDate], 0)) <>0, INDEX(Availability[YTDActual], MATCH(B32, Availability[StartDate], 0)), INDEX(Availability[YTDActual],MATCH(0,Availability[YTDActual],0)-1)) ``` where Availability is the name of the excel table, YTDActual is the name of the column and B2, B3, ... contain the dates.
17,842,296
I have the following excel table: ``` StartDate YTDActual 1/1/2013 100 2/1/2013 200 3/1/2013 99 4/1/2013 33 5/1/2013 45 6/1/2013 0 7/1/2013 0 ``` Is there a formula that returns, for each StartDate, the associated value in YTDActual, if it is different than 0, otherwise it would return the last YTDActual value different than 0 in the previous rows. So, basically the formula would produce the following values in the NewValue column: ``` StartDate NewValue 1/1/2013 100 2/1/2013 200 3/1/2013 99 4/1/2013 33 5/1/2013 45 6/1/2013 45 7/1/2013 45 ``` Note that in Jun & Jul the values are 45 because May had the last non-zero YTDActual value 45. Thanks Update: Just a clarification, the second table goes onto another sheet, they are not side by side.
2013/07/24
[ "https://Stackoverflow.com/questions/17842296", "https://Stackoverflow.com", "https://Stackoverflow.com/users/832783/" ]
This would do it: ``` Col A Col B Col C StartDate YTDActual NewValue 1/1/2013 100 =if(B2<>0,B2,C1) ... ``` Then just drag down the formula in Column C
Is the new data going in a column next to YTDActual? What I am getting at here is does it need to reference the date or could it just be a column C with: ``` =if(B2=0,C1,B2) ``` This would return B2 if not zero or otherwise the cell above it, this could be entered in cell C2 then dragged down to cover the other cells. If this does not work to have the new data in the columns next to column B above then I think you may struggle to do this without VBA. The problem that you will have is that you cannot create loops, so if a value is zero, you can check for another value, but this may also be zero and so on.
17,842,296
I have the following excel table: ``` StartDate YTDActual 1/1/2013 100 2/1/2013 200 3/1/2013 99 4/1/2013 33 5/1/2013 45 6/1/2013 0 7/1/2013 0 ``` Is there a formula that returns, for each StartDate, the associated value in YTDActual, if it is different than 0, otherwise it would return the last YTDActual value different than 0 in the previous rows. So, basically the formula would produce the following values in the NewValue column: ``` StartDate NewValue 1/1/2013 100 2/1/2013 200 3/1/2013 99 4/1/2013 33 5/1/2013 45 6/1/2013 45 7/1/2013 45 ``` Note that in Jun & Jul the values are 45 because May had the last non-zero YTDActual value 45. Thanks Update: Just a clarification, the second table goes onto another sheet, they are not side by side.
2013/07/24
[ "https://Stackoverflow.com/questions/17842296", "https://Stackoverflow.com", "https://Stackoverflow.com/users/832783/" ]
This would do it: ``` Col A Col B Col C StartDate YTDActual NewValue 1/1/2013 100 =if(B2<>0,B2,C1) ... ``` Then just drag down the formula in Column C
I ended up using this formula for the NewValue column: ``` =IF(INDEX(Availability[YTDActual], MATCH(B2, Availability[StartDate], 0)) <>0, INDEX(Availability[YTDActual], MATCH(B32, Availability[StartDate], 0)), INDEX(Availability[YTDActual],MATCH(0,Availability[YTDActual],0)-1)) ``` where Availability is the name of the excel table, YTDActual is the name of the column and B2, B3, ... contain the dates.
7,222,443
I have a 9 million rows table and I'm struggling to handle all this data because of its sheer size. What I want to do is add IMPORT a CSV to the table without overwriting data. Before I would of done something like this; INSERT if not in(select email from tblName where source = "number" and email != "email") INTO (email...) VALUES ("email"...) But I'm worried that I'll crash the server again. I want to be able to insert 10,000s of rows into a table but only if its not in the table with source = "number". Otherwise I would of used unique on the email column. In short, I want to INSERT as quickly as possible without introducing duplicates to the table by checking two things. If email != "email" AND source != "number" then insert into table otherwise do nothing. And I dont want errors reports either. I'm sorry for my bad wording and the question sounding a little silly. I'm just having a hard time adabting to not been able to test it out on the data by downloading backups and uploading if it goes wrong. I hate large datasets :) Thank-you all for your time -BigThings
2011/08/28
[ "https://Stackoverflow.com/questions/7222443", "https://Stackoverflow.com", "https://Stackoverflow.com/users/761501/" ]
If you have unique keys on these fields you can use LOAD DATA INFILE with IGNORE option. It's faster then inserting row by row, and is faster then multi-insert as well. Look at <http://dev.mysql.com/doc/refman/5.1/en/load-data.html>
Set a `UNIQUE` constraint on `email` and `source` columns. Then do: ```sql INSERT INTO table_name(email, source, ...) VALUES ('email', 'source', ...) ON DUPLICATE KEY UPDATE email = email; ``` --- `INSERT IGNORE` will not notify you of any kind of error. I would not recommend it. Neither would I recommend `INSERT ... WHERE NOT IN`. MySQL has an already well optimized functionality for that. That's why `INSERT ... ON DUPLICATE KEY UPDATE` is there.
39,761,575
In my app I generate a QR name in Arabic and then scan and I use `zxing` library to generate but it seems that `zxing` library doesn't support Arabic language because when I scan the generated name it gives me `????`. What is the solution? This is my code to generate: ``` BitMatrix bitMatrix = multiFormatWriter.encode(text2QR, BarcodeFormat.QR_CODE, 500, 500); BarcodeEncoder barcodeEncoder = new BarcodeEncoder(); bitmap = barcodeEncoder.createBitmap(bitMatrix); imageView = (ImageView) findViewById(R.id.imageView); imageView.setImageBitmap(bitmap); ```
2016/09/29
[ "https://Stackoverflow.com/questions/39761575", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4347233/" ]
I found solution: ``` MultiFormatWriter multiFormatWriter = new MultiFormatWriter(); Map<EncodeHintType, Object> hintMap = new EnumMap<EncodeHintType, Object>(EncodeHintType.class); hintMap.put(EncodeHintType.CHARACTER_SET, "UTF-8"); hintMap.put(EncodeHintType.MARGIN, 1); /* default = 4 */ hintMap.put(EncodeHintType.ERROR_CORRECTION, ErrorCorrectionLevel.L); BitMatrix bitMatrix = multiFormatWriter.encode(text2QR, BarcodeFormat.QR_CODE, 500, 500, hintMap); BarcodeEncoder barcodeEncoder = new BarcodeEncoder(); bitmap = barcodeEncoder.createBitmap(bitMatrix); imageView = (ImageView) findViewById(R.id.imageView); imageView.setImageBitmap(bitmap); ```
dont forget to set text encoding. `Hashtable hints = new Hashtable(); hints.put(EncodeHintType.CHARACTER_SET, "utf-8");` so, based on your code it should be `multiFormatWriter.encode(text2QR, BarcodeFormat.QR_CODE, 500, 500, hints);`
48,243,404
I'm curious what the design argument for `doParallel:::doParallelSNOW()` giving a warning when globals are explicitly specified in `.export` could be? For example, ``` library("doParallel") registerDoParallel(cl <- parallel::makeCluster(2L)) a <- 1 y <- foreach(i = 1L, .export = "a") %dopar% { 2 * a } ## Warning in e$fun(obj, substitute(ex), parent.frame(), e$data) : ## already exporting variable(s): a ``` Is it possible to disable above warnings in doParallel? I'd argue that such a warning would suggest the user/developer *not* to specify `.export` and rely fully on foreach adaptors to take care of globals. However, the success of identification of globals differ among adaptors. Package versions: doParallel 1.0.11, iterators 1.0.9, foreach 1.4.4 **CLARIFICATION 2018-01-14**: [These warnings occur after doParallel first having identified globals automatically and then appending the ones the developer list in `.export`](https://github.com/cran/doParallel/blob/b843662b9c49fb610434ae22713fbc188a06b1c3/R/doParallel.R#L414-L434) - my question is on why it doesn't not accept the deliberate choice that was done by the developer? Warning about correct globals is a bit misleading.
2018/01/13
[ "https://Stackoverflow.com/questions/48243404", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1072091/" ]
So it turns out that the solution to this question requires a bit of scripting using `groovy`. Below is the updated process model diagram, in it I start a new instance of the `Complete Task` process using a script task then if the user wishes to add more tasks the exclusive gateway can return the user to the Create task (user task) **OR** finish the process. I clear down any values in the fields held within the user task within the script task before I pass the scope back to the user task. [![Update Process](https://i.stack.imgur.com/yV5m7.png)](https://i.stack.imgur.com/yV5m7.png) The image below shows my *Complete Task* process that gets called by the main process using a script [![Complete Task](https://i.stack.imgur.com/oo51d.png)](https://i.stack.imgur.com/oo51d.png) Here I avoid using `parallel gateways` in preference of creating a new instance of the *Create Task* (user task) and a new instance of the *Complete task* process (not subprocess) via means of the script. To start a new instance of the Complete Task process we have to start the process using the function `startProcessInstanceByKeyAndTenantId()` under a `runtimeService` instance for the process, although I could also use `startProcessInstanceByIdAndTenantId()`: ``` //Import required libraries import org.activiti.engine.RuntimeService; import org.activiti.engine.runtime.ProcessInstance; //instantiate RunTimeService instance RuntimeService runtimeService = execution.getEngineServices().getRuntimeService(); //get tenant id String tenantId = execution.getTenantId(); //variables Map Map<String, Object> variables = runtimeService.getVariablesLocal(execution.getProcessInstanceId()); //start process (processId, variables, tenantId) ProcessInstance completeTask = runtimeService.startProcessInstanceByKeyAndTenantId("CompleteTask", variables, tenantId); //Clear variables to create a fresh task execution.setVariable("title", ""); execution.setVariable("details", ""); ``` Using this approach I avoid creating multiple subprocesses from the parent process and instead create multiple processes that run separate from the parent process. This benefits me as if the parent process completes the others continue to run.
1. Seems like you are updating only one variable (or a single set of variables) as a result of each task. This will override the previous value. use distinct variables, or append something before each variable to mark it unique for the task/ sub-process completed. see [collapsed sub-process](https://www.activiti.org/userguide/#bpmnSubProcess) 2. Yes, each sub process gets its own unique execution id, But the main execution ID or process instance ID remains same
72,041,403
The input boxes move up when the error message appears at the bottom . The error message is enclosed in a span tag When the input boxes are blank and the user tries to hit enter the error message should appear below the input box asking the user to enter the valid input , however when the input appears it moves the boxes up no longer aligning the two boxes when one is valid and the other invalid . I want it so that the error message occurs without moving changing the position of the input boxes ```css .inputs-account > label { font-size: 16px; } .name-inputs { display: flex; justify-content: flex-start; align-items: end; } .first-name-input { margin-right: 15px; } .inputs > .required { float: none; } .inputs > * { float: left; clear: both; } .inputs.reversed > * { float: none; } .inputs input[type="text"], .inputs input[type="password"], .inputs input[type="email"], .inputs input[type="tel"], .inputs select, .inputs textarea { height: 45px; color: #12110C; border-radius: 3px; width: 100%; vertical-align: middle; border: 1px solid #D1DCE1; padding-left: 10px; } ``` ```html <div class="name-inputs inputs-account"> <div class="inputs inputs-account first-name-input"> <label for="FirstName">First name</label> <input class="key-change valid" type="text" data-val="true" data-val- required="First name is required." id="FirstName" name="FirstName" value="userName" aria-describedby="FirstName-error" aria-invalid="false"> <span class="field-validation-valid" data-valmsg-for="FirstName" data- valmsg-replace="true"></span> </div> <div class="inputs inputs-account"> <label for="LastName">Last name</label> <input class="key-change input-validation-error" type="text" data-val="true" data-val-required="Last name is required." id="LastName" name="LastName" value="" aria-describedby="LastName-error" aria-invalid="true"> <span class="field-validation-error" data-valmsg-for="LastName" data- valmsg-replace="true"> <span id="LastName-error" class="">Last name is required.</span> </span> </div> </div> ```
2022/04/28
[ "https://Stackoverflow.com/questions/72041403", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12993416/" ]
Update Columns -------------- ``` Option Explicit Sub UpdateMin() Const FirstCellAddress As String = "N2" Const ColumnOffset As Long = 22 Const ColumnsCount As Long = 100 Const MinCriteria As Double = 8 Dim ws As Worksheet: Set ws = ActiveSheet ' improve! Dim fCell As Range: Set fCell = ws.Range(FirstCellAddress) Dim rg As Range Dim lCell As Range Dim rCount As Long With fCell.Resize(ws.Rows.Count - fCell.Row + 1, _ (ColumnsCount - 1) * ColumnOffset + 1) Set lCell = .Find("*", , xlFormulas, , , xlPrevious) If lCell Is Nothing Then Exit Sub rCount = lCell.Row - .Row + 1 Set rg = .Resize(rCount, 1) End With Dim Data As Variant Dim cValue As Variant Dim r As Long Dim c As Long For c = 1 To ColumnsCount With rg.Offset(, (c - 1) * ColumnOffset) 'Debug.Print .Address Data = .Value For r = 1 To rCount cValue = Data(r, 1) If VarType(Data(r, 1)) = vbDouble Then If cValue < MinCriteria Then Data(r, 1) = MinCriteria End If End If Next r .Value = Data '.Interior.Color = vbYellow End With Next c MsgBox "Columns updated.", vbInformation End Sub ```
Imagine the following data in column A [![enter image description here](https://i.stack.imgur.com/XeoWS.png)](https://i.stack.imgur.com/XeoWS.png) Use the following code to loop through all data and if it is smaller then 8 turn it into 8, omit the cells if they're not numeric or if they are empty. ``` Option Explicit Public Sub Example() Dim ws As Worksheet ' define your worksheet Set ws = ThisWorkbook.Worksheets("Sheet1") Dim LastRow As Long ' find last used row in column A LastRow = ws.Cells(ws.Rows.Count, "A").End(xlUp).Row ' update data to MinValue in the given DataRange UpdateValuesToMinimum MinValue:=8, DataRange:=ws.Range("A1", "A" & LastRow) End Sub Public Sub UpdateValuesToMinimum(ByVal MinValue As Long, ByVal DataRange As Range) Dim DataValues() As Variant ' read all data into an array for faster processing DataValues = DataRange.Value2 Dim iRow As Long ' loop through all rows For iRow = LBound(DataValues, 1) To UBound(DataValues, 1) Dim iCol As Long ' loop through all columns For iCol = LBound(DataValues, 2) To UBound(DataValues, 2) ' check if it is numeric and not empty If IsNumeric(DataValues(iRow, iCol)) And DataValues(iRow, iCol) <> vbNullString Then ' if data is <MinValue set it to MinValue If DataValues(iRow, iCol) < MinValue Then DataValues(iRow, iCol) = MinValue End If End If Next iCol Next iRow ' write array data back to the cells DataRange.Value2 = DataValues End Sub ``` And you will get as result: [![enter image description here](https://i.stack.imgur.com/3KUkV.png)](https://i.stack.imgur.com/3KUkV.png)
72,041,403
The input boxes move up when the error message appears at the bottom . The error message is enclosed in a span tag When the input boxes are blank and the user tries to hit enter the error message should appear below the input box asking the user to enter the valid input , however when the input appears it moves the boxes up no longer aligning the two boxes when one is valid and the other invalid . I want it so that the error message occurs without moving changing the position of the input boxes ```css .inputs-account > label { font-size: 16px; } .name-inputs { display: flex; justify-content: flex-start; align-items: end; } .first-name-input { margin-right: 15px; } .inputs > .required { float: none; } .inputs > * { float: left; clear: both; } .inputs.reversed > * { float: none; } .inputs input[type="text"], .inputs input[type="password"], .inputs input[type="email"], .inputs input[type="tel"], .inputs select, .inputs textarea { height: 45px; color: #12110C; border-radius: 3px; width: 100%; vertical-align: middle; border: 1px solid #D1DCE1; padding-left: 10px; } ``` ```html <div class="name-inputs inputs-account"> <div class="inputs inputs-account first-name-input"> <label for="FirstName">First name</label> <input class="key-change valid" type="text" data-val="true" data-val- required="First name is required." id="FirstName" name="FirstName" value="userName" aria-describedby="FirstName-error" aria-invalid="false"> <span class="field-validation-valid" data-valmsg-for="FirstName" data- valmsg-replace="true"></span> </div> <div class="inputs inputs-account"> <label for="LastName">Last name</label> <input class="key-change input-validation-error" type="text" data-val="true" data-val-required="Last name is required." id="LastName" name="LastName" value="" aria-describedby="LastName-error" aria-invalid="true"> <span class="field-validation-error" data-valmsg-for="LastName" data- valmsg-replace="true"> <span id="LastName-error" class="">Last name is required.</span> </span> </div> </div> ```
2022/04/28
[ "https://Stackoverflow.com/questions/72041403", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12993416/" ]
I propose to separate obtaining and processing of data. As for the latter, why not to apply a formula `=IF(Data < Minimum, Minimum, Data)` to numbers in a data range? To select only numbers, we can use `SpecialCells`. ``` Sub UpdateMin(Data As Range, Optional MinCriteria As Double) Dim Numbers As Range Dim Area As Range Dim Formula As String On Error Resume Next Set Numbers = Data.SpecialCells(xlCellTypeConstants, xlNumbers) If Numbers Is Nothing Then Exit Sub On Error GoTo 0 For Each Area In Numbers.Areas ' =IF(Area < MinCriteria, MinCriteria, Area) Formula = "IF(" & Area.Address & "<" & MinCriteria & "," & MinCriteria & "," & Area.Address & ")" Area.Value2 = Evaluate(Formula) Next Area End Sub ``` We need to iterate over continuous areas here to calculate `IF(...)` as an array formula. To get the range of interest in your case I'd use this code: ``` Function getData() As Range Dim Result As Range Const DataSheet = "Sheet1" Const first = 14 Const delta = 22 Const last = first + 99 * delta Dim i& ' rebuild to your needs With ThisWorkbook.Worksheets(DataSheet) Set Result = .Columns(first) For i = first + delta To last Step delta Set Result = Union(Result, .Columns(i)) Next i Set getData = Intersect(Result, .UsedRange) End With End Function ``` The final part: ``` Sub main_macro() UpdateMin getData, 8 End Sub ``` I'm not sure if this is a good approach, because we are iterating over data twice - to select numbers and then to update them. But both parts are addressed to Excel itself. So the job, I hope, is gonna be done quickly at least in case of big chunks of numbers. The worst scenario, I think, is a regular alternation of numbers and words. Let me know about your choice and how it worked in the end.
Imagine the following data in column A [![enter image description here](https://i.stack.imgur.com/XeoWS.png)](https://i.stack.imgur.com/XeoWS.png) Use the following code to loop through all data and if it is smaller then 8 turn it into 8, omit the cells if they're not numeric or if they are empty. ``` Option Explicit Public Sub Example() Dim ws As Worksheet ' define your worksheet Set ws = ThisWorkbook.Worksheets("Sheet1") Dim LastRow As Long ' find last used row in column A LastRow = ws.Cells(ws.Rows.Count, "A").End(xlUp).Row ' update data to MinValue in the given DataRange UpdateValuesToMinimum MinValue:=8, DataRange:=ws.Range("A1", "A" & LastRow) End Sub Public Sub UpdateValuesToMinimum(ByVal MinValue As Long, ByVal DataRange As Range) Dim DataValues() As Variant ' read all data into an array for faster processing DataValues = DataRange.Value2 Dim iRow As Long ' loop through all rows For iRow = LBound(DataValues, 1) To UBound(DataValues, 1) Dim iCol As Long ' loop through all columns For iCol = LBound(DataValues, 2) To UBound(DataValues, 2) ' check if it is numeric and not empty If IsNumeric(DataValues(iRow, iCol)) And DataValues(iRow, iCol) <> vbNullString Then ' if data is <MinValue set it to MinValue If DataValues(iRow, iCol) < MinValue Then DataValues(iRow, iCol) = MinValue End If End If Next iCol Next iRow ' write array data back to the cells DataRange.Value2 = DataValues End Sub ``` And you will get as result: [![enter image description here](https://i.stack.imgur.com/3KUkV.png)](https://i.stack.imgur.com/3KUkV.png)
23,371,582
I created [this website](http://www.oooysterfestival.com) with the original intention of having it be mobile. However I've had to take that function out and for the time being just wanted to have it so when you visit the site on a mobile device you just see the website as you would see on the screen. Not mobile friendly as you would want it to be but zoomed out so you can see the whole thing. I've already placed in the code to make it behave the way I'd like it to but something is happening and it's not working. Ive looked into the HTML 5 shim and other options for the viewport but I can't figure it out. I've tried a few different variations of the viewport tag ``` <meta name="viewport" content="width=device-width" /> <meta name="viewport" content="initial-scale=1, maximum-scale=1"> <meta name="viewport" content="width=500, initial-scale=1"> ``` This is what the website looks like right now on mobile devices ![enter image description here](https://i.stack.imgur.com/gSu74m.png) This is what I was hoping to make it look like ![like this screenshot](https://i.stack.imgur.com/8LZ13.png) Can you see what I'm missing?
2014/04/29
[ "https://Stackoverflow.com/questions/23371582", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1140019/" ]
I didn't find a css for mobile devices in your themes style.css file. Please write some css for various device like android, iphone, ipad, tablet pc etc. Example: ``` * @media Rule */ @media all and (max-width: 1024px) {here is your css code} @media all and (min-width: 800px) and (max-width: 1024px) {here is your css code} @media all and (min-width: 320px) and (max-width: 780px) {here is your css code} ``` I think it will help you to understand responsive css design properly. * <http://learn.shayhowe.com/advanced-html-css/responsive-web-design> * <http://www.responsivegridsystem.com/> * <http://www.creativebloq.com/responsive-web-design/build-basic-responsive-site-css-1132756> Thanks
If you want it to looked zoom out, then remove the viewport restrictions. It is limiting your field of vision and preventing it from sizing your site correctly. You should only use the mobile viewport if you are reorienting your content based on screen resolution, like the previous example for responsive design.
23,371,582
I created [this website](http://www.oooysterfestival.com) with the original intention of having it be mobile. However I've had to take that function out and for the time being just wanted to have it so when you visit the site on a mobile device you just see the website as you would see on the screen. Not mobile friendly as you would want it to be but zoomed out so you can see the whole thing. I've already placed in the code to make it behave the way I'd like it to but something is happening and it's not working. Ive looked into the HTML 5 shim and other options for the viewport but I can't figure it out. I've tried a few different variations of the viewport tag ``` <meta name="viewport" content="width=device-width" /> <meta name="viewport" content="initial-scale=1, maximum-scale=1"> <meta name="viewport" content="width=500, initial-scale=1"> ``` This is what the website looks like right now on mobile devices ![enter image description here](https://i.stack.imgur.com/gSu74m.png) This is what I was hoping to make it look like ![like this screenshot](https://i.stack.imgur.com/8LZ13.png) Can you see what I'm missing?
2014/04/29
[ "https://Stackoverflow.com/questions/23371582", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1140019/" ]
In your case you should not use any of the suggested meta viewport tags. If you leave the page without any meta viewport tags you should get the desired result in most mobile browsers. You could add `<meta name="viewport" content="width=980">` to tell the browser that you content is 980 px, if that is the case. You seem to have a 960 px wide page but it may look nicer to have some spacing on the sides. **[I find this to be a nice article to explain the meta viewport tag](http://blog.javierusobiaga.com/stop-using-the-viewport-tag-until-you-know-ho)** **[And this is another article about using the meta viewport tag for non-responsive pages](http://webdesignerwall.com/tutorials/viewport-meta-tag-for-non-responsive-design)** The meta viewport tags that you have tried tells the browser a few different things: --- ``` <meta name="viewport" content="width=device-width" /> ``` This tells the browser that content width should fit in the device width. In order to use this successfully your page width should be adjustable to the device. --- ``` <meta name="viewport" content="initial-scale=1, maximum-scale=1"> ``` This tells the browser that it should zoom the page so that 1 CSS pixel from the page equals 1 viewport pixel on the screen (not physical pixels on e.g. Retina displays). This results in your page being zoomed in as it is wider then a normal mobile screen. Maximum-scale also tells the browser not to let you zoom the page any further than that. --- ``` <meta name="viewport" content="width=500, initial-scale=1"> ``` This tells the browser that the content is 500 px wide and that you should zoom the page.
I didn't find a css for mobile devices in your themes style.css file. Please write some css for various device like android, iphone, ipad, tablet pc etc. Example: ``` * @media Rule */ @media all and (max-width: 1024px) {here is your css code} @media all and (min-width: 800px) and (max-width: 1024px) {here is your css code} @media all and (min-width: 320px) and (max-width: 780px) {here is your css code} ``` I think it will help you to understand responsive css design properly. * <http://learn.shayhowe.com/advanced-html-css/responsive-web-design> * <http://www.responsivegridsystem.com/> * <http://www.creativebloq.com/responsive-web-design/build-basic-responsive-site-css-1132756> Thanks
23,371,582
I created [this website](http://www.oooysterfestival.com) with the original intention of having it be mobile. However I've had to take that function out and for the time being just wanted to have it so when you visit the site on a mobile device you just see the website as you would see on the screen. Not mobile friendly as you would want it to be but zoomed out so you can see the whole thing. I've already placed in the code to make it behave the way I'd like it to but something is happening and it's not working. Ive looked into the HTML 5 shim and other options for the viewport but I can't figure it out. I've tried a few different variations of the viewport tag ``` <meta name="viewport" content="width=device-width" /> <meta name="viewport" content="initial-scale=1, maximum-scale=1"> <meta name="viewport" content="width=500, initial-scale=1"> ``` This is what the website looks like right now on mobile devices ![enter image description here](https://i.stack.imgur.com/gSu74m.png) This is what I was hoping to make it look like ![like this screenshot](https://i.stack.imgur.com/8LZ13.png) Can you see what I'm missing?
2014/04/29
[ "https://Stackoverflow.com/questions/23371582", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1140019/" ]
I didn't find a css for mobile devices in your themes style.css file. Please write some css for various device like android, iphone, ipad, tablet pc etc. Example: ``` * @media Rule */ @media all and (max-width: 1024px) {here is your css code} @media all and (min-width: 800px) and (max-width: 1024px) {here is your css code} @media all and (min-width: 320px) and (max-width: 780px) {here is your css code} ``` I think it will help you to understand responsive css design properly. * <http://learn.shayhowe.com/advanced-html-css/responsive-web-design> * <http://www.responsivegridsystem.com/> * <http://www.creativebloq.com/responsive-web-design/build-basic-responsive-site-css-1132756> Thanks
I think you want the look of website in mobile same as you look in the Desktop. as i can see the screeshot you have provided. For that REMOVE the Viewport code which you have putted in header. Also be sure of if some tags are not correctly closed. it might be cause of the issue.
23,371,582
I created [this website](http://www.oooysterfestival.com) with the original intention of having it be mobile. However I've had to take that function out and for the time being just wanted to have it so when you visit the site on a mobile device you just see the website as you would see on the screen. Not mobile friendly as you would want it to be but zoomed out so you can see the whole thing. I've already placed in the code to make it behave the way I'd like it to but something is happening and it's not working. Ive looked into the HTML 5 shim and other options for the viewport but I can't figure it out. I've tried a few different variations of the viewport tag ``` <meta name="viewport" content="width=device-width" /> <meta name="viewport" content="initial-scale=1, maximum-scale=1"> <meta name="viewport" content="width=500, initial-scale=1"> ``` This is what the website looks like right now on mobile devices ![enter image description here](https://i.stack.imgur.com/gSu74m.png) This is what I was hoping to make it look like ![like this screenshot](https://i.stack.imgur.com/8LZ13.png) Can you see what I'm missing?
2014/04/29
[ "https://Stackoverflow.com/questions/23371582", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1140019/" ]
I didn't find a css for mobile devices in your themes style.css file. Please write some css for various device like android, iphone, ipad, tablet pc etc. Example: ``` * @media Rule */ @media all and (max-width: 1024px) {here is your css code} @media all and (min-width: 800px) and (max-width: 1024px) {here is your css code} @media all and (min-width: 320px) and (max-width: 780px) {here is your css code} ``` I think it will help you to understand responsive css design properly. * <http://learn.shayhowe.com/advanced-html-css/responsive-web-design> * <http://www.responsivegridsystem.com/> * <http://www.creativebloq.com/responsive-web-design/build-basic-responsive-site-css-1132756> Thanks
Try only one of this Meta Viewports each time, remove the others. Try this first: `<meta name="viewport" content="width=device-width" />`
23,371,582
I created [this website](http://www.oooysterfestival.com) with the original intention of having it be mobile. However I've had to take that function out and for the time being just wanted to have it so when you visit the site on a mobile device you just see the website as you would see on the screen. Not mobile friendly as you would want it to be but zoomed out so you can see the whole thing. I've already placed in the code to make it behave the way I'd like it to but something is happening and it's not working. Ive looked into the HTML 5 shim and other options for the viewport but I can't figure it out. I've tried a few different variations of the viewport tag ``` <meta name="viewport" content="width=device-width" /> <meta name="viewport" content="initial-scale=1, maximum-scale=1"> <meta name="viewport" content="width=500, initial-scale=1"> ``` This is what the website looks like right now on mobile devices ![enter image description here](https://i.stack.imgur.com/gSu74m.png) This is what I was hoping to make it look like ![like this screenshot](https://i.stack.imgur.com/8LZ13.png) Can you see what I'm missing?
2014/04/29
[ "https://Stackoverflow.com/questions/23371582", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1140019/" ]
I didn't find a css for mobile devices in your themes style.css file. Please write some css for various device like android, iphone, ipad, tablet pc etc. Example: ``` * @media Rule */ @media all and (max-width: 1024px) {here is your css code} @media all and (min-width: 800px) and (max-width: 1024px) {here is your css code} @media all and (min-width: 320px) and (max-width: 780px) {here is your css code} ``` I think it will help you to understand responsive css design properly. * <http://learn.shayhowe.com/advanced-html-css/responsive-web-design> * <http://www.responsivegridsystem.com/> * <http://www.creativebloq.com/responsive-web-design/build-basic-responsive-site-css-1132756> Thanks
Add this in your body tag: ``` body {min-width: 1024px;} ``` Should not effect your meta or media queries with this, but this meta as mentioned is a great one: ``` <meta name="viewport" content="width=device-width" /> ```
23,371,582
I created [this website](http://www.oooysterfestival.com) with the original intention of having it be mobile. However I've had to take that function out and for the time being just wanted to have it so when you visit the site on a mobile device you just see the website as you would see on the screen. Not mobile friendly as you would want it to be but zoomed out so you can see the whole thing. I've already placed in the code to make it behave the way I'd like it to but something is happening and it's not working. Ive looked into the HTML 5 shim and other options for the viewport but I can't figure it out. I've tried a few different variations of the viewport tag ``` <meta name="viewport" content="width=device-width" /> <meta name="viewport" content="initial-scale=1, maximum-scale=1"> <meta name="viewport" content="width=500, initial-scale=1"> ``` This is what the website looks like right now on mobile devices ![enter image description here](https://i.stack.imgur.com/gSu74m.png) This is what I was hoping to make it look like ![like this screenshot](https://i.stack.imgur.com/8LZ13.png) Can you see what I'm missing?
2014/04/29
[ "https://Stackoverflow.com/questions/23371582", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1140019/" ]
In your case you should not use any of the suggested meta viewport tags. If you leave the page without any meta viewport tags you should get the desired result in most mobile browsers. You could add `<meta name="viewport" content="width=980">` to tell the browser that you content is 980 px, if that is the case. You seem to have a 960 px wide page but it may look nicer to have some spacing on the sides. **[I find this to be a nice article to explain the meta viewport tag](http://blog.javierusobiaga.com/stop-using-the-viewport-tag-until-you-know-ho)** **[And this is another article about using the meta viewport tag for non-responsive pages](http://webdesignerwall.com/tutorials/viewport-meta-tag-for-non-responsive-design)** The meta viewport tags that you have tried tells the browser a few different things: --- ``` <meta name="viewport" content="width=device-width" /> ``` This tells the browser that content width should fit in the device width. In order to use this successfully your page width should be adjustable to the device. --- ``` <meta name="viewport" content="initial-scale=1, maximum-scale=1"> ``` This tells the browser that it should zoom the page so that 1 CSS pixel from the page equals 1 viewport pixel on the screen (not physical pixels on e.g. Retina displays). This results in your page being zoomed in as it is wider then a normal mobile screen. Maximum-scale also tells the browser not to let you zoom the page any further than that. --- ``` <meta name="viewport" content="width=500, initial-scale=1"> ``` This tells the browser that the content is 500 px wide and that you should zoom the page.
If you want it to looked zoom out, then remove the viewport restrictions. It is limiting your field of vision and preventing it from sizing your site correctly. You should only use the mobile viewport if you are reorienting your content based on screen resolution, like the previous example for responsive design.
23,371,582
I created [this website](http://www.oooysterfestival.com) with the original intention of having it be mobile. However I've had to take that function out and for the time being just wanted to have it so when you visit the site on a mobile device you just see the website as you would see on the screen. Not mobile friendly as you would want it to be but zoomed out so you can see the whole thing. I've already placed in the code to make it behave the way I'd like it to but something is happening and it's not working. Ive looked into the HTML 5 shim and other options for the viewport but I can't figure it out. I've tried a few different variations of the viewport tag ``` <meta name="viewport" content="width=device-width" /> <meta name="viewport" content="initial-scale=1, maximum-scale=1"> <meta name="viewport" content="width=500, initial-scale=1"> ``` This is what the website looks like right now on mobile devices ![enter image description here](https://i.stack.imgur.com/gSu74m.png) This is what I was hoping to make it look like ![like this screenshot](https://i.stack.imgur.com/8LZ13.png) Can you see what I'm missing?
2014/04/29
[ "https://Stackoverflow.com/questions/23371582", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1140019/" ]
In your case you should not use any of the suggested meta viewport tags. If you leave the page without any meta viewport tags you should get the desired result in most mobile browsers. You could add `<meta name="viewport" content="width=980">` to tell the browser that you content is 980 px, if that is the case. You seem to have a 960 px wide page but it may look nicer to have some spacing on the sides. **[I find this to be a nice article to explain the meta viewport tag](http://blog.javierusobiaga.com/stop-using-the-viewport-tag-until-you-know-ho)** **[And this is another article about using the meta viewport tag for non-responsive pages](http://webdesignerwall.com/tutorials/viewport-meta-tag-for-non-responsive-design)** The meta viewport tags that you have tried tells the browser a few different things: --- ``` <meta name="viewport" content="width=device-width" /> ``` This tells the browser that content width should fit in the device width. In order to use this successfully your page width should be adjustable to the device. --- ``` <meta name="viewport" content="initial-scale=1, maximum-scale=1"> ``` This tells the browser that it should zoom the page so that 1 CSS pixel from the page equals 1 viewport pixel on the screen (not physical pixels on e.g. Retina displays). This results in your page being zoomed in as it is wider then a normal mobile screen. Maximum-scale also tells the browser not to let you zoom the page any further than that. --- ``` <meta name="viewport" content="width=500, initial-scale=1"> ``` This tells the browser that the content is 500 px wide and that you should zoom the page.
I think you want the look of website in mobile same as you look in the Desktop. as i can see the screeshot you have provided. For that REMOVE the Viewport code which you have putted in header. Also be sure of if some tags are not correctly closed. it might be cause of the issue.
23,371,582
I created [this website](http://www.oooysterfestival.com) with the original intention of having it be mobile. However I've had to take that function out and for the time being just wanted to have it so when you visit the site on a mobile device you just see the website as you would see on the screen. Not mobile friendly as you would want it to be but zoomed out so you can see the whole thing. I've already placed in the code to make it behave the way I'd like it to but something is happening and it's not working. Ive looked into the HTML 5 shim and other options for the viewport but I can't figure it out. I've tried a few different variations of the viewport tag ``` <meta name="viewport" content="width=device-width" /> <meta name="viewport" content="initial-scale=1, maximum-scale=1"> <meta name="viewport" content="width=500, initial-scale=1"> ``` This is what the website looks like right now on mobile devices ![enter image description here](https://i.stack.imgur.com/gSu74m.png) This is what I was hoping to make it look like ![like this screenshot](https://i.stack.imgur.com/8LZ13.png) Can you see what I'm missing?
2014/04/29
[ "https://Stackoverflow.com/questions/23371582", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1140019/" ]
In your case you should not use any of the suggested meta viewport tags. If you leave the page without any meta viewport tags you should get the desired result in most mobile browsers. You could add `<meta name="viewport" content="width=980">` to tell the browser that you content is 980 px, if that is the case. You seem to have a 960 px wide page but it may look nicer to have some spacing on the sides. **[I find this to be a nice article to explain the meta viewport tag](http://blog.javierusobiaga.com/stop-using-the-viewport-tag-until-you-know-ho)** **[And this is another article about using the meta viewport tag for non-responsive pages](http://webdesignerwall.com/tutorials/viewport-meta-tag-for-non-responsive-design)** The meta viewport tags that you have tried tells the browser a few different things: --- ``` <meta name="viewport" content="width=device-width" /> ``` This tells the browser that content width should fit in the device width. In order to use this successfully your page width should be adjustable to the device. --- ``` <meta name="viewport" content="initial-scale=1, maximum-scale=1"> ``` This tells the browser that it should zoom the page so that 1 CSS pixel from the page equals 1 viewport pixel on the screen (not physical pixels on e.g. Retina displays). This results in your page being zoomed in as it is wider then a normal mobile screen. Maximum-scale also tells the browser not to let you zoom the page any further than that. --- ``` <meta name="viewport" content="width=500, initial-scale=1"> ``` This tells the browser that the content is 500 px wide and that you should zoom the page.
Try only one of this Meta Viewports each time, remove the others. Try this first: `<meta name="viewport" content="width=device-width" />`
23,371,582
I created [this website](http://www.oooysterfestival.com) with the original intention of having it be mobile. However I've had to take that function out and for the time being just wanted to have it so when you visit the site on a mobile device you just see the website as you would see on the screen. Not mobile friendly as you would want it to be but zoomed out so you can see the whole thing. I've already placed in the code to make it behave the way I'd like it to but something is happening and it's not working. Ive looked into the HTML 5 shim and other options for the viewport but I can't figure it out. I've tried a few different variations of the viewport tag ``` <meta name="viewport" content="width=device-width" /> <meta name="viewport" content="initial-scale=1, maximum-scale=1"> <meta name="viewport" content="width=500, initial-scale=1"> ``` This is what the website looks like right now on mobile devices ![enter image description here](https://i.stack.imgur.com/gSu74m.png) This is what I was hoping to make it look like ![like this screenshot](https://i.stack.imgur.com/8LZ13.png) Can you see what I'm missing?
2014/04/29
[ "https://Stackoverflow.com/questions/23371582", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1140019/" ]
In your case you should not use any of the suggested meta viewport tags. If you leave the page without any meta viewport tags you should get the desired result in most mobile browsers. You could add `<meta name="viewport" content="width=980">` to tell the browser that you content is 980 px, if that is the case. You seem to have a 960 px wide page but it may look nicer to have some spacing on the sides. **[I find this to be a nice article to explain the meta viewport tag](http://blog.javierusobiaga.com/stop-using-the-viewport-tag-until-you-know-ho)** **[And this is another article about using the meta viewport tag for non-responsive pages](http://webdesignerwall.com/tutorials/viewport-meta-tag-for-non-responsive-design)** The meta viewport tags that you have tried tells the browser a few different things: --- ``` <meta name="viewport" content="width=device-width" /> ``` This tells the browser that content width should fit in the device width. In order to use this successfully your page width should be adjustable to the device. --- ``` <meta name="viewport" content="initial-scale=1, maximum-scale=1"> ``` This tells the browser that it should zoom the page so that 1 CSS pixel from the page equals 1 viewport pixel on the screen (not physical pixels on e.g. Retina displays). This results in your page being zoomed in as it is wider then a normal mobile screen. Maximum-scale also tells the browser not to let you zoom the page any further than that. --- ``` <meta name="viewport" content="width=500, initial-scale=1"> ``` This tells the browser that the content is 500 px wide and that you should zoom the page.
Add this in your body tag: ``` body {min-width: 1024px;} ``` Should not effect your meta or media queries with this, but this meta as mentioned is a great one: ``` <meta name="viewport" content="width=device-width" /> ```
49,970,283
Consider this example: ``` import numpy as np a = np.array(1) np.save("a.npy", a) a = np.load("a.npy", mmap_mode='r') print(type(a)) b = a + 2 print(type(b)) ``` which outputs ``` <class 'numpy.core.memmap.memmap'> <class 'numpy.int32'> ``` So it seems that `b` is not a `memmap` any more, and I assume that this forces `numpy` to read the whole `a.npy`, defeating the purpose of the memmap. Hence my question, can operations on `memmaps` be deferred until access time? I believe subclassing `ndarray` or `memmap` could work, but don't feel confident enough about my Python skills to try it. Here is an extended example showing my problem: ``` import numpy as np # create 8 GB file # np.save("memmap.npy", np.empty([1000000000])) # I want to print the first value using f and memmaps def f(value): print(value[1]) # this is fast: f receives a memmap a = np.load("memmap.npy", mmap_mode='r') print("a = ") f(a) # this is slow: b has to be read completely; converted into an array b = np.load("memmap.npy", mmap_mode='r') print("b + 1 = ") f(b + 1) ```
2018/04/22
[ "https://Stackoverflow.com/questions/49970283", "https://Stackoverflow.com", "https://Stackoverflow.com/users/880783/" ]
You can use `nextTick` which will call a function after the next DOM update cycle. ``` this.datepicker = true; Vue.nextTick(function () { $(".jquery-date-picker").datepicker(); }) ``` And here is it's page in the documentation [VueJS Docs](https://v2.vuejs.org/v2/api/#Vue-nextTick)
Vue features triggers, in your case the `mounted()` function could be used. This articles describes how to use it and the whole Vue hook timeline : <https://alligator.io/vuejs/component-lifecycle/> A stackoverflow explanation : [Vue JS mounted()](https://stackoverflow.com/q/45021907/7477557)
383,744
I am trying print data in rows and columns using bash script as follows. ``` #!/bin/bash while IFS='' read -r line || [[ -n "$line" ]]; do echo "$line" done < "$1" { awk 'BEGIN { print "Points"} /Points/ { id = $1; }' } ``` My txt file looks like this: ``` Team Played Wins Tied england 4 3 2 america 9 5 3 ``` The output on terminal should looks like this: ``` Team Played Wins Tied Points england 4 3 2 16 america 9 5 3 26 ``` Here is calculation a team won 1 match so awarded 4 points and for a tie, 2 points are awarded. But I don't know how to perform mathematical operations so unable to do.
2017/08/03
[ "https://unix.stackexchange.com/questions/383744", "https://unix.stackexchange.com", "https://unix.stackexchange.com/users/244887/" ]
You don't need a shell loop for this, at all: ``` awk '{$(NF+1) = NR==1 ? "Points" : $3*4 + $4*2; print}' OFS='\t' input.txt Team Played Wins Tied Points A 2 1 1 6 B 2 0 1 2 ```
In plain bash, you could write: ``` while read -ra fields; do if [[ ${fields[0]} == "Team" ]]; then fields+=("Points") else fields+=( $(( 4 * ${fields[2]} + 2 * ${fields[3]} )) ) fi # changes to IFS variable done inside a subshell (IFS=$'\t'; echo "${fields[*]}") done < "$1" ```
7,998
I'm replacing the floor in my bathroom, which was previously a vinyl sheet. Prior to that (and I think original to the house, built in early 70's) it was some peel and stick-type tiles, except they're very hard (they remind of me what would be sold as commercial tiles now). There were some tiles left under the old vanity, and since I'm replacing it with a differently-sized vanity, I figure I'll put the new floor underneath it as well, which means the subfloor has to be flat. After I scraped up the old tiles, the floor is all black, presumably from the adhesive in the tiles. The rest of the floor though, that was covered by the vinyl sheet, looks like it's had the adhesive cleaned off. ![enter image description here](https://i.stack.imgur.com/YNvDx.jpg) ![enter image description here](https://i.stack.imgur.com/tIcMK.jpg) How was this cleaned, and why is it all white now? The floor was cut exactly to the outline of the vanity, and from the old paint on the wall, it looks like prior to the vanity there was just a wall-mounted sink. I'm going to guess the vanity was installed, and then sometime later the vinyl flooring was installed, as otherwise I can't see how the tiles got cut to this pattern. I'm putting a floating vinyl plank tile floor in place, and this part will be underneath the vanity anyways (the new vanity is slightly bigger). Should I bother trying to clean this part as well, or just put the new floor over top? --- Update: I added a whole bunch of screws to reinforce the floor to the joists below, and help reduce some of the squeaking. In one spot, right along an edge of the plywood, the white stuff flaked off - so it seems rather than being 'cleaned', there's actually a really thin layer of something on top of the black adhesive. There's no noticeable difference between the height of the two sections. I've since laid the new floor on top, I didn't do anything extra to this subfloor.
2011/08/01
[ "https://diy.stackexchange.com/questions/7998", "https://diy.stackexchange.com", "https://diy.stackexchange.com/users/157/" ]
I have made the mistake twice of demoing an old bathroom sink and throwing out the p-trap before the new sink and plumbing went in. Both times I regretted it because when I went to put in the new p-trap, I found some sort of strange/different plumbing setup which required several trips to the hardware store (and me repeating to myself "why did I throw out the old p-trap!?!?"). My recommendation is to use the old p-trap. Take some rags and steel wool and clean it inside and out and you should be able to get it looking like new. (And while you are at it use some rags to clean out the connector in the wall too since that looks pretty dirty too.) And then you can get a [drain extension tube](http://plumbing.hardwarestore.com/51-284-drain-plastic-extensions.aspx) to raise the height up to your new sink fairly easily. The only issue is that the distance from the wall of the old p-trap may not match your new sink. In that case try using part of the old p-trap to attach to the drain in the wall (since you do not have any extra pipe to work with) and then use a coupling to attach your new p-trap to this steel pipe. (Although not sure how easy it would be for you to find a coupling for you to attach to that steel pipe.)
Best way I've thought of so far is to use a drain tube extension coming out of the connector in the wall, then go into another female trap connector, then P-trap, and then finally female drain connector for the actual sink drain. Biggest downside is the pipe will get narrower between the wall and the p-trap, since it's 1 1/4" OD. On the upside, it'll be easy to take the p-trap off and clean it all out.
7,998
I'm replacing the floor in my bathroom, which was previously a vinyl sheet. Prior to that (and I think original to the house, built in early 70's) it was some peel and stick-type tiles, except they're very hard (they remind of me what would be sold as commercial tiles now). There were some tiles left under the old vanity, and since I'm replacing it with a differently-sized vanity, I figure I'll put the new floor underneath it as well, which means the subfloor has to be flat. After I scraped up the old tiles, the floor is all black, presumably from the adhesive in the tiles. The rest of the floor though, that was covered by the vinyl sheet, looks like it's had the adhesive cleaned off. ![enter image description here](https://i.stack.imgur.com/YNvDx.jpg) ![enter image description here](https://i.stack.imgur.com/tIcMK.jpg) How was this cleaned, and why is it all white now? The floor was cut exactly to the outline of the vanity, and from the old paint on the wall, it looks like prior to the vanity there was just a wall-mounted sink. I'm going to guess the vanity was installed, and then sometime later the vinyl flooring was installed, as otherwise I can't see how the tiles got cut to this pattern. I'm putting a floating vinyl plank tile floor in place, and this part will be underneath the vanity anyways (the new vanity is slightly bigger). Should I bother trying to clean this part as well, or just put the new floor over top? --- Update: I added a whole bunch of screws to reinforce the floor to the joists below, and help reduce some of the squeaking. In one spot, right along an edge of the plywood, the white stuff flaked off - so it seems rather than being 'cleaned', there's actually a really thin layer of something on top of the black adhesive. There's no noticeable difference between the height of the two sections. I've since laid the new floor on top, I didn't do anything extra to this subfloor.
2011/08/01
[ "https://diy.stackexchange.com/questions/7998", "https://diy.stackexchange.com", "https://diy.stackexchange.com/users/157/" ]
A 1 1/4" female FIP adapter worked perfectly. As soon as I saw it, I was embarassed for not having thought of it earlier. ![enter image description here](https://i.stack.imgur.com/cPkdW.jpg) I used some teflon tape, screwed the FIP adapter onto the adapter coming out of the wall, then just glued my 1 1/4" pipe directly into it. No reduction in pipe sizes, and 100% ABS parts. ![enter image description here](https://i.stack.imgur.com/C5Mbp.jpg)
I have made the mistake twice of demoing an old bathroom sink and throwing out the p-trap before the new sink and plumbing went in. Both times I regretted it because when I went to put in the new p-trap, I found some sort of strange/different plumbing setup which required several trips to the hardware store (and me repeating to myself "why did I throw out the old p-trap!?!?"). My recommendation is to use the old p-trap. Take some rags and steel wool and clean it inside and out and you should be able to get it looking like new. (And while you are at it use some rags to clean out the connector in the wall too since that looks pretty dirty too.) And then you can get a [drain extension tube](http://plumbing.hardwarestore.com/51-284-drain-plastic-extensions.aspx) to raise the height up to your new sink fairly easily. The only issue is that the distance from the wall of the old p-trap may not match your new sink. In that case try using part of the old p-trap to attach to the drain in the wall (since you do not have any extra pipe to work with) and then use a coupling to attach your new p-trap to this steel pipe. (Although not sure how easy it would be for you to find a coupling for you to attach to that steel pipe.)
7,998
I'm replacing the floor in my bathroom, which was previously a vinyl sheet. Prior to that (and I think original to the house, built in early 70's) it was some peel and stick-type tiles, except they're very hard (they remind of me what would be sold as commercial tiles now). There were some tiles left under the old vanity, and since I'm replacing it with a differently-sized vanity, I figure I'll put the new floor underneath it as well, which means the subfloor has to be flat. After I scraped up the old tiles, the floor is all black, presumably from the adhesive in the tiles. The rest of the floor though, that was covered by the vinyl sheet, looks like it's had the adhesive cleaned off. ![enter image description here](https://i.stack.imgur.com/YNvDx.jpg) ![enter image description here](https://i.stack.imgur.com/tIcMK.jpg) How was this cleaned, and why is it all white now? The floor was cut exactly to the outline of the vanity, and from the old paint on the wall, it looks like prior to the vanity there was just a wall-mounted sink. I'm going to guess the vanity was installed, and then sometime later the vinyl flooring was installed, as otherwise I can't see how the tiles got cut to this pattern. I'm putting a floating vinyl plank tile floor in place, and this part will be underneath the vanity anyways (the new vanity is slightly bigger). Should I bother trying to clean this part as well, or just put the new floor over top? --- Update: I added a whole bunch of screws to reinforce the floor to the joists below, and help reduce some of the squeaking. In one spot, right along an edge of the plywood, the white stuff flaked off - so it seems rather than being 'cleaned', there's actually a really thin layer of something on top of the black adhesive. There's no noticeable difference between the height of the two sections. I've since laid the new floor on top, I didn't do anything extra to this subfloor.
2011/08/01
[ "https://diy.stackexchange.com/questions/7998", "https://diy.stackexchange.com", "https://diy.stackexchange.com/users/157/" ]
A 1 1/4" female FIP adapter worked perfectly. As soon as I saw it, I was embarassed for not having thought of it earlier. ![enter image description here](https://i.stack.imgur.com/cPkdW.jpg) I used some teflon tape, screwed the FIP adapter onto the adapter coming out of the wall, then just glued my 1 1/4" pipe directly into it. No reduction in pipe sizes, and 100% ABS parts. ![enter image description here](https://i.stack.imgur.com/C5Mbp.jpg)
Best way I've thought of so far is to use a drain tube extension coming out of the connector in the wall, then go into another female trap connector, then P-trap, and then finally female drain connector for the actual sink drain. Biggest downside is the pipe will get narrower between the wall and the p-trap, since it's 1 1/4" OD. On the upside, it'll be easy to take the p-trap off and clean it all out.
14,064,932
I wrote this piece of code but not sure why it doesn't print the second sentence, it just prints the first part of it which is "Some string concat is like". I was expecting to see the rest of the sentence from TalkToMe method too. ``` object1 = Object.new def object1.TalkToMe puts ("Depending on the time, they may be in one place or another.") end object1.TalkToMe puts "Some string concat is like " #{object1.TalkToMe} " ```
2012/12/28
[ "https://Stackoverflow.com/questions/14064932", "https://Stackoverflow.com", "https://Stackoverflow.com/users/320724/" ]
`AccessLevel` is meant to represent a set of individual access rights. To check for specific right you should use something like this: ``` (object.getAccessAllowed() & AccessRight.DELETE_AS_INT) == AccessRight.DELETE_AS_INT ```
Here is a way: ``` int accessAllowed = document.getAccessAllowed(); if (checkRight(accessAllowed, AccessRight.DELETE)) { log.trace("Access level " + AccessRight.DELETE.toString() + " is present"); } private boolean checkRight(int rights, AccessRight ar) { return (rights & ar.getValue()) != 0; } ```
42,449,250
I am working on a class assignment (which is why only relevant code is being displayed). I have assigned an array of pointers to an array of random numbers and have to use the bubble sort technique. The array is set up as follows: ``` int array[DATASIZE] = {71, 1899, 272, 1694, 1697, 296, 722, 12, 2726, 1899}; int *arrayPointers = array; // donation array ``` The function call comes from main and looks is the following: ``` bubbleSort(arrayPointers); ``` I have to do the swapping of the pointers in a separate function : ``` void pointerSwap( int *a , int *b) { // swap the pointers and store in a temp int temp = *a; // temp storage of pointer a while being reassigned *a = *b; *b = temp; }// end of pointerSwap ``` from the actual bubble sort: ``` void bubbleSort (int *toStore) { //sort each of the pointers successively int i,j; // counters for (i=DATASIZE-1;i>1;i--) { for (j=0;j<DATASIZE-1;j++) { if (toStore[j]>toStore[j+1]) { pointerSwap(toStore[j],toStore[j+1]); }// end of if? }// end of j for loop }// end of i for loop }// end of buubleSort ``` My issue is that when I try to compile the code, I get the following errors when I call the pointer swap: --- **passing argument 1 of ‘pointerSwap’ makes pointer from integer without a cast** note: expected ‘int \*’ but argument is of type ‘int’ **passing argument 2 of ‘pointerSwap’ makes pointer from integer without a cast** note: expected ‘int \*’ but argument is of type ‘int’ --- I am not sure what I am doing incorrectly, I have tried "&toStore[j]" and "&toStore[j+1]" but the list sorts the original instead of the pointed array (which is to be expected). In advance any help is much appreciated, ~Joey
2017/02/24
[ "https://Stackoverflow.com/questions/42449250", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5553114/" ]
In the call: ``` pointerSwap(toStore[j],toStore[j+1]); ``` you are passing an `int` (`toStore[j]` is equivelent to `*(toStore + j)`) to a function that expects a pointer. You need to pass a pointer, namely: ``` pointerSwap(toStore + j, toStore + j + 1); ``` The second question pertains to sorting out of place. Your function signiture does not allow for anything else: ``` void bubbleSort (int *toStore) ``` You are not returning anything and you don't give a reference to a second array so you cant do anything but sort in place. If you really need a separate array, you can do something like this: ``` int *bubbleSort (int *input) { int* toStore = malloc(DATASIZE * sizeof(int)); memcpy(toStore, input, DATASIZE); ... //sort toStore ... return toStore } ``` This will then return a sorted array and will not touch the original.
Just to expand on the prior answer ... In C the bracket operator [] is equivalent to \*() so that ``` a[5] ``` is equivalent to ``` *(a + 5) ``` Both add an offset to a pointer to get a new pointer and then get the value that's being pointed to. When you pass in toStore[j] to pointerSwap you are passing the integer value that is in the j-th element of toStore when you want to pass in the pointer so that to Store can swap the values at the locations. What you want is ``` (toStore + j) ``` instead of ``` *(toStore + j) ``` Fun C trivia: These are all equivalent expressions ``` toStore[j] *(toStore + j) *(j + toStore) j[toStore] ``` Exercise: Why is this not true for C++?
47,656,329
I created a react component that I want to use twice(or more) inside my page, and I need to load a script tag for it inside the head of my page but just once! I mean even if I use the component twice or more in the page it should add the script tag just once in the head. The Problem is that this script tag should be absolutely a part of the component and not statically inserted in the head of my page. Can anyone help me to make the magic happens? Thanks a lot in advance!
2017/12/05
[ "https://Stackoverflow.com/questions/47656329", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9056870/" ]
Here what I did to fix my issue: In Git Settings, Global Settings in Team Explorer, there is an option to choose between OpenSSL and Secure Channel. Starting with Visual Studio 2017 (version 15.7 preview 3) use of SChannel in Git Global settings fixed my issue.
After two day with system admin support, I got the solution. I post it here in case it may help somebody else. Visual Studio 2017 looks not accepting a self signed certificate, as error states ("local issuer blah blah"). It has to be a local CA to approve it. Steps were: **Server:** 1. Install Company/Trusted CA on TFS machine as Trusted Authority root 2. Preparing certificate for TFS and make it derive from company/trusted CA. 3. Install it as Trusted Authority root in TFS machine 4. Configure TFS-IIS binding in order to make TFS certificate to be compulsory for HTTPS connections **Client:** 1. Install CA certificate as Trusted Authority root on client machine (tried with Windows 7 and 10) 2. Install TFS certificate as Trusted Authority root on client machine (you should see the lock in browser and connecting through it has to be recognized as secure) 3. Install Git client (I have Git-2.15.1.2-64-bit). 4. Run a shell (cmd, Powershell, Git-bash as you prefer) and digit this command: git config --global http.sslCAInfo C:/Users//ca-bundle.crt (because Git and Visual Studio have multiple folders where they store certificates, you are basically creating a global path for both of them) 5. Now you should be able to see a new .gitconfig file with this content: [http] sslCAInfo = C:/Users//ca-bundle.crt 6. if you digit command "git config --list --show-origin" you should see the new path/config added 7. Copy ca-bundle.crt from C:\Program Files\Git\mingw64\ssl\certs path to C:/Users// path 8. Export CA certificate as Base 64 X.509 (.CER) to up to you path (you can view certificates from IE Internet Options/Content/Certificates). 9. Open it with editor like Notepad++ or whatever the CA certificate that you just exported. Content should be: `-----BEGIN CERTIFICATE-----publickey-----END CERTIFICATE-----` 10. Copy this content 11. Open the C:/Users//ca-bundle.crt and paste appending that content 12. Export TFS certificate as Base 64 X.509 (.CER) to up to you path. 13. Open it with the editor you prefer and copy the content 14. Open the C:/Users//ca-bundle.crt and paste appending that content 15. Save the file Now you should be able to clone repository. So basically the point is that certificate has to have the all chain authority in it and **there has to be one**.
47,656,329
I created a react component that I want to use twice(or more) inside my page, and I need to load a script tag for it inside the head of my page but just once! I mean even if I use the component twice or more in the page it should add the script tag just once in the head. The Problem is that this script tag should be absolutely a part of the component and not statically inserted in the head of my page. Can anyone help me to make the magic happens? Thanks a lot in advance!
2017/12/05
[ "https://Stackoverflow.com/questions/47656329", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9056870/" ]
After two day with system admin support, I got the solution. I post it here in case it may help somebody else. Visual Studio 2017 looks not accepting a self signed certificate, as error states ("local issuer blah blah"). It has to be a local CA to approve it. Steps were: **Server:** 1. Install Company/Trusted CA on TFS machine as Trusted Authority root 2. Preparing certificate for TFS and make it derive from company/trusted CA. 3. Install it as Trusted Authority root in TFS machine 4. Configure TFS-IIS binding in order to make TFS certificate to be compulsory for HTTPS connections **Client:** 1. Install CA certificate as Trusted Authority root on client machine (tried with Windows 7 and 10) 2. Install TFS certificate as Trusted Authority root on client machine (you should see the lock in browser and connecting through it has to be recognized as secure) 3. Install Git client (I have Git-2.15.1.2-64-bit). 4. Run a shell (cmd, Powershell, Git-bash as you prefer) and digit this command: git config --global http.sslCAInfo C:/Users//ca-bundle.crt (because Git and Visual Studio have multiple folders where they store certificates, you are basically creating a global path for both of them) 5. Now you should be able to see a new .gitconfig file with this content: [http] sslCAInfo = C:/Users//ca-bundle.crt 6. if you digit command "git config --list --show-origin" you should see the new path/config added 7. Copy ca-bundle.crt from C:\Program Files\Git\mingw64\ssl\certs path to C:/Users// path 8. Export CA certificate as Base 64 X.509 (.CER) to up to you path (you can view certificates from IE Internet Options/Content/Certificates). 9. Open it with editor like Notepad++ or whatever the CA certificate that you just exported. Content should be: `-----BEGIN CERTIFICATE-----publickey-----END CERTIFICATE-----` 10. Copy this content 11. Open the C:/Users//ca-bundle.crt and paste appending that content 12. Export TFS certificate as Base 64 X.509 (.CER) to up to you path. 13. Open it with the editor you prefer and copy the content 14. Open the C:/Users//ca-bundle.crt and paste appending that content 15. Save the file Now you should be able to clone repository. So basically the point is that certificate has to have the all chain authority in it and **there has to be one**.
In a browser open the tfs url then click on the lock icon in the address bar then export the root certificate as Base 64 X.509 (.CER) then appended the root certificate to the cert file here: "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\Common7\IDE\CommonExtensions\Microsoft\TeamFoundation\Team Explorer\Git\mingw32\ssl\certs\ca-bundle.crt"
47,656,329
I created a react component that I want to use twice(or more) inside my page, and I need to load a script tag for it inside the head of my page but just once! I mean even if I use the component twice or more in the page it should add the script tag just once in the head. The Problem is that this script tag should be absolutely a part of the component and not statically inserted in the head of my page. Can anyone help me to make the magic happens? Thanks a lot in advance!
2017/12/05
[ "https://Stackoverflow.com/questions/47656329", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9056870/" ]
After two day with system admin support, I got the solution. I post it here in case it may help somebody else. Visual Studio 2017 looks not accepting a self signed certificate, as error states ("local issuer blah blah"). It has to be a local CA to approve it. Steps were: **Server:** 1. Install Company/Trusted CA on TFS machine as Trusted Authority root 2. Preparing certificate for TFS and make it derive from company/trusted CA. 3. Install it as Trusted Authority root in TFS machine 4. Configure TFS-IIS binding in order to make TFS certificate to be compulsory for HTTPS connections **Client:** 1. Install CA certificate as Trusted Authority root on client machine (tried with Windows 7 and 10) 2. Install TFS certificate as Trusted Authority root on client machine (you should see the lock in browser and connecting through it has to be recognized as secure) 3. Install Git client (I have Git-2.15.1.2-64-bit). 4. Run a shell (cmd, Powershell, Git-bash as you prefer) and digit this command: git config --global http.sslCAInfo C:/Users//ca-bundle.crt (because Git and Visual Studio have multiple folders where they store certificates, you are basically creating a global path for both of them) 5. Now you should be able to see a new .gitconfig file with this content: [http] sslCAInfo = C:/Users//ca-bundle.crt 6. if you digit command "git config --list --show-origin" you should see the new path/config added 7. Copy ca-bundle.crt from C:\Program Files\Git\mingw64\ssl\certs path to C:/Users// path 8. Export CA certificate as Base 64 X.509 (.CER) to up to you path (you can view certificates from IE Internet Options/Content/Certificates). 9. Open it with editor like Notepad++ or whatever the CA certificate that you just exported. Content should be: `-----BEGIN CERTIFICATE-----publickey-----END CERTIFICATE-----` 10. Copy this content 11. Open the C:/Users//ca-bundle.crt and paste appending that content 12. Export TFS certificate as Base 64 X.509 (.CER) to up to you path. 13. Open it with the editor you prefer and copy the content 14. Open the C:/Users//ca-bundle.crt and paste appending that content 15. Save the file Now you should be able to clone repository. So basically the point is that certificate has to have the all chain authority in it and **there has to be one**.
I faced the same issue. Below are two steps that worked for me to fix the issue: 1. Go to Tools > Options > Source Control > Git Global Settings Set *Cryptographic network provider* as *Secure Channel*. 2. Reconnect Project. Go to Team Explorer > Manage Connection > Connect to Project.
47,656,329
I created a react component that I want to use twice(or more) inside my page, and I need to load a script tag for it inside the head of my page but just once! I mean even if I use the component twice or more in the page it should add the script tag just once in the head. The Problem is that this script tag should be absolutely a part of the component and not statically inserted in the head of my page. Can anyone help me to make the magic happens? Thanks a lot in advance!
2017/12/05
[ "https://Stackoverflow.com/questions/47656329", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9056870/" ]
Here what I did to fix my issue: In Git Settings, Global Settings in Team Explorer, there is an option to choose between OpenSSL and Secure Channel. Starting with Visual Studio 2017 (version 15.7 preview 3) use of SChannel in Git Global settings fixed my issue.
You can do a quick workaround by: ``` git config --global http.sslVerify false ``` Ref: <https://confluence.atlassian.com/bitbucketserverkb/ssl-certificate-problem-unable-to-get-local-issuer-certificate-816521128.html>
47,656,329
I created a react component that I want to use twice(or more) inside my page, and I need to load a script tag for it inside the head of my page but just once! I mean even if I use the component twice or more in the page it should add the script tag just once in the head. The Problem is that this script tag should be absolutely a part of the component and not statically inserted in the head of my page. Can anyone help me to make the magic happens? Thanks a lot in advance!
2017/12/05
[ "https://Stackoverflow.com/questions/47656329", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9056870/" ]
Here what I did to fix my issue: In Git Settings, Global Settings in Team Explorer, there is an option to choose between OpenSSL and Secure Channel. Starting with Visual Studio 2017 (version 15.7 preview 3) use of SChannel in Git Global settings fixed my issue.
In a browser open the tfs url then click on the lock icon in the address bar then export the root certificate as Base 64 X.509 (.CER) then appended the root certificate to the cert file here: "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\Common7\IDE\CommonExtensions\Microsoft\TeamFoundation\Team Explorer\Git\mingw32\ssl\certs\ca-bundle.crt"
47,656,329
I created a react component that I want to use twice(or more) inside my page, and I need to load a script tag for it inside the head of my page but just once! I mean even if I use the component twice or more in the page it should add the script tag just once in the head. The Problem is that this script tag should be absolutely a part of the component and not statically inserted in the head of my page. Can anyone help me to make the magic happens? Thanks a lot in advance!
2017/12/05
[ "https://Stackoverflow.com/questions/47656329", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9056870/" ]
Here what I did to fix my issue: In Git Settings, Global Settings in Team Explorer, there is an option to choose between OpenSSL and Secure Channel. Starting with Visual Studio 2017 (version 15.7 preview 3) use of SChannel in Git Global settings fixed my issue.
I faced the same issue. Below are two steps that worked for me to fix the issue: 1. Go to Tools > Options > Source Control > Git Global Settings Set *Cryptographic network provider* as *Secure Channel*. 2. Reconnect Project. Go to Team Explorer > Manage Connection > Connect to Project.
47,656,329
I created a react component that I want to use twice(or more) inside my page, and I need to load a script tag for it inside the head of my page but just once! I mean even if I use the component twice or more in the page it should add the script tag just once in the head. The Problem is that this script tag should be absolutely a part of the component and not statically inserted in the head of my page. Can anyone help me to make the magic happens? Thanks a lot in advance!
2017/12/05
[ "https://Stackoverflow.com/questions/47656329", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9056870/" ]
You can do a quick workaround by: ``` git config --global http.sslVerify false ``` Ref: <https://confluence.atlassian.com/bitbucketserverkb/ssl-certificate-problem-unable-to-get-local-issuer-certificate-816521128.html>
In a browser open the tfs url then click on the lock icon in the address bar then export the root certificate as Base 64 X.509 (.CER) then appended the root certificate to the cert file here: "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\Common7\IDE\CommonExtensions\Microsoft\TeamFoundation\Team Explorer\Git\mingw32\ssl\certs\ca-bundle.crt"
47,656,329
I created a react component that I want to use twice(or more) inside my page, and I need to load a script tag for it inside the head of my page but just once! I mean even if I use the component twice or more in the page it should add the script tag just once in the head. The Problem is that this script tag should be absolutely a part of the component and not statically inserted in the head of my page. Can anyone help me to make the magic happens? Thanks a lot in advance!
2017/12/05
[ "https://Stackoverflow.com/questions/47656329", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9056870/" ]
You can do a quick workaround by: ``` git config --global http.sslVerify false ``` Ref: <https://confluence.atlassian.com/bitbucketserverkb/ssl-certificate-problem-unable-to-get-local-issuer-certificate-816521128.html>
I faced the same issue. Below are two steps that worked for me to fix the issue: 1. Go to Tools > Options > Source Control > Git Global Settings Set *Cryptographic network provider* as *Secure Channel*. 2. Reconnect Project. Go to Team Explorer > Manage Connection > Connect to Project.
60,980,163
This is very simple example of what I want to get. My question is about @returns tag. What should I write there? ```js class Base{ /** * @returns {QUESTION: WHAT SHOUL BE HIRE??} */ static method(){ return new this() } } class Sub extends Base{ } let base= Base.method() // IDE should understand that base is instance of Base let sub= Sub.method() // IDE should understand that sub is instance of Sub ```
2020/04/01
[ "https://Stackoverflow.com/questions/60980163", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3011740/" ]
I did it for you with MU Grids and media queries, if you have questions, ask. I am always ready to help. This is codesandbox link. Let me know if it help you. <https://codesandbox.io/s/charming-shirley-oq6l5>
Show my codesandbox answering your problem : <https://codesandbox.io/s/amazing-sound-1nj87> It display your layout for **md lg xl** correctly. For **xs and sm** screens, sidenav & map take **full height** with a **break page between sidenav and appBa**r
60,980,163
This is very simple example of what I want to get. My question is about @returns tag. What should I write there? ```js class Base{ /** * @returns {QUESTION: WHAT SHOUL BE HIRE??} */ static method(){ return new this() } } class Sub extends Base{ } let base= Base.method() // IDE should understand that base is instance of Base let sub= Sub.method() // IDE should understand that sub is instance of Sub ```
2020/04/01
[ "https://Stackoverflow.com/questions/60980163", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3011740/" ]
I did it for you with MU Grids and media queries, if you have questions, ask. I am always ready to help. This is codesandbox link. Let me know if it help you. <https://codesandbox.io/s/charming-shirley-oq6l5>
Thanks to both, it solved the main part o what i need. Also need to implement a change of page. I forget to mention that the map will be React-Leaflet, so need to implement a flap button over the map for the mobile version. The button is for scroll to up, because any finger movement in the map area only will affect the map content. Do not will have effect in the scroll. [![enter image description here](https://i.stack.imgur.com/ZNcER.png)](https://i.stack.imgur.com/ZNcER.png) Another thing to implement is the break page concept: The behaviour of the break page is like when you see a pdf in presentation mode and press the keyboard button Repag - Avpag, it change all the content and never see the half top and the half down. Grettings
92,235
I've been taught that a carbocation mainly rearranges because of: * increasing degree (1 to 2, 1 to 3, or 2 to 3) * +M stabilization * ring expansion (in an exceptional case, ring contraction as well). However, I've never been taught whether the following carbocation **A** would rearrange: [![enter image description here](https://i.stack.imgur.com/QBYmn.png)](https://i.stack.imgur.com/QBYmn.png) My professor would say that this carbocation would *not* rearrange, since at the alpha position we only have two hydrogen atoms, and either of the hydride shifts would still yield a two degree carbocation **B**: [![enter image description here](https://i.stack.imgur.com/m2jKT.png)](https://i.stack.imgur.com/m2jKT.png) However I believe that **B** is stabilized by the **strong inductive effect of three extra methyl groups** (at the alpha position) that were absent in **A**. I believe this is a strong enough driving force for rearrangement. So, can we say **A** will rearrange into **B**? Is there experimental evidence to support the fact that **A** rearranges/does not rearrange into **B**? Finally, based on these, can inductive effect be the sole driving force for carbocation rearrangement?
2018/03/13
[ "https://chemistry.stackexchange.com/questions/92235", "https://chemistry.stackexchange.com", "https://chemistry.stackexchange.com/users/5026/" ]
The answer to this question is quite difficult to deduce logically. In the first place, the carbocation that is formed is secondary. Rearranging will only change the position of the carbocation, but it will be still secondary. But then there is also a stabilising +I effect. Instead, if we take into account that that these carbocations are intermediates to form alkenes, a conclusion can be drawn. So, the best way is to consider the thermodynamic favour of the rearrangements. Prior to rearrangement, the carbocation is secondary. If you consider that this carbocation is going to form an alkene, the major product from it (Saytzeff product) will be **4-methyl pent-2-ene**, which is of the form $\ce{RCH=CHR}$. After rearrangement, this will be still a secondary carbocation, so there is a significant energy required for this hydride shift. This energy is not really compensated by the +I effect of the isopropyl group. But if we consider that this carbocation is an intermediate for the alkene formation, the major alkene (Saytzeff product) will be **2-methyl pent-2-ene**, which is of the form $\ce{R2C=CHR}$, which is thermodynamically more favourable. So it is seen that in the rearrangement, the energy of the intermediate is increased, but the overall energy of the product is decreased. So, I think that, at higher temperatures, this rearrangement can be possible, because the ultimate product (if we think this as an alkene) is thermodynamically favourable, while at normal temperature this rearrangement is energetically restricted a bit.
I think that without any experimental data, it is no possible to decide. Personally, I don't think the inductive effect differences between the two ($\ce{CH3}$ and $\text{iBu}$ *vs.* $\text{Et}$ and $\text{iPr}$) and are large enough so that the energy gain from the stabilization of the carbocation is enough to overcome the energy barrier of the hydride shift. From [Hammett parameters](https://pubs.acs.org/doi/pdf/10.1021/jo01097a026) , the $\ce{CH3}$ would actually be more electron donating than the $\ce{iPr}$ group, and since $\text{Pr}$ and $\text{Et}$ have the same $\sigma\_\text{p}$ value, I wouldn't expect a difference between $\text{iBu}$ and $\text{Et}$ either. Of course, Hammett parameters aren't necessary a direct measurement of inductive effect, and these are not aromatic rings, but I think it paints a picture of how the inductive effect difference isn't that large. Overall, I wouldn't say that carbocation **B** will never form from carbocation **A**, but it certainly will depend on conditions. My answer in an academic situation would be that it will not form, since the stabilization effect, if any, is minimal. **Edit:** Upon more thinking, the [Taft polar parameter](https://pubs.acs.org/doi/pdf/10.1021/ci060129d), $\sigma^\*$, might be a better representation of this case. These actually show a higher electron donating ability for both $\text{iPr}$ *vs.* $\text{iBu}$, and $\text{Et}$ *vs.* $\text{Me}$, respectively. These are also empirical values, and not necessarily the same as we would observe, but again, they can give an idea. The differences are so small that I would stand on arguing towards the side that the energy barrier for the shift is large enough that it would be minimal for stabilization by shifting to be favored. Again, it would definitely depend on conditions.
30,354,168
I have an HTML page (`courses.html`) that shows a list of courses. These courses are loaded from a database by an AJAX call into the array "courses" defined as global variable in `script_1.js`. Once I go to the page of a specific course in `course.html` I want to be able to pass this array to `script_2.js` to mantain the order of the courses and navigate them without having to perform the AJAX call again. How I can pass this global variable or how I can manage this?
2015/05/20
[ "https://Stackoverflow.com/questions/30354168", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4347551/" ]
The way to approach this would to be use cookies. An answer to a previous stack overflow question explains really well how to store javascript objects in cookies and how to retrieve them. <https://stackoverflow.com/a/11344672/1130119>
You have a couple of options: 1) If you are developing a Single Page Application (SPA): Create a global variable to store your courses, for example: window.courses = []; // fill with your data courses then when you load your page 2 you could access to window.courses variable (keep in mind that you could create a object app and store in it all variable that you need as: window.app = {}; window.app.courses = [] ) 2) It's useful for SPA or classical web application: Save courses on localStorage, you could store the courses and retrieve in the next page (or download if localStorage.getItem('courses') will be undefined).
30,354,168
I have an HTML page (`courses.html`) that shows a list of courses. These courses are loaded from a database by an AJAX call into the array "courses" defined as global variable in `script_1.js`. Once I go to the page of a specific course in `course.html` I want to be able to pass this array to `script_2.js` to mantain the order of the courses and navigate them without having to perform the AJAX call again. How I can pass this global variable or how I can manage this?
2015/05/20
[ "https://Stackoverflow.com/questions/30354168", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4347551/" ]
You have the following option for passing data from one page to the next: 1. **Cookie.** Store some data in a cookie in page1. When page2 loads, it can read the value from the cookie. 2. **Local Storage.** Store some data in Local Storage in page1. When page2 loads, it can read the value from the Local Storage. 3. **Server Storage.** Store some data on your server on behalf of user1 on page1. When page2 loads, the server can either place that user1 data on page2 or page2 can request that data from the server via ajax. 4. **Query Parameter.** When page2 is loaded from page1, a query parameter can be placed onto the URL as in <http://www.example.com/page2?arg=foo> and page2 can parse that query parameter from the URL when it loads. 5. **Common Parent Frame.** If your page is framed by a common origin and you are not changing the top level URL, but just the framed URL, then you can store global data in the top level parent and that data can be accessed from the framed page, even as it goes from page1 to page2. You can often use JSON as a string-based storage format for more complex data items like an array. JSON can be put into any of the above storage options.
The way to approach this would to be use cookies. An answer to a previous stack overflow question explains really well how to store javascript objects in cookies and how to retrieve them. <https://stackoverflow.com/a/11344672/1130119>
30,354,168
I have an HTML page (`courses.html`) that shows a list of courses. These courses are loaded from a database by an AJAX call into the array "courses" defined as global variable in `script_1.js`. Once I go to the page of a specific course in `course.html` I want to be able to pass this array to `script_2.js` to mantain the order of the courses and navigate them without having to perform the AJAX call again. How I can pass this global variable or how I can manage this?
2015/05/20
[ "https://Stackoverflow.com/questions/30354168", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4347551/" ]
You have the following option for passing data from one page to the next: 1. **Cookie.** Store some data in a cookie in page1. When page2 loads, it can read the value from the cookie. 2. **Local Storage.** Store some data in Local Storage in page1. When page2 loads, it can read the value from the Local Storage. 3. **Server Storage.** Store some data on your server on behalf of user1 on page1. When page2 loads, the server can either place that user1 data on page2 or page2 can request that data from the server via ajax. 4. **Query Parameter.** When page2 is loaded from page1, a query parameter can be placed onto the URL as in <http://www.example.com/page2?arg=foo> and page2 can parse that query parameter from the URL when it loads. 5. **Common Parent Frame.** If your page is framed by a common origin and you are not changing the top level URL, but just the framed URL, then you can store global data in the top level parent and that data can be accessed from the framed page, even as it goes from page1 to page2. You can often use JSON as a string-based storage format for more complex data items like an array. JSON can be put into any of the above storage options.
You have a couple of options: 1) If you are developing a Single Page Application (SPA): Create a global variable to store your courses, for example: window.courses = []; // fill with your data courses then when you load your page 2 you could access to window.courses variable (keep in mind that you could create a object app and store in it all variable that you need as: window.app = {}; window.app.courses = [] ) 2) It's useful for SPA or classical web application: Save courses on localStorage, you could store the courses and retrieve in the next page (or download if localStorage.getItem('courses') will be undefined).
64,600,292
I'm trying to build a new WebApi secured using access tokens from azure active directory. I'm using .net core v3.1 and visual studio 2019. I created a new project using the "Asp.net core web application" template and picked an "API" project and changed the authentication type to "Work or School Accounts" and set the App ID Url to Api://Automation/TestApi Visual Studio then scaffolded me a web API with a mock weather forecast service which, if I comment out the [Authorize] attribute spins up nicely in a browser as expected. It also created me an Application Registration in AzureActive Directory. With the [Authorize] attribute back in place I had trouble calling the API from a client app so I decided to call the API using postman to see what's going on. I added a client secret to the app registration visual studio created and put a postman request together as below using the Application (client) Id and api://Automation/TestApi/.default as the scope. [![Postman Call to token endpoint](https://i.stack.imgur.com/cZQjG.png)](https://i.stack.imgur.com/cZQjG.png) This works fine and returns an access token however when I try to use that access token to call the default weatherforcast endpoint I get an HTTP 401 unauthorized error with the following in the WWW-Authenticate response header "Bearer error="invalid\_token", error\_description="The audience 'api://Automation/TestApi' is invalid" Is there something I'm missing? I cannot find any clue as to what the audience is expected to be and no obvious way of controlling that. As Requested here is the content of the expose an API screen [![Expose an API](https://i.stack.imgur.com/5U1Co.png)](https://i.stack.imgur.com/5U1Co.png) and the decoded jwt token I am using [![enter image description here](https://i.stack.imgur.com/eB8Aa.png)](https://i.stack.imgur.com/eB8Aa.png) **Update** I tried out @CarlZhao s answer below and it didn't really work. However I remembered [a question I asked a while ago about the wrong issuer in the token](https://stackoverflow.com/questions/59790209/issuer-in-access-token-from-azure-active-directory-is-https-sts-windows-net-wh) the outcome from this is to manually edit the manifest json in the registration for the API and set "accessTokenAcceptedVersion": 2 Now I get a v2 function with the clientId guid as the audience [![V2 JWT](https://i.stack.imgur.com/zUwW8.png)](https://i.stack.imgur.com/zUwW8.png) However, using this token still doesn't work!! I now get an error about the issuer: `Bearer error="invalid_token", error_description="The issuer 'https://login.microsoftonline.com/{{guid}}/v2.0' is invalid`
2020/10/29
[ "https://Stackoverflow.com/questions/64600292", "https://Stackoverflow.com", "https://Stackoverflow.com/users/428280/" ]
You missed some important steps, your access token is also wrong, it lacks the necessary permissions. You can try to follow my method: You need to create 2 applications, one representing the client application and the other representing the api application, and then use the client application to call the Web api application. First, you need to expose the api of the application representing the web api, you can configure it according to the following process: Azure portal>App registrations>Expose an API>Add a scope>Add a client application Because you are using the **client credential flow**, next, you need to define the **manifest** of api applications and grant application permissions to your client applications (this is the role permissions you define yourself, you can find it in **My APIs** when you add permissions).Then you need to click the **admin consent** button to grant administrator consent for this permission. [This](https://stackoverflow.com/questions/57379397/why-is-application-permissions-disabled-in-azure-ads-request-api-permissions/57385729#57385729) is the process of defining the manifest. [![enter image description here](https://i.stack.imgur.com/sBCPH.png)](https://i.stack.imgur.com/sBCPH.png) This is to grant permissions for the client application: [![enter image description here](https://i.stack.imgur.com/qLVGs.png)](https://i.stack.imgur.com/qLVGs.png) Finally, you can request a token for your api application: [![enter image description here](https://i.stack.imgur.com/nRUgJ.png)](https://i.stack.imgur.com/nRUgJ.png) Parse the token and you will see: [![enter image description here](https://i.stack.imgur.com/qmoyS.png)](https://i.stack.imgur.com/qmoyS.png)
I've made some further progress which I'm going to use to provide my own answer. The generated code is using the Microsoft.AspNetCore.Authentication.AzureAD.UI package v 3.1.x to validate the token. using Fiddler I was able to see that it is using the older endpoints instead of the current "V2.0" endpoints. the significance of this is that the token version dictates which audience and issuer are returned within the token. In a V1 token, the audience is the "Application Id Url" from the application registration and the issuer is "https://sts.windows.net/{tennantId}" in a v2 token, the audience is the Client ID (GUID) of the application registration and the issuer is [https://login.microsoftonline.com/{tenantId}/V2.0](https://login.microsoftonline.com/%7BtenantId%7D/V2.0). The underlying problem is that this library is expecting some kind of hybrid token with the audience value of a v2.0 token (eg the client Id) but from the v1 issuer <https://sts.windows.net/>. I couldn't find a way to make it look at the v2.0 endpoints for configuration but I found a [number of old issues](https://github.com/dotnet/aspnetcore/issues?q=is%3Aissue%20label%3Afeature-AADIntegration%20is%3Aclosed) on git hub with similar issues which have been closed without resolution. In particular * [The issue with the incorrect audience](https://github.com/dotnet/aspnetcore/issues/6030) * [Can not use v2.0 endpoints - causes the issuer problem](https://github.com/dotnet/aspnetcore/issues/6026) My workaround is to set "accessTokenAcceptedVersion": 2 in the application registration "manifest" json on the app registration. This ensures that the correct audience is in the token. The second step is to add custom issuer verification in the ConfigureServices method of the startup class. Here's my code ``` AzureADOptions opt = new AzureADOptions(); Configuration.Bind("AzureAd", opt); string expectedIssuer = $"{opt.Instance}{opt.TenantId}/v2.0"; services.Configure<JwtBearerOptions>(AzureADDefaults.JwtBearerAuthenticationScheme, options => { options.TokenValidationParameters.IssuerValidator = (issuer, securityToken, validationParameters) => { if (issuer == expectedIssuer) return issuer; throw new SecurityTokenInvalidIssuerException("Invalid Issuer") { InvalidIssuer = issuer }; }; }); ``` This does feel like I'm sweeping the underlying issue of a buggy and/or misconfigured middleware under the rug and I cannot help thinking that there must be something simpler - this is wizard generated starter code from visual studio 2019 after all.
64,600,292
I'm trying to build a new WebApi secured using access tokens from azure active directory. I'm using .net core v3.1 and visual studio 2019. I created a new project using the "Asp.net core web application" template and picked an "API" project and changed the authentication type to "Work or School Accounts" and set the App ID Url to Api://Automation/TestApi Visual Studio then scaffolded me a web API with a mock weather forecast service which, if I comment out the [Authorize] attribute spins up nicely in a browser as expected. It also created me an Application Registration in AzureActive Directory. With the [Authorize] attribute back in place I had trouble calling the API from a client app so I decided to call the API using postman to see what's going on. I added a client secret to the app registration visual studio created and put a postman request together as below using the Application (client) Id and api://Automation/TestApi/.default as the scope. [![Postman Call to token endpoint](https://i.stack.imgur.com/cZQjG.png)](https://i.stack.imgur.com/cZQjG.png) This works fine and returns an access token however when I try to use that access token to call the default weatherforcast endpoint I get an HTTP 401 unauthorized error with the following in the WWW-Authenticate response header "Bearer error="invalid\_token", error\_description="The audience 'api://Automation/TestApi' is invalid" Is there something I'm missing? I cannot find any clue as to what the audience is expected to be and no obvious way of controlling that. As Requested here is the content of the expose an API screen [![Expose an API](https://i.stack.imgur.com/5U1Co.png)](https://i.stack.imgur.com/5U1Co.png) and the decoded jwt token I am using [![enter image description here](https://i.stack.imgur.com/eB8Aa.png)](https://i.stack.imgur.com/eB8Aa.png) **Update** I tried out @CarlZhao s answer below and it didn't really work. However I remembered [a question I asked a while ago about the wrong issuer in the token](https://stackoverflow.com/questions/59790209/issuer-in-access-token-from-azure-active-directory-is-https-sts-windows-net-wh) the outcome from this is to manually edit the manifest json in the registration for the API and set "accessTokenAcceptedVersion": 2 Now I get a v2 function with the clientId guid as the audience [![V2 JWT](https://i.stack.imgur.com/zUwW8.png)](https://i.stack.imgur.com/zUwW8.png) However, using this token still doesn't work!! I now get an error about the issuer: `Bearer error="invalid_token", error_description="The issuer 'https://login.microsoftonline.com/{{guid}}/v2.0' is invalid`
2020/10/29
[ "https://Stackoverflow.com/questions/64600292", "https://Stackoverflow.com", "https://Stackoverflow.com/users/428280/" ]
I've found a better way of doing it so thought I would post the answer as an alternative to my first answer. I found this very good [sample application and tutorial](https://github.com/azure-samples/active-directory-dotnet-native-aspnetcore-v2) and worked through the 1st part "Desktop App Calls Web Api" and produces an api that is using the correct endpoints and handles validates the token in a more predictable manor. If you are stating out on a new Web API I would suggest using this as a starting point instead of the api that visual studio scaffolds. To get the scaffolded weather forcast api to accept token an access token * You need seperate application registrations for the client and the api as well as a scope as sugested by @Carl Zhao and the tutorial linked above. * Replace the Microsoft.AspNetCore.Authentication.AzureAD.UI nuget package with Microsoft.Identity.Web * In your startup.cs in Configure services replace the call to services.AddAuthentication(...).AddAzureAdBearer(....) with a call to AddMicrosoftIdentityWebApiAuthentication * remove using directives for Microsoft.AspNetCore.Authentication.\* and add in using Microsoft.Identity.Web; heres what my Configure Services Looks Like now ``` public void ConfigureServices(IServiceCollection services) { services.AddMicrosoftIdentityWebApiAuthentication(Configuration); services.AddControllers(); } ``` The custom issuer validator presented in my other answer is not requried and can be removed.
I've made some further progress which I'm going to use to provide my own answer. The generated code is using the Microsoft.AspNetCore.Authentication.AzureAD.UI package v 3.1.x to validate the token. using Fiddler I was able to see that it is using the older endpoints instead of the current "V2.0" endpoints. the significance of this is that the token version dictates which audience and issuer are returned within the token. In a V1 token, the audience is the "Application Id Url" from the application registration and the issuer is "https://sts.windows.net/{tennantId}" in a v2 token, the audience is the Client ID (GUID) of the application registration and the issuer is [https://login.microsoftonline.com/{tenantId}/V2.0](https://login.microsoftonline.com/%7BtenantId%7D/V2.0). The underlying problem is that this library is expecting some kind of hybrid token with the audience value of a v2.0 token (eg the client Id) but from the v1 issuer <https://sts.windows.net/>. I couldn't find a way to make it look at the v2.0 endpoints for configuration but I found a [number of old issues](https://github.com/dotnet/aspnetcore/issues?q=is%3Aissue%20label%3Afeature-AADIntegration%20is%3Aclosed) on git hub with similar issues which have been closed without resolution. In particular * [The issue with the incorrect audience](https://github.com/dotnet/aspnetcore/issues/6030) * [Can not use v2.0 endpoints - causes the issuer problem](https://github.com/dotnet/aspnetcore/issues/6026) My workaround is to set "accessTokenAcceptedVersion": 2 in the application registration "manifest" json on the app registration. This ensures that the correct audience is in the token. The second step is to add custom issuer verification in the ConfigureServices method of the startup class. Here's my code ``` AzureADOptions opt = new AzureADOptions(); Configuration.Bind("AzureAd", opt); string expectedIssuer = $"{opt.Instance}{opt.TenantId}/v2.0"; services.Configure<JwtBearerOptions>(AzureADDefaults.JwtBearerAuthenticationScheme, options => { options.TokenValidationParameters.IssuerValidator = (issuer, securityToken, validationParameters) => { if (issuer == expectedIssuer) return issuer; throw new SecurityTokenInvalidIssuerException("Invalid Issuer") { InvalidIssuer = issuer }; }; }); ``` This does feel like I'm sweeping the underlying issue of a buggy and/or misconfigured middleware under the rug and I cannot help thinking that there must be something simpler - this is wizard generated starter code from visual studio 2019 after all.
38,473,994
I am using webapi-avplay to play video on samsung tizen tv web app. Video starts buffering when I am forwarding the video and after the completion of buffering, video starts playing. At the time when buffering in progress, I am trying to forward/backward video but unfortunately unable to forward/backward video. So I want to forward/backward video during buffering. I have searched and read doc but not found any help related to my problem. So Please help us to getting out from here.
2016/07/20
[ "https://Stackoverflow.com/questions/38473994", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4264085/" ]
Have you tried coding inside **onbufferingprogress** method. Like: ``` var listener = { onbufferingprogress: function(percent) { console.log("Buffering in progress"); loadingObj.setPercent(percent); /* Move 5 seconds back */ var back_button = document.getElementById("v-back"); /* Back button */ back_button.addEventListener("click", function() { video.currentTime -= 5 }, false); } } webapis.avplay.setListener(listener); ``` Thank you.
when you are trying to seek you should pause the video after that you should seek visually update the progress bar and current time. When the user stopped seeking you should use webapis.avplay.seekTo(seekingTime) and play the video. It works for me. ``` const handleSeekForward = () => { setForwardSteps((prev) => prev + 1); player().pause(); const seekTime = player().getCurrentTime() + 2 * clamp(forwardSteps(), 3, 120); if (seekTime > player()?.getDuration()) { return; } const progress = progressUpdate(player()?.getCurrentTime()); setCurrentProgress(progress); if (hasNativeHLS()) { const hour = getHours(seekTime); const minutes = getMinutes(seekTime); const seconds = getSeconds(seekTime); setCurrentTime(`${hour}:${minutes}:${seconds}`); } player().seek(seekTime); ``` };
47,965,975
While using google map activity in my android application I get this error. **"Could not resolve com.google.android.gms:play-services:11.8.0."** **Project level** Gradle file: ``` buildscript { repositories { jcenter() google() } dependencies { classpath 'com.android.tools.build:gradle:3.0.1' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files } } allprojects { repositories { jcenter() google() } } task clean(type: Delete) { delete rootProject.buildDir } ``` **Application level** Gradle file: ``` dependencies { compile fileTree(include: ['*.jar'], dir: 'libs') androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { exclude group: 'com.android.support', module: 'support-annotations' }) compile 'com.android.support.constraint:constraint-layout:1.0.2' testCompile 'junit:junit:4.12' //noinspection GradleCompatible implementation 'com.android.support:appcompat-v7:26.1.0' implementation 'com.google.android.gms:play-services:11.8.0' } ```
2017/12/25
[ "https://Stackoverflow.com/questions/47965975", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4601864/" ]
So, finally I got the answer, I've turned on gradle offline mode that's why it could not find out cached files for that version play-service. I turned it off (under File-Settings-Build,Execution,Deployment-Gradle) and again sync project and some files have been downloaded then it works now.
You need to include this *class path* inside project level *gradle*. ``` classpath 'com.google.gms:google-services:3.0.0' ``` As well as inside app level *build.gradle*. ``` apply plugin: 'com.google.gms.google-services' ```
1,578,322
I am so confused that I thought to ask you for your opinion. I have written few jquery code with asp.net. But there is group of developer in my company who think that javascript/jquery can be turned off and is insecure * if javascript is insecure, why to use it at the first place * what are the advantages of using jquery with asp.net apart from cross-browser. why not use javascript? * should i use jquery in my asp.net applications? There were a few posts over here that contained similar question, but not even one that contained good explanation. Please share your thoughts.
2009/10/16
[ "https://Stackoverflow.com/questions/1578322", "https://Stackoverflow.com", "https://Stackoverflow.com/users/84950/" ]
> > if javascript is insecure, why to use it at the first place > > > To provide advanced browsing experience to those who have it on. > > what are the advantages of using jquery with asp.net apart from cross-browser. why not use javascript? > > > Rapid development. If you're not comfortable with jQuery, code in JavaScript directly, see no problem here. > > should i use jquery in my asp.net applications? > > > That's up to you to decide. Give it a try and see if you'll like it.
Javascript is no less secure than using the Internet. I would definitely recommend it for the sheer purpose of enhancing the user experience. However, it is also important to make sure your application functions properly with Javascript disabled. How you write your Javascript is up to you. I use jQuery because I am much more productive with it, primarily because I don't waste time dealing with the inherent short-comings of Javascript, as well as the numerous cross-browser oddities. jQuery is, in fact, Javascript, by the way.
1,578,322
I am so confused that I thought to ask you for your opinion. I have written few jquery code with asp.net. But there is group of developer in my company who think that javascript/jquery can be turned off and is insecure * if javascript is insecure, why to use it at the first place * what are the advantages of using jquery with asp.net apart from cross-browser. why not use javascript? * should i use jquery in my asp.net applications? There were a few posts over here that contained similar question, but not even one that contained good explanation. Please share your thoughts.
2009/10/16
[ "https://Stackoverflow.com/questions/1578322", "https://Stackoverflow.com", "https://Stackoverflow.com/users/84950/" ]
> > if javascript is insecure, why to use it at the first place > > > To provide advanced browsing experience to those who have it on. > > what are the advantages of using jquery with asp.net apart from cross-browser. why not use javascript? > > > Rapid development. If you're not comfortable with jQuery, code in JavaScript directly, see no problem here. > > should i use jquery in my asp.net applications? > > > That's up to you to decide. Give it a try and see if you'll like it.
1. To provide a better experience for the users. People today expect web pages to be interactive. The idea of having a totally static site died a while ago. It should also be said, that if someone is really skilled at compromising systems, whether you use JavaScript or not is inconsequential. With cross site scripting attacks etc. someone can embed JavaScript into your site. Using JavaScript might make it easier to compromise a page, but not using, doesn't mean that it is fool proof protection against it. 2. JQuery is a JavaScript framework, and it abstracts a lot of the necessities from knowing the ins and outs of JavaScript and cross browser support. It also abstracts a lot about what you need to know when manipulating the DOM, which can be extremely frustrating at times. It makes development a lot easier unless you really know what you are doing, and then it still makes development easier in a lot of cases. 3. I would recommend using some sort of a framework unless you are really good with JavaScript. Jquery may not be the way to go for you, but it is a good one to use. There are others like Prototype and YUI.
1,578,322
I am so confused that I thought to ask you for your opinion. I have written few jquery code with asp.net. But there is group of developer in my company who think that javascript/jquery can be turned off and is insecure * if javascript is insecure, why to use it at the first place * what are the advantages of using jquery with asp.net apart from cross-browser. why not use javascript? * should i use jquery in my asp.net applications? There were a few posts over here that contained similar question, but not even one that contained good explanation. Please share your thoughts.
2009/10/16
[ "https://Stackoverflow.com/questions/1578322", "https://Stackoverflow.com", "https://Stackoverflow.com/users/84950/" ]
> > if javascript is insecure, why to use it at the first place > > > To provide advanced browsing experience to those who have it on. > > what are the advantages of using jquery with asp.net apart from cross-browser. why not use javascript? > > > Rapid development. If you're not comfortable with jQuery, code in JavaScript directly, see no problem here. > > should i use jquery in my asp.net applications? > > > That's up to you to decide. Give it a try and see if you'll like it.
Javascript is not insecure per se -- but you can certainly create insecure code with it, if you're not careful. All code that is 'critical' security-wise should be run **in the server**, not in the user's browser, because it can be turned off.
1,578,322
I am so confused that I thought to ask you for your opinion. I have written few jquery code with asp.net. But there is group of developer in my company who think that javascript/jquery can be turned off and is insecure * if javascript is insecure, why to use it at the first place * what are the advantages of using jquery with asp.net apart from cross-browser. why not use javascript? * should i use jquery in my asp.net applications? There were a few posts over here that contained similar question, but not even one that contained good explanation. Please share your thoughts.
2009/10/16
[ "https://Stackoverflow.com/questions/1578322", "https://Stackoverflow.com", "https://Stackoverflow.com/users/84950/" ]
``` • what are the advantages of using jquery with asp.net apart from cross-browser. why not use javascript? ``` jQuery *is* javascript. The purpose of javascript is to enhance the user's browser experience. If this is something you want to include in your website then I would advise you use it. If you do opt to use it, depending on what your requirements are, [jQuery](http://jquery.com/) would be the best option.
Javascript is no less secure than using the Internet. I would definitely recommend it for the sheer purpose of enhancing the user experience. However, it is also important to make sure your application functions properly with Javascript disabled. How you write your Javascript is up to you. I use jQuery because I am much more productive with it, primarily because I don't waste time dealing with the inherent short-comings of Javascript, as well as the numerous cross-browser oddities. jQuery is, in fact, Javascript, by the way.
1,578,322
I am so confused that I thought to ask you for your opinion. I have written few jquery code with asp.net. But there is group of developer in my company who think that javascript/jquery can be turned off and is insecure * if javascript is insecure, why to use it at the first place * what are the advantages of using jquery with asp.net apart from cross-browser. why not use javascript? * should i use jquery in my asp.net applications? There were a few posts over here that contained similar question, but not even one that contained good explanation. Please share your thoughts.
2009/10/16
[ "https://Stackoverflow.com/questions/1578322", "https://Stackoverflow.com", "https://Stackoverflow.com/users/84950/" ]
``` • what are the advantages of using jquery with asp.net apart from cross-browser. why not use javascript? ``` jQuery *is* javascript. The purpose of javascript is to enhance the user's browser experience. If this is something you want to include in your website then I would advise you use it. If you do opt to use it, depending on what your requirements are, [jQuery](http://jquery.com/) would be the best option.
1. To provide a better experience for the users. People today expect web pages to be interactive. The idea of having a totally static site died a while ago. It should also be said, that if someone is really skilled at compromising systems, whether you use JavaScript or not is inconsequential. With cross site scripting attacks etc. someone can embed JavaScript into your site. Using JavaScript might make it easier to compromise a page, but not using, doesn't mean that it is fool proof protection against it. 2. JQuery is a JavaScript framework, and it abstracts a lot of the necessities from knowing the ins and outs of JavaScript and cross browser support. It also abstracts a lot about what you need to know when manipulating the DOM, which can be extremely frustrating at times. It makes development a lot easier unless you really know what you are doing, and then it still makes development easier in a lot of cases. 3. I would recommend using some sort of a framework unless you are really good with JavaScript. Jquery may not be the way to go for you, but it is a good one to use. There are others like Prototype and YUI.
1,578,322
I am so confused that I thought to ask you for your opinion. I have written few jquery code with asp.net. But there is group of developer in my company who think that javascript/jquery can be turned off and is insecure * if javascript is insecure, why to use it at the first place * what are the advantages of using jquery with asp.net apart from cross-browser. why not use javascript? * should i use jquery in my asp.net applications? There were a few posts over here that contained similar question, but not even one that contained good explanation. Please share your thoughts.
2009/10/16
[ "https://Stackoverflow.com/questions/1578322", "https://Stackoverflow.com", "https://Stackoverflow.com/users/84950/" ]
``` • what are the advantages of using jquery with asp.net apart from cross-browser. why not use javascript? ``` jQuery *is* javascript. The purpose of javascript is to enhance the user's browser experience. If this is something you want to include in your website then I would advise you use it. If you do opt to use it, depending on what your requirements are, [jQuery](http://jquery.com/) would be the best option.
Javascript is not insecure per se -- but you can certainly create insecure code with it, if you're not careful. All code that is 'critical' security-wise should be run **in the server**, not in the user's browser, because it can be turned off.
39,164,187
I have two columns which I want to combine and show the data, I tried like below ``` select case when status = 'R' then 'Resign' when status = 'A' then 'Active' end as status1, Program_name + ' ' + emp_card_no as program_details, * from GetEmployeeDetails where emp_name = 'ABHAY ASHOK MANE' and STATUS = 'A' order by EMP_NAME ``` but I am getting an error: > > Error converting data type varchar to numeric. > > > Here is the sample data available [![img](https://i.stack.imgur.com/k9Ks0.png)](https://i.stack.imgur.com/k9Ks0.png)
2016/08/26
[ "https://Stackoverflow.com/questions/39164187", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1216804/" ]
Try this : ``` select case when status='R' then 'Resign' when status='A' then 'Active' end as status1, Program_name + ' (' + convert(varchar, emp_card_no) + ') ' as program_details, * from GetEmployeeDetails Where emp_name ='ABHAY ASHOK MANE'and STATUS= 'A' ORDER BY EMP_NAME ```
If you need parentheses, use following: ``` select case when status='R' then 'Resign' when status='A' then 'Active' end as status1, Program_name + ' (' + convert(varchar(10), emp_card_no)+')' as program_details, * from GetEmployeeDetails Where emp_name ='ABHAY ASHOK MANE'and STATUS= 'A' ORDER BY EMP_NAME ```
39,164,187
I have two columns which I want to combine and show the data, I tried like below ``` select case when status = 'R' then 'Resign' when status = 'A' then 'Active' end as status1, Program_name + ' ' + emp_card_no as program_details, * from GetEmployeeDetails where emp_name = 'ABHAY ASHOK MANE' and STATUS = 'A' order by EMP_NAME ``` but I am getting an error: > > Error converting data type varchar to numeric. > > > Here is the sample data available [![img](https://i.stack.imgur.com/k9Ks0.png)](https://i.stack.imgur.com/k9Ks0.png)
2016/08/26
[ "https://Stackoverflow.com/questions/39164187", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1216804/" ]
Try this : ``` select case when status='R' then 'Resign' when status='A' then 'Active' end as status1, Program_name + ' (' + convert(varchar, emp_card_no) + ') ' as program_details, * from GetEmployeeDetails Where emp_name ='ABHAY ASHOK MANE'and STATUS= 'A' ORDER BY EMP_NAME ```
**CAST** Int value column to VARCHAR: In your query **cast emp\_card\_no** to VARCHAR ``` select case when status='R' then 'Resign' when status='A' then 'Active' end as status1, [Program_name] + ' ' + CAST(emp_card_no AS VARCHAR(50)) as program_details, * from GetEmployeeDetails Where emp_name ='ABHAY ASHOK MANE'and STATUS= 'A' ORDER BY EMP_NAME ```
39,164,187
I have two columns which I want to combine and show the data, I tried like below ``` select case when status = 'R' then 'Resign' when status = 'A' then 'Active' end as status1, Program_name + ' ' + emp_card_no as program_details, * from GetEmployeeDetails where emp_name = 'ABHAY ASHOK MANE' and STATUS = 'A' order by EMP_NAME ``` but I am getting an error: > > Error converting data type varchar to numeric. > > > Here is the sample data available [![img](https://i.stack.imgur.com/k9Ks0.png)](https://i.stack.imgur.com/k9Ks0.png)
2016/08/26
[ "https://Stackoverflow.com/questions/39164187", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1216804/" ]
Try this : ``` select case when status='R' then 'Resign' when status='A' then 'Active' end as status1, Program_name + ' (' + convert(varchar, emp_card_no) + ') ' as program_details, * from GetEmployeeDetails Where emp_name ='ABHAY ASHOK MANE'and STATUS= 'A' ORDER BY EMP_NAME ```
You can use concat which will convert internally.. ``` select case when status='R' then 'Resign' when status='A' then 'Active' end as status1, concat(Program_name, ' ', emp_card_no) as program_details, * from GetEmployeeDetails Where emp_name ='ABHAY ASHOK MANE'and STATUS= 'A' ORDER BY EMP_NAME ```
39,164,187
I have two columns which I want to combine and show the data, I tried like below ``` select case when status = 'R' then 'Resign' when status = 'A' then 'Active' end as status1, Program_name + ' ' + emp_card_no as program_details, * from GetEmployeeDetails where emp_name = 'ABHAY ASHOK MANE' and STATUS = 'A' order by EMP_NAME ``` but I am getting an error: > > Error converting data type varchar to numeric. > > > Here is the sample data available [![img](https://i.stack.imgur.com/k9Ks0.png)](https://i.stack.imgur.com/k9Ks0.png)
2016/08/26
[ "https://Stackoverflow.com/questions/39164187", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1216804/" ]
Try this : ``` select case when status='R' then 'Resign' when status='A' then 'Active' end as status1, Program_name + ' (' + convert(varchar, emp_card_no) + ') ' as program_details, * from GetEmployeeDetails Where emp_name ='ABHAY ASHOK MANE'and STATUS= 'A' ORDER BY EMP_NAME ```
column combination can be done for string type values. so you have to convert columns into varchar data type if not. Below is your solution with **one improvement in case statement.** ``` select case status when 'R' then 'Resign' when 'A' then 'Active' end as status1, Program_name + ' ' + convert(varchar(50),emp_card_no) as program_details, * from GetEmployeeDetails where emp_name = 'ABHAY ASHOK MANE' and STATUS = 'A' order by EMP_NAME ```
39,164,187
I have two columns which I want to combine and show the data, I tried like below ``` select case when status = 'R' then 'Resign' when status = 'A' then 'Active' end as status1, Program_name + ' ' + emp_card_no as program_details, * from GetEmployeeDetails where emp_name = 'ABHAY ASHOK MANE' and STATUS = 'A' order by EMP_NAME ``` but I am getting an error: > > Error converting data type varchar to numeric. > > > Here is the sample data available [![img](https://i.stack.imgur.com/k9Ks0.png)](https://i.stack.imgur.com/k9Ks0.png)
2016/08/26
[ "https://Stackoverflow.com/questions/39164187", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1216804/" ]
If you need parentheses, use following: ``` select case when status='R' then 'Resign' when status='A' then 'Active' end as status1, Program_name + ' (' + convert(varchar(10), emp_card_no)+')' as program_details, * from GetEmployeeDetails Where emp_name ='ABHAY ASHOK MANE'and STATUS= 'A' ORDER BY EMP_NAME ```
You can use concat which will convert internally.. ``` select case when status='R' then 'Resign' when status='A' then 'Active' end as status1, concat(Program_name, ' ', emp_card_no) as program_details, * from GetEmployeeDetails Where emp_name ='ABHAY ASHOK MANE'and STATUS= 'A' ORDER BY EMP_NAME ```
39,164,187
I have two columns which I want to combine and show the data, I tried like below ``` select case when status = 'R' then 'Resign' when status = 'A' then 'Active' end as status1, Program_name + ' ' + emp_card_no as program_details, * from GetEmployeeDetails where emp_name = 'ABHAY ASHOK MANE' and STATUS = 'A' order by EMP_NAME ``` but I am getting an error: > > Error converting data type varchar to numeric. > > > Here is the sample data available [![img](https://i.stack.imgur.com/k9Ks0.png)](https://i.stack.imgur.com/k9Ks0.png)
2016/08/26
[ "https://Stackoverflow.com/questions/39164187", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1216804/" ]
If you need parentheses, use following: ``` select case when status='R' then 'Resign' when status='A' then 'Active' end as status1, Program_name + ' (' + convert(varchar(10), emp_card_no)+')' as program_details, * from GetEmployeeDetails Where emp_name ='ABHAY ASHOK MANE'and STATUS= 'A' ORDER BY EMP_NAME ```
column combination can be done for string type values. so you have to convert columns into varchar data type if not. Below is your solution with **one improvement in case statement.** ``` select case status when 'R' then 'Resign' when 'A' then 'Active' end as status1, Program_name + ' ' + convert(varchar(50),emp_card_no) as program_details, * from GetEmployeeDetails where emp_name = 'ABHAY ASHOK MANE' and STATUS = 'A' order by EMP_NAME ```
39,164,187
I have two columns which I want to combine and show the data, I tried like below ``` select case when status = 'R' then 'Resign' when status = 'A' then 'Active' end as status1, Program_name + ' ' + emp_card_no as program_details, * from GetEmployeeDetails where emp_name = 'ABHAY ASHOK MANE' and STATUS = 'A' order by EMP_NAME ``` but I am getting an error: > > Error converting data type varchar to numeric. > > > Here is the sample data available [![img](https://i.stack.imgur.com/k9Ks0.png)](https://i.stack.imgur.com/k9Ks0.png)
2016/08/26
[ "https://Stackoverflow.com/questions/39164187", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1216804/" ]
**CAST** Int value column to VARCHAR: In your query **cast emp\_card\_no** to VARCHAR ``` select case when status='R' then 'Resign' when status='A' then 'Active' end as status1, [Program_name] + ' ' + CAST(emp_card_no AS VARCHAR(50)) as program_details, * from GetEmployeeDetails Where emp_name ='ABHAY ASHOK MANE'and STATUS= 'A' ORDER BY EMP_NAME ```
You can use concat which will convert internally.. ``` select case when status='R' then 'Resign' when status='A' then 'Active' end as status1, concat(Program_name, ' ', emp_card_no) as program_details, * from GetEmployeeDetails Where emp_name ='ABHAY ASHOK MANE'and STATUS= 'A' ORDER BY EMP_NAME ```
39,164,187
I have two columns which I want to combine and show the data, I tried like below ``` select case when status = 'R' then 'Resign' when status = 'A' then 'Active' end as status1, Program_name + ' ' + emp_card_no as program_details, * from GetEmployeeDetails where emp_name = 'ABHAY ASHOK MANE' and STATUS = 'A' order by EMP_NAME ``` but I am getting an error: > > Error converting data type varchar to numeric. > > > Here is the sample data available [![img](https://i.stack.imgur.com/k9Ks0.png)](https://i.stack.imgur.com/k9Ks0.png)
2016/08/26
[ "https://Stackoverflow.com/questions/39164187", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1216804/" ]
**CAST** Int value column to VARCHAR: In your query **cast emp\_card\_no** to VARCHAR ``` select case when status='R' then 'Resign' when status='A' then 'Active' end as status1, [Program_name] + ' ' + CAST(emp_card_no AS VARCHAR(50)) as program_details, * from GetEmployeeDetails Where emp_name ='ABHAY ASHOK MANE'and STATUS= 'A' ORDER BY EMP_NAME ```
column combination can be done for string type values. so you have to convert columns into varchar data type if not. Below is your solution with **one improvement in case statement.** ``` select case status when 'R' then 'Resign' when 'A' then 'Active' end as status1, Program_name + ' ' + convert(varchar(50),emp_card_no) as program_details, * from GetEmployeeDetails where emp_name = 'ABHAY ASHOK MANE' and STATUS = 'A' order by EMP_NAME ```
39,164,187
I have two columns which I want to combine and show the data, I tried like below ``` select case when status = 'R' then 'Resign' when status = 'A' then 'Active' end as status1, Program_name + ' ' + emp_card_no as program_details, * from GetEmployeeDetails where emp_name = 'ABHAY ASHOK MANE' and STATUS = 'A' order by EMP_NAME ``` but I am getting an error: > > Error converting data type varchar to numeric. > > > Here is the sample data available [![img](https://i.stack.imgur.com/k9Ks0.png)](https://i.stack.imgur.com/k9Ks0.png)
2016/08/26
[ "https://Stackoverflow.com/questions/39164187", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1216804/" ]
You can use concat which will convert internally.. ``` select case when status='R' then 'Resign' when status='A' then 'Active' end as status1, concat(Program_name, ' ', emp_card_no) as program_details, * from GetEmployeeDetails Where emp_name ='ABHAY ASHOK MANE'and STATUS= 'A' ORDER BY EMP_NAME ```
column combination can be done for string type values. so you have to convert columns into varchar data type if not. Below is your solution with **one improvement in case statement.** ``` select case status when 'R' then 'Resign' when 'A' then 'Active' end as status1, Program_name + ' ' + convert(varchar(50),emp_card_no) as program_details, * from GetEmployeeDetails where emp_name = 'ABHAY ASHOK MANE' and STATUS = 'A' order by EMP_NAME ```
11,851,938
So I have a page with about 60 of links on it, with random URL's, each one needs to be clicked and downloaded individually. I'm working on the fundamental script to tab over to the next link, hit enter, and then 'ok' to download to desktop. I'm new, but I cannot seem to get the 'floating' window which pops up, to let me keystroke 'return' or click on 'OK'. I'm looking to save the file to desktop, but I can't seem to reference the window by title in the app, or guess the index number or window ID. Any help is much appreciated.. I've also seen the dictionary, in script editor, and many of the properties of 'window' for Firefox, throw syntax and other errors. ``` tell application "System Events" tell application "Firefox" to activate tell window "$thewindowtitle" keystroke tab delay 1.0 keystroke return end tell tell application "Firefox" tell window visible click button "OK" end tell end tell end tell end tell ``` Thanks!
2012/08/07
[ "https://Stackoverflow.com/questions/11851938", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1169758/" ]
Try passing `fastIframe: false` in the colorbox configuration. It makes colorbox wait until all contents of the iframe are loaded before attempting to show anything. ``` $('a').colorbox({ iframe: true, fastIframe: false }); ```
The white flash is the result of colorbox dynamically generating the iframe. While the iframe is loading you see the background color of the colorbox window itself. One way to solve this issue is to use the "black" colorbox css styles as demonstrated in [this jsfiddle](http://jsfiddle.net/XSzq5/4/embedded/result/). You can find this colorbox.css file in the "Example 3" folder when you [download colorbox](http://www.jacklmoore.com/colorbox). Using this style you will of course see a black flash rather than and white flash, but it blends in better with the translucent black of the colorbox overlay. Alternatively you can customize the colorbox.css file that's best suited to your needs. There's 5 prebuilt styles, which you can see demonstrated at the official colorbox site.
17,702,895
I have the following code in a batch file: ``` set /p user="Enter username: " %=% cd w:\Files @echo off setLocal EnableDelayedExpansion set /a value=0 set /a sum=0 set /a valA=0 FOR /R %1 %%I IN (*) DO ( set /a value=%%~zI/1024 set /a sum=!sum!+!value! set /a sum=!sum!/1024 ) @echo Size of "FILES" is: !sum! MB @echo off FOR /R %1 %%I IN (*) DO ( set /a sum=!sum!/1024 set /a valA=!sum! ) @echo Size of "FILES" is: !sum! GB cd W:\Documents and Settings\%user%\Desktop @echo off setLocal EnableDelayedExpansion set /a value=0 set /a sum=0 set /a valB=0 FOR /R %1 %%I IN (*) DO ( set /a value=%%~zI/1024 set /a sum=!sum!+!value! set /a sum=!sum!/1024 ) @echo Size of Desktop is: !sum! MB @echo off FOR /R %1 %%I IN (*) DO ( set /a sum=!sum!/1024 set /a valB=!sum! ) @echo Size of Desktop is: !sum! GB ``` There are a few other folders it checks, but you should get the idea. I get this output: ``` C:\Users\pprescott\Desktop>cd w:\Files Size of "FILES" is: 215 MB Size of "FILES" is: 0 GB Size of Desktop is: 215 MB Size of Desktop is: 0 GB Size of Favorites is: 215 MB Size of Favorites is: 0 GB Size of Documents is: 215 MB Size of Documents is: 0 GB Total size is: 0 MB Total size is: 0 GB Press any key to continue . . . ``` This is designed to count folder size on an old xp machine to prepare for a data transfer. The xp machine is mapped to drive W.
2013/07/17
[ "https://Stackoverflow.com/questions/17702895", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2252537/" ]
try to remove the `for /r` parameter `%1`: ``` FOR /R %%I IN (*) DO ( ``` --- Try this code: ``` @ECHO OFF &SETLOCAL FOR /R "w:\Files" %%I IN (*) DO set /a asum+=%%~zI SET /a sum=asum/1048576 echo Size of "FILES" is: %sum% MB set /a sum=asum/1073741824 echo Size of "FILES" is: %sum% GB FOR /R "W:\Documents and Settings\%user%\Desktop" %%I IN (*) DO set /a asum+=%%~zI SET /a sum=asum/1048576 echo Size of "DESKTOP" is: %sum% MB set /a sum=asum/1073741824 echo Size of "DESKTOP" is: %sum% GB ```
Use the `dir` command output. See this example This will take the folder size and convert it into the different values. Note that the conversion only works for numeric values up to 2 gigabytes. ``` @echo off for /f "tokens=3" %%A IN ('dir /s /-c ^| find /i "bytes" ^| find /v /i "free"') do set T=%%A echo Bytes = %T% set /a T/=1024 echo Kilobytes = %T% set /a T/=1024 echo Megabytes = %T% set /a T/=1024 echo Gigabytes = %T% ``` Output: ``` C:\Users\User\Desktop>Test.bat Bytes = 18280552 Kilobytes = 17852 Megabytes = 17 Gigabytes = 0 ```
17,702,895
I have the following code in a batch file: ``` set /p user="Enter username: " %=% cd w:\Files @echo off setLocal EnableDelayedExpansion set /a value=0 set /a sum=0 set /a valA=0 FOR /R %1 %%I IN (*) DO ( set /a value=%%~zI/1024 set /a sum=!sum!+!value! set /a sum=!sum!/1024 ) @echo Size of "FILES" is: !sum! MB @echo off FOR /R %1 %%I IN (*) DO ( set /a sum=!sum!/1024 set /a valA=!sum! ) @echo Size of "FILES" is: !sum! GB cd W:\Documents and Settings\%user%\Desktop @echo off setLocal EnableDelayedExpansion set /a value=0 set /a sum=0 set /a valB=0 FOR /R %1 %%I IN (*) DO ( set /a value=%%~zI/1024 set /a sum=!sum!+!value! set /a sum=!sum!/1024 ) @echo Size of Desktop is: !sum! MB @echo off FOR /R %1 %%I IN (*) DO ( set /a sum=!sum!/1024 set /a valB=!sum! ) @echo Size of Desktop is: !sum! GB ``` There are a few other folders it checks, but you should get the idea. I get this output: ``` C:\Users\pprescott\Desktop>cd w:\Files Size of "FILES" is: 215 MB Size of "FILES" is: 0 GB Size of Desktop is: 215 MB Size of Desktop is: 0 GB Size of Favorites is: 215 MB Size of Favorites is: 0 GB Size of Documents is: 215 MB Size of Documents is: 0 GB Total size is: 0 MB Total size is: 0 GB Press any key to continue . . . ``` This is designed to count folder size on an old xp machine to prepare for a data transfer. The xp machine is mapped to drive W.
2013/07/17
[ "https://Stackoverflow.com/questions/17702895", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2252537/" ]
try to remove the `for /r` parameter `%1`: ``` FOR /R %%I IN (*) DO ( ``` --- Try this code: ``` @ECHO OFF &SETLOCAL FOR /R "w:\Files" %%I IN (*) DO set /a asum+=%%~zI SET /a sum=asum/1048576 echo Size of "FILES" is: %sum% MB set /a sum=asum/1073741824 echo Size of "FILES" is: %sum% GB FOR /R "W:\Documents and Settings\%user%\Desktop" %%I IN (*) DO set /a asum+=%%~zI SET /a sum=asum/1048576 echo Size of "DESKTOP" is: %sum% MB set /a sum=asum/1073741824 echo Size of "DESKTOP" is: %sum% GB ```
This should report the size of the trees in bytes up to 999 GB. The lower answer uses a VBS script to convert the numbers to GB (dropping decimals) ``` @echo off call :size "w:\Files" call :size "W:\Documents and Settings\%user%\Desktop" pause goto :eof :size for /f "tokens=3" %%b in ('dir /s "%~1" 2^>nul ^|find " File(s) "') do set "n=%%b" for /f "tokens=1-4 delims=," %%c in ("%n%") do ( echo %%c%%d%%e%%f "%~1" ) ) ``` Solution to return approx GB figures ``` @echo off call :size "w:\Files" call :size "W:\Documents and Settings\%user%\Desktop" pause goto :eof :size for /f "tokens=3" %%b in ('dir /s "%~1" 2^>nul ^|find " File(s) "') do set "n=%%b" for /f "tokens=1-4 delims=," %%c in ("%n%") do ( >"%temp%\VBS.vbs" echo Set fso = CreateObject^("Scripting.FileSystemObject"^) : Wscript.echo ^(%%c%%d%%e%%f/1024/1024^) for /f "tokens=1 delims=." %%z in ('cscript /nologo "%temp%\VBS.vbs"') do echo %%z GB "%~1" del "%temp%\VBS.vbs" ) ) ```
24,809,965
I noticed a weird thing when I was writing an angular directive. In the isolated scope of the directive, if I bind an attribute using `myAttr: '@'` to the parent scope variable with the same name, and then use that attribute in the html template, there will be an extra space trailing the attribute value. If the attribute is bound to the parent scope variable with a different name using `myAttr: '@thatAttr'`, however, there is no extra space and the world is happy. Please see [this jsFiddle](http://jsfiddle.net/EEpv2/2/) for a demonstration. As you can see, the css rules under `div[bad=foo]` is not applied because of the extra space, while `div[good=bar]` is perfectly fine. The fiddle uses Angular 1.3 by the way. Does anyone know why this is the case?
2014/07/17
[ "https://Stackoverflow.com/questions/24809965", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1264587/" ]
[Known bug](https://github.com/angular/angular.js/issues/8132) in Angular, likely will not be fixed
I had a similar problem - I added "@id" as an attribute in m Directive. That worked - however it inserted me an additional blank space at the end of the id value. It turned out that Angular takes over the id by default! After removing "@id" from the scope attributes of my directive, I could use "{{id}}" without any problems.
9,675
I am starting some tests for building a game on the Android program. So far everything is working and seems nice. However I do not understand how to make sure my game looks correct on all phones as they all will have slightly different screen ratios (and even very different on some odd phones) What I am doing right now is making a view frustum (could also be ortho) which I set to go from -ratio to +ratio (as I have seen on many examples) however this causes my test shape to be stretched and sometimes cut off by the edge of the screen. I am tilting my phone to landscape to do my tests (a bit extreme) but it should still render correctly if I have done things right. Should I be scaling by some ratio before drawing or something? An example would be greatly appreciated. PS. I am doing a 2D game .
2011/03/12
[ "https://gamedev.stackexchange.com/questions/9675", "https://gamedev.stackexchange.com", "https://gamedev.stackexchange.com/users/6053/" ]
From a high-level perspective there's only a handful of options, depending on which is more important, maintaining a consistent aspect ratio, or ensuring that no one to see more than someone else just because they have a wider or taller screen. Your options are: 1. Cropping the parts that don't fit. 2. Stretching the screen to fit, which has the issue you're seeing of stretched images. 3. "[Letterboxing](http://en.wikipedia.org/wiki/Letterbox)" which maintains both aspect ratio and ensures that no player sees more than any other player because of their screen size,
The ratio you're referring to is called the 'aspect ratio'. It is usually calculated as the 'width / height' (although if you arranged your viewport differently that could be 'height / width') Remember to cast the divisor to a float! ``` float aspect_ratio = width / (float) height; ``` HTH
9,675
I am starting some tests for building a game on the Android program. So far everything is working and seems nice. However I do not understand how to make sure my game looks correct on all phones as they all will have slightly different screen ratios (and even very different on some odd phones) What I am doing right now is making a view frustum (could also be ortho) which I set to go from -ratio to +ratio (as I have seen on many examples) however this causes my test shape to be stretched and sometimes cut off by the edge of the screen. I am tilting my phone to landscape to do my tests (a bit extreme) but it should still render correctly if I have done things right. Should I be scaling by some ratio before drawing or something? An example would be greatly appreciated. PS. I am doing a 2D game .
2011/03/12
[ "https://gamedev.stackexchange.com/questions/9675", "https://gamedev.stackexchange.com", "https://gamedev.stackexchange.com/users/6053/" ]
The 3 options from Davy8's answer are: * Cropping the parts that don't fit. * Stretching the screen to fit, which has the issue you're seeing of stretched images. * "Letterboxing" which maintains both aspect ratio and ensures that no player sees more than any other player because of their screen size I would add a fourth option, which is my preferred approach. It's really a variation on letterboxing; traditional letterboxing fills the extra space with black, whereas this approach fills the extra space with extra graphics. You could simply extend the background color/image and possibly show an extra logo. Another way to think about it is that I always crop the screen for every display, and the full display is purposely designed to be bigger than all mobile displays/aspect ratios. Thus there's always extra graphics to fill out the letterboxed area. In addition, depending on the nature of your game (ie. would this change give certain players an unfair advantage?) and on how your UI is designed you could even shift over some UI elements to fill the extra space. Think of it like a fluid website design, where the right menu stays on the right no matter how wide the window is.
The ratio you're referring to is called the 'aspect ratio'. It is usually calculated as the 'width / height' (although if you arranged your viewport differently that could be 'height / width') Remember to cast the divisor to a float! ``` float aspect_ratio = width / (float) height; ``` HTH
9,675
I am starting some tests for building a game on the Android program. So far everything is working and seems nice. However I do not understand how to make sure my game looks correct on all phones as they all will have slightly different screen ratios (and even very different on some odd phones) What I am doing right now is making a view frustum (could also be ortho) which I set to go from -ratio to +ratio (as I have seen on many examples) however this causes my test shape to be stretched and sometimes cut off by the edge of the screen. I am tilting my phone to landscape to do my tests (a bit extreme) but it should still render correctly if I have done things right. Should I be scaling by some ratio before drawing or something? An example would be greatly appreciated. PS. I am doing a 2D game .
2011/03/12
[ "https://gamedev.stackexchange.com/questions/9675", "https://gamedev.stackexchange.com", "https://gamedev.stackexchange.com/users/6053/" ]
From a high-level perspective there's only a handful of options, depending on which is more important, maintaining a consistent aspect ratio, or ensuring that no one to see more than someone else just because they have a wider or taller screen. Your options are: 1. Cropping the parts that don't fit. 2. Stretching the screen to fit, which has the issue you're seeing of stretched images. 3. "[Letterboxing](http://en.wikipedia.org/wiki/Letterbox)" which maintains both aspect ratio and ensures that no player sees more than any other player because of their screen size,
The 3 options from Davy8's answer are: * Cropping the parts that don't fit. * Stretching the screen to fit, which has the issue you're seeing of stretched images. * "Letterboxing" which maintains both aspect ratio and ensures that no player sees more than any other player because of their screen size I would add a fourth option, which is my preferred approach. It's really a variation on letterboxing; traditional letterboxing fills the extra space with black, whereas this approach fills the extra space with extra graphics. You could simply extend the background color/image and possibly show an extra logo. Another way to think about it is that I always crop the screen for every display, and the full display is purposely designed to be bigger than all mobile displays/aspect ratios. Thus there's always extra graphics to fill out the letterboxed area. In addition, depending on the nature of your game (ie. would this change give certain players an unfair advantage?) and on how your UI is designed you could even shift over some UI elements to fill the extra space. Think of it like a fluid website design, where the right menu stays on the right no matter how wide the window is.
52,443,412
i have to insert data with ajax into database, now it insert data in to database,but not upload the image. **ajax Code** ``` $(document).on("click","#save", function(){ jQuery.ajax({ method :'post', url:''+APP_URL+'/products/add_product', data:$("#product_form").serialize(), success: function(response){ $("#product_list").load("<?php echo url('products/tblproducts');?>").fadeIn("slow") } }); }); ``` "product\_form" is ID of form. **Route** ``` Route::post('products/add_product','admin\ProductsController@add_new_product'); ``` **Controller Function** ``` public function add_new_product(Request $request){ try{ DB::beginTransaction(); $product_image = NULL; if ($request->hasFile('product_photo')){ $ext = $request->product_image->getClientOriginalExtension(); $product_image = uniqid().".".$ext; $file = $request->file('product_image'); $destinationPath = public_path("products"); $file->move($destinationPath, $product_image); } $bdata['product_photo']=$product_image; $bdata['product_name']= $request->item_name; $bdata['product_barcode']= $request->barcode; DB::table('tbl_products')->insert($bdata); DB::commit(); $this->CreateMessages('add'); }catch(\Exception $v){ DB::rollback(); $this->CreateMessages('not_added'); throw $v; } ``` }
2018/09/21
[ "https://Stackoverflow.com/questions/52443412", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8648172/" ]
``` Try below code to upload image: `$(document).on("click","#save", function(){ var fd = new FormData(); fd.append('product_photo',$('#id_of_image_uploader').prop('files')[0]); fd.append('item_name', $('#id_of_item_name').val()); fd.append('barcode', $('#id_of_barcode').val()); jQuery.ajax({ method :'post', url:''+APP_URL+'/products/add_product', data: fd, cache: false, contentType: false, processData: false, success: function(response){ $("#product_list").load("<?php echo url('products/tblproducts');?>").fadeIn("slow") } }); });` ```
You have to modify: ``` data:$("#product_form").serialize() ``` To become: ``` data: new FormData("#product_form") ``` And your form must have the `enctype` attribute set to `multipart/form-data`.
52,443,412
i have to insert data with ajax into database, now it insert data in to database,but not upload the image. **ajax Code** ``` $(document).on("click","#save", function(){ jQuery.ajax({ method :'post', url:''+APP_URL+'/products/add_product', data:$("#product_form").serialize(), success: function(response){ $("#product_list").load("<?php echo url('products/tblproducts');?>").fadeIn("slow") } }); }); ``` "product\_form" is ID of form. **Route** ``` Route::post('products/add_product','admin\ProductsController@add_new_product'); ``` **Controller Function** ``` public function add_new_product(Request $request){ try{ DB::beginTransaction(); $product_image = NULL; if ($request->hasFile('product_photo')){ $ext = $request->product_image->getClientOriginalExtension(); $product_image = uniqid().".".$ext; $file = $request->file('product_image'); $destinationPath = public_path("products"); $file->move($destinationPath, $product_image); } $bdata['product_photo']=$product_image; $bdata['product_name']= $request->item_name; $bdata['product_barcode']= $request->barcode; DB::table('tbl_products')->insert($bdata); DB::commit(); $this->CreateMessages('add'); }catch(\Exception $v){ DB::rollback(); $this->CreateMessages('not_added'); throw $v; } ``` }
2018/09/21
[ "https://Stackoverflow.com/questions/52443412", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8648172/" ]
``` Try below code to upload image: `$(document).on("click","#save", function(){ var fd = new FormData(); fd.append('product_photo',$('#id_of_image_uploader').prop('files')[0]); fd.append('item_name', $('#id_of_item_name').val()); fd.append('barcode', $('#id_of_barcode').val()); jQuery.ajax({ method :'post', url:''+APP_URL+'/products/add_product', data: fd, cache: false, contentType: false, processData: false, success: function(response){ $("#product_list").load("<?php echo url('products/tblproducts');?>").fadeIn("slow") } }); });` ```
you can upload image and serialize form data as the following: ``` <script> var formData = new FormData($("#FormId")[0]); $.ajax({ url:''+APP_URL+'/products/add_product', type: "POST", data: formData, processData: false, contentType: false, dataType: 'application/json', headers: { 'X-CSRF-TOKEN': "{{ csrf_token() }}" }, success: function (data, textStatus, jqXHR) { // do what you want }, error: function (jqXHR, textStatus, errorThrown) { } }); </script> ```
73,750,583
Here's what i have at the moment: ``` let userTeams = ['Liverpool', 'Manchester City', 'Manchester United']; let object = { teams: { 'Liverpool': { player: ['Salah', 'Nunez'] }, 'Manchester United': { player: ['Ronaldo', 'Rashford'] }, 'Manchester City': { player: ['Haaland', 'Foden'] }, }, }; let userTeam = userTeams[Math.floor(Math.random() * 3)]; ``` I need the team selection to be directly but randomly from the object rather than from the userTeams array. How would i go about that?
2022/09/16
[ "https://Stackoverflow.com/questions/73750583", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17265256/" ]
I'm guessing that the OP really aims to get a random team name (key) and that team's data (value) in an object. Abstractly, in a few steps: Here's how to get a random element from an array: ``` const randomElement = array => array[Math.floor(Math.random()*array.length)]; ``` That can be used to get a random key from an object: ``` const randomKey = object => randomElement(Object.keys(object)); ``` And that can be used to get a random key-value pair: ``` const randomKeyValue = object => { const key = randomKey(object); return { [key] : object[key] }; }; ``` All together: ```js let object = { teams: { 'Liverpool': { player: ['Salah', 'Nunez'] }, 'Manchester United': { player: ['Ronaldo', 'Rashford'] }, 'Manchester City': { player: ['Haaland', 'Foden'] }, }, }; const randomElement = array => array[Math.floor(Math.random() * array.length)]; const randomKey = object => randomElement(Object.keys(object)); const randomKeyValue = object => { const key = randomKey(object); return { [key]: object[key] }; }; console.log(randomKeyValue(object.teams)) ```
You can use random on the array which is the keys (or values) of `object.teams` ```js let object = { teams: { 'Liverpool': { player: ['Salah', 'Nunez' ] }, 'Manchester United': { player: ['Ronaldo', 'Rashford' ] }, 'Manchester City': { player: ['Haaland', 'Foden' ] }, }, }; var teams = Object.values(object.teams); let userTeam = teams[Math.floor(Math.random() * teams.length)]; console.log(userTeam); ```
33,973,634
I am getting some peculiar behavior in Firefox with localForage. I set up a page to load two arrays using the standard 'setItem' form: ``` <script src="localforage.js"></script> <body> <script> var data = [1,2,3,4,5]; localforage.setItem("saveData", data, function(err, value) { if (err) { console.error('error: ', err); } else { console.log("Data Saved"); }}); localforage.getItem("saveData", function (err, value) { if (err) { console.error('error: ', err); } else { console.log('saveData is: ', value); localforage.keys(function(err, keys) { console.log("Keys: " + keys); console.log("Number of keys: " + keys.length); }); }}); </script> </body> </html> ``` The array was saved correctly. I then made a second page, using exactly the same "getItem" function. In Chrome, the data showed up, but in Firefox it was not listed at all, and could not be opened. Has anyone else experienced this? In Firefox, even opening the second page in the same session fails to find the saved file. I have tried changing security.fileuri.strict\_origin\_policy, but it made no difference. I would rather use Firefox, but I can't if it keeps losing saved data.
2015/11/28
[ "https://Stackoverflow.com/questions/33973634", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4370702/" ]
I also had the same issue but solved it after some researching, trials and discussions. Extensions like FireStorage Plus! and simple session storage do not work flawlessly for detecting this data, especially if it is being performed on a page/file other than the original root page/file. The solution for me was to use the native FF Storage Inspector. Only then could I see ALL of the data I was missing. Those extensions did not show the data, even though it was being set. Refer to: [localForage setItem/getItem unreliable in Firefox / FireStorage Plus](https://stackoverflow.com/questions/36482778/localforage-setitem-getitem-unreliable-in-firefox-firestorage-plus) [![enter image description here](https://i.stack.imgur.com/LRGwz.png)](https://i.stack.imgur.com/LRGwz.png) In addition, **for future assistance with localForage issues, try their IRC chat** **#localforage** at <https://webchat.freenode.net/> and look for **tofumatt**. He is the guru you want to confer with. ^5
Are you testing this from `file://` as opposed to `http://`? I believe in Firefox you cannot access IndexedDB if you open an HTML page from `file://`. So in this case you would need to run an HTTP server – easiest way is to do `python -m SimpleHTTPServer 8080` and then go to `http://localhost:8080`. Chrome might be different.
279,840
Let's consider a function with evaluated and unevaluated arguments inside: ``` list1 = {1,2,3} list2 = {x,y,z} fun[list_]:={list,ToString@Unevaluated@list} ``` When I use Map over `fun` I expect to get result like this: ``` {fun[list1],fun[list2]} (*{{{1, 2, 3}, "list1"}, {{x, y, z}, "list2"}}*) ``` But instead I get this: ``` fun /@ {list1, list2} {{{1, 2, 3}, "{1, 2, 3}"}, {{x, y, z}, "{x, y, z}"}} ``` This is surely connected with my misunderstanding of evaluation behaviour, but no obvious answer was found in Robby Villegas notebook <https://library.wolfram.com/infocenter/Conferences/377/> , nor here in StackExchange. How to solve this problem? ver. 12.1, Windows 10 **EDIT** Setting attribute `Listable` help a bit making unnecessary to use `Map`: ``` SetAttributes[fun, {HoldAll, Listable}]; fun[{list1,list2}] `` (*{{{1, 2, 3}, "list1"}, {{x, y, z}, "list2"}} *) ```
2023/02/11
[ "https://mathematica.stackexchange.com/questions/279840", "https://mathematica.stackexchange.com", "https://mathematica.stackexchange.com/users/72560/" ]
``` sol1 = {#[[1]] - 172, #[[2]]} & /@ points ; sol2 = points - Threaded[{172, 0}]; sol3 = MapAt[Subtract[#, 172] &, points, {All, 1}]; sol4 = {#1 - 172, #2} & @@@ points; sol1 == sol2 == sol3 == sol4 (* True *) ```
Try the following variations: ``` TranslationTransform[{-172, 0}][points] SubsetMap[# - 172 &, points, {All, 1}] First@Last@Reap@Do[Sow[points[[i]] - {172, 0}], {i, 1, Length@points}] points - ConstantArray[{172, 0}, Length@points] ```
236,424
I have the data stored in the textfile like this: 0.5 0.5 -0.7 -0.8 0.51 0.51 -0.75 -0.85 0.6 0.1 0.1 1.00 and so on 4 numbers in each row. Two first numbers means coordinates (x0,y0), two last - (x1,y1). This determines the coordinates of a line. So, the first row tells, that I have a line starting from (0.5, 0.5) and finishing in (-0.7, -0.8). The aim is to plot all of these lines. How can I do this? Explain it for beginner, please.
2020/12/12
[ "https://mathematica.stackexchange.com/questions/236424", "https://mathematica.stackexchange.com", "https://mathematica.stackexchange.com/users/76234/" ]
``` data = Import["/Users/roberthanlon/Downloads/lines.txt", "Data"] (* {{0.5, 0.5, -0.7, -0.8}, {0.51, 0.51, -0.75, -0.85}, {0.6, 0.1, 0.1, 1.}} *) Graphics[Line /@ (Partition[#, 2] & /@ data), Axes -> True] ``` [![enter image description here](https://i.stack.imgur.com/vTHRm.png)](https://i.stack.imgur.com/vTHRm.png) Highlight any function or operator and press `F1` for help.
This is another way to do it: ``` data = ImportString[ "0.5 0.5 -0.7 -0.8 0.51 0.51 -0.75 -0.85 0.6 0.1 0.1 1.00", "Table"] ``` ``` Graphics[ Table[ Line[Partition[row, 2]], {row, data} ] ] ``` Try each piece of the code separately to see what it does (this applies to all situations when you are trying to understand some code). For example, try these and observe the output: ``` Partition[{0.5, 0.5, -0.7, -0.8}, 2] ``` ``` Table[ f[row], {row, data} ] ``` ``` Table[ Line[Partition[row, 2]], {row, data} ] ```
236,424
I have the data stored in the textfile like this: 0.5 0.5 -0.7 -0.8 0.51 0.51 -0.75 -0.85 0.6 0.1 0.1 1.00 and so on 4 numbers in each row. Two first numbers means coordinates (x0,y0), two last - (x1,y1). This determines the coordinates of a line. So, the first row tells, that I have a line starting from (0.5, 0.5) and finishing in (-0.7, -0.8). The aim is to plot all of these lines. How can I do this? Explain it for beginner, please.
2020/12/12
[ "https://mathematica.stackexchange.com/questions/236424", "https://mathematica.stackexchange.com", "https://mathematica.stackexchange.com/users/76234/" ]
You can use `"Table"` to keep the structure of your data. And then you define a function `Line[{{#1, #2}, {#3, #4}}]&` to draw the `Line` by two points `{#1,#2}` and `{#3,#4}`. ``` 0.5 0.5 -0.7 -0.8 0.51 0.51 -0.75 -0.85 0.6 0.1 0.1 1.00 ``` ``` data = Import["data.txt", "Table"] (* {{0.5, 0.5, -0.7, -0.8}, {0.51, 0.51, -0.75, -0.85}, {0.6, 0.1, 0.1, 1.}} *) Graphics[Line[{{#1, #2}, {#3, #4}}] & @@@ data] ``` [![enter image description here](https://i.stack.imgur.com/aGFZ4.png)](https://i.stack.imgur.com/aGFZ4.png)
This is another way to do it: ``` data = ImportString[ "0.5 0.5 -0.7 -0.8 0.51 0.51 -0.75 -0.85 0.6 0.1 0.1 1.00", "Table"] ``` ``` Graphics[ Table[ Line[Partition[row, 2]], {row, data} ] ] ``` Try each piece of the code separately to see what it does (this applies to all situations when you are trying to understand some code). For example, try these and observe the output: ``` Partition[{0.5, 0.5, -0.7, -0.8}, 2] ``` ``` Table[ f[row], {row, data} ] ``` ``` Table[ Line[Partition[row, 2]], {row, data} ] ```
272,779
I wrote an answer to this question on [Distinct States](https://physics.stackexchange.com/questions/272556/schroeders-thermal-physics-multiplicity-of-a-single-ideal-gas-molecule/272585#272585), but I am not happy with the answer I gave to the short question at the end. Hopefully this question is self contained, but please read the link above for full details, thanks. The problem is set in momentum space, and deals with the multiplicity of a monotonic ideal gas. From my textbook: > > The number of independent wavefunctions is finite, if the total available position space and momentum space are limited. > > > [![enter image description here](https://i.stack.imgur.com/5DU6Q.jpg)](https://i.stack.imgur.com/5DU6Q.jpg) L/$\Delta x$ is the number of distinct position states and L$\_p$/$\Delta p$ is the number of distinct momentum states, (in a 1 dimensional system). The total number of distinct states is the product: $\frac {L} {\Delta (x)}$$\frac {L\_p} {\Delta (p )}$ =$\frac {LL\_p} {h}$ Using the uncertainty principle. My question is, what does this physically represent? I am fairly familiar with Q.M., it is the momentum space concepts in thermodynamics that I am just starting to study. My interpretation is that it simply represents the fact the particle could be at any distinct position within the space, and can have a distinct momentum at that position. So $X = 5$, $P = 7$, or any other combination of these distinct variables. I self study, (with no one else to check with, so please excuse the confirm my idea aspect). If it's as simple as that explanation, I shall be excruciatingly embarrassed, but at least happy that I have it sorted out.
2016/08/05
[ "https://physics.stackexchange.com/questions/272779", "https://physics.stackexchange.com", "https://physics.stackexchange.com/users/-1/" ]
**OBJECTIVE:** **how to Wick rotate a path integral using Cauchy's theorem**. I like the approach of using Cauchy's theorem and I must admit I haven't seen the finite-time problem approached from this viewpoint before, so it seemed like a fun thing to think about (on this rainy Sunday afternoon!). When I started thinking about this I was more optimistic than I am now (it's now Wednesday). I start by stating my conclusions (details of all claims will follow): **1.** There is a local obstruction that enforces the quantity you call $$ e^{-i\int\_C dz\,\mathcal{L}(z)}, $$ to contribute non-trivially. This is the first hint that the whole approach is creating more problems than it solves. (There is an easier way to do the analytic continuation.) **2.** Your choice of contour does not make your life easy. If instead of the first quadrant you continued into the fourth quadrant of the complex-$z$ plane you would get the correct minus sign in the suppression factor (but not quite the expected integrand). [![correct contour](https://i.stack.imgur.com/2M6ng.png)](https://i.stack.imgur.com/2M6ng.png) **3.** The assumption of holomorphicity is justified, in that there exists a complete basis expansion for $\tilde{x}(t)$ (and its analytically continued extension, $\tilde{x}(z)$) such that the quantity: $$ \oint\_{L\_R}dz\,\mathcal{L}(z)+\oint\_{L\_I}dz\,\mathcal{L}(z)+\oint\_{C}dz\,\mathcal{L}(z), $$ indeed vanishes, so that the closed contour can be contracted to a point. **4.** Boundary conditions are important: it is the quantum fluctuations terms involving $\tilde{x}(t)$ that need continuing, not the zero mode (classical) piece, $x\_{\rm cl}(t)$, where $$ x(t)=x\_{\rm cl}(t)+\tilde{x}(t), $$ subject to $x\_{\rm cl}(0)=x\_i$, $x\_{\rm cl}(T)=x\_f$, $\tilde{x}(0)=\tilde{x}(T)=0$. The last two conditions make your life slightly easier. **5.** It is much more efficient and natural to analytically continue $\tilde{x}(t)$ in problems such as these, when there are finite time intervals involved. This is also true in QFT. **6.** When you expand $\tilde{x}(t)$ as a Fourier series subject to the above boundary conditions (I'm forgetting about interactions because these are irrelevant for Wick rotations, at least within perturbation theory), $$ \tilde{x}(t) = \sum\_{n\neq0}a\_n\psi\_n(t),\qquad {\rm with}\qquad \psi\_n(t)=\sqrt{\frac{2}{T}}\sin\frac{n\pi t}{T}, $$ it becomes clear that the (unique) analytically continued expression, obtained from the above by replacing $t\rightarrow z$, does not have a well-behaved basis: $\{\psi\_n(z)\}$ is no longer complete, nor orthonormal and in fact diverges for large enough $\beta$, where $z=t+i\beta$. But it is holomorphic within its radius of convergence, and then you might expect Cauchy's theorem to come to the rescue because for any closed contour: $$ \oint dz\,\psi\_n(z)\psi\_m(z)=0, $$ and so given that $\int\_0^Tdt\,\psi\_n(t)\psi\_m(t)=\delta\_{n,m}$ one can say something meaningful about the integrals in the remaining regions of the complex plane. And a comment (which is mainly addressed to some of the comments you have received @giulio bullsaver and @flippiefanus): the path integral is general enough to be able to capture both finite and infinite limits in your action of interest, in both QM and QFT. One complication is that sometimes it is not possible to define asymptotic states when the limits are finite (the usual notion of a particle only makes sense in the absence of interactions, and at infinity the separation between particles can usually be taken to be large enough so that interactions are turned off), and although this is no problem of principle one needs to work harder to make progress. In quantum mechanics where there is no particle creation things are simpler and one can consider a single particle state space. As I mentioned above this is just a taster: when I find some time I will add flesh to my claims. --- **DETAILS:** ------------ Consider the following path integral for a free non-relativistic particle: $$ \boxed{Z= \int \mathcal{D}x\,e^{\frac{i}{\hbar}\,I[x]},\qquad I[x]=\int\_0^Tdt\,\Big(\frac{dx}{dt}\Big)^2} $$ (We set the mass $m=2$ throughout to avoid unnecessary clutter, but I want to keep $\hbar$ explicit. We can restore $m$ at any point by replacing $\hbar\rightarrow \hbar 2/m$.) This path integral is clearly completely trivial. However, the question we are aiming to address (i.e. to understand Wick rotation in relation to Cauchy's theorem) is (within perturbation theory) independent of interactions. Stripping the problem down to its ''bare bones essentials'' will be sufficient. Here is my justification: **will not perform any manipulations that we would not be able to also perform in the presence of interactions within perturbation theory**. So this completely justifies considering the free theory. For pedagogical reasons I will first describe how to go about evaluating such path integrals unambiguously, including a detailed discussion of how to use Cauchy's theorem to make sense of the oscillating exponential, and only after we have reached a result will we discuss the problems associated to following the approach suggested in the question. **How to Wick Rotate Path Integrals Unambiguously:** To compute any path integral the first thing one needs to do is **specify boundary conditions**. So suppose our particle is at $x\_i=x(0)$ at $t=0$ and at $x\_f=x(T)$ at $t=T$. To implement these let us factor out a classical piece and quantum fluctuations: $$ x(t) = x\_{\rm cl}(t)+\tilde{x}(t), $$ and satisfy the boundary conditions by demanding that quantum fluctuations are turned off at $t=0$ and $t=T$: $$ \tilde{x}(0)=\tilde{x}(T)=0, $$ so the classical piece must then inherit the boundary conditions of $x(t)$: $$ x\_{\rm cl}(0)=x\_i,\qquad x\_{\rm cl}(T)=x\_f. $$ In addition to taking care of the boundary conditions, the decomposition into a classical piece and quantum fluctuations plays the following very important role: integrating out $x(t)$ requires that you be able to invert the operator $-d^2/dt^2$. This is only possible when what it acts on is not annihilated by it, i.e. when the eigenvalues of this operator are non-vanishing. We call the set of things that are annihilated by $-d^2/dt^2$ the *kernel of* $-d^2/dt^2$, so then the classical piece $x\_{\rm cl}(t)$ is precisely the kernel of $-d^2/dt^2$: \begin{equation} -\frac{d^2}{dt^2}x\_{\rm cl}(t)=0. \end{equation} This is of course precisely the classical equation of motion of a free non-relativistic particle with the unique solution (subject to the above boundary conditions): $$ x\_{\rm cl}(t) = \frac{x\_f-x\_i}{T}t+x\_i. $$ So now we implement the above into the path integral, starting from the action. The decomposition $x(t) = x\_{\rm cl}(t)+\tilde{x}(t)$ leads to: \begin{equation} \begin{aligned} I[x]&=\int\_0^Tdt\Big(\frac{dx}{dt}\Big)^2\\ &=\int\_0^Tdt\Big(\frac{dx\_{\rm cl}}{dt}\Big)^2+\int\_0^Tdt\Big(\frac{d\tilde{x}}{dt}\Big)^2+2\int\_0^Tdt\frac{dx\_{\rm cl}}{dt}\frac{d\tilde{x}}{dt}\\ \end{aligned} \end{equation} In the first term we substitute the solution to the equations of motion given above. In the second term we integrate by parts taking into account the boundary conditions on $\tilde{x}(t)$. In the third term we integrate by parts taking into account the boundary conditions on $\tilde{x}(t)$ and use the fact that $d^2x\_{\rm cl}/dt^2=0$ for all $t$. All in all, \begin{equation} I[x]=\frac{(x\_f-x\_i)^2}{T}+\int\_0^Tdt\,\tilde{x}(t)\Big(-\frac{d^2}{dt^2}\Big)\tilde{x}(t),\quad{\rm with}\quad \tilde{x}(0)=\tilde{x}(T)=0, \end{equation} and now we substitute this back into the path integral, $Z$, in order to consider the Wick rotation in detail: \begin{equation} \boxed{Z= e^{i(x\_f-x\_i)^2/\hbar T}\int \mathcal{D}\tilde{x}\,\exp\, \frac{i}{\hbar}\int\_0^T\!\!\!dt\,\tilde{x}(t)\Big(-\frac{d^2}{dt^2}\Big)\tilde{x}(t), \quad{\rm with}\quad \tilde{x}(0)=\tilde{x}(T)=0} \end{equation} Clearly, given that we have fixed the boundary values of $x(t)$, we also have that: $\mathcal{D}x=\mathcal{D}\tilde{x}$. That is, *we are only integrating over quantities that are not fixed by the boundary conditions on $x(t)$*. So the first point to notice is that only the quantum fluctuations piece might need Wick rotation. **Isolated comment:** Returning to a point I made in the beginning of the DETAILS section: if our objective was to simply solve the free particle theory we'd be (almost) done! We wouldn't even have to Wick-rotate. We would simply introduce a new time variable, $t\rightarrow t'=t/T$, and then redefine the path integral field at every point $t$, $\tilde{x}\rightarrow \tilde{x}'=\tilde{x}/\sqrt{T}$. The measure would then (using zeta function regularisation) transform as $\mathcal{D}\tilde{x}\rightarrow =\mathcal{D}\tilde{x}'=\sqrt{T}\mathcal{D}\tilde{x}$, so the result would be: $$ Z=\frac{N}{\sqrt{T}}e^{i(x\_f-x\_i)^2/\hbar T}, $$ the quantity $N$ being a normalisation (see below). But as I promised, we will not perform any manipulations that cannot also be performed in fully interacting theories (and within perturbation theory). So we take the long route. There is value in mentioning the shortcut however: it serves as an important consistency check for what follows. **Wick Rotation:** Consider the quantum fluctuations terms in the action, $$ \int\_0^T\!\!\!dt\,\tilde{x}(t)\Big(-\frac{d^2}{dt^2}\Big)\tilde{x}(t), \quad{\rm with}\quad \tilde{x}(0)=\tilde{x}(T)=0, $$ and search for a complete (and ideally orthonormal) basis, $\{\psi\_n(t)\}$, in which to expand $\tilde{x}(t)$. We can either think of such an expansion as a Fourier series expansion of $\tilde{x}(t)$ (where it is obvious the basis will be complete), or we can equivalently define the basis as the full set of eigenvectors of $-d^2/dt^2$. There are three requirements that the basis must satisfy (and a fourth optional one): **(a)** it must not live in the kernel of $-d^2/dt^2$ (the kernel has already been extracted out and called $x\_{\rm cl}(t)$). **(b)** it must be real (because $\tilde{x}(t)$ is real); **(c)** it must satisfy the correct boundary conditions inherited by $\tilde{x}(0)=\tilde{x}(T)=0$; **(d)** it is convenient for it to be orthonormal with respect to some natural inner product, $(\psi\_n,\psi\_m)=\delta\_{n,m}$, but this is not necessary. The unique (up to a constant factor) solution satisfying these requirements is: $$ \tilde{x}(t)=\sum\_{n\neq0}a\_n\psi\_n(t),\qquad {\rm with}\qquad \psi\_n(t)=\sqrt{\frac{2}{T}}\sin \frac{n\pi t}{T}, $$ where the normalisation of $\psi\_n(t)$ is fixed by our *choice* of inner product: $$ (\psi\_n,\psi\_m)\equiv \int\_0^Tdt\,\psi\_n(t)\,\psi\_m(t)=\delta\_{n,m}. $$ (In the present context this is a natural inner product, but more generally and without referring to a particular basis, $(\delta \tilde{x},\delta \tilde{x})$ is such that it preserves as much of the classical symmetries as possible. Incidentally, not being able to find a natural inner product that preserves *all* of the classical symmetries is the source of potential anomalies.) This basis $\{\psi\_n(t)\}$ is real, orthonormal, satisfies the correct boundary conditions at $t=0,T$ and corresponds to a complete set of eigenvectors of $-d^2/dt^2$: $$ -\frac{d^2}{dt^2}\psi\_n(t)=\lambda\_n\psi\_n(t),\qquad {\rm with}\qquad \lambda\_n=\Big(\frac{n\pi}{T}\Big)^2. $$ From the explicit expression for $\lambda\_n$ it should be clear why $n=0$ has been omitted from the sum over $n$ in $\tilde{x}(t)$. To complete the story we need to define the **path integral measure**. I will mention two equivalent choices, starting from the pedagogical one: $$ \mathcal{D}\tilde{x}=\prod\_{n\neq0}\frac{d a\_n}{K}, $$ for some choice of $K$ which is fixed at a later stage by any of the, e.g., two methods mentioned below (we'll find $K=\sqrt{4T}$). (The second equivalent choice of measure is less transparent, but because it is more efficient it will also be mentioned below.) To evaluate the path integral we now rewrite the quantum fluctuations terms in $Z$ in terms of the basis expansion of $\tilde{x}(t)$, and make use of the above relations: \begin{equation} \begin{aligned} \int \mathcal{D}\tilde{x}\,&\exp\, \frac{i}{\hbar}\int\_0^T\!\!\!dt\,\tilde{x}(t)\Big(-\frac{d^2}{dt^2}\Big)\tilde{x}(t)\\ &=\int \prod\_{n\neq0}\frac{d a\_n}{K}\,\exp\, i\sum\_{n\neq0}\frac{1}{\hbar}\Big(\frac{n\pi}{T}\Big)^2a\_n^2\\ &=\prod\_{n\neq0}\Big( \frac{T\sqrt{\hbar}}{K\pi |n|}\Big)\prod\_{n\neq0}\Big(\int\_{-\infty}^{\infty} d a\,e^{ia^2}\Big), \end{aligned} \end{equation} where in the last equality we redefined the integration variables, $a\_n\rightarrow a=\frac{|n|\pi}{\sqrt{\hbar}T}a\_n$. The evaluation of the infinite products is somewhat tangential to the main point of thinking about Wick rotation, so I leave it as an **Exercise:** Use zeta function regularisation to show that: $$ \prod\_{n\neq0}c=\frac{1}{c},\qquad \prod\_{n\neq0}|n| = 2\pi, $$ for any $n$-independent quantity, $c$. (Hint: recall that $\zeta(s)=\sum\_{n>0}1/n^s$, which has the properties $\zeta(0)=-1/2$ and $\zeta'(0)=-\frac{1}{2}\ln2\pi$.) All that remains is to evaluate: $$ \int\_{-\infty}^{\infty} d a\,e^{ia^2}, $$ which is also a standard exercise in complex analysis, but I think there is some value in me going through the reasoning as it is central to the notion of Wick rotation: the integrand is analytic in $a$, so for any closed contour, $C$, Cauchy's theorem ensures that, $$ \oint\_Cda\,e^{ia^2}=0. $$ Let us choose in particular the contour shown in the figure: [![Contour for Gaussian integral](https://i.stack.imgur.com/pPzTB.png)](https://i.stack.imgur.com/pPzTB.png) Considering each contribution separately and taking the limit $R\rightarrow \infty$ leads to: $$ \int\_{-\infty}^{\infty} d a\,e^{ia^2}=\sqrt{i}\int\_{-\infty}^{\infty}da\,e^{-a^2}=\sqrt{\pi i} $$ (Food for thought: what is the result for a more general choice of angle, $\theta\in (0,\frac{\pi}{2}]$? which in the displayed equation and figure is $\theta=\pi/4$.) An important conclusion is that Gaussian integrals with oscillating exponentials are *perfectly well-defined*. There was clearly no need to Wick rotate to imaginary time at any point of the calculation. The whole analysis above was to bring the original path integral into a form that contains a product of well-defined ordinary integrals. Using this result for the $a$ integral, zeta function regularisation for the infinite products (see above), and rearranging leads to: \begin{equation} \begin{aligned} \int \mathcal{D}\tilde{x}\,&\exp\, \frac{i}{\hbar}\int\_0^T\!\!\!dt\,\tilde{x}(t)\Big(-\frac{d^2}{dt^2}\Big)\tilde{x}(t)=\frac{1}{2\pi}\frac{K\pi}{T\sqrt{\hbar}}\frac{1}{\sqrt{\pi i}}. \end{aligned} \end{equation} Substituing this result into the boxed expression above for the full path integral we learn that: $$ Z[x\_f,T;x\_i,0]=\frac{e^{i(x\_f-x\_i)^2/\hbar T}}{\sqrt{\pi i\hbar T}}\,\frac{K}{\sqrt{4 T}}. $$ **Normalisation:** Although somewhat tangential, some readers may benefit from a few comments regarding the normalisation: $K$ may be determined by demanding consistent factorisation, $$ Z[x\_f,T;x\_i,0] \equiv \int\_{-\infty}^{\infty}dy\,Z[x\_f,T;y,t]Z[y,t;x\_i,0], $$ (the result is independent of $0\leq t\leq T$) or, if one (justifiably) questions the uniqueness of the normalisation of the $\int dy$ integral one may instead determine $K$ by demanding that the path integral reproduce the Schrodinger equation: the (position space) wavefunction at $t=T$ given a wavefunction at $t=0$, $\psi(x\_i,0)$, is by definition, $$ \psi(x,t) = \int\_{-\infty}^{\infty}dy\,Z[x,t;y,0]\psi(y,0), $$ and then Taylor expanding in $t$ and $\eta$ upon redefining the integration variable $y\rightarrow \eta=x-y$ leads to Schrodinger's equation, $$ i\hbar \partial\_t\psi(x,t)=-\frac{\hbar^2}{4}\partial^2\_x\psi(x,t), $$ provided the normalisation, $K=\sqrt{4T}$, (recall $m=2$). (A more boring but equivalent method to determine $K$ is to demand consistency with the operator approach, where $Z=\langle x\_f,t|x\_i,0\rangle$, leading to the same result.) So, the full correctly normalised path integral for a free non-relativistic particle (of mass $m=2$) is therefore, $$ \boxed{Z[x\_f,T;x\_i,0]=\frac{e^{i(x\_f-x\_i)^2/\hbar T}}{\sqrt{\pi i\hbar T}}} $$ (Recall from above that to reintroduce the mass we may effectively replace $\hbar\rightarrow 2\hbar/m$.) **Alternative measure definition:** I mentioned above that there is a more efficient but equivalent definition for the measure of the path integral, but as this is not central to this post I'll only list it as an **Exercise 1:** Show that, for any constants $c,K$, the following measure definitions are equivalent: $$ \mathcal{D}\tilde{x}=\prod\_{n\neq0}\frac{d a\_n}{K}, \qquad \Leftrightarrow\qquad \int \mathcal{D}\tilde{x}e^{\frac{i}{\hbar c}(\tilde{x},\tilde{x})}=\frac{K}{\sqrt{\pi i\hbar c}}, $$ where the inner product was defined above. **Exercise 2:** From the latter measure definition one has immediately that, $$ \int \mathcal{D}\tilde{x}e^{\frac{i}{\hbar }(\tilde{x},-\partial\_t^2\tilde{x})}=\frac{K}{\sqrt{\pi i\hbar }}\,{\rm det}^{-\frac{1}{2}}\!(-\partial\_t^2). $$ Show using zeta function regularisation that ${\rm det}^{-\frac{1}{2}}\!(-\partial\_t^2)\equiv(\prod\_{n\neq0}\lambda\_n)^{-1/2}=\frac{1}{2T}$, thus confirming (after including the classical contribution, $e^{i(x\_f-x\_i)^2/\hbar T}$) precise agreement with the above boxed result for $Z$ when $K=\sqrt{4T}$. (Notice that again we have not had to Wick rotate *time*, and the path integral measure is perfectly well-defined if one is willing to accept zeta function regularisation as an interpretation for infinite products.) --- **WICK ROTATING TIME? maybe not..** Having discussed how to evaluate path integrals without Wick-rotating rotating time, we now use the above results in order to understand what might go wrong when one does Wick rotate time. **So we now follow your reasoning (but with a twist):** We return to the path integral over fluctuations. We analytically continue $t\rightarrow z=t+i\beta$ and wish to construct a contour (I'll call the full closed contour $C$), such that: $$ \oint\_C dz\,\tilde{x}(z)\Big(-\frac{d^2}{dz^2}\Big)\tilde{x}(z)=0. $$ Our work above immediately implies that any choice of $C$ can indeed can be contracted to a point without obstruction. This is because using the above basis we have a unique analytically continued expression for $\tilde{x}(z)$ given $\tilde{x}(t)$: $$ \tilde{x}(z)=\sqrt{\frac{2}{T}}\sum\_{n\neq0}a\_n\sin \frac{n\pi z}{T}. $$ This is clearly analytic in $z$ (as are its derivatives) with no singularities except possibly outside of the radius of convergence. The first indication that this might be a bad idea is to notice that by continuing $t\rightarrow z$ we end up with a bad basis that ceases to be orthonormal and the sum over $n$ need not converge for sufficiently large imaginary part of $z$. So this immediately spells trouble, but let us try to persist with this reasoning, in the hope that it might solve more problems than it creates (it doesn't). Choose the following contour (note the different choice of contour compared to your choice): [![enter image description here](https://i.stack.imgur.com/2M6ng.png)](https://i.stack.imgur.com/2M6ng.png) I chose the fourth quadrant instead of the first, because (as you showed in your question) the first quadrant leads to the wrong sign Gaussian, whereas the fourth quadrant cures this. So we may apply Cauchy's theorem to the contour $C=a+b+c$. Using coordinates $z=re^{i\theta}$ and $z=t+i\beta$ for contour $b$ and $c$ respectively, \begin{equation} \begin{aligned} \int\_0^T& dt\,\tilde{x}\Big(-\frac{d^2}{dt^2}\Big)\tilde{x}\\ &=- \int\_0^{-\pi/2}(iTe^{i\theta}d\theta)\,\tilde{x}(Te^{i\theta})\frac{1}{T^2e^{2i\theta}}\Big(\frac{\partial^2}{\partial \theta^2}-i\frac{\partial}{\partial \theta}\Big)\tilde{x}(Te^{i\theta})\\ &\qquad+i\int\_{-T}^0d\beta\,\tilde{x}(i\beta)\Big(-\frac{d^2}{d\beta^2}\Big)\tilde{x}(i\beta) \end{aligned} \end{equation} where by the chain rule, along the $b$ contour: $$ dz|\_{r=T}=iTe^{i\theta}d\theta,\qquad {\rm and}\qquad -\frac{d^2}{dz^2}\Big|\_{r=T} = \frac{1}{T^2e^{2i\theta}}\Big(\frac{\partial^2}{\partial \theta^2}-i\frac{\partial}{\partial \theta}\Big), $$ are evaluated at $z=Te^{i\theta}$. Regarding the integral along contour $b$ (i.e. the $\theta$ integral) there was the question above as to whether this quantity actually contributes or not. That it *does* contribute follows from an elementary theorem of complex analysis: the Cauchy-Riemann equations. Roughly speaking, the statement is that if a function, $f(z)$, is holomorphic in $z$ then the derivative of this function with respect to $z$ at any point, $p$, is independent of the *direction* of the derivative. E.g., if $z=x+iy$, then $\partial\_zf(z) = \partial\_xf(z)=-i\partial\_yf(z)$ at any point $z=x+iy$. Applying this to our case, using the above notation, $z=re^{i\theta}$, this means that derivatives along the $\theta$ direction evaluated at any $\theta$ and at $r=T$ equal corresponding derivatives along the $r$ direction at the same $\theta$ and $r=T$, which in turn equal $z$ derivatives at the same $z=Te^{i\theta}$. So we conclude immediately from this that the integral along the $b$ contour is: \begin{equation} \begin{aligned} - \int\_0^{-\pi/2}(iTe^{i\theta}d\theta)&\,\tilde{x}(Te^{i\theta})\frac{1}{T^2e^{2i\theta}}\Big(\frac{\partial^2}{\partial \theta^2}-i\frac{\partial}{\partial \theta}\Big)\tilde{x}(Te^{i\theta})\\ &=- \int\_bdz\,\tilde{x}(z)\Big(-\frac{d^2}{dz^2}\Big)\tilde{x}(z)\Big|\_{z=Te^{i\theta}}\\ &=- \sum\_{n,m\neq0}\Big(\frac{n\pi}{T}\Big)^2a\_na\_m\int\_bdz\,\psi\_n(z)\psi\_m(z)\Big|\_{z=Te^{i\theta}}, \end{aligned} \end{equation} where we made use of the analytically-continued basis expansion of $\tilde{x}(z)$. We have an explicit expression for the integral along the $b$ contour: \begin{equation} \begin{aligned} \int\_bdz\,\psi\_n(z)\psi\_m(z)\Big|\_{z=Te^{i\theta}}&=2i\int\_0^{-\pi/2}d\theta \,e^{i\theta}\sin (n\pi e^{i\theta})\sin (m\pi e^{i\theta})\\ &=-\frac{2}{\pi}\frac{m\cosh m\pi \sinh n\pi-n\cosh n\pi \sinh m\pi}{(m-n)(m+n)} \end{aligned} \end{equation} where we took into account that $m,n\in \mathbb{Z}$. It is worth emphasising that this result follows directly from the analytic continuation of $\tilde{x}(t)$ with the physical boundary conditions $\tilde{x}(0)=\tilde{x}(T)=0$. Notice now that the basis $\psi\_n(z)$ is no longer orthogonal (the inner product is no longer a simple Kronecker delta as it was above), and the presence of hyperbolic sines and cosines implies the sum over $n,m$ is not well defined. Of course, we can diagonalise it if we so please, but clearly this analytic continuation of $t$ is not making life easier. It is clear that the integral along the $\theta$ direction contributes non-trivially, and this follows directly and inevitably from the Cauchy-Riemann equations which links derivatives of holomorphic functions in different directions. Given $\partial\_t^m\psi\_n(t)$ do not generically vanish at $t=T$, the $\theta$ integral along the $b$ contour cannot vanish identically and will contribute non-trivially, as we have shown by direct computation. Notice furthermore, that in the path integral there is a factor of $i=\sqrt{-1}$ multiplying the action $I[x]$, so from the above explicit result it is clear the exponent associated to the $b$ contour *remains oscillatory*. Finally, consider the action associated to the $c$ contour. From above: \begin{equation} \begin{aligned} i\int\_{-T}^0d\beta\,&\tilde{x}(i\beta)\Big(-\frac{d^2}{d\beta^2}\Big)\tilde{x}(i\beta). \end{aligned} \end{equation} In the path integral this contributes as: $$ \exp -\frac{1}{\hbar}\int\_{-T}^0d\beta\,\tilde{x}(i\beta)\Big(-\frac{d^2}{d\beta^2}\Big)\tilde{x}(i\beta), $$ so we seemingly might have succeeded in obtaining an exponential damping at least along the $c$ contour. What have we gained? To bring it to the desired form we shift the integration variable, $\beta\rightarrow \beta'=\beta+T$, $$ \exp -\frac{1}{\hbar}\int\_0^Td\beta'\,\tilde{x}(i\beta'-iT)\Big(-\frac{d^2}{d{\beta'}^2}\Big)\tilde{x}(i\beta'-iT) $$ This looks like it might have the desired form, but we must remember that the $\tilde{x}(i\beta)$ is already determined by the analytic continuation of $\tilde{x}(t)$, and as a consequence of this it is determined by the analytic continuation of the basis $\psi\_n(t)$. This basis along the $\beta$ axis is no longer periodic, so we have lost the good boundary conditions on $\tilde{x}(i\beta)$. In particular, although $\tilde{x}(0)=0$, we have $\tilde{x}(iT)\neq0$, so we can't even integrate by parts without picking up boundary contributions. One might try to redefine the path integral fields, $\tilde{x}(i\beta)\rightarrow \tilde{x}'(\beta)$, and then Fourier series expand $\tilde{x}'(\beta)$, but then we loose the connection with Cauchy's theorem. I could go on, but I think a conclusion has already emerged: analytically continuing time in the integrand of the action is generically a bad idea (at least I can't see the point of it as things stand), and it is much more efficient to analytically continue the full field $\tilde{x}(t)$ as we did above. (Above we continued the $a\_n$ which is equivalent to continuing $\tilde{x}(t)$.) I'm not saying it's wrong, just that it is inefficient and one has to work a lot harder to make sense of it. I want to emphasise one point: Gaussian integrals with oscillating exponentials are perfectly well-defined. There is no need to Wick rotate to imaginary time at any point of the calculation.
Normally (in quantum field theory) the integration would go to infinity. Then the part that closes the loop at infinity should vanish because the fields are assumed to go to zero there. For the remaining integral one should find that in different half spaces (upper or lower) the exponential either grows or decays and one would then simply pick the one that decays so that the integral converges.
63,419,309
MISRA c++:2008 was published in 2008. It was written for C++03. Does this refer to just the syntax of C++2003 standard or do have to use the compiler as well. We have written our code base in VS2017 and we only have available for the Language Standard: * ISO C++14 Standard * ISO C++17 Standard * ISO C++ Latest Draft Standard There is no ISO C++03 for VS2017.
2020/08/14
[ "https://Stackoverflow.com/questions/63419309", "https://Stackoverflow.com", "https://Stackoverflow.com/users/767829/" ]
It will be very hard to argue and say that you are MISRA-C++ compliant when not even compiling in C++03 mode. MISRA-C++ is a safe subset of C++03, so it bans a lot of things from that standard. If you run off and compile for C++11 or later, all bets are off. Visual Studio is not suitable for the kind of mission-critical applications that MISRA was designed for. Nor is C++11 or later. I'd avoid C++ entirely for such applications, even though it is theoretically possible to write safe C++ programs, if you have lots of knowledge about what machine code the compiler generates.
From what I can see on their website, the MISRA standard is not public, so there's really no way for the average person to answer this question. It's probably mostly an issue of what, if any, of the Standard C++ Library you can use and meet the MIRSA requirements. > > I suspect given the vast majority of the Standard C++ library is written assuming C++ exception handling, which is generally not considered safe in critical systems, you aren't supposed to use the bulk of the Standard C++ Library for this application. Again, that's just a guess. > > > Visual C++ does not claim conformance for MISRA, and VS 2017 is a "C++14" compiler. It does not have a formal compliance mode for older C++ standards.
969,986
Okay, this is an example from *Challenge and Trill of Pre-college Mathematics* by Krishnamurthy et al. > > In how many ways can we form a committee of three from a group of 10 men and 8 women, so that our committee consists of at least one woman? > > > I know howit usualy goes: let the answer be *$N$*. The number of committees with no restrictions is $18\choose 3$, and we subtract the number of committees with no women from it, giving $$N = {{18}\choose{3}} - {{10}\choose{3}} = 816 - 120 = 696$$ However, why is this wrong? We must choose at least *one* woman, which we can do in $8$ ways. We have to choose two more members, which we can then do in ${17\choose 2}$ ways. Hence $$N = 8\times {17\choose 2} = 1088 \color{red}{\ne 696} $$ Where's the mistake hiding?
2014/10/12
[ "https://math.stackexchange.com/questions/969986", "https://math.stackexchange.com", "https://math.stackexchange.com/users/42814/" ]
Your first way is absolutely correct, and the easiest way to do it. Another, more cumbersome, way, is to consider cases: 1. exactly one woman: ${8 \choose 1}{10 \choose 2} = 8 \times 45 = 360$ ways. 2. exactly two women: ${8 \choose 2}{10 \choose 1} = 28 \times 10 = 280$ ways. 3. exactly three women: ${8 \choose 3} = 56$ ways. All in all: $360+280+56 = 696$ ways, confirming your own way. The second way you propose does double counting (which seems logical, as it's more). Namely, whenever there are two or more women in the committtee. If there are, say, exactly two women in the committee, A and B, you can pick A first as one of the 8, and then B as one of the remaining 17. **Or** you can pick B first as one of the eight, and A as one of the 17. So you count that committee twice. For comittees with 3 women, you count them thrice, depending on which one is chosen as one of the 8. If there is one woman only there is no double counting. So you count $360 + 2\times 280 + 3 \times 56 = 1088$..
If you want to use your idea, you'd better separate your discussion into three cases:1) choose 1 woman and two men,2)choose two women and 1 men,3) choose three women In your answer, you double count some cases, say 1)choose woman A first, then choose woman B, 2)choose woman B and then choose woman A. They are the same combination, but you count them twice
126,659
The $10$ generators of the Poincare group $P(1;3)$ are $M^{\mu\nu}$ and $P^\mu$. These generators can be determined explicitly in the matrix form. However, I have found that $M^{\mu\nu}$ and $P^\mu$ are often written in terms of position $x^\mu$ and momentum $p^\mu$ as $$ M^{\mu\nu} = x^\mu p^\nu - x^\nu p^\mu $$ and $$ P^\mu = p^\mu$$ How do we get these relations?
2014/07/15
[ "https://physics.stackexchange.com/questions/126659", "https://physics.stackexchange.com", "https://physics.stackexchange.com/users/21270/" ]
One obtains those expressions by considering a particular action of the Poincare group on fields. Consider, for example, a single real scalar field $\phi:\mathbb R^{3,1}\to\mathbb R$. Let $\mathcal F$ denote the space of such fields. Define an action $\rho\_\mathcal F$ of $P(3,1)$ acting on $\mathcal F$ as follows \begin{align} \rho\_\mathcal F(\Lambda,a)(\phi)(x) = \phi(\Lambda^{-1} (x-a)) \end{align} Sometimes people will write this as $\phi'(x) = \phi(\Lambda^{-1} x)$ for brevity. Now let $G$ denote a generator of the Lie algebra of the Poincare group (namely an element of a chosen basis for this Lie algebra). We can use this generator to define a corresponding infinitesimal generator for group action $\rho\_\mathcal F$ as follows: \begin{align} G\_\mathcal F(\phi) = i\frac{\partial}{\partial\epsilon}\rho\_\mathcal F(e^{-i\epsilon G})(\phi)\bigg|\_{\epsilon = 0} \end{align} **Example - translations.** Consider the translation generators $P^\mu$ which have the property \begin{align} e^{-ia\_\mu P^\mu}x = x+a \end{align} The generator of $\rho\_\mathcal F$ corresponding to $P^0$, for instance, is \begin{align} (P^0)\_\mathcal F(\phi)(x) &= i\frac{\partial}{\partial\epsilon}\rho\_\mathcal F(e^{-i\epsilon P^0})(\phi)\bigg|\_{\epsilon = 0} \\ &= i\frac{\partial}{\partial\epsilon}\phi(x + \epsilon e\_0)\bigg|\_{\epsilon = 0} \\ &= i\partial^0\phi(x) \end{align} where $e\_0 = (1,0,0,0)$, and similarly for the other $P^\mu$, which gives \begin{align} (P^\mu)\_\mathcal F = i\partial^\mu. \end{align} **Example - Lorentz boosts.** If you use this same procedure for Lorentz boost generators, you will find that \begin{align} (M^{\mu\nu})\_\mathcal F = i(x^\mu\partial^\nu - x^\nu\partial^\mu) = x^\mu p^\nu - x^\nu p^\mu \end{align} **Disclaimer about signs etc.** There are a lot of conventional factors of $i$ and negative signs floating around which I wasn't super careful to keep track of, if you notice an error in this regard, please let me know and I'll fix it.
The generators of isometry, also generators of the Poincare group, are the Killing vectors, hence we need the Killing vectors of Minkowski spacetime, $ds^2 = -dt^2 + dx^2 + dy^2+ dz^2$. The defining equation of the Killing vectors in terms of their components ($\xi = \xi^\mu \partial\_\mu$ is a Killing vector with components $\xi^\mu$) is $$\partial\_{(\mu} \xi\_{\nu)}=0,$$ where the parentheses denote symmetrization over the enclosed indices. We differentiate once, then cyclically permute the indices, $$\begin{split}\partial\_c\partial\_a \xi\_b + \partial\_b\partial\_c \xi\_a &=0,\\ \partial\_a\partial\_b\xi\_c + \partial\_c\partial\_a\xi\_b&= 0,\\ \partial\_b\partial\_c\xi\_a + \partial\_a\partial\_b\xi\_c &=0,\end{split}$$ which is a linear system with unknowns $\partial\_a\partial\_b\xi\_c$ and its permutations. The only solution of the system is the trivial $\partial\_a\partial\_b\xi\_c=0$, from which we obtain $\xi\_a = a\_{ab} x^b + b\_a$ with $a\_{ab}$ and $b\_a$ constants. From the defining equation we obtain $a\_{ab} = -a\_{ba}$ and, since the Killing vectors are unique up to multiplication with a constant and translation, we obtain $$ \begin{aligned} \partial\_{t} && \partial\_{x} && \partial\_{y} && \partial\_{z},\\ -x\partial\_{t} - t\partial\_{x}, && -y\partial\_{t} - t \partial\_{y} && - z\partial\_{y} - t\partial\_{z},\\ x\partial\_{y} - y\partial\_{x} && y\partial\_{z} - z\partial\_{x} && z\partial\_{x} - x \partial\_{z}.&& \end{aligned}$$ On the first line are the translation generators, on the second the boost generators and on the third the rotation generators.
43,242,076
I am quite new to MySQL. I have data in more than 2000 text files that I need to import into a table. I have created the table as follow: ``` CREATE TABLE test1 ( Month TINYINT UNSIGNED, Day TINYINT UNSIGNED, Year TINYINT UNSIGNED, Weight FLOAT UNSIGNED, length FLOAT UNSIGNED, Site_Number CHAR(3), id INT UNSIGNED NOT NULL AUTO_INCREMENT, PRIMARY KEY (id) ); ``` All data in my text files are comma separated. Each file contains thousands of rows and each row include month, day, year, weight and length information. The site\_number is the first three numbers of the file name. For example, if the file name is A308102316.txt, the site\_number of all the records imported from this file will be 308. Also, I want the ID to be auto increment. My question is: how can I achieve what I described above using MySQL command line client as I know nothing about PHP or other. I know how to import one text file into the table, but don't know how to write a loop to read many of them. Also, not know how to get site\_number from the file name. Thank you for any help that you can provide.
2017/04/05
[ "https://Stackoverflow.com/questions/43242076", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7821588/" ]
Pattern match is performed linearly as it appears in the sources, so, this line: ``` case Row(t1: Seq[String], t2: Seq[String]) => Some((t1 zip t2).toMap) ``` Which doesn't have any restrictions on the values of t1 and t2 never matter match with the null value. Effectively, put the null check before and it should work.
I think you will need to encode null values to blank or special String before performing assert operations. Also keep in mind that Spark executes lazily. So from the like "val values = df.flatMap" onward everything is executed only when show() is executed.
43,242,076
I am quite new to MySQL. I have data in more than 2000 text files that I need to import into a table. I have created the table as follow: ``` CREATE TABLE test1 ( Month TINYINT UNSIGNED, Day TINYINT UNSIGNED, Year TINYINT UNSIGNED, Weight FLOAT UNSIGNED, length FLOAT UNSIGNED, Site_Number CHAR(3), id INT UNSIGNED NOT NULL AUTO_INCREMENT, PRIMARY KEY (id) ); ``` All data in my text files are comma separated. Each file contains thousands of rows and each row include month, day, year, weight and length information. The site\_number is the first three numbers of the file name. For example, if the file name is A308102316.txt, the site\_number of all the records imported from this file will be 308. Also, I want the ID to be auto increment. My question is: how can I achieve what I described above using MySQL command line client as I know nothing about PHP or other. I know how to import one text file into the table, but don't know how to write a loop to read many of them. Also, not know how to get site\_number from the file name. Thank you for any help that you can provide.
2017/04/05
[ "https://Stackoverflow.com/questions/43242076", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7821588/" ]
The issue is that whether you find `null` or not the first pattern matches. After all, `t2: Seq[String]` could theoretically be `null`. While it's true that you can solve this immediately by simply making the `null` pattern appear first, I feel it is imperative to use the facilities in the Scala language to get rid of `null` altogether and avoid more bad runtime surprises. So you could do something like this: ``` def foo(s: Seq[String]) = if (s.contains(null)) None else Some(s) //or you could do fancy things with filter/filterNot df.map { case (first, second) => (foo(first), foo(second)) } ``` This will provide you the `Some`/`None` tuples you seem to want, but I would see about flattening out those `None`s as well.
I think you will need to encode null values to blank or special String before performing assert operations. Also keep in mind that Spark executes lazily. So from the like "val values = df.flatMap" onward everything is executed only when show() is executed.
26,137,413
I have an old website, and I would like to add a glyphicons to a page of this site. I cannot install bootstrap (link bootstrap.js and bootstrap.css to this page) because it will change all styled elements on the page. Is there a way to add only "glyphicons functionality"?
2014/10/01
[ "https://Stackoverflow.com/questions/26137413", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1049569/" ]
You can build your bootstrap to components, which you need, on <http://getbootstrap.com/customize/> For example for **only glyphicon**, you can check only glyphicon checkbox and download. Direct url for this setting is **<http://getbootstrap.com/customize/?id=428c81f3f639eb0564a5>** Scroll down and download it. You download only two folders with css for glyphicon (bootstrap.min.css) and fonts files (in all only 170 Kb).
You can download glyphicons png on <http://glyphicons.com/>
26,137,413
I have an old website, and I would like to add a glyphicons to a page of this site. I cannot install bootstrap (link bootstrap.js and bootstrap.css to this page) because it will change all styled elements on the page. Is there a way to add only "glyphicons functionality"?
2014/10/01
[ "https://Stackoverflow.com/questions/26137413", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1049569/" ]
I prefer to use something called 'font-awsome' it has a huge library of icons and it only takes one line of code to include it into any project. - It works the same way as glyphicon being able to format with CSS etc. I know this is not a answer to your question, but its a valid work around, and I prefer the font-awesome icons. <http://fortawesome.github.io/Font-Awesome/> View here how to include it on your website: <http://fortawesome.github.io/Font-Awesome/get-started/> Have Fun!
You can download glyphicons png on <http://glyphicons.com/>
26,137,413
I have an old website, and I would like to add a glyphicons to a page of this site. I cannot install bootstrap (link bootstrap.js and bootstrap.css to this page) because it will change all styled elements on the page. Is there a way to add only "glyphicons functionality"?
2014/10/01
[ "https://Stackoverflow.com/questions/26137413", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1049569/" ]
You can build your bootstrap to components, which you need, on <http://getbootstrap.com/customize/> For example for **only glyphicon**, you can check only glyphicon checkbox and download. Direct url for this setting is **<http://getbootstrap.com/customize/?id=428c81f3f639eb0564a5>** Scroll down and download it. You download only two folders with css for glyphicon (bootstrap.min.css) and fonts files (in all only 170 Kb).
I prefer to use something called 'font-awsome' it has a huge library of icons and it only takes one line of code to include it into any project. - It works the same way as glyphicon being able to format with CSS etc. I know this is not a answer to your question, but its a valid work around, and I prefer the font-awesome icons. <http://fortawesome.github.io/Font-Awesome/> View here how to include it on your website: <http://fortawesome.github.io/Font-Awesome/get-started/> Have Fun!
50,027,919
I can trigger my AWS pipeline from jenkins but I don't want to create buildspec.yaml and instead use the pipeline script which already works for jenkins.
2018/04/25
[ "https://Stackoverflow.com/questions/50027919", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7372933/" ]
In order to user Codebuild you need to provide the Codebuild project with a buildspec.yaml file along with your source code or incorporate the commands into the actual project. However, I think you are interested in having the creation of the buildspec.yaml file done within the Jenkins pipeline. Below is a snippet of a stage within a Jenkinsfile, it creates a build spec file for building docker images and then sends the contents of the workspace to a codebuild project. This uses the plugin for Codebuild. ``` stage('Build - Non Prod'){ String nonProductionBuildSpec = """ version: 0.1 phases: pre_build: commands: - \$(aws ecr get-login --registry-ids <number> --region us-east-1) build: commands: - docker build -t ces-sample-docker . - docker tag $NAME:$TAG <account-number>.dkr.ecr.us-east-1.amazonaws.com/$NAME:$TAG post_build: commands: - docker push <account-number>.dkr.ecr.us-east-1.amazonaws.com/$NAME:$TAG """.replace("\t"," ") writeFile file: 'buildspec.yml', text: nonProductionBuildSpec //Send checked out files to AWS awsCodeBuild projectName: "<codebuild-projectname>",region: "us-east-1", sourceControlType: "jenkins" } ``` I hope this gives you an idea of whats possible. Good luck! Patrick
You will need to write a buildspec for the commands that you want AWS CodeBuild to run. If you use the CodeBuild plugin for Jenkins, you can add that to your Jenkins pipeline and use CodeBuild as a Jenkins build slave to execute the commands in your buildspec. See more details here: <https://docs.aws.amazon.com/codebuild/latest/userguide/jenkins-plugin.html>
50,027,919
I can trigger my AWS pipeline from jenkins but I don't want to create buildspec.yaml and instead use the pipeline script which already works for jenkins.
2018/04/25
[ "https://Stackoverflow.com/questions/50027919", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7372933/" ]
In order to user Codebuild you need to provide the Codebuild project with a buildspec.yaml file along with your source code or incorporate the commands into the actual project. However, I think you are interested in having the creation of the buildspec.yaml file done within the Jenkins pipeline. Below is a snippet of a stage within a Jenkinsfile, it creates a build spec file for building docker images and then sends the contents of the workspace to a codebuild project. This uses the plugin for Codebuild. ``` stage('Build - Non Prod'){ String nonProductionBuildSpec = """ version: 0.1 phases: pre_build: commands: - \$(aws ecr get-login --registry-ids <number> --region us-east-1) build: commands: - docker build -t ces-sample-docker . - docker tag $NAME:$TAG <account-number>.dkr.ecr.us-east-1.amazonaws.com/$NAME:$TAG post_build: commands: - docker push <account-number>.dkr.ecr.us-east-1.amazonaws.com/$NAME:$TAG """.replace("\t"," ") writeFile file: 'buildspec.yml', text: nonProductionBuildSpec //Send checked out files to AWS awsCodeBuild projectName: "<codebuild-projectname>",region: "us-east-1", sourceControlType: "jenkins" } ``` I hope this gives you an idea of whats possible. Good luck! Patrick
@hynespm - excellent example mate. Here is another one based off yours but with stripIndent() and "withAWS" to switch roles: ``` #!/usr/bin/env groovy def cbResult = null pipeline { . . . script { echo ("app_version TestwithAWS value : " + "${app_version}") String buildspec = """\ version: 0.2 env: parameter-store: TOKEN: /some/token phases: pre_build: commands: - echo "List files...." - ls -l - echo "TOKEN is ':' \${TOKEN}" build: commands: - echo "build':' Do something here..." - echo "\${CODEBUILD_SRC_DIR}" - ls -l "\${CODEBUILD_SRC_DIR}" post_build: commands: - pwd - echo "postbuild':' Done..." """.stripIndent() withAWS(region: 'ap-southeast-2', role: 'CodeBuildWithJenkinsRole', roleAccount: '123456789123', externalId: '123456-2c1a-4367-aa09-7654321') { sh 'aws ssm get-parameter --name "/some/token"' try { cbResult = awsCodeBuild projectName: 'project-lambda', sourceControlType: 'project', credentialsType: 'keys', awsAccessKey: env.AWS_ACCESS_KEY_ID, awsSecretKey: env.AWS_SECRET_ACCESS_KEY, awsSessionToken: env.AWS_SESSION_TOKEN, region: 'ap-southeast-2', envVariables: '[ { GITHUB_OWNER, special }, { GITHUB_REPO, project-lambda } ]', artifactTypeOverride: 'S3', artifactLocationOverride: 'special-artifacts', overrideArtifactName: 'True', buildSpecFile: buildspec } catch (Exception cbEx) { cbResult = cbEx.getCodeBuildResult() } } } //script . . . } ```
22,820,666
I have a string like this and I want to convert it to DateTime format(MM/dd/yyyyTHH:mm:ss). but it fails, Please let me know where I'm wrong. ``` Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US"); string stime = "4/17/2014T12:00:00"; DateTime dt = DateTime.ParseExact(stime, "MM/dd/yyyyTHH:mm:ss", CultureInfo.InvariantCulture); ``` This is the code, how I'm setting this string: ``` string startHH = DropDownList1.SelectedItem.Text; string startMM = DropDownList2.SelectedItem.Text; string startSS = DropDownList3.SelectedItem.Text; string starttime = startHH + ":" + startMM + ":" + startSS; string stime = StartDateTextBox.Text + "T" + starttime; ``` Getting this exception ``` String was not recognized as a valid DateTime. ```
2014/04/02
[ "https://Stackoverflow.com/questions/22820666", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3475314/" ]
You wrote `MM` in your format string, which means that you need a two digit month. If you want a one digit month, just use `M`. ``` DateTime dt = DateTime.ParseExact(stime, "M/dd/yyyyTHH:mm:ss", CultureInfo.InvariantCulture); ``` The other solution is to change your string to match your format. ``` string stime = "04/17/2014T12:00:00"; DateTime dt = DateTime.ParseExact(stime, "MM/dd/yyyyTHH:mm:ss", CultureInfo.InvariantCulture); ``` The key to this is remembering you're doing [parse *exact*.](http://msdn.microsoft.com/en-us/library/ms131038%28v=vs.110%29.aspx) Therefore, you must exactly match your string with your format.
**Problem :** in your date string `4/17/2014T12:00:00` you have only single digit `Month` value (4) but in your DateFormat string you mentione double `MM` **Solution :** you should specify single `M` instead of double `MM` Try This: ``` DateTime dt = DateTime.ParseExact(stime, "M/dd/yyyyTHH:mm:ss", CultureInfo.InvariantCulture); ```
22,820,666
I have a string like this and I want to convert it to DateTime format(MM/dd/yyyyTHH:mm:ss). but it fails, Please let me know where I'm wrong. ``` Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US"); string stime = "4/17/2014T12:00:00"; DateTime dt = DateTime.ParseExact(stime, "MM/dd/yyyyTHH:mm:ss", CultureInfo.InvariantCulture); ``` This is the code, how I'm setting this string: ``` string startHH = DropDownList1.SelectedItem.Text; string startMM = DropDownList2.SelectedItem.Text; string startSS = DropDownList3.SelectedItem.Text; string starttime = startHH + ":" + startMM + ":" + startSS; string stime = StartDateTextBox.Text + "T" + starttime; ``` Getting this exception ``` String was not recognized as a valid DateTime. ```
2014/04/02
[ "https://Stackoverflow.com/questions/22820666", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3475314/" ]
**Problem :** in your date string `4/17/2014T12:00:00` you have only single digit `Month` value (4) but in your DateFormat string you mentione double `MM` **Solution :** you should specify single `M` instead of double `MM` Try This: ``` DateTime dt = DateTime.ParseExact(stime, "M/dd/yyyyTHH:mm:ss", CultureInfo.InvariantCulture); ```
Pay attention your date string contains only 1 digit for month but your patters defines `MM`. So either use month `04` or change pattern to `M`.
22,820,666
I have a string like this and I want to convert it to DateTime format(MM/dd/yyyyTHH:mm:ss). but it fails, Please let me know where I'm wrong. ``` Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US"); string stime = "4/17/2014T12:00:00"; DateTime dt = DateTime.ParseExact(stime, "MM/dd/yyyyTHH:mm:ss", CultureInfo.InvariantCulture); ``` This is the code, how I'm setting this string: ``` string startHH = DropDownList1.SelectedItem.Text; string startMM = DropDownList2.SelectedItem.Text; string startSS = DropDownList3.SelectedItem.Text; string starttime = startHH + ":" + startMM + ":" + startSS; string stime = StartDateTextBox.Text + "T" + starttime; ``` Getting this exception ``` String was not recognized as a valid DateTime. ```
2014/04/02
[ "https://Stackoverflow.com/questions/22820666", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3475314/" ]
You wrote `MM` in your format string, which means that you need a two digit month. If you want a one digit month, just use `M`. ``` DateTime dt = DateTime.ParseExact(stime, "M/dd/yyyyTHH:mm:ss", CultureInfo.InvariantCulture); ``` The other solution is to change your string to match your format. ``` string stime = "04/17/2014T12:00:00"; DateTime dt = DateTime.ParseExact(stime, "MM/dd/yyyyTHH:mm:ss", CultureInfo.InvariantCulture); ``` The key to this is remembering you're doing [parse *exact*.](http://msdn.microsoft.com/en-us/library/ms131038%28v=vs.110%29.aspx) Therefore, you must exactly match your string with your format.
Pay attention your date string contains only 1 digit for month but your patters defines `MM`. So either use month `04` or change pattern to `M`.
8,256,104
I have a sliding section set up as below. I was wondering if I can somehow add `easeIn` and `easeOut` when the slide goes up and down. ``` $('a#slide-up').click(function () { $('.slide-container').slideUp(400, function(){ $('#slide-toggle').removeClass('active'); }); return false; }); $('a#slide-toggle').click(function(e) { e.preventDefault(); var slideToggle = this; if ($('.slide-container').is(':visible')) { $('.slide-container').slideUp(400,function() { $(slideToggle).removeClass('active'); }); } else { $('.slide-container').slideDown(400); $(slideToggle).addClass('active'); } }); ```
2011/11/24
[ "https://Stackoverflow.com/questions/8256104", "https://Stackoverflow.com", "https://Stackoverflow.com/users/893654/" ]
You can. Please check the documentation of [slideDown](http://api.jquery.com/slideDown/) at jQuery docs;. By default jQUery implements only linear and swing easing functions. For additional easing functions you have to user jQUery UI --- UPDATE: Acoording to the doc, the second optional argument is a string indicating the name of the easing function. So, ``` $('.slide-container').slideUp(400, function(){ $('#slide-toggle').removeClass('active'); }); ``` will become ``` $('.slide-container').slideUp(400,'linear', function(){ $('#slide-toggle').removeClass('active'); }); ``` to use linear easing function. Similarly , for other easing functions also.
You sure can, make sure you include the jQuery UI script as you do you regular jQuery library and add in the easing parameter to the [slideUp()](http://api.jquery.com/slideUp/) function. Like so... ``` $('a#slide-up').click(function () { $('.slide-container').slideUp(400,'easeIn', function(){ $('#slide-toggle').removeClass('active'); }); return false; }); $('a#slide-toggle').click(function(e) { e.preventDefault(); var slideToggle = this; if ($('.slide-container').is(':visible')) { $('.slide-container').slideUp(400,'easeOut',function() { $(slideToggle).removeClass('active'); }); } else { $('.slide-container').slideDown(400); $(slideToggle).addClass('active'); } ``` }); The same goes for the [slideDown()](http://api.jquery.com/slideDown/) Theres a whole load of [easing functions](http://jqueryui.com/demos/effect/easing.html)
8,256,104
I have a sliding section set up as below. I was wondering if I can somehow add `easeIn` and `easeOut` when the slide goes up and down. ``` $('a#slide-up').click(function () { $('.slide-container').slideUp(400, function(){ $('#slide-toggle').removeClass('active'); }); return false; }); $('a#slide-toggle').click(function(e) { e.preventDefault(); var slideToggle = this; if ($('.slide-container').is(':visible')) { $('.slide-container').slideUp(400,function() { $(slideToggle).removeClass('active'); }); } else { $('.slide-container').slideDown(400); $(slideToggle).addClass('active'); } }); ```
2011/11/24
[ "https://Stackoverflow.com/questions/8256104", "https://Stackoverflow.com", "https://Stackoverflow.com/users/893654/" ]
You can. Please check the documentation of [slideDown](http://api.jquery.com/slideDown/) at jQuery docs;. By default jQUery implements only linear and swing easing functions. For additional easing functions you have to user jQUery UI --- UPDATE: Acoording to the doc, the second optional argument is a string indicating the name of the easing function. So, ``` $('.slide-container').slideUp(400, function(){ $('#slide-toggle').removeClass('active'); }); ``` will become ``` $('.slide-container').slideUp(400,'linear', function(){ $('#slide-toggle').removeClass('active'); }); ``` to use linear easing function. Similarly , for other easing functions also.
for *slideUp* and *slideDown* you ca add the easing effect: ``` $(".slide-container").slideUp({ duration:500, easing:"easeOutExpo", complete:function(){ $(slideToggle).removeClass("active"); } }); ``` HTH
8,256,104
I have a sliding section set up as below. I was wondering if I can somehow add `easeIn` and `easeOut` when the slide goes up and down. ``` $('a#slide-up').click(function () { $('.slide-container').slideUp(400, function(){ $('#slide-toggle').removeClass('active'); }); return false; }); $('a#slide-toggle').click(function(e) { e.preventDefault(); var slideToggle = this; if ($('.slide-container').is(':visible')) { $('.slide-container').slideUp(400,function() { $(slideToggle).removeClass('active'); }); } else { $('.slide-container').slideDown(400); $(slideToggle).addClass('active'); } }); ```
2011/11/24
[ "https://Stackoverflow.com/questions/8256104", "https://Stackoverflow.com", "https://Stackoverflow.com/users/893654/" ]
for *slideUp* and *slideDown* you ca add the easing effect: ``` $(".slide-container").slideUp({ duration:500, easing:"easeOutExpo", complete:function(){ $(slideToggle).removeClass("active"); } }); ``` HTH
You sure can, make sure you include the jQuery UI script as you do you regular jQuery library and add in the easing parameter to the [slideUp()](http://api.jquery.com/slideUp/) function. Like so... ``` $('a#slide-up').click(function () { $('.slide-container').slideUp(400,'easeIn', function(){ $('#slide-toggle').removeClass('active'); }); return false; }); $('a#slide-toggle').click(function(e) { e.preventDefault(); var slideToggle = this; if ($('.slide-container').is(':visible')) { $('.slide-container').slideUp(400,'easeOut',function() { $(slideToggle).removeClass('active'); }); } else { $('.slide-container').slideDown(400); $(slideToggle).addClass('active'); } ``` }); The same goes for the [slideDown()](http://api.jquery.com/slideDown/) Theres a whole load of [easing functions](http://jqueryui.com/demos/effect/easing.html)
41,099
I have a tentative understanding of modal logic. Can anyone explain modal logic as it is used in computer science?
2015/04/07
[ "https://cs.stackexchange.com/questions/41099", "https://cs.stackexchange.com", "https://cs.stackexchange.com/users/30383/" ]
I think you can find many good examples if you search a bit online. Some very-easy-to-find examples are in the following list: From [Stanford Encyclopedia](http://plato.stanford.edu/entries/logic-modal/) > > In computer science, labeled transition systems (LTSs) are commonly used to represent possible computation pathways during execution of a program. > > > Wikipedia has some examples in its article [modal logic](http://en.wikipedia.org/wiki/Modal_logic): > > Versions of temporal logic can be used in computer science to model computer operations and prove theorems about them. In one version, ◇P means "at a future time in the computation it is possible that the computer state will be such that P is true"; □P means "at all future times in the computation P will be true". In another version, ◇P means "at the immediate next state of the computation, P might be true"; □P means "at the immediate next state of the computation, P will be true". > > > Also, if you go to [Logic in Action](http://www.logicinaction.org/), you will find several examples, e.g.: > > [Chapter 6] introduces dynamic logic, a system that was introduced in computer science for reasoning about the behaviour of computer programs, by Vaughan Pratt and others, in the 1970s. > > > In [Chapter 10] it is explained how predicate logic can be used for programming. The chapter gives an introduction to concepts used in automating logical theorem proving. This leads to computational tools underlying the well known logic programming language Prolog, popular in AI an in computational linguistics. The inferential mechanism behind Prolog is called SLD-resolution. This is the reasoning engine for a natural fragment of predicate logic (the so-called Horn-fragment). > > >
Modal logic is useful for verification of [reactive systems](http://en.wikipedia.org/wiki/Reactive_system) > > A reactive system is a system that responds (reacts) to external events. > Typically, biological systems are reactive, because they react to certain events. However, the term is used primarily for describing human-made systems. For example, a light consisting of a bulb and a switch is a reactive system, reacting to the user changing the switch position. > > > Specification of such systems may be given as a labelled transition system (LTS) or by some process algebra expressions (CCS for example). In this context, both [safety](http://en.wikipedia.org/wiki/Safety_(distributed_computing)) and [livenss](http://en.wikipedia.org/wiki/Liveness) properties are important: > > In distributed computing, **safety** properties informally require that "something bad will never happen" > > > In distributed computing, **liveness** properties informally require that "something good eventually happens" > > > **Safety properties:** * At most 1 process in critical section using a [mutex](http://en.wikipedia.org/wiki/Mutual_exclusion) * No deadlocks **Livness properties:** * A request is eventually followed by a grant * Every packet sent must be received at destination Liveness properties should be specified and verified to ensure that the system makes progress and is "alive", while safety ensures that no bad state is reached. Such properties can be specified using a (temporal) modal logic, such as [CTL](http://en.wikipedia.org/wiki/Computation_tree_logic)
30,332,197
I am working with learning SQL, I have taken the basics course on pluralsight, and now I am using MySQL through Treehouse, with dummy databases they've set up, through the MySQL server. Once my training is complete I will be using SQLServer daily at work. I ran into a two-part challenge yesterday that I had some trouble with. The first question in the challenge was: > > "We have a 'movies' table with a 'title' and 'genre\_id' column and a > 'genres' table which has an 'id' and 'name' column. Use an INNER JOIN > to join the 'movies' and 'genres' tables together only selecting the > movie 'title' first and the genre 'name' second." > > > Understanding how to properly set up JOINS has been a little confusing for me, because the concepts seem simple but like in cooking, execution is everything ---and I'm doing it wrong. I *was* able to figure this one out after some trial and error, work, and rewatching the Treehouse explanation a few times; here is how I solved the first question, with a Treehouse-accepted answer: ``` SELECT movies.title, genres.name FROM movies INNER JOIN genres ON movies.genre_id = genres.id; ``` --BUT-- The next question of the challenge I have not been so successful with, and I'm not sure where I'm going wrong. I would really like to get better with JOINS, and picking the brains of all you smartypantses is the best way I can think of to get an explanation for this specific (and I'm sure, pitifully simple for you guys) problem. Thanks for your help, here's where I'm stumped: > > "Like before, bring back the movie 'title' and genre 'name' but use > the correct OUTER JOIN to bring back all movies, regardless of whether > the 'genre\_id' is set or not." > > > This is the closest (?) solution that I've come up with, but I'm clearly doing something (maybe a lot) wrong here: ``` SELECT movies.title, genres.name FROM movies LEFT OUTER JOIN genres ON genres.id; ``` I had initially tried this (below) but when it didn't work, I decided to cut out the last portion of the statement, since it's mentioned in the requirement criteria that I need a dataset that doesn't care if genre\_id is set in the movies table or not: ``` SELECT movies.title, genres.name FROM movies LEFT OUTER JOIN genres ON movies.genre_id = genres.id; ``` I know this is **total** noob stuff, but like I said, I'm learning, and the questions I researched on Stack and on the Internet at large were not necessarily geared for the same problem. I am *very* grateful to have your expertise and help to draw on. Thank you for taking the time to read this and help out if you choose to do so!
2015/05/19
[ "https://Stackoverflow.com/questions/30332197", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4611445/" ]
Remove `float:left` from `.menu` and `.menu a` and just add ``` margin: 0 auto; ``` to `.menu` to make the links centered. Also, change your `display` from `block` to `inline-block` for `.menu a` Remember to give a width for `.menu`. I just tried a width of `61%` via Inspect Element and it got right. **OR** Add ``` text-align: center; ``` to `.menu` and change your `display` from `block` to `inline-block` for `.menu a`. **No need for specifying width for `.menu` in this method.** May be the easiest solution.
Taken from [Learn CSS Layout](http://learnlayout.com/margin-auto.html): ``` .menu { width: 600px; margin: 0 auto; } ``` > > Setting the `width` of a block-level element will prevent it from > stretching out to the edges of its container to the left and right. > Then, you can set the left and right margins to `auto` to horizontally > center that element within its container. The element will take up the > width you specify, then the remaining space will be split evenly > between the two margins. > > >
48,185,675
I´ve been searching for a solution to create a dropdownlist in ColumnC (with start from row 2) if there is value in ColumnA same row. But all I was able to find is how to create one dropdownlist using VBA. ``` Sub DVraschwab() Dim myList$, i% myList = "" For i = 1 To 7 myList = myList & "ListItem" & i & "," Next i myList = Mid(myList, 1, Len(myList) - 1) With Range("A5").Validation .Delete .Add _ Type:=xlValidateList, _ AlertStyle:=xlValidAlertStop, _ Formula1:=myList End With End Sub ``` Is this possible? And how should I begin? The dropdownlist should contain "Yes" and "No" and No would be standard. This is code that execute when I have written anythins in A Col: ``` Private Sub Worksheet_Change(ByVal Target As Range) If Intersect(Target, Me.Range("A:A")) Is Nothing Then Exit Sub Application.EnableEvents = False 'to prevent endless loop On Error GoTo Finalize 'to re-enable the events For Each columnAcell In Target.Cells columnAcell.Offset(0, 3) = Mid(columnAcell, 2, 3) If IsEmpty(columnAcell.Value) Then columnAcell.Offset(0, 4).ClearContents Next Application.ScreenUpdating = False Dim w1 As Worksheet, w2 As Worksheet Dim c As Range, FR As Variant Set w1 = Workbooks("Excel VBA Test.xlsm").Worksheets("AP_Input") Set w2 = Workbooks("Excel VBA Test.xlsm").Worksheets("Datakom") For Each c In w1.Range("D2", w1.Range("D" & Rows.Count).End(xlUp)) FR = Application.Match(c, w2.Columns("A"), 0) If IsNumeric(FR) Then c.Offset(, 1).Value = w2.Range("B" & FR).Value Next c Call Modul1.DVraschwab If Target.Column = 1 Then If Target.Value = vbNullString Then Target.Offset(, 2).Clear End If End If Finalize: Application.EnableEvents = True End Sub ``` The module I call is the dropdown you helped me with: ``` Sub DVraschwab() Dim myList As String, r As Range myList = "Yes,No" For Each r In Range("A2", Range("A" & Rows.Count).End(xlUp)) If r.Value <> vbNullString Then With r.Offset(, 2).Validation .Delete .Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Formula1:=myList End With r.Offset(, 2).Value = Split(myList, ",")(1) End If Next r End Sub ```
2018/01/10
[ "https://Stackoverflow.com/questions/48185675", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7888468/" ]
Do you mean like this? You basically just need a loop added to your code to check column A. ``` Sub DVraschwab() Dim myList As String, r As Range myList = "Yes,No" For Each r In Range("A2", Range("A" & Rows.Count).End(xlUp)) If r.Value <> vbNullString Then With r.Offset(, 2).Validation .Delete .Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Formula1:=myList End With r.Offset(, 2).Value = Split(myList, ",")(1) End If Next r End Sub 'this in the relevant sheet module Private Sub Worksheet_Change(ByVal Target As Range) If Target.Column = 1 and target.row>1 Then If Target.Value = vbNullString Then Target.Offset(, 2).Clear End If End If End Sub ```
This code will set the validation and write the default value in each cell. ``` Sub DVraschwab() ' 10 Jan 2018 Const MyList As String = "Yes,No" Dim Rl As Long, R As Long With Worksheets("Duplicates") ' replace with your sheet's name ' change column from "A" if not applicable Rl = .Cells(.Rows.Count, "A").End(xlUp).Row For R = 2 To Rl With .Cells(R, 3).Validation .Delete .Add Type:=xlValidateList, _ AlertStyle:=xlValidAlertStop, _ Formula1:=MyList End With .Cells(R, 3).Value = Split(MyList, ",")(1) Next R End With End Sub ```
7,811,268
I have recently started going through sound card drivers in Linux[ALSA]. Can a link or reference be suggested where I can get good basics of Audio like : Sampling rate,bit size etc. I want to know exactly how samples are stored in Audio files on a computer and reverse of this which is how samples(numbers) are played back.
2011/10/18
[ "https://Stackoverflow.com/questions/7811268", "https://Stackoverflow.com", "https://Stackoverflow.com/users/993969/" ]
The [Audacity](http://audacity.sourceforge.net/) [tutorial](http://audacity.sourceforge.net/manual-1.2/tutorial_basics_1.html) is a good place to start. Another [introduction](http://www.pgmusic.com/tutorial_digitalaudio.htm) that covers similar ground. The [PureData](http://puredata.info/) [tutorial at flossmanuals](http://en.flossmanuals.net/pure-data/ch003_what-is-digital-audio/) is also a good starting point. [Wikipedia](http://en.wikipedia.org/wiki/Digital_audio) is a good source once you have the basics down. Audio is input into a computer via an [analog-to-digital](http://en.wikipedia.org/wiki/Analog-to-digital_converter) converter (ADC). Digital audio is output via a [digital-to-analog](http://en.wikipedia.org/wiki/Digital-to-analog_converter) converter (DAC). Sample rate is the number of times per second at which the analog signal is measured and stored digitally. You can think of the sample rate as the time resolution of an audio signal. Bit size is the number of bits used to store each sample. You can think of it as analogous to the color depth of an image pixel. [David Cottle's](http://www.music.utah.edu/faculty/faculty_a-z/david_michael_cottle) [SuperCollider](http://supercollider.sourceforge.net/) book also has a [great introduction](http://supercolliderbook.net/) to digital audio.
I was in the same situation, and certainly this kind of information is out there but you need to do some research first. This is what I have found: Digital Audio processing is a branch of DSP (Digital Signal Processing). > > DSP is one of the most powerful technologies that will > shape science and engineering in the twenty-first century. > Revolutionary changes have already been made in a broad range of > fields: communications, medical imaging, radar & sonar, high fidelity > music reproduction, and oil prospecting, to name just a few. Each of > these areas has developed a deep DSP technology, with its own > algorithms, mathematics, and specialized techniques… > > > This quote was taken from a very helpful guide that covers every topic in depth called the “**The Scientist and Engineer's Guide to Digital Signal Processing**”. And though you are not asking for DSP specifically there’s a chapter that covers all digital audio related topics with a very good explanation. You can find it in the [chapter 22 - Audio Processing](http://www.dspguide.com/ch22.htm), and covers all this topics: * Human Hearing: how the sound is perceived by our ears, this is the basis of how then the sound is then generated artificially. * Timbre: explains the properties of sound, like loudness, pitch and timbre. * Sound Quality vs. Data Rate: once you know the previous concepts we start to translate it to the electronic side. * High Fidelity Audio: gives you a picture of how sound is then processed digitally. * Companding: here you can find how sound is then processed and compressed for telecommunications. * Speech Synthesis and Recognition: More processes applied to the sound, like filters, synthesis, etc. * Nonlinear Audio Processing: this is more advanced but understandable, for sound treatment and other topics. It explains the basics of sound in the real world, in case you might want to take a look, and then it explains how the sound is processed in the computer including what you are asking for. But there are other topics that can be found in wikipedia that are more specific, let’s say the “[Digital audio](https://en.wikipedia.org/wiki/Digital_audio)” page that explains every detail of this topic, this site can be used as a reference for further research, just in the beginning you can find a few links to sample rate, sound waves, digital forms, standards, bit depth, telecommunications, etc. There are a few things you might need to study more, like the nyquist-shannon theorem, fourier transforms, complex numbers and so on, but this is only used in very specific and advanced topics that you might not review or use. But I mention it just in case you are interested. You can find information in both the DSP guide book and wikipedia although you need to study some math. I’ve been using python to develop and study these subjects with code since it has a lot of useful libraries, like numpy, sound device, scipy, etc. And then you can start plating with sound. On youtube you can find lots of videos that also guide you on how to do this. I’ve found synthesis, filters, voice recognition, you can create wav files with just code, which is great. But also I’ve seen projects in C/C++, Javascript, and other languages, so it might help you to keep learning and coding fun things. There are a few other references across the internet but you might need to know what you are looking for, this book and the wikipedia page would be the best starting points for me, since it gives you the basics and explains in depth every topic. Then depending on the goal you want to achieve you can then start looking for more information.
3,800,925
What are some of the better libraries for image generation in Python? If I were to implement a GOTCHA (for example's sake), thereby having to manipulate an image on the pixel level, what would my options be? Ideally I would like to save resulting image as a low-resolution jpeg, but this is mere wishing, I'll settle for any common image format. Thank you for your attention.
2010/09/27
[ "https://Stackoverflow.com/questions/3800925", "https://Stackoverflow.com", "https://Stackoverflow.com/users/181165/" ]
The Python Imaging Library (PIL) is the *de facto* image manipulation library on Python. You can find it [here](http://www.pythonware.com/products/pil/), or through **easy\_install** or **pip** if you have them. Edit: PIL has not been updated in a while, but it has been forked and maintained under the name **[pillow](http://pillow.readthedocs.io/)**. Just install it this way in a shell: ``` pip install Pillow ``` The `import` statements are still the same as PIL (e.g., `from PIL import image`) and is backward compatible.
If you should generate text or other vector based images (and then save to .png or .jpg), you could also consider Cairo (PyCairo, in this case). I use it a lot. Otherwise, for pixel-level manipulation, PIL is the obvious choice.
3,800,925
What are some of the better libraries for image generation in Python? If I were to implement a GOTCHA (for example's sake), thereby having to manipulate an image on the pixel level, what would my options be? Ideally I would like to save resulting image as a low-resolution jpeg, but this is mere wishing, I'll settle for any common image format. Thank you for your attention.
2010/09/27
[ "https://Stackoverflow.com/questions/3800925", "https://Stackoverflow.com", "https://Stackoverflow.com/users/181165/" ]
The Python Imaging Library (PIL) is the *de facto* image manipulation library on Python. You can find it [here](http://www.pythonware.com/products/pil/), or through **easy\_install** or **pip** if you have them. Edit: PIL has not been updated in a while, but it has been forked and maintained under the name **[pillow](http://pillow.readthedocs.io/)**. Just install it this way in a shell: ``` pip install Pillow ``` The `import` statements are still the same as PIL (e.g., `from PIL import image`) and is backward compatible.
[Pillow](http://pillow.readthedocs.org/) is a fork of PIL that is still actively developed. While PIL is not dead it has been a number of years since the last release.
3,800,925
What are some of the better libraries for image generation in Python? If I were to implement a GOTCHA (for example's sake), thereby having to manipulate an image on the pixel level, what would my options be? Ideally I would like to save resulting image as a low-resolution jpeg, but this is mere wishing, I'll settle for any common image format. Thank you for your attention.
2010/09/27
[ "https://Stackoverflow.com/questions/3800925", "https://Stackoverflow.com", "https://Stackoverflow.com/users/181165/" ]
[Pillow](http://pillow.readthedocs.org/) is a fork of PIL that is still actively developed. While PIL is not dead it has been a number of years since the last release.
If you should generate text or other vector based images (and then save to .png or .jpg), you could also consider Cairo (PyCairo, in this case). I use it a lot. Otherwise, for pixel-level manipulation, PIL is the obvious choice.
3,013,831
I have an existing database design that stores Job Vacancies. The "Vacancy" table has a number of fixed fields across all clients, such as "Title", "Description", "Salary range". There is an EAV design for "Custom" fields that the Clients can setup themselves, such as, "Manager Name", "Working Hours". The field names are stored in a "ClientText" table and the data stored in a "VacancyClientText" table with VacancyId, ClientTextId and Value. Lastly there is a many to many EAV design for custom tagging / categorising the vacancies with things such as Locations/Offices the vacancy is in, a list of skills required. This is stored as a "ClientCategory" table listing the types of tag, "Locations, Skills", a "ClientCategoryItem" table listing the valid values for each Category, e.g., "London,Paris,New York,Rome", "C#,VB,PHP,Python". Finally there is a "VacancyClientCategoryItem" table with VacancyId and ClientCategoryItemId for each of the selected items for the vacancy. There are no limits to the number of custom fields or custom categories that the client can add. --- I am now designing a new system that is very similar to the existing system, however, I have the ability to restrict the number of custom fields a Client can have and it's being built from scratch so I have no legacy issues to deal with. For the Custom Fields my solution is simple, I have 5 additional columns on the Vacancy Table called CustomField1-5. This removes one of the EAV designs. It is with the tagging / categorising design that I am struggling. If I limit a client to having 5 categories / types of tag. Should I create 5 tables listing the possible values "CustomCategoryItems1-5" and then an additional 5 many to many tables "VacancyCustomCategoryItem1-5" This would result in 10 tables performing the same storage as the three tables in the existing system. Also, should (heaven forbid) the requirements change in that I need 6 custom categories rather than 5 then this will result in a lot of code change. --- Therefore, can anyone suggest any DB Design Patterns that would be more suitable to storing such data. I'm happy to stick with the EAV approach, however, the existing system has come across all the usual performance issues and complex queries associated with such a design. Any advice / suggestions are much appreciated. The DBMS system used is SQL Server 2005, however, 2008 is an option if required for any particular pattern.
2010/06/10
[ "https://Stackoverflow.com/questions/3013831", "https://Stackoverflow.com", "https://Stackoverflow.com/users/40655/" ]
Have you thought about using an XML column? You can enforce all your constraints declaratively through XSL. Instead of EAV, have a single column with XML data validated by a schema (or a collection of schemas).
Why not store the custom fields in a key-value table? ``` | vacancy ID | CustomFieldType | CustomFieldValue | ``` Then have auxillary tables listing possible values per type (1 table) and may be possible types per vacancy type (it seems to be the original ClientCategory)
3,013,831
I have an existing database design that stores Job Vacancies. The "Vacancy" table has a number of fixed fields across all clients, such as "Title", "Description", "Salary range". There is an EAV design for "Custom" fields that the Clients can setup themselves, such as, "Manager Name", "Working Hours". The field names are stored in a "ClientText" table and the data stored in a "VacancyClientText" table with VacancyId, ClientTextId and Value. Lastly there is a many to many EAV design for custom tagging / categorising the vacancies with things such as Locations/Offices the vacancy is in, a list of skills required. This is stored as a "ClientCategory" table listing the types of tag, "Locations, Skills", a "ClientCategoryItem" table listing the valid values for each Category, e.g., "London,Paris,New York,Rome", "C#,VB,PHP,Python". Finally there is a "VacancyClientCategoryItem" table with VacancyId and ClientCategoryItemId for each of the selected items for the vacancy. There are no limits to the number of custom fields or custom categories that the client can add. --- I am now designing a new system that is very similar to the existing system, however, I have the ability to restrict the number of custom fields a Client can have and it's being built from scratch so I have no legacy issues to deal with. For the Custom Fields my solution is simple, I have 5 additional columns on the Vacancy Table called CustomField1-5. This removes one of the EAV designs. It is with the tagging / categorising design that I am struggling. If I limit a client to having 5 categories / types of tag. Should I create 5 tables listing the possible values "CustomCategoryItems1-5" and then an additional 5 many to many tables "VacancyCustomCategoryItem1-5" This would result in 10 tables performing the same storage as the three tables in the existing system. Also, should (heaven forbid) the requirements change in that I need 6 custom categories rather than 5 then this will result in a lot of code change. --- Therefore, can anyone suggest any DB Design Patterns that would be more suitable to storing such data. I'm happy to stick with the EAV approach, however, the existing system has come across all the usual performance issues and complex queries associated with such a design. Any advice / suggestions are much appreciated. The DBMS system used is SQL Server 2005, however, 2008 is an option if required for any particular pattern.
2010/06/10
[ "https://Stackoverflow.com/questions/3013831", "https://Stackoverflow.com", "https://Stackoverflow.com/users/40655/" ]
Take a look [**at this**](https://stackoverflow.com/questions/2932322/how-to-design-a-schema-where-the-columns-of-a-table-are-not-fixed/2932403#2932403) question/answer; describes the observation pattern. It uses five tables and can be implemented in a "standard" RDBMS -- Sql Server 2005 will do. No limit on number of custom properties (observations) that an entity can have. **EDIT** If tags (categories) are needed for properties, take a look **[at this one](https://stackoverflow.com/questions/1712622/how-to-setup-organization-specific-data-elements-about-shared-items/1716026#1716026)**.
Why not store the custom fields in a key-value table? ``` | vacancy ID | CustomFieldType | CustomFieldValue | ``` Then have auxillary tables listing possible values per type (1 table) and may be possible types per vacancy type (it seems to be the original ClientCategory)