How to access (get or set) object attribute given string corresponding to name of that attribute
How do you set/get the values of attributes of `t` given by `x`? ``` class Test: def __init__(self): self.attr1 = 1 self.attr2 = 2 t = Test() x = "attr1" ```
- Modified
- 5 Dec at 12:42
C fopen vs open
Is there any reason (other than syntactic ones) that you'd want to use ``` FILE *fdopen(int fd, const char *mode); ``` or ``` FILE *fopen(const char *path, const char *mode); ``` instead of `...
How to use '-prune' option of 'find' in sh?
I don't quite understand the example given from the `man find`, can anyone give me some examples and explanations? Can I combine regular expression in it? --- The more detailed question is like ...
Checking for empty queryset in Django
What is the recommended idiom for checking whether a query returned any results? Example: ``` orgs = Organisation.objects.filter(name__iexact = 'Fjuk inc') # If any results # Do this with the res...
- Modified
- 7 Sep at 05:50
Does List<T> guarantee insertion order?
Say I have 3 strings in a List (e.g. "1","2","3"). Then I want to reorder them to place "2" in position 1 (e.g. "2","1","3"). I am using this code (setting indexToMoveTo to 1): ``` listInstance.Remove...
- Modified
- 20 Jun at 09:12
How do I create a custom Error in JavaScript?
For some reason it looks like constructor delegation doesn't work in the following snippet: ``` function NotImplementedError() { Error.apply(this, arguments); } NotImplementedError.prototype = ne...
- Modified
- 26 Jul at 21:1
What is a Predicate Delegate and where should it be used?
Can you explain to me: - - - Descriptive source code will be appreciated.
How to properly overload the << operator for an ostream?
I am writing a small matrix library in C++ for matrix operations. However my compiler complains, where before it did not. This code was left on a shelf for 6 months and in between I upgraded my comput...
- Modified
- 24 Aug at 16:6
How do I overload the square-bracket operator in C#?
DataGridView, for example, lets you do this: ``` DataGridView dgv = ...; DataGridViewCell cell = dgv[1,5]; ``` but for the life of me I can't find the documentation on the index/square-bracket oper...
- Modified
- 13 Nov at 19:39
Docker Error bind: address already in use
When I run `docker-compose up` in my Docker project it fails with the following message: > Error starting userland proxy: listen tcp 0.0.0.0:3000: bind: address already in use ``` netstat -pna | grep ...
- Modified
- 1 Jul at 17:24
How to get rid of underline for Link component of React Router?
I have the following: [](https://i.stack.imgur.com/Od7Ho.png) How do I get rid of the blue underline? The code is below: ``` <Link to="first"><MenuItem style={{paddingLeft: 13, textDecoration: 'none'}...
- Modified
- 30 Jun at 19:6
ITSAppUsesNonExemptEncryption export compliance while internal testing?
I got this message while selecting build for internal testing.it says about setting in info.plist what does it mean? is it necessary? [](https://i.stack.imgur.com/M0QBP.png)
- Modified
- 2 Mar at 05:42
How can I display a modal dialog in Redux that performs asynchronous actions?
I'm building an app that needs to show a confirm dialog in some situations. Let's say I want to remove something, then I'll dispatch an action like `deleteSomething(id)` so some reducer will catch th...
- Modified
- 26 Feb at 01:24
Can't push image to Amazon ECR - fails with "no basic auth credentials"
I'm trying to push a docker image to an Amazon ECR registry. I'm using docker client Docker version 1.9.1, build `a34a1d5`. I use `aws ecr get-login --region us-east-1` to get the docker login creds. ...
- Modified
- 4 Feb at 12:51
You need to install postgresql-server-dev-X.Y for building a server-side extension or libpq-dev for building a client-side application
I am working on Django project with virtualenv and connect it to local postgres database. when i run the project is says, ``` ImportError: No module named psycopg2.extensions ``` then i used this c...
- Modified
- 31 Jan at 16:21
Using streams to convert a list of objects into a string obtained from the toString method
There are a lot of useful new things in Java 8. E.g., I can iterate with a stream over a list of objects and then sum the values from a specific field of the `Object`'s instances. E.g. ``` public cla...
- Modified
- 2 Sep at 09:47
How to center buttons in Twitter Bootstrap 3?
I am building a form in Twitter Bootstrap but I'm having issues with centering the button below the input in the form. I have already tried applying the `center-block` class to the button but that did...
- Modified
- 11 Oct at 17:50
Deciding between HttpClient and WebClient
Our web application is running in .NET Framework 4.0. The UI calls the controller methods through Ajax calls. We need to consume the REST service from our vendor. I am evaluating the best way to cal...
- Modified
- 20 Jun at 12:41
Disable Laravel's Eloquent timestamps
I'm in the process of converting one of our web applications from CodeIgniter to Laravel. However at this moment we don't want to add the `updated_at` / `created_at` fields to all of our tables as we ...
Parallel foreach with asynchronous lambda
I would like to handle a collection in parallel, but I'm having trouble implementing it and I'm therefore hoping for some help. The trouble arises if I want to call a method marked async in C#, withi...
- Modified
- 21 May at 06:52
Split a python list into other "sublists" i.e smaller lists
I have a python list which runs into 1000's. Something like: ``` data=["I","am","a","python","programmer".....] ``` where, len(data)= say 1003 I would now like to create a subset of this list (dat...
- Modified
- 12 Mar at 16:46
Can't compile project when I'm using Lombok under IntelliJ IDEA
I'm trying to use [Lombok](http://projectlombok.org/) in my project that I'm developing using IntelliJ IDEA 11. I've installed [3rd-party plugin for IDEA](http://code.google.com/p/lombok-intellij-plug...
- Modified
- 22 Dec at 20:9
UTF-8 byte[] to String
Let's suppose I have just used a `BufferedInputStream` to read the bytes of a UTF-8 encoded text file into a byte array. I know that I can use the following routine to convert the bytes to a string, b...
Pythonic way to combine datetime.date and datetime.time objects
I have two objects that represent the same event instance --- one holds the date, the other the time of this event, and I want to create a datetime object. Since one can't simply add date and time o...
Do something if screen width is less than 960 px
How can I make jQuery do something if my screen width is less than 960 pixels? The code below always fires the 2nd alert, regardless of my window size: ``` if (screen.width < 960) { alert('Less ...
- Modified
- 5 Jun at 11:6