This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* implementing a dynamic programming solution as an exercise for | |
* https://www.topcoder.com/community/data-science/data-science-tutorials/dynamic-programming-from-novice-to-advanced/ | |
* | |
* The runtime complexity is O(N^2). | |
* | |
Note, that their Test 4 shows that the end result is consistent with rules | |
only for adjacent rows. | |
result indexes= 1 3 5 0 2 4 from original order | |
height 2 4 6 1 3 5 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
UML Class Diagrams can be made with graphviz. | |
(1) download graphviz | |
http://www.graphviz.org/Download.php | |
(2) write your dot file. | |
Note that in your dot file, you may want to exclude most dependencies | |
because the dot layout algorithm will weigh them equally with | |
the inheritance edges and you probably want a preference for better | |
display of the inheritance and composition relationships. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Generating Coverage Reports with Xcode 5.1.1 | |
If you need to test using the IOS 6.x simulator due to | |
testing in-app purchases, for example, you won't be able to use | |
the new XCTest library as those are IOS >= 7. The apple store | |
(simulator) is only available in the IOS 6.x simulators. | |
The notes below use GTM UnitTesting which are extensions | |
of SenTestingKit instead of XCTest. | |
This is an example of targets built for an older Xcode project that |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
If you're seeing | |
java.lang.ClassCastException: com.sun.tools.javadoc.ClassDocImpl cannot be cast | |
to com.sun.javadoc.AnnotationTypeDoc | |
the classloader used by the javadoc tool is not finding your 3rd party | |
annotation definitions. | |
This is a problem present in JDK 1.6. | |
An quick workaround to enable the classloader to find the annotation definitions |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Can make a bubble with a CSS3 opacity gradient placed over any background. | |
<div class='abubble'> | |
<div class='innerbubble'></div> | |
</div> | |
and change the location of the bubble and it's size by changing the properties in the .bubble class selector. | |
.abubble { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Notes on exporting and importing data to appengine. | |
Schema refactoring or complex relationships between entities may | |
require custom transforms to be written and added to the config yaml | |
file that the bulkloader generates automatically. | |
A few helpful resources on that are | |
http://wereword-gae.googlecode.com/hg/backup/helpers.py | |
http://bulkloadersample.appspot.com/ | |
http://longsystemit.com/javablog/?p=23 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
If you want to test upgrades of your database schemas against new releases that have | |
included database version changes: | |
To save your database, | |
adb shell pull /data/data/your.android.package.name/databases/yourprojectname.db \ | |
/yourprojectcvsdir/databases/yourprojectname_version.db | |
If you're using a ContentProvider such as given by the Android example | |
http://developer.android.com/resources/samples/NotePad/src/com/example/android/notepad/NotePadProvider.html | |
make the methods accepting SQLiteDatabase arguments accessible. In the example |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
The goal is to insert a new event and update the counter for it and have both | |
operations fail or both succeed. The solution below places each of these | |
2 operations is in a 2 two-phase locking transaction which must attempt to | |
both succeed or fail, and so the pattern of | |
lock1 operation1 (commit1 and lock2 operation2 commit2) or (rollback1) | |
is applied, with an additional pattern of first operation successfully committed | |
with the second retried if it fails. | |
private Key insert(Event event) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
The sharded counter approach to keeping track of the number of entities of a | |
given type is in Appengine article: | |
http://code.google.com/appengine/articles/sharding_counters.html | |
Google's Appengine cloud services are optimized for reads, so for high frequency | |
updates and to keep track of entities when there are more than 1000 (=count limit), | |
a sharded counter approach using the datastore and memcache is used below. | |
The sharded counter approach is to divide the container holding the sum of values | |
into multiple containers that are randomly chosen and less likely to be accessed |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Here's a way to make an activity indicator that is simple to import into an | |
activity, and allows the rest of the window to continue receiving events. | |
The 5 classes ActivityIndicatorView.java, ActivityIndicatorListener.java, | |
IActivityIndicatorCallback.java, ActivityIndicatorAction.java, and ActivityIndicatorEventTypes.java are printed below 2 snippets showing how | |
to import the view and how to broadcast messages that the view will indirectly | |
respond to. | |
The animation is in ActivityIndicatorView.java which extends android.view.View. | |
It renders a simple activity indicator and registers itself as a callback for |