Where do I put the iTunesArtwork Image in a PhoneGap Build Ad Hoc Project?

Uncategorized
Question: I am not using Xcode to develop but rather HTML5stack with PhoneGap Build. I do not have a "Resources" folder but rather an "Image" folder. I understand that this file should not be included with my .ipa build for the App Store Review. But if I want my app Icon to show up in the iTunes Library under an Ad Hoc Developer certificate build, then which folder should I put the iTunesArtwork (512x512px with no file extension) file--in "Image" folder or at the root of the "www" folder with Icon.png and splash.png files? Answer: Read more
Read More

Django deleting querysets with paging, not catching all parts of the set

Uncategorized
Question: I have a bit of a strange problem that I'm not quite able to explain. I have a django project with some old, stale objects lying around. For example, lets say my objects look something like this:class blog_post(models.Model):user_account = models.ForeignKey('accounts.Account') text = models.CharField(max_length=255) authors = models.ManyToManyField(author) created = models.DateTimeField(blank=True, null=True) This is not an exact copy of my model, but is close enough. I've created a management command to build ordered querysets of these objects, and then delete with with a Paginator My command looks something like this:all_accounts = Account.objects.all() for act in all_accounts.iterator():stale_objects = blog_post.objects.filter(user_account=act, created=django.utils.timezone.now() - datetime.timedelta(days=7)) paginator = Paginator(stale_objects.order_by('id'), 100) for page in range(1, paginator.num_pages + 1):page_stale_objects = blog_post.objects.filter(id__in=paginator.page(page).object_list.values_list('id')) page_stale_objects.delete() The problem I'm having is, after I delete these objects with my command, there are still…
Read More

Accessing another model from an .each loop in Rails

Uncategorized
Question: I am trying to create a restaurant manager app that has users, orders, and meals. User has many orders, order has many meals. I want a table that lists all orders by a user together with meals' names and prices. I have three models: User, Order, and Meal. While it's not a problem to access order_id from this loop:- @userOrders.each do |order| %tr %td= order.id when I try to access meal's name by - @userOrders.each do |order| %tr %td= order.id %td= order.meals.name here's what I get: Table with what's supposes to be meals' names In Ruby console, when I type user.orders[1].meals, I get: Console output This is my orders_controller.rb def index user_id = current_user.id @userOrders = Order.where(:user_id => user_id) end Below is my order.rb:class Order < ApplicationRecord belongs_to :user…
Read More

Can not do UI work in method finish() of Activity when using Espresso rules?

Uncategorized
Question: I'm using Espresso to do UI test for my Android app. Following the official guide, I used ActivityTestRule to launch the Activity under test. But when test finishes, a crash occurred. stack trace is android.view.ViewRootImpl$CalledFromWrongThreadException: Only the original thread that created a view hierarchy can touch its views. at android.view.ViewRootImpl.checkThread(ViewRootImpl.java:6247) at android.view.ViewRootImpl.playSoundEffect(ViewRootImpl.java:5222) at android.view.View.playSoundEffect(View.java:17876) at android.view.View.performClick(View.java:4755) at com.example.android.activityinstrumentation.ReadExternalFileActivity.finish(ReadExternalFileActivity.java:196) at android.support.test.rule.ActivityTestRule.finishActivity(ActivityTestRule.java:234) at android.support.test.rule.ActivityTestRule$ActivityStatement.evaluate(ActivityTestRule.java:259) at org.junit.rules.RunRules.evaluate(RunRules.java:20) at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268) at org.junit.runners.ParentRunner.run(ParentRunner.java:363) at org.junit.runners.Suite.runChild(Suite.java:128) at org.junit.runners.Suite.runChild(Suite.java:27) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268) at org.junit.runners.ParentRunner.run(ParentRunner.java:363) at org.junit.runner.JUnitCore.run(JUnitCore.java:137) at org.junit.runner.JUnitCore.run(JUnitCore.java:115) at android.support.test.internal.runner.TestExecutor.execute(TestExecutor.java:59) at android.support.test.runner.AndroidJUnitRunner.onStart(AndroidJUnitRunner.java:262) at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:1837) Throw the call stack, I found AndroidJunitRunner tried to call finish() of the Activity from non-UI thread, which caused the crash.…
Read More

Fabric js. Cannot make pattern fill for multiple rects

Uncategorized
Question: Good day, I hope someone can give me a hand on this. I have a for statement, that create and add multiple Rects on fabric js canvas. I need to set texture for each of created rects, so i use the following code. var rect = new fabric.Rect({ width: 100, height: 100, selectable: true, hasControls: false, borderColor: 'red', borderWidth: 2, lockMovementX: true, lockMovementY: true }); canvas.add(rect); fabric.util.loadImage('construct/css/img/patterns/1.jpg', function(img) { rect.set('fill', new fabric.Pattern({ source: img, repeat: 'repeat' })); }); Выполнить For some reason, after code execution, not all rects having texture, but only the last one added. This is realy drives me crazy. Would appreciate any help on this Thanks in advance. Answer: Read more
Read More

which thread will get concurrentModificationException with two threads

Uncategorized
Question: I have two thread one thread is adding,removing in ArrayList and another thread iterating with iterator the ArrayList. which thread will get the ConcurrentModificationExcetion; Answer: The thread with the iterator. It's the iterator that detects (on a best effort basis) that the underlying collection has changed, and throws the exception. Of course the most common situation for ConcurrentModificationException is when using a single thread that both iterates the collection and attempts to modify it:List foo = ... ; for(String s : foo) { // Exception will be thrown here after 1st iteration foo.add("Let's throw an exception!"); } Read more
Read More