user678392

1

votes
2

answer
575

views

dequeueReusableCellWithIdentifier causes blank table cell

My goal is to display a list of cells that are populated by some data I pull down from a server. And as the user scrolls down I would like there to be, briefly, a table cell that says 'Loading More', and then goes away as more cells are filled in with data. Here are the relevant sections to do this:...
user678392
1

votes
1

answer
584

views

Android studio tells me I need a version of Gradle >= 1.8 and <=1.6

Steps I took to download Android Studio: http://wiki.ros.org/sig/Rosjava/Android%20Studio/Download So when I try to use the default gradle wrapper it tells me that I need to version 1.8. So I looked up how to fix this, and so I downloaded a gradle version 1.8. Whenever I use that, it tells me that I...
user678392
1

votes
2

answer
944

views

Incompatible Mat in OpenCV for Android

prevPts = new MatOfPoint2f(prev); prev is a Mat; The first line prevPts = new MatOfPoint2f(prev); raises and exception Incompatible MAT. I don't understand why it is doing this. The API says that MatOfPoint2f can take in a MAT.
user678392
1

votes
2

answer
0

views

Typecast for qsort function pointer

#include #include #include #include static int cmpstringp(const void *p1, const void *p2) { /* The actual arguments to this function are 'pointers to pointers to char', but strcmp(3) arguments are 'pointers to char', hence the following cast plus dereference */ return strcmp(* (char * const *) p...
user678392
1

votes
1

answer
965

views

How to write a function to do the dot product on n-dimensional vector?

First of all, here's a short reminder on what the dot product is. I would like to be able to have a chunk of code, which I can use in the following manner: let x = Vector(dimensions: 3) let y = Vector(dimensions: 3) //... //assign some values (coordinates) to x and y //x.dotProduct(y) How do I imp...
user678392
1

votes
1

answer
2.4k

views

Is there a way to initialize an array in Swift to have a repeated value of some Type T

In my init function, I have: self.x = [T](count: dimensions, repeatedValue: 0) This does not work. How do I get this to work. I want x to be an array with type T that is initialized to 0. (T is intuitively like Int but could be some other number representation.)
user678392
1

votes
2

answer
1.5k

views

Add Sdk (Pushwoosh SDK)

I probably have the simplest question in the world. Here goes: I am using pushwoosh for push notifications for my ios app. Basically, you just have to simply add Push NotificationsSDK to your project. Here is the link to the sdk: https://github.com/shaders/push-notifications-sdk/tree/master/SDK/iPho...
user678392
2

votes
2

answer
1.6k

views

Installing Vuforia for Augmented Reality apps

I'm trying to install Vuforia so I can develop Augmented Reality apps for my phone. I'm on step 3: https://developer.vuforia.com/resources/dev-guide/step-3-compiling-running-vuforia-sample-app Here is the step I'm on: Change directory to ImageTargets in the \vuforia-sdk-android-xx-yy-zz\samples whe...
user678392
4

votes
1

answer
3.3k

views

How do you remove files from one and only one branch in git

I want a branch to hold all the files from my master branch except for foo.txt and foo2.txt. How do I do this?
user678392
2

votes
4

answer
1.5k

views

Regular expression for finding two words in a string

Here is my basic problem: I am reading some lines in from a file. The format of each line in the file is this: John Doe 123 There is a tab between Doe and 123. I'm looking for a regex such that I can 'pick off' the John Doe. Something like scanner.next(regular expression) that would give me the...
user678392
2

votes
1

answer
361

views

Swing, Java and multithreading, and coloring buttons

Yes, this is homework. Yes, I am completely stuck. Here is the gist. I have created a JFrame. There are 3 panels (top, middle, bottom). In the bottom panel are 3 buttons called: Red, Green, and Blue. In the top Panel are 3 text fields that give us the number of times we have clicked the respective b...
user678392
2

votes
1

answer
1.2k

views

Find all possible combinations of a scores consistent with data

So I've been working on a problem in my spare time and I'm stuck. Here is where I'm at. I have a number 40. It represents players. I've been given other numbers 39, 38, .... 10. These represent the scores of the first 30 players (1 -30). The rest of the players (31-40) have some unknown score. What...
user678392
2

votes
2

answer
1.4k

views

How do you assign a slice of numbers to an array in swift

x is an object that holds an array called point. x implements the subscript operator so you can do things, like x[i] to get the array's ith element (of type T, which is usually an Int or Double). This is what I want to do: x[0...2] = [0...2] But I get an error that says ClosedInterval is not conver...
user678392
3

