id
stringlengths
3
6
prompt
stringlengths
100
55.1k
response_j
stringlengths
30
18.4k
213358
I received an email today from a Stack Exchange Community Manager: > > As another year draws to a close, we wanted to do something fun and lighthearted with our communities, as a way of celebrating the many amazing people who make the sites awesome. So, we’re announcing **Winter Bash 2014!** > > > The Gist of it ...
t = ``` (when (hatp) (wear-fun-hats)) ```
213699
[Composition root](http://blog.ploeh.dk/2011/07/28/CompositionRoot/) looks very strange pattern. We have a single very large God object that knows everything about anything. What's the correct way to split up a Composition Root to some modules that will encapsulate initialization of its own part of the object graph? ...
I don't agree with the premise that a Composition Root is a [God Object](https://en.wikipedia.org/wiki/God_object). While, conceptually, a Composition Root may contain many lines of code, it has only a [single responsibility](https://en.wikipedia.org/wiki/Single_responsibility_principle): compose an object graph. A Co...
213875
A SEO question if someone would be kind enough to help. A friend has an existing website with plenty of issues and I decided to rebuild it from scratch. Reasons? * Many URL's don't match the actual title of the post + different languages have the same url almost, except "eng-" in front. What the f\*\*\* ? :) * No H1 ...
Nofollow *is* what you are looking for. It doesn't pass any link juice and google wont open or save them. > > In general, we don't follow them. This means that Google does not > transfer PageRank or anchor text across these links. Essentially, > using nofollow causes us to drop the target links from our overall > ...
214125
I have a `scala.collection.immutable.HashSet` that I want to randomly select an element from. I could solve the problem with an extension method like this: ``` implicit class HashSetExtensions[T](h: HashSet[T]) { def nextRandomElement (): Option[T] = { val list = h.toList list match { case null | Nil ...
**WARNING** This answer is for experimental use only. For real project you probably should use your own collection types. So i did some research in the [HashSet source](https://github.com/scala/scala/blob/v2.11.6/src/library/scala/collection/immutable/HashSet.scala#L1) and i think there is little opportunity to somewa...
214340
Let's say I have a dataset (`sim_data`) with 16 variables, including psychological data (15 items from a questionnaire), and the first column is a categorical variable (country). I can easily get means/sd **by group** using: ``` sim_data.groupby("country").describe() ``` However, I would like to apply a function (C...
Usually, base R (not tidy R) is easier to translate to Python Pandas. What your R code appears to be doing is subsetting the dataframe by *country* column and running each subset into `psych::alpha()`. Then extracted statistics are returned into a data frame with country indicator. You can do the exact same with base ...
214822
First, I'm sorry for my english, it's not my native language. I try to do my best I have some problems with my display. I've a java.util.List of Panel with some elements already inside. I'd like to insert them into a JPanel at the creation of my JDialog. There are two JButton in my JDialog, 'add' and 'delete', wich, r...
I using two ways and in both cases should be added a [JPanel](http://docs.oracle.com/javase/tutorial/uiswing/components/panel.html) nested [JComponent](http://docs.oracle.com/javase/tutorial/uiswing/components/index.html)s, * [JPanel with JComponents to the JTable](https://stackoverflow.com/a/6355910/714968) * [JPane...
214994
$ npx react-native run-android info Running jetifier to migrate libraries to AndroidX. You can disable it using "--no-jetifier" flag. Jetifier found 864 file(s) to forward-jetify. Using 4 workers... info Starting JS server... info Launching emulator... error Failed to launch the emulator. Reason: Could not start an emu...
In the `React Native` version **0.62.x** even the initialized application is not ready for a development build. I change the **Gradle** version to the latest and I could to have a clean build, so change this file: ``` // this file => /android/gradle/wrapper/gradle-wrapper.properties ``` from: ``` distributionUrl=h...
215163
Let $X$ be an uncountable set with the discrete topology. Prove that the one point compactification $Y$ of $X$ cannot be imbedded into the plane $\mathbb{R}^{2}$. I'm assuming that there exists an imbedding $f: Y \rightarrow f(Y)$ of $Y$ into $\mathbb{R}^{2}$ and trying to get a contradiction. If $f$ exists, it is a c...
You can look at cardinalities of the sets, in the first topological space you have the cardinality of the power set of the Real numbers, in the second you can use the fact that the real numbers have a countable base therefore there can be at most the cardinality of the power set of N of open sets.
215278
``` public class XPBN extends Activity{ private Map _map; @Override public void onCreate(Bundle savedInstanceState){ super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_NO_TITLE); final Map data = (Map)getLastNonConfigurationInstance(); if (data == null) { Toast.makeText(th...
Have you confirmed that `onRetainNonConfigurationInstance()` is actually being called? I see you have a toast being displayed in it, but you don't actually say it is being shown. (And why a toast instead of just a `Log.i()`?) As the documentation says, "this function is called purely as an optimization, and you must n...
215634
I'm developing an ERP using Spring MVC and JPA/Hibernate frameworks. My problem is that the bean `construireBilanImpl` in the service layer can't be instantiated because the `opmanimpl` field can't be autowired and return `NullPointerException` **com.ensi.erp.metier.CreerBilanImpl:** ``` @Transactional @Component pu...
The interface `OperationManager` might have other implementation classes also. Hence Spring would not be able to figure out which implementation has to be created. If that is the case, then the below should help. Also the interface need not be marked as a `Component`. `@Autowired(required=true) @Qualifier("operationMa...
215715
I'm trying to get the balance to change in the account after a withdraw but it just stays at 10.00. I don't know how to properly apply a method in SavingsAccount that will change it. I tried but had no success. ``` import java.util.Date; public class Account { private int id; private double balance; priva...
try: ``` public void deposit(double ammount) { balance = balance + ammount; setBalance(balance); } ``` You should call setBalance at the end of withdraw and balance, passing in the new balance amount.
215901
I am making a program in c that reads line by line and does some operation on the elements of every line. I am calling my read\_row function like this. ``` while(filePointer!=NULL) { int result=readRow(filePointer,headerRow,lineRow); printf("The value of row is |%d|\n",result); } ``` Inside my read\...
When you pass a pointer to the function and then change it, you are actually changing the copy of that pointer, not the pointer itself. You need to pass a pointer to pointer for this to work, here's a small example: ``` int a = 2; int b = 5; //note the pointer to pointer: void foo(int **ptr) { *ptr = &b; } int m...
216163
I am running Eclipse CDT in Redhat Enterprise, the default version of gcc compiler is 4.4.6. The support team added gcc 4.6.3 recently, I am wondering how can I set up Eclipse in such a way that I can choose to compile the application with either gcc 4.4.6 or 4.6.3. Thanks.
If you really want both gcc 4.6 and 4.4 in your eclipse, you will have to adjust your build configurations (as far I know there is no "easy" way to do this by default). > > Project -> Properties -> C/C+++ Build -> Manage Configurations -> create new > > > Once this is created (& selected) you set it just like oth...
216341
I am getting this error when transtioning from a fragment to an activity as shown below: ``` java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String android.content.Context.getPackageName()' on a null object reference at android.content.ComponentName.<init>(ComponentName.java:130) ...
It seems that you're getting a wrong context that raises this `NullPointerException` Try to replace the below line: ``` Intent mainIntent = new Intent (getContext(), MainActivity.class); ``` With: >> if you're within an activity ``` Intent mainIntent = new Intent (this, MainActivity.class); ``` with: >> if you'r...
216673
I have a subroutine that looks like this. It has two parameters. ``` Sub Advance(ByRef listR() As String, rCount) ...code End Sub ``` When I try to call this: ``` Advance listR:=theList, theCount ``` It gives me a compile error: > > Expected: named parameter > > > Why is this? It works fine like... ```...
I believe that you can call your sub any of the following ways, but you can't name the first parameter and not name the second one: ``` Advance listR:=theList, rCount:=theCount Advance rCount:=theCount, listR:=theList Advance theList, rCount:=theCount Advance theList, theCount Call Advance(listR:=theList, rCount:=the...
216688
I am trying to write my first Laravel program that uses Vue components. I am using Laravel 8.x and Vue 2.x and running on Windows 10. I'm imitating a [video](https://www.youtube.com/watch?v=hbq2CAHNRZM&t=2131s) that shows how to do it. Unfortunately, not everything he's doing works for me. Some people here were very he...
The closure of `this` in function(){ //code } is the function itself. If you want to access the `this` of the object which you defined the function you will need to use arrow function as follow. ``` var obj = { getToDos() { // this here refer to obj axios.get('/todo') .then( res => { ...
216934
I have a program that uses boost asio to connect to 3 TCP sockets asynchronously using a `deadline_timer` as a connect timeout. On windows everything works as expected. The connection times out after 5 seconds. However, on Unix(Ubuntu on WSL, Linux Mint VM, macOS) the connectDeadline never fires. The async\_connect ope...
To use the `var` keyword with **JDK 10** in NetBeans: * Ensure that you are [running the latest version of Apache NetBeans](https://netbeans.apache.org/download/index.html). * In NetBeans add **JDK 10** as a Java platform (**Tools > Java Platforms > Add Plaform...**). It is not necessary to make **JDK 10** the default...
217153
I am currently trying to copy a file from one folder to another specified folder using Excel VBA Macro,my data is on Sheet 1 on Excel, I've set my file name to be on cell B5, the source folder is on B6, and the destination folder is on cell B7. This is my code below : ``` 'In this Example I am Copying the File From on...
when using `sSFolder & sFile` make sure you have a "\" between the 2 variables, like this ``` sSFolder & "\" & sFile ```
217772
Has anyone been able to successfully integrate `Realm` with `SwiftUI`, especially deleting records/rows from a `SwiftUI List`? I have tried a few different methods but no matter what I do I get the same error. After reading some related threads I found out that other people have the same issue. The following code succ...
Here is an example of how i do this. This is without realm operations but i hope u get the idea where you can put the realm stuff. (I also almost never use the realm objects directly but instead convert them to structs or classes.) ``` import Foundation import Realm import Combine import SwiftUI struct dogs: Hashable...
217860
I am trying to convert this code into a while loop or a do while loop. I don't quite grasp the best understanding of the subject. Can anyone help? This is the project I am trying to create a loop for. I'm not sure what the loop would be used for: The Barking Lot is a dog boarding facility. It provides boarding for an...
Don't know exactly what part of your code you would like to loop (I mean the result you want to achieve). So I will leave a coding style recommendation, that might help you in the near future! ;-) ``` // Comment your code. You are going to need it and avoid some people // swearing at your code. :-) // Alw...
218191
I am using react dropzone uploader as per the doc to upload file to my server. I am adding some extra body params to formdata object as mentioned in the RDU component document here <https://react-dropzone-uploader.js.org/docs/api#getuploadparams> but it it always sending the request with standard request body of RDU. ...
Correct way of using this ``` getUploadParams = ({ file, meta }) => { const body= new FormData() body.append('customFile', file) body.append('type', 'normal') return { url: uploadUrl, body } } ```
219330
In my Rails app I've created a set of checkboxes as follows: ``` <div class="form_row"> <label for="features[]">Features:</label> <% ['scenarios', 'news', 'role_profiles', 'private_messages', 'chatrooms', 'forums', 'polls'].each do |feature| %> <br><%= check_box_tag 'features[]', feature, (@fea...
Using jQuery; ``` <script type="text/javascript"> function selectAll(){ $("input:checkbox").each(function(){ $(this).attr('checked', true); }); return false; } </script> ``` HTML button: ``` <a href="#" onclick="selectAll()">Select All</a> ```
219754
I'm using the `hyperref` package and am unable to load `tocloft`. I've tried everything including a *voodoo ritual involving a rubber chicken* to get the two to shake hands. Is there a work around to get dots in the table of contents, list of figures/tables? Also, in my list of figures/tables I have the depth set to ...
With the following setting chapters have their dots and **hyperref** doesn't complain. ``` \documentclass[a4paper]{book} \usepackage{tocloft} \renewcommand{\cftdot}{\normalfont.} % don't inherit the \bfseries attribute \renewcommand{\cftchapdotsep}{4.5} % same spacing as for sections \usepackage{hyperref} ```
220018
If $\gamma:[a,b] \rightarrow \mathbb{C}$ is a piecewise smooth differentiable curve. Let $\overline{\gamma}$ denote the image of $\gamma$ under $z \mapsto \overline{z}$. Show if $f$ is continuous on $\gamma$, then $z \mapsto \overline{f(\overline{z})}$ is continuous and $$\overline{\int\_\gamma f(z) dz}=\int\_\overlin...
Use Taylor's formula with integral remainder. If you take $x\_{0}\in\Omega$ you can find a ball $\overline{B(x\_{0},r)}\subseteq\Omega$. The ball is actually a cube. Then for every $x,y\in B(x\_{0},r)$, $$ f\_{n}(x)=f\_{n}(y)+\sum\_{|\alpha|=1}^{k}\frac{1}{\alpha!}\partial^{\alpha}% f\_{n}(y)(x-y)^{\alpha}+\sum\_{|\alp...
220359
How would I handle a belong\_to with the following include. Instead of displaying the product\_colour\_id id like to show the associated colour (**Update:Solved this part below**). The product\_colour\_id is in the Product table and matches the corresponding Product\_colour id. ***Its the case of two or more has\_man...
``` @products = Product.includes(:product_images, :colour, :supply_companies) .where(product_images: {product_id: product_ids, :default_image => true}) .select('products.*, product_colours.product_colour') ``` this the query with all associations. index.html.erb ``` <% @product...
220435
I just started coding in React using [create-react-app](https://github.com/facebookincubator/create-react-app). In the documentation it's said > > The page will reload if you make edits. > > > I don't know which module is responsible for auto reload (webpack or react-hot-reloader?) but it's not working. I edited...
I hope to save someone else the same pain I experienced. I'm using Windows 10 and Ubuntu 20.04 WSL, with nvm to manage node/npm. I had to: * Use Node v16.14.2 in nvm (which also uses npm 8.5.0) * Change react-scripts from `"react-scripts": "5.0.0"` to `"react-scripts": "4.0.3"` in my package.json file * Change my pa...
220448
I just changed my Laptop, downloaded Android Studio Arctic Fox and cloned the project on which I was already working on in my previous machine. I see that few of the tags are not imported and are in red in the xml layout. When I hover over it, it says "Cannot resolve class TextView". Similar issue with ImageView. What ...
***after clean the project sync the build gradle or cut and paste a one dependency and sync the gradle***
220518
I'm trying to group two columns in my MySQL database and show counts for them respectively (as separate columns). Is there a way of doing this or do I have to join two sub-queries? I'm aware of `WITH ROLLUP` but can't produce the right query. This gives the right result: ``` SELECT A.mid, B.pid, A.count AS mid_count...
I removed one of the subqueries from yours but fundamentally as mysql doesn't support count over partition etc, it will need more than one pass through the table: ``` Select test.mid, test.pid, A.cnt as midCount, count(*) as pidCount from test join (Select mid, count(*) as cnt from test group by mid) A on test.mid = ...
220655
I'm using IO.DirectoryInfo to sanitize a path. However, it seems to exhibit strange behaviour when a path ends with "\CON". For example: ``` IO.DirectoryInfo("C:\FOOBAR\").FullName ``` Will return: ``` C:\FOOBAR\ ``` However, in these examples: ``` IO.DirectoryInfo("C:\CON").FullName IO.DirectoryInfo("C:\SUB\CON...
CON is a reserved file name, with a long history as an MS-DOS device name. As is stated in documentation on naming files, paths and namespaces: > > **Do not use the following reserved names for the name of a file:** > CON, PRN, AUX, NUL, COM1, COM2, COM3, COM4, COM5, COM6, COM7, COM8, COM9, LPT1, LPT2, LPT3, LPT4, L...
220664
After reading up on how to best [handle users in multiple timezones](https://stackoverflow.com/questions/2532729/daylight-saving-time-and-timezone-best-practices) properly, I've learned that the way to go is to store all dates in an normalized, application-wide timezone - `UTC` and then apply the diff between the norma...
One standard approach is to store both an amount and a currency whenever monetary values are held and manipulated. See the [Money Pattern](http://martinfowler.com/eaaCatalog/money.html) in Martin Fowler's Patterns of Enterprise Application Architecture. Fowler describes defining a simple datatype to hold the two prim...
220917
Launching myself into Swift and SwiftUI, I find the process of migrating from UIKit quite hard. Presently stomped by UserDefaults, even after trying to make sense of the many tutorials I found on the web. Please tell me what I'm doing wrong here : VERY simple code to : 1. register a bool value to a UserDefault, 2. d...
Your issue is that the `Text(...)` initializer takes a `LocalizedStringKey` rather than a `String` which supports different types in its string interpolation than plain strings do (which does not include `Bool` apparently). There's a couple ways you can work around this. You could use the `Text` initializer that take...
221076
I'm using *`LabelEncoder`* and *`OneHotEncoder`* from *`sklearn`* in a Machine Learning project to encode the labels (country names) in the dataset. Everything works good and my model runs perfectly. The project is to classify whether a bank customer will continue with or leave the bank based on a number of features(da...
It seems like you may be looking for the `.transform()` method of your estimator. ``` >>> from sklearn.preprocessing import LabelEncoder >>> c = ['France', 'UK', 'US', 'US', 'UK', 'China', 'France'] >>> enc = LabelEncoder().fit(c) >>> encoded = enc.transform(c) >>> encoded array([1, 2, 3, 3, 2, 0, 1]) >>> encoded.tr...
221284
When I click on an item of a listView, the background of an other item than I have clicked is changed. If I click on the first one, the background of that and of the last item of the ListView is changing. If I scroll down and click on an item, the item after the one I clicked changes its color. What can I do to just ch...
You can set the background of the list item when you click with `xml` also First add `android:listSelector` to `listview` ``` <ListView android:id="@+id/lv" android:layout_width="match_parent" android:layout_height="fill_parent" android:layout_marginLeft="6dp" android:layout_marginRight="6dp" ...
221339
I need to change edit/create methods in Pages controller (or any custom generated engine), but can't find any. I has overrode all the controllers and tried searching the whole project for any "def edit" and did not find any. I am new to Rails and I don't understand how this works. debug(params) points to refinery/admi...
You said: > > floatval(preg\_replace('/[^\d.]/', '', $price[0])) > but it added "36" > to the number - insteadh of 18.95 i got 3618.95 > > > It comes in my mind that you doesn't have a `$` sign in front of your values but `&#36;` that is the representation of `$`. In order to see if my guess is correct, prin...
221392
New to react native. Here is what I am trying to do: 1. Render a page with three components: top panel, middle row, and content box. 2. When the user scrolls down, the top panel is scrolled and disappears, middle row is scrolled but is sticky to the top of the screen, and the content box is scrolled all the way down u...
It's just an eslint warning so you don't *have* to fix it. But basically any variables which are used in the `useEffect` function are expected to be included in the dependency array. Otherwise, the effect will never be re-run even if the function `fetchBudgets` were to change. It is expecting your hook to look like `...
221560
I have this in my viewWillAppear method ``` [RPCoreData getFetchedControllerForCategoryDiscoverDelegate:self completion:^(NSFetchedResultsController *controller) { self.fetchedResultController = controller; self.fetchedResultController.delegate = self; }]; ``` and this in my CoreData.m ``` + (void) get...
You don't need to wrap the creation of a `NSFetchedResultsController` around a `saveWithBlock:` from `MagicalRecord` since you are effectively only fetching objects, not changing them. I do understand why you did it though (in order to get a local `NSManagedObjectContext`) `MagicalRecord` has a convenience method tha...
222166
In book 2 of [*Aurora Leigh*](https://www.gutenberg.org/ebooks/56621) by Elizabeth Barrett Browning, Aurora’s cousin Romney doubts there is any value in women writing poetry: > >                                               ‘Who has time, > > An hour’s time … think! … to sit upon a bank > > And hear the cymb...
Removing the parenthetical interruption so as to follow the syntax better, we have > > While I in vain touch cymbals. Yet, concede, > > Such sounding brass has done some actual good, > > ... > > In colonising beehives.’ > > > So what do cymbals have to do with beehives? In [this webpage](https://www...
222399
When a user open the app for the first time the permissions page comes back with a *code* that i'm using here <https://graph.facebook.com/oauth/access_token?client_id=ID&redirect_uri=MY_URL&client_secret=SECRET&code=CODE> to get the access token. If is the first time that the user open the app it works. If is not the ...
No, this cannot be done. However, as [Nick Johnson](https://stackoverflow.com/a/1318416/1101070) points out, you can use [remote\_api](http://code.google.com/appengine/articles/remote_api.html) to do what you need.
223242
I am getting this error > > "Android resource linking failed > C:\Users\xervice111\AndroidStudioProjects\ud843-QuakeReport-starting-point\app\src\main\res\layout\list\_item.xml:10: > error: resource drawable/magnitude\_circle (aka > com.example.android.quake > > > report:drawable/magnitude\_circle) not found. e...
**Try This** ``` <?xml version="1.0" encoding="utf-8"?> <!-- Background circle for the magnitude value --> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="oval"> <solid android:color="@color/magnitude1" /> <size android:width="36dp" android:height="36dp" />...
223358
I would like to use CSS filters in JavaScript. Example of CSS filters: ``` .filter { -webkit-filter: blur(20px); /* Blur filter */ -webkit-filter: invert(1); /* Invert filter */ -webkit-filter: hue-rotate(100deg); /* Rotate Hue */ ... } ``` For example, how can I make a blurred image using JavaScrip...
I recommend using **this** so the function can be used with any element/Img you want later ``` <img id="image" onmouseover="ImageHover(this);" src="source.png"/> function ImageHover(el){ el.classList.add("filter"); }; ```
223494
So I have the code bellow. My problem, is that to make the «vous êtes amis» message appear, the user have to click twice on the submit button. But I want to make the user click only once on the submit button. Thanks! ``` <?php $checkcontact = mysql_query("SELECT * FROM contacts WHERE IDcontact = '".$dnn[...
Move this block of code to the end: ``` $checkcontact = mysql_query("SELECT * FROM contacts WHERE IDcontact = '".$dnn['id']."'"); if(mysql_num_rows($checkcontact) == 1) { echo "<h1>Vous êtes amis</h1>"; } else { ``` This checks the value in the database AFTER it's been inserte...
223548
Something is wrong with my code that i can't figure it out, will you help me to find my mistake? Thank you! ``` /// Calculate Prime private static int countPrimes(int number){ int count =0; for(int i=1; i<=MAX_PRIME; i++) { if(isPrime(i)){ count++; } } System.out.println("Exactl...
It seems that your implicit parameter, int number, is never used in your program. Try this code: ``` private static int countPrimes(int number){ int count =0; int countPrimes=0; if(number<2) return 0; for(int i=2; i<=number; i++) { //start i=2, because you know that 1 is not a prime number. ...
223988
I'm using a SplitViewController which can't be part of a navigation controller. I'm using SetRootViewController on an IBAction, which is fine, but it's not animated. Ideally I'd like to use the same animation as the Navigation Controller does (slide in from the left/right) but if that's not possible I'd like to use a c...
I'm not sure about this, but I would suggest the following. Set the `UISplitViewController` as your `UIWindow`'s `rootViewController`. In the `viewDidLoad`, you make a `presentModalViewController:animated:` call with the button's `UIViewController` as modal. Make sure you don't animate it. This gives you the illusion ...
224315
I am trying to read and get the size of the zip file in PHP. Following is my code: ``` function create_zip($files, $file_name, $overwrite = false) { foreach ($files as $imglink) { $img = file_get_contents($imglink); $destination_path = $_SERVER['DOCUMENT_ROOT'] . 'demoproject/downloads/' ....
try this - ``` $fileSize = filesize($filepath . $filename)/1024; echo 'size of the file is : '.$fileSize.' kb'; ```
224399
The DenOfGeek article [Brew2013] has screen captures from the movie [*Superman III*](https://en.wikipedia.org/wiki/Superman_III), in particular the early scenes in the movie where character Gus Gorman is at computer programming school. ![A screen capture from Superman III](https://i.stack.imgur.com/oL2lL.jpg) The ter...
*[So far not an Answer, just a pointer from some Google supported memory - nice question research BTW]* There are other scenes showing the terminals, for example later on, when he get's his first pay check (and the idea to round up pennies) like seen in [this Youtube clip](https://www.youtube.com/watch?v=N7JBXGkBoFc)....
224593
I've been working on an instantiation method that will allow me to package a variety of similar classes into one outer class. I could then instantiate each unique class type by passing the name of that type to the constructor. After a lot of research and errors, this is what I have come up with. I have left an error, t...
Non-static inner classes need an instance of the outer class to work properly. So, they don't "really" have a default constructor, they always have a kind of hidden parameter in which they expect an outer class instance. I don't know why you want to have them all in a single class. If you are doing this so that it's o...
224623
Basically I need to replicate Hartley's 'A User's Guide to Solving Real Business Cycle Models' (<http://www.econ.ucdavis.edu/faculty/kdsalyer/LECTURES/Ecn235a/Linearization/ugfinal.pdf>). Specifically, I want to simulate the dynamical system implied by the model which is specified as follows: ![enter image description...
**Explosiveness** The paper contains an error, which causes the explosive dynamics in your simulation (although presumably the underlying computations in the paper were correct). The equilibrium condition derived from eigenvalue decomposition is contained in the third row of matrix $Q^{-1}$ on page 12 of the paper, wi...
224873
I have an PHP code that makes a call to a webservice and returns a XSD, but I don't know how to read its elements. What would be the best way? I've searched and ended up with DOMDocuments, but I didn't understood it quite well. Is that the best way? **EDIT** - Ok, I was able to get my xsd to a DOMDocument, now how can...
Solved!! Turned my XSD into an array with code below ``` $doc = new DOMDocument(); $doc->preserveWhiteSpace = true; $doc->loadXML($response); $doc->save('t.xml'); $xmlfile = file_get_contents('t.xml'); $parseObj = str_replace($doc->lastChild->prefix.':',"",$xmlfile); $ob = simplexml...
225455
I am trying to link to an external site. where as $location outputs the URL (e.g. www.siteurl.com) How do I make the outputted url a link and not just text Thanks
Just `echo` out the anchor tags ``` echo '<a href="'.$location.'">Click</a>'; ```
225607
I am able to successfully store image in SQL DB, There is a field for image as varchar50. This is the code that I tried ``` DataTable dt=new DataTable(); dt=neworder.Selectfromimage1(); if (dt.Rows.Count > 0) { // byte[] image =(byte[])dt.Rows[0]["image"]; byte image=Convert.ToByte(dt.Rows[0]["image"]); Memory...
You store the path to the image in your database. Your code should look like this: ``` string imagePath=dt.Rows[0]["image"].ToString(); byte[] imageBytes; using (FileStream fs = File.Open(imagePath)) { btncompanion.Image = Image.FromStream(fs); } ``` Try this, not...
225868
> > **Possible Duplicate:** > > [count vs length vs size in a collection](https://stackoverflow.com/questions/300522/count-vs-length-vs-size-in-a-collection) > > > Really strange: C# arrays such as the following ``` double[] test = new double[1]; ``` support the Length property to get the size of the array...
Simply, they chose to call it `Length`, and implement `Count` via explicit interface implementation -something like: ``` int ICollection.Count { get { return Length; } } ```
226199
hey there, I'm creating a series of input elements and for some reason their values aren't `$_POST`ing. Any light shed on the subject would be appreciated! My current code is as follows: `javascript` ``` Afields = 1; function addAdultInput() { if (Afields != 10) { document.getElementById(...
I am not sure if this is what is particularly happening with you, but generally using `innerHTML` to add input fields is not recommended. Instead, you should use `createElement()` and `appendChild()`, or you can alternatively use a library like JQuery or Prototype. You can find tons of help on using these two function...
226272
I would like to know which is best suited for displaying visitor stats in our websites The key areas under our consideration are 1. User Count 2. Unique User Count 3. User Location Regards, naveenj
[Google Analytics](http://www.google.com/analytics/) is free and it fits all your requirements.
226279
Consider the following code: ``` auditlog.getMessages() .stream() .filter(m -> messageId.equals(m.getMessageid())) .findFirst() .orElseThrow(NoMessageFoundException::new) ``` `NoMessageFoundException` is a custom unchecked exception, extending from `RuntimeException`. When `findFirst()` returns an em...
There is no limitation on the type of Exception that can be thrown. ``` public <X extends Throwable> T orElseThrow(Supplier<? extends X> exceptionSupplier) throws X { if (value != null) { return value; } else { throw exceptionSupplier.get(); } } ``` If the code "carries on", it means that...
226304
Tried everything. This UPDATE don't work. No error or something - it just not updates the table. ``` void SetDisable (Integer ID, boolean action){ Integer s; if (action==true) s = 0; else s = 1; db.rawQuery("UPDATE sms SET disabled="+s+" WHERE id="+ID+"",null); } ``` This is my table sc...
**Try this:** ``` db.execSQL("UPDATE sms SET disabled="+s+" WHERE id="+ID+""); ``` SQL queries which return a table (a cursor) are to be run with rawQuery, and those that do not return tables are to be run with execSQL **See this:** [Increase the value of a record in android/sqlite database](https://stackoverfl...
227194
I use Apache Camel module deployed inside ActiveMQ service. Given I use Spring DSL and I have route definition ( implemented as `routeContext`) in the `FilteringRouteContext.xml` file (simplified): ``` <routeContext id="filteringRouteContext" xmlns="http://camel.apache.org/schema/spring"> <route id="myFilteringRo...
I got another instance of **ProcMon** running and filtered results to show only *IISExpress* results (Since this is the one which is giving me error). Then I compiled and launched my application from the IDE and waited for the error to come. After I got the error, I filtered the results by "*Access Denied*". Usually ...
227207
I am trying to use gcm notification. My server code is working fine and I am getting success as acknowledgment. The problem is notification is getting sent properly : 1) In most of devices notification is received instantaneously. Tested on google nexus,sony phones. 2) Other devices are also receiving notification...
* GCM works through Google Play Services * Devices connect to Google Play Services through **TCP on port 5228** * Devices should use port 443 as fallback if port 5228 is blocked, but apparently they just don't use the fallback sometimes (happened to multiple of my devices) * Device sends a **heartbeat packet to Google ...
227291
I'm running a script that returns HTML in the following format into a variable (i.e var results;) ``` var results = titleResults[0]; return results; ***RETURNS the below*** <h2> <a href="https://www.southwest.com/about/southwest/index.html"><b>About Southwest</b></a> </h2> ``` How can I parse out only the 'southwes...
[EDIT] Full apps script code here: ``` var html = '<h2><a href="https://www.southwest.com/about/southwest/index.html"><b>About Southwest</b></a></h2>'; var doc = XmlService.parse(html); var root = doc.getRootElement(); var children = root.getDescendants(); children.forEach(function(ch){ var chelm = ch.a...
227367
I'm using bash to read a file and after doing opeation on particular line ,i need to delete that line from input file. Can you please suggest some way to do so using sed or any other way ? i've tried using sed command like this :- ``` #!/bin/sh file=/Volumes/workplace/GeneratedRules.ion while read line;do printf "...
You effectively said you want your process to be [restartable](https://en.wikipedia.org/wiki/Application_checkpointing). Depending upon how you define the successful completion of an iteration of your while loop, you should store a line number in a separate file, `x`, that indicates how many lines you have successfully...
227395
I'm using PHP and PHPMyAdmin to create a small profile site. I'm giving members an ID number, based on which is the biggest number currently in the database, +1 I did 25 tests before I got the PHP script where I wanted it to be. I then deleted those 25 entries using PHPMyAdmin. But now, when my PHP code does this: ...
It's probably because you have auto\_increment set and the query is returning the highest id. When you deleted the other records, you probably didn't reset the auto increment count.
227455
I'm working and on a large C++ project and making it compile with clang would be painful, so I'm stuck with GCC. I want to use the nice `-fsanitize=leak` flag that I already used with clang on a previous job, but it does not seem to work. I made a very simple example to test it: ``` #include <stdlib.h> void FooBar()...
I think this is not possible at moment (with InfluxDB 0.9). In order to compute [ratios between timeseries (fields)](https://github.com/grafana/grafana/issues/2349) you would have to be able to do either [nested queries](https://github.com/influxdata/influxdb/issues/4619) or [joins](https://docs.influxdata.com/influxdb...
227599
I am working on an android application using RSA encryption. I can get from my server, my private key and my friends public key. Private key are like this: ``` {"n":"...","d":"...","p":"...","q":"...","dmp1":"...","dmq1":"...","coeff":"..."} (jsbn json format) modulus => n public exponent => e private exponent => d...
change isset to !empty, and remove the else like suggested earlier. ``` if(!empty($_POST['email_address']) { //do stuff } ```
227803
href # is not appending to end of URL I have written the html page on which one of the anchor tag has href "#". Whenever I am clicking on it, # is not appending at the end of URL path in browser. Same functionality is working in different websites. Please suggest.. ``` <li class="nav-item d-md-down-none"> <a cl...
This issue is solved. There is `<base href=”/”>` tag present in my html which was loading alternative html link while clicking on `href="#"`. Thanks for all your help.
227850
I am having hard time filtering using the checkboxes in the d3 graph. Here I have five checkboxes and I have to filter the particular data depends upon the checkboxes value. HTML ``` <div id="company" <ul id='BestBrands'> <label class="checkbox"> <input cla...
See here for a very similar question and answer: [d3 map with checkbox filtering](https://stackoverflow.com/questions/15044385/d3-map-with-checkbox-filtering) I think you should start by appending the circles in your scatterplot to a "dot" class. Like so: ``` svg.selectAll(".dot") .data(data) .enter().append("cir...
228139
So this code runs, but it's firing the callback in .flatmap 5 times: ``` var i = 0; const values = {}; return this.obsClient.take(5) .flatMap(v => { const time = Date.now(); values[i] = {time: time, count: v.clientCount}; console.log('...
**Types of Routing in Laravel** There are some Routing methods in Laravel, There are **1. Basic GET Route** `GET` is the method which is used to retrieve a resource. In this example, we are simply getting the user route requirements then return the message to him. ``` Route::get('/home', function() { return 'This i...
228255
C/C++ would be good option to write some of the performance critical aspects of a Ruby Application. I know this is possible. I would like to know how to add C/C++ code into Ruby code; any other language for that matter. Are there any practical applications of this which you noticed in open source projects or else?
Look in the "Extending Ruby" section of the Pickaxe book: <http://www.ruby-doc.org/docs/ProgrammingRuby/html/ext_ruby.html>
228285
SCCM Version: 2012 R2 PowerShell Version: 3 Operating System: Windows Server 2008 R2 SP1 I've written a script to create driver packs in SCCM using only signed hard drive controller (HDC) and network (NET) driver classes but I'm getting all sorts of drivers showing up in SCCM. ![problem description](https://i....
From what I can see there is nothing wrong with your script. I am working on a similar solution but I get the same result as you. The output list looks good but when adding the drivers to a package I get all sort of other drivers no matter what I do. The only thing common to the drivers I want to add (only hdc in my ca...
228466
I'm trying to generate some text in an image that will be embedded in an email. I would like to look as much as possible as the other text in the message body; so I tried: ``` i = Image.new(500, 100) d = Draw.new d = d.annotate(i, 0,0,0,25,nombre){ self.font = "Arial-Regular" self.pointsize = 12 self.text_antialias...
The problem is almost certainly not the DPI, it's that ImageMagick is doing both stroke and fill for fonts. Try `d.stroke('transparent')` on your graphics context, and then you should just see the fill, which is the actual region the font was trying to draw, rather than its outline.
228613
I am new to Kibana, logstash. I am trying push xml (generated as output of nunit) in logstash. I want to have the xml elements attributes, its Parents attributes and child attributes in the same row in Kibana. However, i can get only the xml elements attribute. Parent and child attributes are not generated in the same ...
**It depends on your needs** If you require this number to be as random as physically possible, then yes you should use the `RNGCryptoServiceProvider()` class. If this is just a random number for something seemingly trivial, then it's not really necessary that it uses this class. For example, if you are just trying t...
228812
i am doing a Wpf Application and i create a Control with the shape of an eye ,i put a Ellipse(eye) in a Canvas and my purpose is when the cursor of the mouse enter in the Canvas the Ellipse follow the cursor of mouse. Do you have any suggestion how perform this task? Thanks so much for your attention. Cheers EDIT ===...
Use MouseMove and make sure the Canvas has a Background for hit testing. XAML: ``` <Canvas MouseMove="Canvas_MouseMove" Background="Transparent"> <Ellipse x:Name="eye" Width="50" Height="20" Fill="Blue" /> </Canvas> ``` Codebehind: ``` private void Canvas_MouseMov...
229147
I have a cron job which parses a # of RSS feeds. It turns out it takes too long so I'm getting a HardDeadlineExceededError. I tried just creating two cron jobs, one which parses the even feeds, one which parses the odd feeds, I still get the error. What's the best way to break up this work so it fits within a 30 secon...
I recommend using the [Task Queue](http://code.google.com/appengine/docs/java/taskqueue/overview.html) -- a task can perform any number N of sub-tasks of your choice, making sure to get close but not *too* close to the hard-deadline, then it spawns another task to continue where the spawner left off.
229459
I'm having trouble using `strpos` correctly. if I search for`<br />` it will find it. If I search for `<br /><br /><br />` with or without space between, it won't and using `htmlspecialchars` I can tell the string is full of it. ``` <?php $picArray = glob('projectData/' . $data['folder'] . '/*.jpg',GLOB_BRACE);...
This is because `nl2br` keeps the original line break characters in place, just after the `'<br />'`. You need to include the line break characters in the string to search for. Since there can be a few different patterns for this it's easiest to use a regexp to match it: ``` $text = preg_replace('/(?:<br \/>\r?\n?){3}...
229652
I'm trying to get some exchange rates through API but I do not know how to transform all this to one table like: ``` date | timestamp | base | Currency Name | Currency | ``` I need rates to expand in two columns Currency Name and Currency? ```bsh $request = website $X = Invoke-WebRequest $request $JSONResult = $x ...
After the conversion the value of the `rates` property of your JSON data is a custom object with the currency names as properties and the exchange rates(?) as their value. Use the intrinsic property `PSObject` of that object to enumerate the object properties and their values: ``` $JSONResult.rates.PSObject.Properties...
229759
I'm pretty new to React, I'm trying to return a JSX from a method, code as follows: ```js import React, { useReducer } from 'react'; import ReactDOM from 'react-dom'; import './index.css'; import * as serviceWorker from './serviceWorker'; const formatName = (user) => { return user.firstName + ' ' + user.last...
`getGreeting` should return a JSX and not an object try this: ``` const greeting = ( <h1>Hello {formatName(user)}</h1> ); const forbidden = ( <h1>Hello stranger!</h1> ); const getGreeting = (user) => { if (user) { return greeting } else { return forbidden } } ```
230185
I tried searching but didn't get any useful information. What does the word "Relational" mean here? Is it tables being related to each other just like the real life entities, or does it mean something else?
The word *relational* comes from <http://en.wikipedia.org/wiki/Relational_algebra> which was invented by E.F. Codd. SQL and relational databases started as an attempt to make Codd's ideas practical.
230270
Apologies if this has been answered elsewhere but I couldn't find anything here or online. Does openrowset have a file size limit? I'm trying to write a stored procedure, part of which checks if certain characters exist within the file and if they do I'd have to skip to the next section of the stored procedure. So far...
I know it's not your main question, but you mentioned slow performance. When checking if a certain character or substring exists within a larger string, you should try using CHARINDEX('x', strColumn) instead of LIKE '%x%'. This will boost your performance drastically. Using LIKE with % surrounding your search-term is v...
230396
**Spring Boot Actuator** provides several **endpoints** to **monitor** an **application** as: ``` /metrics /beans /health ... ``` Checking the endpoints with: ``` curl http://localhost:8080/metrics ``` results in: ``` {"counter.status.200.env":1,"counter.status.200.health":1,"counter.status.200.info":2,"counter....
For Spring Boot 1.5.1 I have in my YML file: ``` spring: jackson: serialization: INDENT_OUTPUT: true ``` @BertrandRenuart answer was the closest, but by IDE did not see indent\_output as correct.
230425
What is the best way to allow for the adding of images and embedding of video in the body:text field of a Ruby on Rails blog. I understand that I can use an attachment like Paperclip to add a photo to a record but I am wondering how to get images/vids into the actual body of the post.
Try [CKEditor for Rails](http://github.com/galetahub/rails-ckeditor#readme). It is new version of FCK editor with very clean HTML generator. Very easy to embed. All you need to do is replace your input(text-area) helper tag (for content) with another helper tag. Everything is described nicely in project [README](http:/...
230478
I'm having trouble getting Angular 2 routing to work. I am using Angular 2 and Webpack. In the Angular 2 webpack starter, I noticed they had webpack generating their html and their links, but I was hoping I would not have to webpack my html files. Here's my app.routes.ts... ``` import { ModuleWithProviders } from '@a...
Add `pathMatch: 'full'` ``` { path: '', component: HomeComponent, pathMatch: 'full' }, ``` otherwise both routes ``` { path: '', component: HomeComponent }, { path: 'schedule', component: ScheduleComponent }, ``` match on route `/schedule` because `''` matches, but doesn't consume anything from the route and then...
230545
I would like to retrieve an ordered query result, but I need to have some specific row(s) to be in front of the list. Something like here on Stack Overflow, in the list of answers the right answer is always the first one. Assumed I need to have the rows with IDs 1,2,3 to be the head, the rest sorted by a date field, i...
Your first example looks almost there to me. ``` SELECT * FROM foo ORDER BY id IN (1,2,3) DESC, created_date ASC ``` Added `DESC` because `id IN (1,2,3)` returns `1` if true or `0` if false. `1 > 0`, so ordering them in descending order gets the desired result. Added `ASC` because I like to be explicit. Based on y...
230548
I'm learning react without redux, mobx or any other libraries. The reason why I don't use redux, and so on is that someone told me that it is important to get use to react before using libraries. I'm trying to get data from firestore and render it, but because of async, I'm stuck to render data. I can't render because ...
You are retrieving data but does not set your state, you don't have any state at all. This is why your component does not re-render after getting data. Maybe one approach could be like this (there could be better ways): ``` export default class CategoryButtonSet extends React.Component { state = { categor...
230585
My controller like this : ``` public function index(Request $request) { $param = $request->all(); $data = $this->itemDetailRepository->getData($param); return view('item-detail.index', compact('param')) ->withItems(count($data)>0?$data:null); } ``` If I debug `$data` or in laravel (`dd($data)`), ...
Try this out: ``` @php $counts = array_map('count', $data); $key = array_flip($counts)[max($counts)]; @endphp <table> <tr> @foreach ($data[$key] as $key => $value) <th>{{$key}}</th> @endforeach </tr> @foreach($data as $value) <tr> @foreach ($value as $key...
230926
``` ResponseEntity<JsonNode> response = null; //Calling POST Method response=restTemplate.exchange(url, HttpMethod.POST,request,JsonNode.class); restResponse.setStatusCode(response.getStatusCode()); restResponse.setHeaders(response.getHeaders()); if(response.getBody().isNull()) { //...
I would use [`HttpEntity#hasBody`](https://docs.spring.io/spring/docs/current/javadoc-api/org/springframework/http/HttpEntity.html#hasBody--) before retrieving the body. There is a good chance the entity doesn't have a body. It's more expressive than a `response.getBody() != null` check. Please, don't assume that `isN...
231337
I have a view controller in Cocoa Touch that detects when the device rotates and switches between the views of the 2 view controllers it has: landscape and portrait. I want the `UIViewControllers` in it to be able to access the `FRRRotatingViewController`, in a similar way as all `UIViewControllers` can access the `UI...
You can use forward declarations for classes and protocols in headers in most situations to avoid circular import issues, except in the case of inheritance. In `FRRViewController.h`, instead of importing `FRRRotatingViewController.h`, can you not make a forward declaration? ``` @class FRRRotatingViewController; ```
231873
I am having issues with my combo box. I am trying to set the selection at runtime, but the binding is not working. ``` public ICLINKDesignatorCandidate SelectedDesignator SelectedDesignator.Designator = somevalue; ... <ComboBox Grid.Row="4" DisplayMemberPath="DisplayName" SelectedValuePath="{Binding Path...
DesignatorId is not the same as DesignatorID Property names are case sensitive The XAML does not match the property name
232078
I'm trying to join tables and load data with a specific value from a Textbox but It's giving the following error: "An exception of type 'System.NullReferenceException' occurred in Boxing.exe but was not handled in user code Additional information: Object reference not set to an instance of an object." My code: ``` ...
You could use a map to achieve this See the snippet below ```js function removeDuplicate(arrayOfObject){ let store = new Map() return arrayOfObject.filter(obj=>{ // If the item exist in the store already return false and do not add it to the new array if(store.get(obj.name) === obj.customer_id ){ retu...
232288
I've been doing the Weather tutorial on [The New Boston](http://www.youtube.com/watch?v=Z1rtldBTzCE&feature=edu&list=PL2F07DBCDCC01493A&noredirect=1) In logcat I see the following error : error opening trace file: No such file or directory(2). The emulator can run the program but when I type "stad" in the upper editte...
The easiest thing to do here is to write a regular expression to capture the text, then parse out the captures to see what you got. To start, lets assume you have your test bench: ``` $tests = array( 'Genesis 1:1' => 'Genesis Chapter 1, Verse 1', '1 Kings 2:5' => '1 Kings Chapter 2, Verse 5', 'Job 3' => '...
232459
I have to open different Modals based on the onClick event on IDs using same Function. I'm using If condition to check, but it is always taking the first condition to be true. Please help. ``` //html <div id="Remote-Parking" class="element parking" onclick="modalFunction()">Remote-Parking</div> <div id="Emergency-Brak...
In the way you have asked the questioned, my answer is following. Hope it will help you ```html <div id="Remote-Parking" class="element parking" onclick="modalFunction( this.id )">Remote-Parking</div> <div id="Emergency-Braking" class="element collision-detection" onclick="modalFunction( this.id )">Emergency-Braking<...
232470
I'm having some trouble trying to make a simple view background within a method like: ``` self.view.backgroundColor=[UIColor redColor]; ``` It works on the "- (void)viewDidLoad" thing, but not on mine. Heres the .m: ``` #import "DetailView.h" #import "MainViewController.h" @interface DetailView () @end @implement...
The way I understand it right now is that Node-space is local to that node, and World-space is global space (but not necessarily screen-space, because of 3D cameras or whatever). The so if you want to get a position of one node's position relative to another, you first convert that node's position to world-space, usin...
232497
I'm new to python and continuously learning to build better codes in python. I have two lists; one with indexes stored in x variable, where the indexes in the x represents index of tuples in list named bb with string ('IN') and surrounded on both sides at least with one tuple containing 'NN'. What i'm trying to get f...
This seems like a good problem for [`itertools.groupby`](https://docs.python.org/2/library/itertools.html#itertools.groupby) which groups contiguous elements of a list together based on whether each element is true or not according to some condition that you define. In your case you can use the following: ``` groups ...
232761
I'm a noob with R. I want the alphabet index of each letter in a word. I don't understand what I'm doing wrong, since the individual command works perfectly... ``` word <- "helloworld" l <- numeric(nchar(word)) for (i in 0:nchar(word)) { l[i] <- match(substr(word,i,i+1), letters) } l ``` returns a weird `[1] NA NA...
The problem with your code is two fold. First R indices start at 1 so when i = 0, l[i] is undefined. Second, it doesn't just pull off a single letter at a time ``` i = 1 substr(word,i,i+1) [1] "he" ``` A different approach ``` setNames(1:26, letters)[ strsplit("hello", NULL )[[1]] ] ```
233522
Recently, I am doing the flyback, when I design the control stage I have some questions: This is the [optocoupler(PC817)](https://www.farnell.com/datasheets/73758.pdf) I used and this figure is Current Transfer Ratio vs. Forward Current. There are my questions: 1.) How to decide the CTR value, because the forward cur...
In a closed-loop system like with a switching power supply, the optocoupler collector current will vary depending on the operating conditions. For most of the controllers configurations, regulation is ensured by pulling down the FB pin. This is easy for the PCB layout as you do not need to resort to another bias and ro...
234252
I have a URL displayed in the UI,Something like below ``` <div class="form-group col-md-3 col-sm-3 col-xs-12"> <label for="url" l10nTranslate >URL</label > <a [href]="fg.Url.value">{{ fg.Url.value }}</a> </div> ``` So I have a clickable URL displayed in the UI below the URL label. Whe...
The problem is that every call from the `run()` method to `studentRepository` and `studentService` are separate sessions/transactions. It's virtually as-if you did this: ``` ... beginTransaction(); this.studentRepository.save(student); commit(); ... beginTransaction(); this.sectionRepository.save(section); commit();...
234454
Referring to the [Question](https://serverfault.com/questions/339661/will-changing-nameservers-cause-down-time) already asked, several people have said > > No, as long as both sets of nameservers have the same records you'll experience no downtime. > > > What does same records meant here? How can I do that? I cu...
I guess you know all IP range, so please scan all of them. Generally speaking in the open port you will have the DNS for all the DC. You can issue an **nbtstat** after to find the domain from computer that are possible DC from what you discovered; > > nbtstat -A IP\_ADDRESS > > > It would issue an answer like t...
234579
I want to, for example, use rules to notify all users in a particular section that an item of content in their section is 'awaiting moderation'. Is there a way in Rules to get access to a node's Workbench section? I can get access to the workbench access term id/menu id, depending on the scheme I'm using, but how can...
If you use workbench access with a taxonomy scheme you could try this In rules, add an event After moderation transition. Add the conditions (previous state moderation, current state moderation) according to yours states in workbench moderation Add the condition Entity has field and then select the field of your workb...
235258
I'm trying to send an invoice message in the Telegram bot, but get an error {"ok":false,"error\_code":400,"description":"Bad Request: can't parse prices JSON object"} Here is my send invoice def: ``` def sendInvoice(chat_id): invoice = {'chat_id': chat_id, 'title': 'Оплата услуги', '...
You need to convert your list of prices to json serializable - use the json module built it in python ``` json.dumps([ { "label": "My product", "amount": 999999 } ]) ```
235280
I'm trying to redact phone number information from an html file ... and while I can identify all of the phone numbers easily enough I can't figure out why I am unable to replace the phone numbers that have parentheses in them. Sample below: ``` import re from bs4 import BeautifulSoup text = '''<html> <head> <meta con...
You can use `.find_all(text=True)` to obtain all text content from the HTML soup, and then replace it with `re.sub` (that way, you preserve all tags, including `<li>`): ``` for content in soup.find_all(text=True): s = re.sub(r'(\(?\d{3}\)?)([\s.-]*)(\d{3})([\s.-]*)(\d{4})', '(XXX) XXX-XXXX', content) content.r...
235433
I'm trying to make a service that works 24/7 and it's been working until I updated to Android 12. I've checked the new foreground restrictions but still don't understand why it isn't working since I'm starting it from an activity. ACTIVITY ``` import android.content.Intent; import android.os.Build; import android.os....
Turns out samsung put my app on deep sleep which caused it to close itself if not used for a minute. Also thanks to the people who took their time to try and help.
235568
In device driver programming we are using 1. device driver code, 2. device file, 3. user space application code and 4. actual physical hardware. * I am able to write the driver code, user space application code and manually creating device file but interfacing hardware i want to try (at least blinking an LED through ...
Because strings in JavaScript don't have an `equals` method. You compare them via `===`. Also, you can simplify your `isPermutation` function by returning the result of the comparison directly. ```js function sort(string) { return string .split("") .sort() .join(""); } function isPermutation(s1,...
235579
I'm building a program that communicates with Emacs, and one of the challenges I'm facing is writing Emacs's process filter function. Its input string is a series of s-expressions to be evaluated. Here is a sample: ``` (gimme-append-to-buffer "25 - William Christie dir, Les Arts Florissants - Scene 2. Prelude - Les Ar...
That's what I do in a shell mode I use. I look for a special end-of-record string in the process output, to know when the output is complete. Until then I concat the chunks. ``` (defun my-shell-exec-filter (process result) (let ((end-of-result (string-match my-shell-end-of-record-string result))) (if (and end...