How to clear the canvas for redrawing

How to clear the canvas for redrawing

After experimenting with composite operations and drawing images on the canvas I'm now trying to remove images and compositing. How do I do this?I need to clear the canvas for redrawing other images; this can go on for a while so I don't th

Generic htaccess redirect www to non-www

Generic htaccess redirect www to non-www

I would like to redirect www.example.com to example.com. The following htaccess code makes this happen:RewriteCond %{HTTP_HOST} ^www\.example\.com [NC]RewriteRule ^(.*)$ http://example.com/$1 [L,R=301]But, is there a way to do this in a gen

Is there an eval() function in Java?

Is there an eval() function in Java?

I have a string like the following:String str = "4*5";Now I have to get the result of 20 by using the string.I know in some other languages the eval() function will do this.How can I do this in Java? 1:You can use the ScriptEngine class

From an array of objects, extract value of a property as array

From an array of objects, extract value of a property as array

I have JavaScript object array with the following structure:objArray = [ { foo: 1, bar: 2}, { foo: 3, bar: 4}, { foo: 5, bar: 6} ];I want to extract an array containing the values of key foo, resulting in a value of [ 1, 3, 5 ].I have accom

Using Auto Layout in UITableView for dynamic cell layouts & variable row heights

Using Auto Layout in UITableView for dynamic cell layouts & variable row heights

How do you use Auto Layout within UITableViewCells in a table view to let each cell's content and subviews determine the row height (itself/automatically), while maintaining smooth scrolling performance? 1:TL;DR: Don't like reading? Jump

Extract label values from a LabelledGeneric instance

Extract label values from a LabelledGeneric instance

Consider the following example:import shapeless._case class Foo(bar: String, baz: Boolean)val labl = LabelledGeneric[Foo]Now, the type of labl is (prettified)LabelledGeneric[Foo] { type Repr = FieldType[Symbol @@ String("bar"), String]

Saving in-memory H2 database to disk

Saving in-memory H2 database to disk

How can I save/load full embedded h2 in-memory database to some file or directory in binary mode for faster loading.I want to use this for caching data so I don't have to run all the lines of create table/insert clauses every time. 1:Ins

.parent().remove() issue

.parent().remove() issue

I have a jQuery-based form where you can add extra people to the application. I'm cloning the first fieldset and adding it onto the end up to a max of 3 additional people. When you've added 1 extra person then you have the option to remove

How to replace a JSON value in Play

How to replace a JSON value in Play

How do I replace a value in a JSON value in Play?Code to illustrate:def newReport() = Action(parse.json) { request => var json = request.body if((json \ "customerId").as[Int] == -1){ // replace customerId after some logic to find

Control Flow via Return vs. If/Else [closed]

Control Flow via Return vs. If/Else [closed]

Which one is better (implicit control flow via return or control flow via if) -- see below. Please explain what you see as advantage/disadvantage to either one. I like option A because it's less code. Flow via Return:public ActionResult Edi

Smooth scrolling for WPF DataGrid

Smooth scrolling for WPF DataGrid

I am using WPF datagrid, only modification I have in place is: I have this modification so if the cell contents are longer, they stretch the line height, no text is hidden.Problem is with DataGrid's scrolling beha

Load package dynamically in golang

Load package dynamically in golang

Is it possible to load a specific package during runtime? I want to have a kind of plugins where each one has the same functions than the others but with different behaviour, and depending on the configuration file, load one or other.Thanks

Where does mysql store data?

Where does mysql store data?

Where does mysql store data? I found out (by using mysql>SELECT @@datadir ) that it's in var/lib/mysql - but that can't be it. I have a quite big database (4 GB) called 'bot', but all the files in the 'bot' subdirectory (var/lib/mysql/bot)

Google Places Autocomplete - Pick first result on Enter key?

Google Places Autocomplete - Pick first result on Enter key?

I'm using a Google Places Autocomplete and I simply want it to select the top item in the results list when the enter key is pressed in the form field and suggestions exist. I know this has been asked before:Google maps Places API V3 autoc

AndroidStudio/Gradle with powermock

AndroidStudio/Gradle with powermock

I couldn't find any info on how to setup powermock with Android Studio/Gradle. Everything I've tried resulted in build exceptions.Could anybody show a correct way to do it? Thanks. 1:Im posting in order to help future readers, you need t

Plotting Great Circle Paths

Plotting Great Circle Paths

I'm trying to plot some path/connection based maps but am unable to figure out how.I see a lot of possibilities for one point based metrics (crime hotspots in London, etc. with googleVis, ggmap, etc.) but I can't find too many examples of t

Find longest repeating strings?

Find longest repeating strings?

I have some HTML/CSS/JavaScript with painfully long class, id, variable and function names and other, combined strings that get used over and over. I could probably rename or restructure a few of them and cut the text in half.So I'm looking

Android App Presentation

Android App Presentation

I wanted to make a video presentation of my android application. i know i can make the presentation by holding a camcorder in front of the screen and give walkthrough the application. But is there any other way this can be done, something o

python: change sys.stdout print to custom print function

python: change sys.stdout print to custom print function

Im trying to understand how to create a custom print function.(using python 2.7) import sysclass CustomPrint(): def __init__(self): self.old_stdout=sys.stdout #save stdout def write(self, text): sys.stdout = self.old_std

Square instead of rounded corners in UITableViewCell grouped style

Square instead of rounded corners in UITableViewCell grouped style

I want to have square corners for my grouped tableview cells instead of the default rounded corners, and I don't just want to use an image to give that effect. Is it possible? 1:Most simply, in your tableView:cellForRowAtIndexPath: usece

how to ignore blank lines and comment lines using awk

how to ignore blank lines and comment lines using awk

i am writing this code:awk -F'=' '!/^$/{arr[$1]=$2}END{for (x in arr) {print x"="arr[x]}}' 1.txt 2.txtthis code ignore blank lines, but i also want to ignore line starting with # (comments).Any idea how to add multiple patterns? 1:Change

How to pass array structure between two verilog modules

How to pass array structure between two verilog modules

I am trying to pass a array structure as reg [0:31]instructionmem[0:31] between two modules.I coded it as follows : Module No 1: module module1(instructionmem); output reg [0:31]instructionmem[0:31]; -----------

touch events firing twice

touch events firing twice

I am having problems on mobile devices/tablets with the events firing twice. When I click the following function, the menu that is supposed to drop down will drop down then immediataly slide back up. It is only an issue with touch devices.$

Test Anything Protocol in Shell scripts

Test Anything Protocol in Shell scripts

Has anyone seen, tried to implement, or otherwise played with TAP in shell? We're looking to create unit tests across many languages (don't get me started on why this doesn't exist so far), and since we have so much Perl code, we'll be loo

Iphone - device - linker error

Iphone - device - linker error

I have added libpng to my application. If I build for simulator, everything is OK. When I build application for device, I got linker error: Undefined symbols for architecture armv7: "_png_init_filter_functions_neon", referenced from: _pn