Loop through array for INSERT query parameters

So a INSERT query is like this: $stmt = $db->prepare("INSERT INTO table () VALUES ()"); I have an array here: $array = ['a', 'aa', 'aaa', 'b', 'bb', 'sds', 'asdf', 'sdfswe', 'sdvsd', 'sdasss', 'sbdss', 'sdfabwew', 'asdfavs', 'sdbweq', 'sdfbs',...
more »

2017-08-13 22:08 (1) Answers

Plotting 3D image form a data in NumPy-array

I have a data file in NumPy array, I would like to view the 3D-image. I am sharing an example, where I can view 2D image of size (100, 100), this is a slice in xy-plane at z = 0. import numpy as np from matplotlib import pyplot as plt from mpl_toolk...
more »

2017-08-13 20:08 (1) Answers

numpy array with the second dimension empty

Although I have seen some answers for this question, I was wondering if there's any better way to solve this problem. For example, N = 15 A = np.repeat(1/N, N) if I do this the result will have shape (15, ) If I want the shape to be (15,1), I t...
more »

2017-08-13 19:08 (1) Answers

codewar challenge javascript

I hope everyone is having a good day. This is my first ever post on Stackoverflow! I have just completed the javascript course on codeacademy and have read a couple of books on it too. Now I am on codewars. I would classify myself as a beginner in ...
more »

2017-08-13 16:08 (5) Answers

Cakephp hash extract parent_id null

Using array below i am trying to extract the id for vocabulary_id and null parent_id. Hash::extract(array, '{n}[vocabulary_id=9]') works Hash::extract(array, '{n}[vocabulary_id=9][parent_id=null') fails array( array( 'id' => 240,'parent_id' =>...
more »

2017-08-13 11:08 (0) Answers

Modifying array inside a function in C

// test.txt 50 13 124 - void hi ( int *b, FILE *pfile ) { rewind ( pfile ); int i; for( i = 0 ; i < 3 ; i++ ) { fscanf ( pfile, "%d", &b[i] ); } } int main ( void ) { FILE *fp = fopen ( "test.txt", "r" ); ...
more »

2017-08-13 01:08 (3) Answers

convert numpy array to 0 or 1

A = np.array([[0.94366988, 0.86095311, 0.88896715, 0.93630641, 0.74075403, 0.52849619 , 0.03094677, 0.85707681, 0.88457925, 0.67279696, 0.26601085, 0.4823794 , 0.74741157, 0.78575729, 0.00978911, 0.9203284, 0.02453...
more »

2017-08-12 11:08 (4) Answers

Subscript outside of limit

I tried several times in my cmd running this code but every time it says subscript out of limit at line 1 at the Declare but I haven't found any problem what should I do? declare type namesarray is varray(5) of varchar2(10); type grades i...
more »

2017-08-12 08:08 (1) Answers

Compare two arrays of musical scale notes

I have two arrays — one representing the musical notes of a scale (in MIDI note numbers), and the other representing the user's raw input of notes recorded by an instrument. Both arrays are lists of Ints, representing musical notes. The scale arr...
more »

2017-08-12 02:08 (1) Answers

Pass variable from array into a function

I have this function: function getTotal () { var args = Array.prototype.slice.call(arguments); var total = 0; for (var i = 0; i < args.length; i++) { total += args[i]; } return total; } Lets say that I have an array...
more »

2017-08-11 16:08 (5) Answers

I have trouble with quicksort algorithm

I have problems with Quicksort algorithm. I have read on the internet about it on different pages, also Wikipedia. But they explained not too much in detail. I have understood their examples when you choose the very last element as pivotelement. In t...
more »

2017-08-11 14:08 (2) Answers

Post array and variable to view

I want to post an array and a variable to view. Here is my variable. $ausgabeSpieltag = $saisonMaxSpieltagEins; And here is my array and the way like I post it to view at the moment. But now I need additional the variable in the ->with part. $spi...
more »

2017-08-11 11:08 (3) Answers

JavaScript to split data and calculate sums

I believe what I need are two JavaScript functions. I am receiving a comma separated string that holds two types of data: 1) device name followed by 2) numeric value. These two values are separated by a comma, and each set is also separated by a comm...
more »

2017-08-11 10:08 (4) Answers

Swift generics and subclasses

my question might be simple, but it got me puzzled a bit: Imagine I have an array of different objects which all have a common parent class "MyClass". var values = [MyClass]() However they all have their specific subclass like for example "...
more »

2017-08-11 09:08 (3) Answers

Manipulating the constructor of a class in Java

I have an exercise about the analysis of passwords (weak vs strong) and I have to create 2 constructors. One of them must receive the length of a password and the password must be created randomly, how can I do that ? Also I'm having trouble determi...
more »

2017-08-11 05:08 (3) Answers