Peterk.

1

votes
1

answer
16

views

In C++ Is there a (new) way to test if a class has a vrtual destructor in a templace without instantiating an intance?

I have done some looking around and many discussions say "no you can't do that" but it is all evolving fast and I would like to test for this characteristic in a template that does not have access to a pointer to an instance of the object.
peterk
-2

votes
1

answer
35

views

Is there a way in C++ to determine if a string is “interned” or in a read only persistent location?

many compilers and loaders will assign strings simply declared as "a string" to read only persistent memory segments. Is there a way to determine this at runtime so as not to allocate duplicates when persistence is desired and one gets passed "const char *" arguments ? Also to prevent freeing them.
peterk
2

votes
0

answer
31

views

How do I override touch zoom and pan in firefox & chrome with pointer events

This goes for other browsers too but primary targets are Firefox and Chrome. I have registered all pointer event listeners and had to register mouse down and moue up listeners to get the button state changes ( button states in pointer events are not accurate or "chorded" ) But even if I do event.pre...
peterk
1

votes
2

answer
27

views

In a git repository is it possible to pre-specify “remotes” in the clone's configs?

In a git repository I would like to "pre specify" remotes so when one clones the repository the remotes are pre-loaded into the clone's .git/config? Is this reasonably possible ? If so how?
peterk
1

votes
2

answer
5.1k

views

self.navigationController popToRootViewControllerAnimated:YES do not pop back to the root

I have this line of code to pop back to the root menu when clicking the "back" button on the top bar: - (void)viewWillDisappear:(BOOL)animated { [super viewWillDisappear:animated]; [self.navigationController popToRootViewControllerAnimated:YES]; } I have had no problem with this until now, i still u...
PeterK
1

votes
1

answer
49

views

Can one declare a constructor using a typeded or typename as in Microsoft C in other compilers?

Well annoyingly it seems to work in Microsoft C but not other compilers I use. Especially desirable when using templates. Maybe I don't know the "standards compliant way" to do this, but It is really useful and i want code to compile on gcc, clang, etc. template class MyTemplate { protected: typede...
peterk
2

votes
2

answer
248

views

NSDictionary, why is this

I am learning this trade and is currently focusing on NSDictionary. I am currently doing examples from the book "Beginning iPhone Development Exploring the iPhone SDK" (Dave Mark / jeff LaMarche). The example i am working on is in chapter 7 (page 166), Tab Bars and Pickers. I would like to ask why t...
PeterK
2

votes
3

answer
457

views

looping array and saving objects in NSMutableDictionary does not work?? logical problem?

It seems like i have a logical problem in this loop. I am trying to: Looping myKeys (from a dict) to find selected players Setting three BOOL parameters for the selected players (YES or NO) in an NSMutableArray (thePlayers) Updating a dict (selectedPlayerDict) with 'thePlayers' and 'myKeys' Empty t...
PeterK
3

votes
1

answer
587

views

Torch: NN handling text and numeric input

