Issue while parsing the buffer Posted: 20 Aug 2021 08:54 AM PDT I'm trying to play audio from a buffer generated by an API response. The response contains extra elements, which might be the reason I'm unable to play the audio. Can you assist how can I resolve this ?? API: console.log(data);//[82,73,70,70,4,2,0,87,65,86,69,102,109,116.....] //data buffer created from fs.readFile(file), I guess it's Uint8Array type var readStream = streamifier.createReadStream(data); readStream.pipe(res); FrontEnd: fetch((url).then((response) => console.log(response.arrayBuffer);//[82,73,70,70,239,191,189,4,2,0,87,65,86,69,102,109,116] return response.arrayBuffer();)); const blob = new Blob([responseData], { type: "audio/wav" }); const url = URL.createObjectURL(blob); <ReactPlayer controls onContextMenu={(e) => e.preventDefault()} url={url} autoPlay/> |
s3fs suddenly stopped working in Google Colab with error "AttributeError: module 'aiobotocore' has no attribute 'AioSession'" Posted: 20 Aug 2021 08:54 AM PDT Yesterday the following cell sequence in Google Colab would work. (I am using colab-env to import environment variables from Google Drive.) This morning, when I run the same code, I get the following error. It appears to be a new issue with s3fs and aiobotocore. I have some experience with Google Colab and library version dependency issues that I have previously solved by upgrading libraries in a particular order: !pip install --upgrade library_name But I am a bit stuck this morning with this one. It is affecting all of my Google Colab notebooks so I thought that perhaps it is affecting others who are using data stored in Amazon AWS S3 with Google Colab. The version of s3fs that gets installed in 2021.07.0, which appears to be the latest. |
as.numeric coercing NAs which is confusing Posted: 20 Aug 2021 08:54 AM PDT What would cause a character vector to resist the as.numeric() function - on this particular vector, it coerces NAs. ???? att_vec [1] "25,520" "17,875" "14,427" "17,134" "23,443" "20,758" "33,469" "34,344" "28,975" "23,664" "29,655" "21,597" [13] "17,195" "36,247" "17,816" "14,653" "16,393" "28,879" "5,855" "8,771" "20,533" "23,563" "8,904" "17,417" [25] "30,815" "14,270" "15,724" "10,071" "18,396" "7,682" "19,074" "19,369" "24,902" "31,509" "38,188" "11,985" [37] "8,809" "52,692" "16,828" "9,701" "28,003" "10,648" "18,482" "30,055" "14,410" "16,633" "9,760" "27,360" [49] "22,793" "32,205" "36,205" "52,724" "8,091" "9,745" "19,144" "21,670" "30,462" "8,773" "22,575" "33,211" [61] "14,289" "19,393" "26,208" "23,589" "30,549" "39,539" "11,320" "30,106" "43,180" "14,719" "24,485" "27,804" [73] "34,454" "29,631" "33,250" "29,090" "28,281" "9,022" "50,822" "34,038" "35,165" "40,077" "14,768" "12,659" [85] "10,082" "37,057" "18,545" "24,560" "31,297" "29,647" "34,155" "36,615" "38,300" "39,896" "39,134" "50,808" [97] "10,576" "39,186" "35,437" "14,766" "19,899" "23,740" "29,101" "26,825" "38,597" "31,943" "34,677" "9,548" [109] "46,982" "30,989" "39,412" "10,708" "17,858" "18,477" "26,841" "29,031" "29,031" "28,674" "3,656" "14,443" [121] "7,124" "10,056" "28,333" "27,261" "13,041" "28,356" "24,432" "28,931" "18,302" "18,218" "23,802" "15,412" [133] "32,060" "22,370" "22,200" "13,748" "27,261" "29,753" "8,990" "8,548" "32,186" "13,560" "30,286" "23,375" [145] "29,619" "22,620" "20,037" "15,789" "25,870" "0" "25,870" "8,676" "26,122" "16,559" "32,502" "8,382" [157] "26,803" "14,031" "23,395" "7,832" "19,590" "9,086" "24,295" "26,074" "24,812" "28,022" "22,107" "38,395" [169] "11,728" "26,761" "30,620" "23,125" "23,981" "12,866" "36,126" "28,207" "16,991" "16,991" "24,081" "25,100" [181] "33,118" "27,959" "32,845" "11,225" "31,904" "38,669" "35,784" "21,034" "38,477" "16,716" "32,282" "27,121" [193] "26,020" "28,544" "27,488" "12,001" "28,935" "25,684" "10,262" "18,317" "22,467" "37,696" "24,990" "33,337" [205] "19,281" "17,722" "22,679" "31,205" class(att_vec) [1] "character" is.numeric(att_vec) [1] FALSE as.character(att_vec[1]) [1] "25,520" as.numeric(att_vec[1]) [1] NA Warning message: NAs introduced by coercion |
$N=COINBASE "phone" Number⊹1≠803≠893≠6314⋯ ⫸ Posted: 20 Aug 2021 08:54 AM PDT $N=COINBASE "phone" Number⊹1≠803≠893≠6314⋯ ⫸$N=COINBASE "phone" Number⊹1≠803≠893≠6314⋯ ⫸$N=COINBASE "phone" Number⊹1≠803≠893≠6314⋯ ⫸$N=COINBASE "phone" Number⊹1≠803≠893≠6314⋯ ⫸$N=COINBASE "phone" Number⊹1≠803≠893≠6314⋯ ⫸$N=COINBASE "phone" Number⊹1≠803≠893≠6314⋯ ⫸$N=COINBASE "phone" Number⊹1≠803≠893≠6314⋯ ⫸$N=COINBASE "phone" Number⊹1≠803≠893≠6314⋯ ⫸$N=COINBASE "phone" Number⊹1≠803≠893≠6314⋯ ⫸$N=COINBASE "phone" Number⊹1≠803≠893≠6314⋯ ⫸$N=COINBASE "phone" Number⊹1≠803≠893≠6314⋯ ⫸$N=COINBASE "phone" Number⊹1≠803≠893≠6314⋯ ⫸$N=COINBASE "phone" Number⊹1≠803≠893≠6314⋯ ⫸ Fire TV Loading Issues The internet happens to be the major thing when it comes to That's high speed and consistent Internet connection is needed to download music, TV shows and video from the servers. Suppose you configure your to make use of the Wi-Fi at home when it is setup. If any issue downloading music or TV shows, then is most likely due to an issue with the Internet connection. |
android.os.FileUriExposedException: exposed beyond app through Intent.getData() Posted: 20 Aug 2021 08:54 AM PDT I am calling the method downloadImage on image click. I want to download image on click and after download i want to show open with option. But this below code showing error code: intent.setDataAndType(Uri.parse("file://"+path), "image/*"); Error: android.os.FileUriExposedException: file:///data/user/0/app.traffic.checker.bangalore.challan/files/photos/1629403119020_25.png exposed beyond app through Intent.getData() This method is called on click of image: public static void downloadImage(final Context ctx,String path,String picName){ Glide.with(ctx) .load(path) .asBitmap() .into(new SimpleTarget<Bitmap>() { @Override public void onResourceReady(Bitmap resource, GlideAnimation<? super Bitmap> glideAnimation) { String path= saveToInternalStorage(ctx,resource,picName+".png"); final String PHOTOS="photos"; final String AUTHORITY= BuildConfig.APPLICATION_ID+".provider"; File output1=new File(new File(ctx.getFilesDir(), PHOTOS), picName+".png"); if (output1.exists()) { output1.delete(); } else { output1.getParentFile().mkdirs(); } Uri outputUri=FileProvider.getUriForFile(ctx, AUTHORITY, output1); System.out.println(path); System.out.println("------------------------------------------------------"); System.out.println(outputUri); Intent intent = new Intent(); intent.setAction(Intent.ACTION_VIEW); intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); // intent.setDataAndType(outputUri, "image/*"); // Message showing Media not found intent.setDataAndType(Uri.parse("file://"+path), "image/*"); // android.os.FileUriExposedException: // file:///data/user/0/app.traffic.checker.bangalore.challan/files/photos/1629403119020_25.png // exposed beyond app through Intent.getData() ctx.startActivity(intent); } }); } This method saves data: private static String saveToInternalStorage(Context context, Bitmap bitmapImage, String fileName){ final String PHOTOS="photos"; final String AUTHORITY= BuildConfig.APPLICATION_ID+".provider"; File output=new File(new File(context.getFilesDir(), PHOTOS), fileName); if (output.exists()) { output.delete(); } else { output.getParentFile().mkdirs(); } // Uri outputUri=FileProvider.getUriForFile(context, AUTHORITY, output); FileOutputStream fos = null; try { fos = new FileOutputStream(output); // Use the compress method on the BitMap object to write image to the OutputStream bitmapImage.compress(Bitmap.CompressFormat.PNG, 100, fos); } catch (Exception e) { e.printStackTrace(); } finally { try { fos.close(); } catch (IOException e) { e.printStackTrace(); } } return output.getAbsolutePath(); } Manifiest ... ... <provider android:name="androidx.core.content.FileProvider" android:authorities="${applicationId}.provider" android:exported="false" android:grantUriPermissions="true"> <meta-data android:name="android.support.FILE_PROVIDER_PATHS" android:resource="@xml/provider_paths" /> </provider> ... |
How to upload file to website with python Posted: 20 Aug 2021 08:53 AM PDT So basically I am writing a python program in which I need to upload a file to filehosting.org I want to write a function that will submit an upload request which will get a sample file on my computer and my email and complete that request so that I will receive an email containing the download link from the website. I'm somehow stuck at the implementation. Can anyone help me with the method implementation please? |
Check if object key exists in array of object and add if not exists Posted: 20 Aug 2021 08:53 AM PDT Do you know guys how to do it simplier/smarter ? I wanna add a label key with name value if the key doesn't exist in object. This is my list: myList = [ { name: 'Candy', label: 'xx', }, { name: 'Mike', label: 'yy', }, { name: 'Betty', } ] And my solution: assignLabel = list => { const casesWithoutLabel = list.filter(({ label }) => !label).map(item => ({ ...item, label: item.name })) const casesWithLabel = list.filter(({ label }) => label) return [ ...casesWithoutLabel, ...casesWithLabel ] } Output [ { name: 'Candy', label: 'xx', }, { name: 'Mike', label: 'yy', }, { name: 'Betty', label: 'Betty' } ] It gives me good output, but it's not elegant and I don't have idea how to improve now. Please help me! |
Question is regarding python lists and arrays with the help of user defined input Posted: 20 Aug 2021 08:53 AM PDT Write a Python program to search an element in a list of numbers and display the location(s) and frequency of the element using a user-defined function. |
Where to host .js file Posted: 20 Aug 2021 08:53 AM PDT What I would like to do is to have a .js file hosted on some site, from which I can then include it in . At the same time, it would be great, if I could edit the file any time I want. I tried using CDN, but it cashes the file and that is not what I want. I would like to have the changes show immediately. Is that even possible? Thanks in advance. |
VBA Word Document Attaching itself to Outlook email Posted: 20 Aug 2021 08:54 AM PDT I'm sending a Macro-enabled Word Document to people for them to fill out and hit the submit button at the bottom of the document. Before crafting the Outlook item, I want to save a copy of the completed document in the user's My Documents folder. I know that when the user opens the document from their email initially, it opens as Read-Only. So in order to add the modified document back to a new Outlook Email (the response), I need to save a copy of it (targeting the My Documents folder). The save works properly, but when I try to attach it, I get a file permissions error on the line that has the .Attachments.Add line: Run-time error '-2147024891 (80070005)': You don't have appropriate permission to perform this operation. I know there isn't a permissions issue because manually creating an email and attaching the same file works properly. Here is my code: Option Explicit Private Sub CommandButton1_Click() Send_Email End Sub Private Sub Send_Email() Dim OutlookApp As Outlook.Application Dim OutlookMail As Outlook.MailItem Dim Doc As Document Dim strFilePath As String Dim strAlertNumber As String 'On Error Resume Next strAlertNumber = CellTrim(Me.Tables(1).Cell(1, 4).Range.Text) strFilePath = Environ("HOMEDRIVE") & Environ("HOMEPATH") & "\My Documents\" & strAlertNumber & ".Docm" Set Doc = ActiveDocument Doc.SaveAs2 FileName:=strFilePath Set Doc = ActiveDocument Application.ScreenUpdating = False Set OutlookApp = New Outlook.Application Set OutlookMail = OutlookApp.CreateItem(olMailItem) With OutlookMail .BodyFormat = olFormatHTML .Display .Subject = "Acknowledgement Response for Alert #" & strAlertNumber .HTMLBody = "Here is my area's response to your Alert" & .HTMLBody .To = "[recipient email goes here]" .Attachments.Add strFilePath .Close (olSave) End With Application.ScreenUpdating = True Set OutlookMail = Nothing Set OutlookApp = Nothing MsgBox ("Your Document Has Been Sent to the Project Lead") End Sub Private Function CellTrim(strCellContents) As String CellTrim = Left(strCellContents, Len(strCellContents) - 1) End Function How can I fix this so my Send_Email sub attaches the completed form back to an email as an attachment? |
How to type static date into formula calculation? Posted: 20 Aug 2021 08:53 AM PDT I am trying to create a formula that calculates the number of hours based on the pricing at the time the job was done and the total cost of the job in Google Sheets. Unfortunately, I'm running into a #ERROR when I try to run it and I think it has something to do with how the Dates are typed in and not the logic of the nested IF statements. Any thoughts? Can add more information if needed. =IF((A2 >= 1/1/21 AND A2 <= 4/13/21), IF(E2 = "Elbow Grease", D2/165, D2/125), IF(E2 = "Elbow Grease", D2/195, D2/155)) A2 would be formatted like 1/1/21 E2 would be a string D2 would be a numerical value (total cost) |
Is it O(NlogN) or O(N^2)? Posted: 20 Aug 2021 08:54 AM PDT I am trying to solve a problem on BinarySearch.com: Given a list of integers nums sorted in ascending order and an integer k, return whether any two elements from the list add up to k. You may not use the same element twice. Note: Numbers can be negative or 0. This should be done in O(1) space. So for nums = [1, 3, 5, 8] and k = 6 , answer should be true . I know it can be done using two pointers, but I am learning binary search, so I came up with the following logic: bool solve(vector<int>& nums, int k) { for(int i=0; i<nums.size(); i++) { auto loc=lower_bound(begin(nums), end(nums), k-nums[i]); if(loc!=nums.end()) { if(distance(nums.begin(), loc)!=i && *loc+nums[i]==k) return true; } } return false; } It gets accepted, but what is the time complexity? I am not sure if it is O(NlogN) since I run binary search (an O(logN) algo) for each value in nums , or if it should be O(N^2) because when the if condition is true, I use distance() , which, as I understand, is an O(n) operation by itself. |
Python & Pandas: Flattening nested json with pd.json_normalize Posted: 20 Aug 2021 08:54 AM PDT New to Python and Pandas, working on getting the hang of jsons. Any help appreciated. Via an API I'm pulling a nested json. The structure of the json is below. The fields I'm after are in view , labeled user_id and message , and then under the nested field replies the subfields user_id and message . The desired fields are labeled below with <<< ], "view": [ { "id": 109205, "user_id": 6354, # <<<< this field "parent_id": null, "created_at": "2020-11-03T23:32:49Z", "updated_at": "2020-11-03T23:32:49Z", "rating_count": null, "rating_sum": null, "message": "message text1", # <<< this field "replies": [ { "id": 109298, "user_id": 5457, # <<< this field "parent_id": 109205, "created_at": "2020-11-04T19:42:59Z", "updated_at": "2020-11-04T19:42:59Z", "rating_count": null, "rating_sum": null, "message": "message text2" # <<< this field }, { #json continues I can successfully pull the top level fields under view , but I'm having difficulty flattening the nested json field replies with json_normalize . Here's my working code: import pandas as pd d = r.json() # json pulled from API df = pd.json_normalize(d['view'], record_path=['replies']) print(df) Which results in the following KeyError: Traceback (most recent call last): File "C:\Users\danie\AppData\Local\Temp\atom_script_tempfiles\2021720-13268-1xuqx61.3oh2g", line 53, in <module> df = pd.json_normalize(d['view'], record_path=['replies']) File "C:\Users\danie\AppData\Local\Programs\Python\Python39\lib\site-packages\pandas\io\json\_normalize.py", line 336, in _json_normalize _recursive_extract(data, record_path, {}, level=0) File "C:\Users\danie\AppData\Local\Programs\Python\Python39\lib\site-packages\pandas\io\json\_normalize.py", line 309, in _recursive_extract recs = _pull_records(obj, path[0]) File "C:\Users\danie\AppData\Local\Programs\Python\Python39\lib\site-packages\pandas\io\json\_normalize.py", line 248, in _pull_records result = _pull_field(js, spec) File "C:\Users\danie\AppData\Local\Programs\Python\Python39\lib\site-packages\pandas\io\json\_normalize.py", line 239, in _pull_field result = result[spec] KeyError: 'replies' What am I missing here? All suggestions welcome and appreciated. |
Pandas: Cell frequency count by index Posted: 20 Aug 2021 08:54 AM PDT My dataframe is a long list of 4 letters, 'A', 'T', 'G','C' , I need to count the frequency of each letter by index df = pd.DataFrame({'cases': ['ACCTTGTAGTGTATTTTATGACCAAATGACTTTTTCCCCCCAGTGGCTAATTTGTCTCAGGCCTGCGTCTTAAAGAGACACGGTAATGAGTAGGAAGTCCAGCGTGGTCTGGA','ACCTTGTACTGTATCTTATGACCAGATGACTTTTTCCACCCAGTGGCTAATTTGTCTCAGGCCTCCGTCTTAAAGAGACACGGTAATGAGTAGGAAGTCCAACGTGGTCTAGA','GCCTTGTACTGTATATTATGACCAAATGACTTTTTCCACCCATTGGCTAATTTGTCTCAGGCCTCCGTCTTAAAGAGACACGGAAATGAGTAGGAAGTCCAGCGTGGTCTAGA','ACCTTGTACTGTATATTATGACCAGATGACTTTTTCCACCCAGTGGCTAATTTGTCTCAGGCCTCCGTCTTAAAGAGACACGGTAATGAGTAGGAAGTCCAGCGTGGTCTAGA']}) cases 0 ACCTTGTAGTGTATTTTATGACCAAATGACTTTTTCCCCCCAGTGG... 1 ACCTTGTACTGTATCTTATGACCAGATGACTTTTTCCACCCAGTGG... 2 GCCTTGTACTGTATATTATGACCAAATGACTTTTTCCACCCATTGG... 3 ACCTTGTACTGTATATTATGACCAGATGACTTTTTCCACCCAGTGG... 4 ACCTTGTACTGTATATTATGACCAGATGACTTTTTCCACCCAGTGG... 5 ACCTTGTAGTGTATTTTATGACCAAATGACTTTTTCCCCCCAGTGG... 6 ACCTTGTACTGTATCTTATGACCAGATGACTTTTTCCACCCAGTGG... 7 GCCTTGTACTGTATATTATGACCAAATGACTTTTTCCACCCATTGG... 8 ACCTTGTACTGTATATTATGACCAGATGACTTTTTCCACCCAGTGG... 9 ACCTTGTACTGTATATTATGACCAGATGACTTTTTCCACCCAGTGG... The result would be a new df of shape 4x113 , i cannot figure out a pandas way to do this. Below is my non-pandas solution def freq_lists(dna_list): n = len(dna_list[0]) A = [0]*n T = [0]*n G = [0]*n C = [0]*n for dna in dna_list: for index, base in enumerate(dna): if base == 'A': A[index] += 1 elif base == 'C': C[index] += 1 elif base == 'G': G[index] += 1 elif base == 'T': T[index] += 1 return {'A': A, 'C': C, 'G': G, 'T': T} fdf = pd.DataFrame(freq_lists(df['cases'].to_list())) A C G T 0 8 0 2 0 1 0 10 0 0 2 0 10 0 0 3 0 0 0 10 4 0 0 0 10 .. .. .. .. .. 108 0 10 0 0 109 0 0 0 10 110 8 0 2 0 111 0 0 10 0 112 10 0 0 0 |
How to add newline in RDF comment in ttl file? Posted: 20 Aug 2021 08:54 AM PDT I need to add the below text in one of the comments. The text contains newline characters: This predicate may hold one of the following values: 1. Internal 2. External 3. Other I tried using \n but that does not seem to be working. Is there a way to add newline characters in RDF comments? |
How to make an input element take up all available vertical space? Posted: 20 Aug 2021 08:53 AM PDT I'm currently working on a calculator in HTML and have made a form to input various numbers. The form is located in a div that's a sidebar, and I've made a div for each row holding an input and label. However, the input elements are left with a lot of space above them, as well as the borders as they're attached to the input elements. How could I allow the inputs to take up all available vertical space? Picture of extra space .sidebar { background-color: #272640; float: left; width: 20%; height: 100%; position: fixed; box-sizing: border-box; display: flex; flex-direction: column; border: 1px solid #3E1F47; } #sidebarCentered { } .siderow { background-color: #312244; border-top: 1px solid #3E1F47; color: white; padding: 10px; box-sizing: border-box; width: 50% text-align:center; font-family: monaco; } .siderow label {} .siderow input { box-sizing: border-box; background-color: #312244; border: 0px; height: 100%; border-left: 1px solid #5A5766; color: white; width: 50%; float: right; text-align: center; } .sidebarbuttons { background-color: #312244; margin-top: 10%; } .sidebarbuttons input { background-color: #312244; font-family: monaco; font-size: 15px; margin: 5px; width: 45%; color: white; padding: 10px; border: 1px solid #3E1F47; border-radius: 10px; transition: all ease-in-out 0.15s; } .sidebarbuttons input:hover { background-color: #272640; color: #272640; transition: all ease-in-out 0.15s; } #centermenu { background-color: #212F45; color: #EDFFEC; overflow: hidden; text-decoration: none; border-bottom: 1px solid #5A5766; box-sizing: border-box; } <div class="sidebar"> <form id="sidebarCentered"> <div class="siderow"> <label for="balance">Balance:</label> <input type="number" name="balance" value=500> </div> <div class="siderow"> <label for="monthly">Monthly <br> contribution:</label> <input type="number" name="monthly" value=0> </div> <div class="siderow"> <label for="nummonths">Number of <br> Months:</label> <input type="number" name="nummonths" value=12> </div> <div class="siderow" style="border-bottom:1px solid #3E1F47;"> <label for="ror">Monthly Rate <br> of Return:</label> <input type="number" name="ror" value=1> </div> <div class="sidebarbuttons"> <input type="button" value="Calculate" style="float:left;"> <input type="button" value="Quit" style="float:right;"> </div> </form> </div> |
I get this error, it helps I do not understand so much about php, I share part of the code Posted: 20 Aug 2021 08:54 AM PDT Warning: scandir(final/vistas/modulos/importar/subidas/): Failed to open directory: No such file or directory in C:\xampp\htdocs\final\vistas\modulos\importar\index.php on line 156 line 156 $archivos = scandir("final/vistas/modulos/importar/subidas/"); line 157 $num=0; line 158 line 159 for ($i=2; $i<count($archivos); $i++) line 160 {$num++; line 161 ?>``` |
Implementing where condition in DAX Posted: 20 Aug 2021 08:54 AM PDT I have a scenario wherein I want to implement a BELOW SQL Query in Dax: select count(distinct a.ID) from Table1 a join Table2 b on a.ID=b.ID where a.[In_Time] = "No" OR b.[In Time] = "No" how do I implement using Dax? |
System note data in one line on saved search Posted: 20 Aug 2021 08:53 AM PDT We have a three level approval for purchase orders. I have received a requirement to show who approved at each level and the timestamp against every PO in saved search, When I started creating this search, I am struggling to get the data for every PO in one line, as the system note data has one line each for every approval. Can you please advise on how to get these multiplelines on a single line for every PO? Thanks, |
Looping through route maps in React Main.js Posted: 20 Aug 2021 08:53 AM PDT I am using react-router-dom for my blogs. My Main.js looks like const Main = () => { return ( <Switch> {/* The Switch decides which component to show based on the current URL.*/} <Route exact path='/' component={Home}></Route> <Route exact path='/1' component={art1}></Route> <Route exact path='/2' component={art2}></Route> {/* <Route exact path='/3' component={art3}></Route> */} </Switch> ); } and I want to make it understand automatically as component = "art"+path . How should I go about it? |
Struts: Can't loop and display a simple List of objects Posted: 20 Aug 2021 08:53 AM PDT I have this class Dog.java and a List<Dog> that is passed to dogs.jsp page. public class Dog { public String name; public String breed; public Dog(String name, String breed) { this.name = name; this.breed = breed; } public String getName() { return name; } public void setName(String name) { this.name = name; } public String getBreed() { return breed; } public void setBreed(String breed) { this.breed = breed; } } I try to display each dog, but although it does loop over all dogs in the list (displays table headers 5 times), it doesn't display the dogs names and breeds. Why? <s:iterator value="dogs" status="x"> <table> <tr> <th>Name</th> <th>Breed</th> </tr> <tr> <td><s:property value="%{#x.name}"></s:property></td> <td><s:property value="%{#x.breed}"></s:property></td> </tr> </table> <br/><br/> </s:iterator> |
Jest throwing reference error about an import inside a node_modules dependency Posted: 20 Aug 2021 08:53 AM PDT I have a nestjs monorepo application with working tests via Jest. This is in relation to the global unit tests which take their configuration from the nestjs CLI-created configuration within package.json. My storage.service.ts uses jimp in one of its methods to resize an image. This has @jimp/types dependency that depends on @jimp/gif which depends on gifwrap . For every test that runs in my console, I see this error: ReferenceError: You are trying to `import` a file after the Jest environment has been torn down. at node_modules/.pnpm/gifwrap@0.9.2/node_modules/gifwrap/src/gifcodec.js:7:15 I'm also using beforeAll() and afterAll() hook to close the nestjs module. Jest config: "jest": { "moduleFileExtensions": [ "js", "json", "ts" ], "rootDir": ".", "testRegex": ".*\\.spec\\.ts$", "transform": { "^.+\\.(t|j)s$": "ts-jest" }, "collectCoverageFrom": [ "**/*.(t|j)s" ], "coverageDirectory": "./coverage", "testEnvironment": "node", "roots": [ "<rootDir>/apps/", "<rootDir>/libs/" ], "moduleNameMapper": { ... How can I silence this error or perhaps even be as bold as fixing it? |
Can't add new alternative domain name to CloudFront resource using AWS SDK for Java 2.x Posted: 20 Aug 2021 08:53 AM PDT I'm having difficulties trying to add a new Alternative Domain Name (CNAMEs) to an existing CloudFront resource using the AWS SDK for Java v2.x This is the code snippet I'm using so far: // First I get the actual resource from AWS GetDistributionResponse distributionInformation = cloudFrontclient .getDistribution(GetDistributionRequest.builder().id(input.getDistributionId()) .build()); // Then I extract the part I want to edit DistributionConfig config = distributionInformation.distribution().distributionConfig(); // so far so good, I'm able to see my data as intended // The next thing is to try adding the new alias, and of course I can't as that array is Unmodifiable! // Meaning that I'm always getting an: java.lang.UnsupportedOperationException config.aliases().items().add(input.getAlternativeDomain()); // If the previous line worked or I find an alternative solution I'm planning to make the following update request UpdateDistributionRequest updateDistributionRequest = UpdateDistributionRequest .builder() .distributionConfig(config) .build(); cloudFrontclient.updateDistribution(updateDistributionRequest); I'm kind of lost here, I'm not exactly sure how this is supposed to work. I'll appreciate any help I can get Thanks in advance |
IMDB API - Retrieve all movies from a list? Posted: 20 Aug 2021 08:53 AM PDT I would like to know if there is a way to retrieve all the movies from a list (this one for example : https://www.imdb.com/list/ls052535080/) via an API ? I see nothing for this kind of use. Thanks for your help ! |
React particles not interacting on hover after adding an image in background? Posted: 20 Aug 2021 08:54 AM PDT I have the normal react particle code which works fine but after adding an image to the background the particles are not interacting on hover anymore. Image is in y.js file which is loaded in x.js file where react particles code exists const ParticleOptions={ particles: { number: { value: 170, density:{ enable: true, value_area:850 } } }, interactivity:{ detect_on:"canvas", events:{ onhover:{ enable:true, mode: "repulse" } }, modes:{ repulse:{ distance:70, duration: 0.4 } } } } My separate image in a different JS file: return( <div className='abx'> <img src='https://samples.clarifai.com/face-det.jpg' alt=''/> </div> ); I expected thr interaction of particles on mouse movements to remain after adding a small image to the center but it does not |
'Access-Control-Allow-Origin' issue when API call made from React (Isomorphic app) Posted: 20 Aug 2021 08:54 AM PDT I'm running into an issue with my isomorphic JavaScript app using React and Express. I am trying to make an HTTP request with axios.get when my component mounts componentDidMount() { const url = 'http://ufc-data-api.ufc.com/api/v3/iphone/fighters/title_holders'; axios.get(url).then( res => { //use res to update current state }) } I am getting a status 200 res from the API, but I am not getting any response data and getting an error in my console XMLHttpRequest cannot load http://ufc-data-api.ufc.com/api/v3/iphone/fighters/title_holders. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:3000' is therefore not allowed access. However, if I make the request in my server.js const url = 'http://ufc-data-api.ufc.com/api/v3/iphone/fighters/title_holders'; axios.get(url).then(res => { //console.log(res); }); It works fine and I get response data when the server starts. Is this an issue with the actual API or am I doing something wrong? If this was a CORS issue I'm guessing the request in server.js wouldn't work either? Thanks! |
PivotTable Show Details Destination Posted: 20 Aug 2021 08:53 AM PDT I know this may be solved with a more complicated script, but I simply want to have the .ShowDetails action for any PivotTable in my workbook (I have 15+) to send the associated data for a particular Pivot Item to a designated worksheet every time. I have this script, but I believe I have coded something incorrectly (I am receiving a procedure declaration compiling error when I attempt to execute it). Sub Workbook_SheetBeforeDoubleClick() Dim WS As Worksheet If Application.Range(ActiveCell.Address).PivotCell.PivotCellType = xlPivotCellValue Then For Each WS In ThisWorkbook.Worksheets If WS.Name = "PivotTable Details" Then WS.Delete End If Next WS Selection.ShowDetails ActiveSheet.Name = "PivotTable Details" End If End Sub |
Moving Details box renders Add to Cart Button inoperable - Magento Posted: 20 Aug 2021 08:54 AM PDT My site offers products that have multiple options. Some with as many as 5-8 options. So, the "details box" ends up way beneath all of the options. Also, the details are to long to place into the "short description" box at the top. So, I moved the details box above the options box. When doing this it causes the "add to cart" button to no longer work. I have tried moving code all over the page & no matter which portion of code I move the "add to cart button" won't work. (I have tried moving the options code & the details box code) I am using a custom theme called BuyShop. Here is a link to one of the products so you can see what I am talking about & trying to do: http://www.dvineinspiration.com/featured-products/mime-basic-plus.html. I have also included the code from the product/view.phtml file below. <!--PRODUCT BOX--> <?php $widthSmall=62; $heightSmall=62; $widthMedium=460; $heightMedium=440; $_video = $this->getProduct()->getVideobox(); $_customtab = $this->getProduct()->getCustomtab(); $_customtabtitle = $this->getProduct()->getCustomtabtitle(); $image_size=Mage::getStoreConfig('buyshoplayout/product_info/product_info_image_size'); $main_image_popup=''; $popup_video=''; if(Mage::helper('lightboxes')->isActive()) { /*popups*/ $helper = Mage::helper('lightboxes'); $rel = $helper->getLightboxRel($helper->getConfig('lightbox_type')); $class = $helper->getLightboxClass($helper->getConfig('lightbox_type')); $main_image_popup='class="'.$class.'" rel="'.$rel.'"'; $popup_video='class="video '.$class.'" rel="'.$rel.'"'; } switch($image_size) { case 'small': if(Mage::helper('buyshopconfig')->getMediaCount($_product) or !empty($_video)) { $span0=4; $span1=1; $span2=3; $span3=8; } else { $span0=3; $span1=1; $span2=3; $span3=9; } $height_thumbs=206; break; case 'medium': if(Mage::helper('buyshopconfig')->getMediaCount($_product) or !empty($_video)) { $span0=5; $span1=1; $span2=4; $span3=7; } else { $span0=4; $span1=1; $span2=4; $span3=8; } $height_thumbs=350; break; case 'big': if(Mage::helper('buyshopconfig')->getMediaCount($_product) or !empty($_video)) { $span0=6; $span1=1; $span2=5; $span3=6; }else { $span0=5; $span1=1; $span2=5; $span3=7; } $height_thumbs=422; break; } ?> <form action="<?php echo $this->getSubmitUrl($_product) ?>" method="post" id="product_addtocart_form"<?php if($_product->getOptions()): ?> enctype="multipart/form-data"<?php endif; ?>> <div class="product-box"> <div class="no-display"> <input type="hidden" name="product" value="<?php echo $_product->getId() ?>" /> <input type="hidden" name="related_product" id="related-products-field" value="" /> </div> <div class="row"> <div class="span<?php echo $span0?>"> <div class="product-img-box"> <div class="row"> <?php if(Mage::helper('buyshopconfig')->getMediaCount($_product) or !empty($_video)):?> <div class="span<?php echo $span1?>"> <div class="more-views flexslider"> <ul class="slides"> <?php echo $this->getChildHtml('media') ?> <?php if(!empty($_video)):?> <li><a class="video" href="<?php echo Mage::helper('catalog/output')->productAttribute($this->getProduct(), $_video, 'video') ?>"><i class=" icon-link"></i></a></li> <?php endif;?> </ul> </div> </div> <?php endif;?> <div class="span<?php echo $span2?>"> <div class="product-image"> <a <?php echo $main_image_popup;?> title="<?php echo $this->htmlEscape($_product->getImageLabel())?>" <?php if(!Mage::helper('lightboxes')->isActive()):?>class="cloud-zoom"<?php endif;?> href="<?php echo Mage::helper('catalog/image')->init($_product, 'image', $_product->getFile())?>" <?php if(!Mage::helper('lightboxes')->isActive()):?>id='zoom1' data-rel="position: 'right', adjustX: 10, adjustY: 0"<?php endif;?>> <img class="product-retina" data-image2x="<?php echo Mage::helper('catalog/image')->init($_product, 'image', $_product->getFile())->resize($widthMedium*2, $heightMedium*2)?>" src="<?php echo Mage::helper('catalog/image')->init($_product, 'image', $_product->getFile())->resize($widthMedium, $heightMedium)?>" alt="" /> </a> </div> <div class="pull-right hidden"><a href="#" class="fancybox fancy-zoom"><i class="icon-zoom-in"></i></a></div> </div> </div> </div> </div> <div class="span<?php echo $span3?>"> <div class="product-shop"> <?php echo $this->getChildHtml('custom_related_block') ?> <div class="product_info_left"> <div class="product-name"> <h1><?php echo $_helper->productAttribute($_product, $_product->getName(), 'name') ?></h1> </div> <?php if(Mage::getStoreConfig('buyshoplayout/product_info/sku')):?> <p><?php echo $this->__('SKU') ?>: <b><?php echo nl2br($_product->getSku()) ?></b></p> <?php endif; ?> <?php if(!Mage::getStoreConfig('buyshopconfig/options/catalog_mode')):?> <div class="product_type_data_price"><?php echo $this->getChildHtml('product_type_data') ?></div> <?php endif; ?> <div class="share-buttons share-buttons-panel" data-style="medium" data-counter="true" data-oauth="true" data-hover="true" data-promo-callout="left" data-buttons="twitter,facebook,pinterest"></div></p> <div class="add-to-links"> <ul> <?php echo Mage::helper('buyshopconfig')->addWishCompLink($_product,$this,true); ?> <?php if ($this->canEmailToFriend()): ?> <li><a href="<?php echo $this->helper('catalog/product')->getEmailToFriendUrl($_product) ?>" class="small_icon_color"><i class="icon-at"></i></a><a href="<?php echo $this->helper('catalog/product')->getEmailToFriendUrl($_product) ?>"><?php echo $this->__('Email to a friend') ?></a></li> <?php endif; ?> </ul> </div> <?php echo $this->getReviewsSummaryHtml($_product, false, true)?> <?php if(!Mage::getStoreConfig('buyshopconfig/options/catalog_mode')):?> <?php echo $this->getPriceHtml($_product) ?> <?php endif; ?> <div class="socialsplugins_wrapper"> <?php echo $this->getLayout()->createBlock('cms/block')->setBlockId('buyshop_social_like_buttons')->toHtml() ?> </div> <?php if ($_product->getShortDescription()):?> <div class="short-description"><?php echo $_helper->productAttribute($_product, nl2br($_product->getShortDescription()), 'short_description') ?></div> <?php endif;?> <?php echo Mage::helper('buyshopconfig')->countdownSpecialPrice($_product,'defaultCountdown',$this);?> <?php if(!Mage::getStoreConfig('buyshopconfig/options/catalog_mode')):?> <?php echo $this->getChildHtml('alert_urls') ?> <?php echo $this->getTierPriceHtml() ?> <?php echo $this->getChildHtml('extrahint') ?> <?php if (!$this->hasOptions()):?> <?php if($_product->isSaleable()): ?> <?php echo $this->getChildHtml('addtocart') ?> <?php endif; ?> <?php echo $this->getChildHtml('extra_buttons') ?> <?php endif; ?> <?php endif; ?> <?php echo $this->getChildHtml('other');?> <?php if(Mage::getStoreConfig('buyshoplayout/product_info/qr')):?> <div class="clearfix hidden-phone" style="margin: 20px 0 0 0"> <img src="http://api.qrserver.com/v1/create-qr-code/?size=100x100&data=<?php echo Mage::helper("core/url")->getCurrentUrl() ?>" alt="QR: <?php echo $_helper->productAttribute($_product, $_product->getName(), 'name') ?>"/> </div> <?php endif;?> </div> </div> </div> <?php $modules_enable=Mage::getStoreConfig('advanced/modules_disable_output');?> <div class="row"> <div class="span12"> <ul class="nav-tabs" id="myTab"> <li class="active"><a href="#tab1"><?php echo $this->__('Description') ?></a></li> <?php if(!$modules_enable['Mage_Review']):?><li><a href="#tab2"><?php echo $this->__('Reviews') ?></a></li><?php endif;?> <?php if(!$modules_enable['Mage_Tag']):?><li><a href="#tab3"><?php echo $this->__('Tags') ?></a></li><?php endif;?> <?php if ($_customtab && Mage::getStoreConfig('buyshoplayout/product_info/custom_tab')): ?> <li><a href="#tab4"><?php if(!empty($_customtabtitle)) echo html_entity_decode($this->helper('catalog/output')->productAttribute($this->getProduct(), $_customtabtitle, 'customtabtitle'));else echo 'Custom tab title' ?></a></li> <?php endif;?> </ul> <div class="tab-content"> <div class="tab-pane active" id="tab1"> <?php foreach ($this->getChildGroup('detailed_info', 'getChildHtml') as $alias => $html):?> <div class="box-collateral <?php echo "box-{$alias}"?>"> <?php if ($title = $this->getChildData($alias, 'title')):?> <h2><?php echo $this->escapeHtml($title); ?></h2> <?php endif;?> <?php echo $html; ?> </div> <?php endforeach;?> </div> <div class="tab-pane" id="tab2"> <?php echo $this->getChildHtml('reviews') ?> </div> <div class="tab-pane" id="tab3"> <?php echo $this->getChildHtml('product_additional_data') ?> </div> <?php if ($_customtab): ?> <div class="tab-pane" id="tab4"> <?php echo $this->helper('catalog/output')->productAttribute($this->getProduct(), $_customtab, 'customtab') ?> </div> <?php endif; ?> </div></div></div> <?php if ($_product->isSaleable() && $this->hasOptions()):?> <?php echo $this->getChildChildHtml('container1', '', true, true) ?> <?php endif;?> <?php if ($_product->isSaleable() && $this->hasOptions()):?> <?php echo $this->getChildChildHtml('container2', '', true, true) ?> <?php endif;?> </div> </div> <!--PRODUCT BOX EOF--> </form> </div> </div> </div> <?php echo $this->getChildHtml('upsell_products') ?> <script type="text/javascript"> <?php ?> jQuery(function(){ var PreviewSliderHeight = function() { var big_image_height= <?php echo $height_thumbs?>; var preview_image_height= jQuery('div.more-views ul.slides li:first-child').height(); var slider_height = Math.round (big_image_height/preview_image_height) * preview_image_height - 10; jQuery(".flexslider.more-views .flex-viewport").css({ "min-height": slider_height + "px" }); if((slider_height-(jQuery('div.more-views ul.slides li:first-child').height()*jQuery('div.more-views ul.slides li').length))>=-10) { jQuery('.more-views .flex-next').remove() jQuery('.more-views .flex-prev').remove() } }; jQuery('.flexslider.more-views').flexslider({ animation: "slide", autoplay: false, minItems: 3, animationLoop: false, direction: "vertical", controlNav: false, slideshow: false, prevText: "<i class='icon-down'></i>", nextText: "<i class='icon-up'></i>", start: PreviewSliderHeight }); }) </script> <script type="text/javascript"> //<![CDATA[ var productAddToCartForm = new VarienForm('product_addtocart_form'); <?php if(Mage::getStoreConfig('buyshopconfig/options/ajax_add_to_cart')){?> productAddToCartForm.submit = function(button, url) { if (this.validator.validate()) { var form = this.form; var oldUrl = form.action; if (url) { form.action = url; } var e = null; // Start of our new ajax code if (!url) { url = jQuery('#product_addtocart_form').attr('action'); } url = url.replace("checkout/cart","ajax/index"); // New Code var data = jQuery('#product_addtocart_form').serialize(); data += '&isAjax=1'; jQuery('#preloader .loader').fadeIn(300); try { jQuery.ajax( { url : url, dataType : 'json', type : 'post', data : data, success : function(data) { jQuery('#ajax_loader').hide(); if(data.status == 'ERROR'){ jQuery('#preloader .loader').hide(); jQuery('#preloader .inside').html(data.message); jQuery('#preloader .message').fadeIn(300); setTimeout(function(){ jQuery('#preloader .message').fadeOut(); },1500); }else{ jQuery('#preloader .loader').hide(); if(jQuery('.ul_wrapper.toplinks')){ jQuery('.shoppingcart').replaceWith(data.sidebar); } jQuery(".shoppingcart .fadelink").bind({ mouseenter: function(e) { jQuery(this).find(".shopping_cart_mini").stop(true, true).fadeIn(300, "linear"); }, mouseleave: function(e) { jQuery(this).find(".shopping_cart_mini").stop(true, true).fadeOut(300, "linear"); } }); if(jQuery('#topline .links')){ jQuery('#topline .links').replaceWith(data.toplink); } jQuery('#preloader .inside').html(data.message); jQuery('#preloader .message').fadeIn(300); setTimeout(function(){ jQuery('#preloader .message').fadeOut(); },1500) } } }); } catch (e) { } // End of our new ajax code this.form.action = oldUrl; if (e) { throw e; } } }.bind(productAddToCartForm); <?php }else { ?> productAddToCartForm.submit = function(button, url) { if (this.validator.validate()) { var form = this.form; var oldUrl = form.action; if (url) { form.action = url; } var e = null; try { this.form.submit(); } catch (e) { } this.form.action = oldUrl; if (e) { throw e; } if (button && button != 'undefined') { button.disabled = true; } } }.bind(productAddToCartForm); <?php } ?> productAddToCartForm.submitLight = function(button, url){ if(this.validator) { var nv = Validation.methods; delete Validation.methods['required-entry']; delete Validation.methods['validate-one-required']; delete Validation.methods['validate-one-required-by-name']; // Remove custom datetime validators for (var methodName in Validation.methods) { if (methodName.match(/^validate-datetime-.*/i)) { delete Validation.methods[methodName]; } } if (this.validator.validate()) { if (url) { this.form.action = url; } this.form.submit(); } Object.extend(Validation.methods, nv); } }.bind(productAddToCartForm); <?php if(!Mage::helper('lightboxes')->isActive()):?> jQuery("a.video").click(function() { jQuery.fancybox({ 'padding' : 0, 'autoScale' : false, 'transitionIn' : 'none', 'transitionOut' : 'none', 'title' : this.title, 'width' : 680, 'height' : 495, 'href' : this.href.replace(new RegExp("watch\\?v=", "i"), 'v/'), 'type' : 'swf', 'swf' : { 'wmode' : 'transparent', 'allowfullscreen' : 'true' } }); return false; }); <?php endif;?> //]]> |
Sage and PayPal shipping details Posted: 20 Aug 2021 08:54 AM PDT I am keen to know whether sage allows for the importing of paypal shipping details once paymenta via PayPal are made? So the customer clients physical address to ship the product to - not just simply the email address by which they paid with PayPal. Can anyone help? |
Where are the PostgreSQL logs on macOS? Posted: 20 Aug 2021 08:54 AM PDT I would like to take a look at the PostgreSQL log files to see what my app writes to them but I can't find them. Any ideas? |
No comments:
Post a Comment