votes
5

answer
4.9k

views

Adding unsigned integers in C

Here are two very simple programs. I would expect to get the same output, but I don't. I can't figure out why. The first outputs 251. The second outputs -5. I can understand why the 251. However, I don't see why the second program gives me a -5. PROGRAM 1: #include int main() { unsigned char a; un...
user678392
4

votes
3

answer
2.3k

views

Getting Docker to recognize nvidia graphics card on mac

When I am in my container, I run lspci | grep -i nvidia and nothing shows. When I run ./deviceQuery from the samples NVIDIA provides I get no CUDA-capable device is detected I know I have a nvidia driver on my mac. I just can't figure out how to get my docker container to realize that.
user678392
3

votes
1

answer
498

views

How does this C code (from lua library, Torch) even compile/work?

See https://github.com/torch/nn/blob/master/generic/Tanh.c For example, static int nn_(Tanh_updateOutput)(lua_State *L) { THTensor *input = luaT_checkudata(L, 2, torch_Tensor); THTensor *output = luaT_getfieldcheckudata(L, 1, 'output', torch_Tensor); THTensor_(resizeAs)(output, input); if (input->nD...
user678392
2

votes
1

answer
1k

views

UIApplicationDidBecomeActiveNotification notifications not firing when run app first time

I have called this line of code in the init method and viewDidLoad method. However, the method applicationDidBecomeActiveNotification NEVER fires on the first time I run the app. It only runs after I have run it once. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(applicat...
user678392
1

votes
3

answer
5.2k

views

Open a workspace, not a project in xcode

This is probably a trivial question, but I downloaded some code that is supposed to demo how some 3rd party code is supposed to work. It doesn't work. I've been told that I should open the workspace, not the project. I have no idea what this means.
user678392
3

votes
1

answer
1.6k

views

OpenCV for Android: Sample Project ClassNotFound Exception

I'm trying to run a sample from opencv for android. It's not working. java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{org.opencv.samples.puzzle15/org.opencv.samples. puzzle15.Puzzle15Activity}: java.lang.ClassNotFoundException: Didn't find class 'org.opencv.samples.puzzle15....
user678392
1

votes
1

answer
958

views

Removing Gravity from Accelerometer … Documentation code

public void onSensorChanged(SensorEvent event) { // alpha is calculated as t / (t + dT) // with t, the low-pass filter's time-constant // and dT, the event delivery rate final float alpha = 0.8; gravity[0] = alpha * gravity[0] + (1 - alpha) * event.values[0]; gravity[1] = alpha * gravity[1] + (1 - a...
user678392
3

votes
2

answer
1.7k

views

Minimize set of edges in a directed graph keeping connected components

Here is the full question: Assume we have a directed graph G = (V,E), we want to find a graph G' = (V,E') that has the following properties: G' has same connected components as G G' has same component graph as G E' is minimized. That is, E' is as small as possible. Here is what I got: First, run th...
user678392
2

votes
1

answer
814

views

Max Flow Linear time algorithm, Find a valid flow

So let me explain the question: You are given a graph. You find the max flow. But it turns out that an edge, e_i, had the wrong capacity. It had one less. Unfortunately, the flow was maxed out at the old capacity. Compute the new max flow in linear time (in terms of the number of edges and vertices)...
user678392
1

votes
5

answer
91

views

Declaring structs in C

struct node { int data; struct node *next; }*head; Why do we have *head? And is this different (better?) than doing typedef struct { int data; struct node *next; }head;
user678392
4

votes
2

answer
1.1k

views

What is the difference between Local and External Parameter Names in Swift

https://developer.apple.com/library/ios/documentation/Swift/Conceptual/Swift_Programming_Language/Initialization.html#//apple_ref/doc/uid/TP40014097-CH18-ID203 struct Celsius { var temperatureInCelsius: Double init(fromFahrenheit fahrenheit: Double) { temperatureInCelsius = (fahrenheit - 32.0) / 1.8...
user678392
66

votes
8

answer
36.9k

views

Manacher's algorithm (algorithm to find longest palindrome substring in linear time)

After spending about 6-8 hours trying to digest the Manacher's algorithm, I am ready to throw in the towel. But before I do, here is one last shot in the dark: can anyone explain it? I don't care about the code. I want somebody to explain the ALGORITHM. Here seems to be a place that others seemed to...
user678392
8

votes
1

answer
3.2k

views

When does Caffe make copies of the data?

// Assuming that data are on the CPU initially, and we have a blob. const Dtype* foo; Dtype* bar; foo = blob.gpu_data(); // data copied cpu->gpu. foo = blob.cpu_data(); // no data copied since both have up-to-date contents. bar = blob.mutable_gpu_data(); // no data copied. // ... some operations ......
user678392
2

votes
1

answer
5.9k

views

KeyTyped method says TextField is blank … when it's not

Jtxtfield.addKeyListener(new KeyListener() { public void keyPressed(KeyEvent e) {}; public void keyTyped(KeyEvent e) { if(Jtxtfield.getText().equals('')) System.out.println('hello1'); }public void keyReleased(KeyEvent e) { if(Jtxtfield.getText().equals('')) System.out.println('hello2'); } }); Output...
user678392
3

votes
1

answer
814

views

OpenCv for iphone build error

I'm trying to follow this tutorial: http://docs.opencv.org/doc/tutorials/ios/video_processing/video_processing.html I have followed the steps but in the viewController.h file, it tells you to type 'using namespace cv;' near the top of the file. Xcode sees this as an error. And it won't let me build....
user678392
1

votes
2

answer
2.1k

views

.get function with an opened file stream in C++

I have an open input file stream. It is able to open the other file (a txt file) successfully. And by making adjustments to the code right below I can get it read and output the other txt file (all ASCII characters, just letters) just fine. However, I was playing around with the below function. This...
user678392
2

votes
2

answer
301

views

Column item_name not found in android

Does anyone have an answer? Code in my database helper class: public void onCreate(SQLiteDatabase db) { db.execSQL(DATABASE_CREATE); db.execSQL(CREATE_ITEM_DB); } public static final String ITEM_NAME = 'item_name'; public static final String ITEM_STATUS = 'item_status'; public static final String IT...
user678392
2

votes
1

answer
647

views

Caffe Deep Learning Library example

Here is an example from http://caffe.berkeleyvision.org/tutorial/net_layer_blob.html I'm kind of lost. What am I supposed to infer from this example? // Assuming that data are on the CPU initially, and we have a blob. const Dtype* foo; Dtype* bar; foo = blob.gpu_data(); // data copied cpu->gpu. foo...
user678392
1

votes
2

answer
3.2k

views

Way to round up number to an int size boundary number of bytes

The following code rounds up the argument to an int size boundary number of bytes. #define _INTSIZE(n) ((sizeof(n) + sizeof(int) - 1) & ~(sizeof(int) - 1)) On my machine int is 4 bytes, so -- correct me if I'm wrong -- this should be the same as looking for the next multiple of 4 of an integer (on m...
user678392
2

votes
1

answer
310

views

EGOTableViewPullRefresh Too quick

I've put EGOTableViewPullRefresh in my project. However, I've noticed one troubling thing. If I ever need to download a (semi-moderately) large file by pulling down to refresh, EGOTableViewPullRefresh says that I am done downloading much faster than I really am. Is there a way to make EGOTableViewPu...
user678392
2

votes
1

answer
271

views

UINavigationController pushes UIViewController and nothing happens

Here are the relevant lines of code: ... if([top class] == [SitesViewController class]){ BackupsViewController *backup = [[BackupsViewController alloc] initWithStyle:UITableViewStyleGrouped andID:cg_id]; [websites pushViewController:backup animated:NO]; [websites pushViewController:details_controll...
user678392
1

votes
2

answer
896

views

Explain Python code for listing all permutations

class Permutation: def __init__(self,justalist): self._data = justalist[:] self._sofar = [] def __iter__(self): return self.next() def next(self): for elem in self._data: if elem not in self._sofar: self._sofar.append(elem) if len(self._sofar) == len(self._data): yield self._sofar[:] else: for v in...
user678392
8

votes
3

answer
2.8k

views

Don't understand closures example in Swift

I'm trying to learn about swift and closures. I'm stuck on this example. numbers.map({ (number: Int) -> Int in let result = 3 * number return result }) What is (number: Int) -> Int? Is it a function? Where is it defined? https://developer.apple.com/library/ios/documentation/Swift/Conceptual/Swift_Pr...
user678392
0

votes
0

answer
1.2k

views

NDK Android: Your APP_BUILD_SCRIPT points to an unknown file

Your APP_BUILD_SCRIPT points to an unknown file: /Users/myusername/jni/Android.mk /Users/myusername/Android/Development/android-ndk-r9/build/core/add-application.mk:176: * Android NDK: Aborting... . Stop. Lots of people seem to have this error. However, none of help seems to be helping. If you...
user678392