I have the following NN architecture: Part 1: nn.Sequential { [input -> (1) -> (2) -> (3) -> (4) -> (5) -> (6) -> (7) -> output] (1): nn.TemporalConvolution (2): nn.TemporalMaxPooling (3): nn.TemporalConvolution (4): nn.TemporalMaxPooling (5): nn.Reshape(14336) (6): nn.Dropout(0.500000) (7): nn.Line...
PeterK
18

votes
2

answer
10k

views

Shift count negative or too big error - correct solution?

I have the following function for reading a big-endian quadword (in a abstract base file I/O class): unsigned long long File::readBigEndQuadWord(){ unsigned long long qT = 0; qT |= readb()
PeterK
18

votes
6

answer
19.1k

views

How to correctly fix “zero-sized array in struct/union” warning (C4200) without breaking the code?

I'm integrating some code into my library. It is a complex data structure well optimized for speed, so i'm trying not to modify it too much. The integration process goes well and actually is almost finished (it compiles). One thing is still bothering me. I'm getting the C4200 warning multiple times:...
PeterK
2

votes
3

answer
2.1k

views

NSMutableArray addObject mistake

I can not addObject into 'easyQArray' (NSMutableArray). It did work when I had the array defined locally but when I moved the declaration into the .h file it does not work anymore. The app crash ofc as I try to access an index in the array that does not exist: // Create question arrays if (easyPlaye...
PeterK
19

votes
3

answer
5.1k

views

Release mode static library much larger than debug mode version

today i found out that the compiled static library i'm working on is much larger in Release mode than in Debug. I found it very surprising, since most of the time the exact opposite happens (as far as i can tell). The size in debug mode is slightly over 3 MB (its a fairly large project), but in rele...
PeterK
2

votes
2

answer
340

views

Two dimensional arrays allocation problem

this is an interview question my friend was asked yesterday. The question was something like: will this program crash with an "access violation" error or not? I looked at it for a while and thought no, it won't. But actually trying this out in visual studio proved me wrong. I cannot figure out what...
PeterK
2

votes
2

answer
3.2k

views

Problem with linking against a static library which has inline functions

i have a static library which (among other things) implements a tiny function that only returns some string from a table of const strings. This function is not called anywhere inside the library, but still it's declared as inline. For clarity, it looks like this: namespace flow { inline const char*...
PeterK
1

votes
1

answer
984

views

CoreData: error: (14) on device, not in simulator

I get this error when running on the device, not the simulator (now). I did get the same error on simulator as well and implemented the solution from this thread: enter link description here with this code: - (NSPersistentStoreCoordinator *)persistentStoreCoordinator { if (__persistentStoreCoordinat...
PeterK
2

votes
1

answer
59

views

Are there tools for culling unused classes from a jar file or set of jar files for a java applicaton

So we have an extensive library of java code in a number projects that make jar files and external libraries. I am working on an app that uses a sparse set of classes from the large set of jar files in the class path. Because we are loading the app on a device with limited storage I would like to...
peterk
2

votes
1

answer
1.6k

views

Storing int32 in Core Data model and Cocoa Error 1660

Edit: I was able to fix the presentation thing by changing the NSLog to present the actual int rather than the pointer. NSLog(@"id: %i", [[info valueForKey:@"idQ"] intValue]); Still have the Cocoa error 1660 to solve?? I am doing my first tests with Core Data and is using this (http://www.raywende...
PeterK
3

votes
2

answer
283

views

Specialize member function of a templated derived class

I have the following code (very simplified for the sake of clarity): class Base { virtual int DoStuff(int arg) = 0; }; template class Derived : public Base { int DoStuff(int arg) override { // do some stuff return 0; } }; This works great. Now I want to implement a special (vectorized) implementati...
PeterK
1

votes
2

answer
56

views

Multi threaded access to map object that won't be modified after creation

What is the best practice for creating a Map object that will be access from multiple threads, but that will not be modified after initialization? Would it be: use a ConcurrentHashMap object create a normal HashMap object and wrap this in a Collections#unmodifiableMap call? Only retaining a referenc...
PeterK
2

votes
2

answer
1.1k

views

Update read-only Core Data sqlite in main bundle

I am using a read-only Core Data sqlite from the Main Bundle, works well. When i add a new version of the database (more read-only data) to the main bundle it still reads the "Old" version of the database. Anyone that can help me understand why and what to do to get the new database version the curr...
PeterK
5

votes
4

answer
7.7k

views

Flexible logger class using standard streams in C++

i would like to create a flexible logger class. I want it to be able to output data to a file or to standard output. Also, i want to use streams. The class should look something like: class Logger { private: std::ostream m_out; // or ofstream, iostream? i don't know public: void useFile( std::string...
PeterK
2

votes
1

answer
325

views

Game Center turn-based match data is not saved and/or read

I am planning to develop a turn-based game and is trying to understand how to communicate with Game Center and send and receive mach data. I have read about it and tested this for days now and just cannot get it to work as planned. The only thing i try to do with the code below is to be able to sav...
PeterK
3

votes
3

answer
723

views

Is there a way to 'expand' the #define directive?

I have a lot of "stupid" #define in a project and I want to remove them. Unfortunately, I can't do a simple search and replace, since the #define is parameterized. For example: #define FHEADGRP( x ) bool _process_grp##x( grp_id_t , unsigned char ) This is used to generate headers of a couple of func...
PeterK
2

votes
3

answer
3.7k

views

How to write data in specified format into a binary file with Perl?

this might be quite a newbie question, but i need to process a certain text file and dump its content into a binary file and i do not know how - i decided to use perl, but my perl skills are quite low. I probably should have written this in C++, but this seem like a nice and easy task for perl, so w...
PeterK
2

votes
4

answer
3.4k

views

Given an array of uint8_t what is a good way to extract any subsequence of bits as a uint32_t?

I have run into an interesting problem lately: Lets say I have an array of bytes (uint8_t to be exact) of length at least one. Now i need a function that will get a subsequence of bits from this array, starting with bit X (zero based index, inclusive) and having length L and will return this as an u...
PeterK
2

votes
2

answer
3.7k

views

Xcode cannot run using the selected device when trying to build on my device SDK 4.3, iPhone 3G 4.2.1

I get this message and i do believe i know where the problem is. I realized that i have IOS 4.2.1 on my iPhone (3G) and running SDK 4.3, i would guess this is the root to the problem. As this is an old iPhone it does not support 4.3. Is there anything i can do if i want to test on this device?
PeterK
2

votes
4

answer
2.1k

views

Implementing a simple thread pool

I'm currently in the need of a simple and efficient thread pool implementation. I have searched here and also on Google and found numerous interesting links, but nothing i've found so far seems to be suitable. Most of the implementations i have found on the web are either too complicated or lack som...
PeterK
12

votes
1

answer
14.9k

views

Filled and hollow shapes where the fill color = the line color

I want to convey three types of information in a dot-plot. I can use color, shape and fill (my actual data has too many points to use size effectively). But it would look best if the fill color was the same as the outline color. The closest I can get is this: data(mtcars) p
PeterK
3

votes
4

answer
4.6k

views

react on incoming sms on an iPhone

After researching the possibility to read incoming sms programmatically i realize that it is not possible on a standard iPhone. I am researching an application which should have the following sequence for action: User#1 send an sms to User#2 with a specific keyword, maybe &&XX&& User#2 receives the...
PeterK
1

votes
1

answer
57

views

is it possible to get ieee: float “bits” from javascript number?

I want to write out to, and read in ieee format float/double values from a binary byte stream in a javascript module. Anyone know of how one would go about doing this? an equivalent to the doubleToRawLongBits and longBitsToDouble functionality in java.
peterk
2

votes
1

answer
78

views

Why is the array empty

I am just starting to learn Unity3D javascript, this is my first try to learn, trying to copy a shuffle Objective-C code snippet i have, and I have the following code: function Shuffle(theCardArray : Array) { var dupeArray = new Array(); var count = theCardArray.length; print("theCardArray: " + theC...
PeterK
2

votes
4

answer
151

views

What is the relative memory overhead per mapped value of the different Java map types

I have a case where I have "property maps" one each attached to a very large collection of objects. I am only interested in the overhead of the map itself not of the attached keys and values. Many have a small number of properties ie: < 5, and many none. For empty maps I use a singleton "empty inst...
peterk
1

votes
3

answer
517

views

How to programatically find the bytecode (CIL) in a .Net executable/dll?

I would like to open a PE file (which i know is a .Net assembly) and find where the .Net bytecode is (ideally starting at the entrypoint). I know that the PE header data (entrypoint RVA) take me just to a stub which calls CorExeMain from mscoree.dll. This is not what i'm looking for though. I would...
PeterK
2

votes
1

answer
2.1k

views

Loading badly formated numbers into Vertica

I'm trying to load some data into Vertica. One of the columns is a floating point number in the range of 0.0 to 10.0, examples: 5.9, 3.7, 1.0, 3.2 etc. But not: 5.93, 3.71214, 1 ... So it always rounded to one decimal place and this is not omitted even if it's zero. The problem is, that the decimal...
PeterK
2

votes
1

answer
1.3k

views

XCode/iOS: Storyboard Segue event does not work after adding UIGestureRecognizerDelegate to UIViewController

I have simple Storyboard with two Scenes (SceneA and SceneB) and two custom UIViewController implementation. SceneA has a button with a segue (modal) over to SceneB. It works just fine this far: app starts with SceneA and pressing the button flips over to SceneB. In the next step I add to the ViewC...
PeterK
2

votes
3

answer
91

views

Is there a way in Java to detemine if a method is called in a static initializer (or not)?

as in a way to check appropriate use of a static registry: class AClass { static final IDType = IDregistry.registerId(...); } class IDRegistry { public static registerId(...) { if(isCalledInStaticInitializer()) { return(new IDType(...)); } assert false : "NO NO - can't do this !!!"; } }
peterk
6

votes
3

answer
6.6k

views

How to check if NSUserDefaults exist

I have been looking for an answer but not really found what i am looking for. I have an application and is using NSUserDefaults to store 'currentGameStatus' and would like to ask the following questions: How do i check if the NSUserDefaults .plist exists? Need this to determine if i need to create i...
PeterK
3

votes
2

answer
72

views

Counting zero b-bit subsequences in a byte array

I am looking for the fastest way of counting the number of b-bit subsequences (non-overlapping) that are zero in an uint8_t array of arbitrary size S (S is usually small though). Constraints: b is always a power of two, valid values are actually only: 1, 2, 4, 8, 16 and 32 it is assumed that the num...
PeterK
1

votes
6

answer
701

views

Any good reason to #include source (*.c *.cpp) files?

i've been working for some time with an opensource library ("fast artificial neural network"). I'm using it's source in my static library. When i compile it however, i get hundreds of linker warnings which are probably caused by the fact that the library includes it's *.c files in other *.c files (a...
PeterK

View additional