How to do things

Designing a generic API response object with a dynamic nature

I want to minimize the number of classes I create, and if there is a way to not have to create a class for each and every API response that would be great.I want to wrap all my API responses with:

class ApiResponse
def initialize(success, message)
@success = success
@message = message

I will then return with something like:

def show
ar = ApiResponse.

Databases that support serialized transactions without locking on updates

So far I've seen the following behavior in databases that claim to support serialized transactions - or to be precise serializable isolation level for transactions:

(e.Oracle, Postgres) If multiple simultaneous transaction try to modify the same row, one "wins" and the others lock on update until "winner" transaction commits or rolls back.

cout pi - why is the output different than the input?

I am sure the answer is probably something simple, and I don't know what is going on due to the fact that I'm still a newb after programming for 20 years, but will some sharp person please help me understand why cout's output is different than the value I have given it?h>

using namespace std;

int main() {


Python regular expression quoted string

I have the following string:

str1 = "I am doing 'very well' for your info"

and I want to extract the part between the single quotes i.I tried the following but obviously it will give wrong result

import re
pt = re.

make d3 force static layout more quickly


You are looking to modify the alpha decay rate, which controls the rate at which the force simulation cools:

The alpha decay rate determines how quickly the current alpha
interpolates towards the desired target alpha; since the default
target alpha is zero, by default this controls how quickly the
simulation cools.Higher decay rates cause the simulation to stabilize
more quickly, but risk getting stuck in a local minimum; lower values
cause the simulation to take longer to run, but typically converge on
a better layout.

Print the maximum non perfect square

I'm trying to make a c++ program that finds the maximum non perfect square in an array and print it, perfect square: i.e x = y^2 => 4=2^2

Here is what I've tried and doesn't work for me, don't know why?

PHP Push notification API

What are available HTML/PHP API's to send push notifications?I am planning to send a push notification in a time set by the user (sort of an alarm/reminder).