Wednesday, May 23, 2012

android copy folders from assets to internal device app data folder

I created two folders inside assets ("images" and "files") both containing some files. I need to copy it when first launch to data/data/com.relatedPackage.myApp keeping same name and same file contents. I am an iOS programmer and that os does not allow to copy whole folders so, in android, which is the proper method to do it?



Possible to copy whole folder "images" (including its files) from assets to data/...? That would be great.
If not, should I create first empty folders using same names at data/... and then copy files from assets to current? In this case would be necessary to list all files inside folders in order to copy to data/...? Thank you.





Make text height 100% of div?

I'm trying to make the text 100% height of a div but it doesn't work. It just becomes 100% of the body { font-size:?; }. Is there any way to make it follow the div height?
The div height is 4% of the whole page and I wan't the text to follow it when you rezise/change resolution.



best regards,
Daniel





Serving different XML content on the same web

I don't know if this is the suitable place to ask this question, so I am sorry if I am doing it wrong. I think this is not a duplicate question. If it is, I am sorry too.



Currently, I have a web app which takes its content from a unique XML document. The URL is "http://webapp.com/"



The problem is that now I have to create a second version of the web which uses a new different XML document, so I have to put them different URLs, something like the following:



http://webapp.com/activities

http://webapp.com/stages



How can I have all my sources on just one directory on server-side (I suppose it's better to maintain, the resources are cached better, etc...) but with these 2 URLs pointing to the folder and making the PHP loades the XML depending on the URL?



I suppose I have to change the .htaccess file to redirect to that folder, but how can I tell what XML I must load? And the user must see on the search bar the URL he used, for example "http://webapp.com/activities"



Can anybody help me please?
Thanks for all





How to press back button in android programatically?

I my app i have a logout functionality. If user clicks logout it goes to home screen.Now i am exiting my app by pressing back button. But what i want is i need to exit automatically(i.e Programatically) as same like as back button functionality. I know by calling finish() will do the functionality. But the thing is it goes to the previous activity.



Thanks for your help guys





Spring @Transactional does not work in JUnit test?

I am using Spring 3.2 and JUnit 4.



My Dao class is as follows:



@Transactional public class SomeDaoImpl implements SomeDao {



The update operations on this work if executed directly from web application. However, I am seeing that junit integration tests that exercise the update methods do not actually persist the changes. Is something rolling the transactions back when junit methods are executed?





Best practices for API backwards compatibility

I'm working on an iPhone/iPad/Android app which communicates with a JSON API.



The first release of the version of the app is complete, and now additional phases of development are taking place. In the additional phases, the app needs to integrate with a new version of the API and allow the user access to additional features such as new screens or modified behaviour within existing screens. The app does however need to be backwards with previous versions of the API.



What is the best practice for tackling such a requirement?
I could of could do checks throughout the code:



if (APIVersion == 1) {

} else if (APIVersion == 2) {

} else if (APIVersion == ....) {

}...


But I'm concerned about the scalability of this approach.
The factory method comes to mind but I'm not sure how far this would get me.



Thanks,
Mark





array variable in awk

A=(aaa bbb ccc)    
cat abc.txt | awk '{ print $1, ${A[$1]} }'


I want to index an array element based on the $1, but the code above is not correct in awk syntax. Could someone help? Thanks!





Extension method in where clause in linq to Entities

In linq to Entities we needed a method that works like "sql like". We have implemented our own extension method to IQueryable, because contains method not work for us because doesn't accept patterns like '%a%b%'



The created code is:



private const char WildcardCharacter = '%';

public static IQueryable<TSource> WhereLike<TSource>(this IQueryable<TSource> _source, Expression<Func<TSource, string>> _valueSelector, string _textSearch)
{
if (_valueSelector == null)
{
throw new ArgumentNullException("valueSelector");
}

return _source.Where(BuildLikeExpressionWithWildcards(_valueSelector, _textSearch));
}

private static Expression<Func<TSource, bool>> BuildLikeExpressionWithWildcards<TSource>(Expression<Func<TSource, string>> _valueSelector, string _textToSearch)
{
var method = GetPatIndexMethod();

var body = Expression.Call(method, Expression.Constant(WildcardCharacter + _textToSearch + WildcardCharacter), _valueSelector.Body);

var parameter = _valueSelector.Parameters.Single();
UnaryExpression expressionConvert = Expression.Convert(Expression.Constant(0), typeof(int?));
return Expression.Lambda<Func<TSource, bool>> (Expression.GreaterThan(body, expressionConvert), parameter);
}

private static MethodInfo GetPatIndexMethod()
{
var methodName = "PatIndex";

Type stringType = typeof(SqlFunctions);
return stringType.GetMethod(methodName);
}


This works correctly and the code is executed entirely in SqlServer, but now we would use this extension method inside where clause as:



myDBContext.MyObject.Where(o => o.Description.Like(patternToSearch) || o.Title.Like(patterToSerch));


The problem is that the methods used in the where clause have to return a bool result if is it used with operators like '||' , and I don't know how to make that the code I have created returns a bool and keep the code executed in sqlserver. I suppose that I have to convert the returned Expression by BuildLinqExpression method to bool, but I don't know how to do it



To sum up! First of all it's possible to create our own extensiond methods in Linq to Entities that execute the code in SqlServer? if this is possible how I have to do it?



Thanks for your help.





Post JSON to Python CGI

I am looking to post JSON sent by any standard library such as 'JQUERY' using the standard.



$.ajax() post routine with my JSON.



can you tell me if on the page I post to ("saveList.py") this code is correct that will get the resultant json and then return the response as successful.



cheers, I've only ever worked with Django and now raw cgi so im slightly confused.



#!/usr/bin/env python
# -*- coding: UTF-8 -*-

import sys
import json

def get():
result = {'success':'true','message':'The Command Completed Successfully'}
data = sys.stdin.read()
myjson = json.loads(data)

self.response.out.write(str(result))




show 1 insted of 01 with PHP pack for Persian numbers

there is a function for converting English standard nums to Persian (Farsi) or Arabic nums:




function farsinum($str){ if (strlen($str) == 1){
$str = "0".$str; $out = ""; for ($i = 0; $i < strlen($str); ++$i) {
$c = substr($str, $i, 1);
$out .= pack("C*", 0xDB, 0xB0 + $c); } } return $out; }




but this function produce 01 02 03 ... insted of 1 2 3 ...
i think something must be change here:




$out .= pack("C*", 0xDB, 0xB0 + $c);




any help appreciated.





Confusion in int conversion of a string in PHP

I am unable to get the exact value of $data, which I converted into integer from this,



<?php

$data = '9999999999';
echo $datan = (int) $data;

?>


How can I get the exact value of $data from $datan?





Unable to use ActionBarSherlock library

I have Created a new android project from existing source(ActionBarSherlock library) with API 15. I added this library to my project(Project properties -> android -> library-> add ->com_actionbarsherlock ->apply ->ok).But When I again see (Project properties -> android -> library->) com_actionbarsherlock is showing red color cross.So, I am unable to import the library classes.I am really struggling with this.
Any help would be appreciate.Screen Shot When I add library
Screen Shot After library is added





Python script - How to set the right server, when I perform request/open of application

Python 3.2.2, I want to check HTTP status code (eg. 200 or 404) on some www application.



There are five servers and each server have a copy of this www application



(The user is automatically redirected to the application on the server with low traffic/sometimes on random server).



Suppose that the name of servers is: 0,1,2,3,4



I tried various options i have tried, three of them I pasted below (they works -always return 200, but choose not this server what I want):



1



import urllib.request,urllib.parse, http.cookiejar
values2= {"server":"2"}
data2 = urllib.parse.urlencode(values2)
data2 = data2.encode("utf-8")
request2 = urllib.request.Request(url,data2)
cj2 = http.cookiejar.CookieJar()
cj2.add_cookie_header(request2)
urlOpener2 = urllib.request.build_opener(urllib.request.HTTPCookieProcessor(cj2))
url2 = urlOpener2.open(request2)
x2 = url2.getcode()


2



import urllib.request
headers1 = {"Set-Cookie":"server=2"}
req1 = urllib.request.Request(url, None, headers1)
t1 = urllib.request.urlopen(req1)
coderesp1 = t1.getcode()


3



import urllib.request
urlOpener3 = urllib.request.build_opener()
urlOpener3.addheaders.append(("Set-Cookie", "server=2"))
url3 = urlOpener3.open(url)
x3 = url3.getcode()


If you have some questions about my problem, please write, I will immediately reply to what you want to know.





Android bitmap out of memory error

I get the famous out of memory error. But i have tried many of the suggested solutions on this problem without any luck. I understand that to prevent a bitmap to exceed the memory, you make a static variable of the drawable (Android docs). But that isn't working in my app because i have so many markers as you can see..



Does anyone have a suggestion to a solution?



for(Poi p : poiarray){

WeakReference<Bitmap> bitmap = new WeakReference<Bitmap>(p.get_poiIcon());
if(bitmap!=null){

Drawable marker = new BitmapDrawable(Bitmap.createScaledBitmap(bitmap.get(), 60, 60, true));
annotationOverLays.add(new CustomAnnotation(marker,p,this,mapView));
//mapView.getOverlays().add(new CustomAnnotation(marker,p,this,mapView));
}
}
mapView.getOverlays().addAll(annotationOverLays);


ERROR:



05-23 13:08:31.436: E/dalvikvm-heap(22310): 20736-byte external allocation too large for this process.
05-23 13:08:31.436: E/dalvikvm(22310): Out of memory: Heap Size=23111KB, Allocated=22474KB, Bitmap Size=1505KB
05-23 13:08:31.436: E/GraphicsJNI(22310): VM won't let us allocate 20736 bytes




Sending JSON through GET Method in Objective-C

I have a seemingly easy question. I'm trying to send data from my iPad device to a server using JSON. The thing is, all tutorials I see about sending JSON to the server uses the POST method. My question is, is it possible to send JSON using the GET method? It will be really helpful if you can give me some pointers on how to do it. Thanks.





Defining JQuery Function

The two below functions work as scripted except for when i add the Function next () {;} and function prev () {'} around it to define the custom function.



What am I doing wrong here?



function next() {

$('#up').click(function() {
$("#two").prev().animate({height:'80%'}, 500);
});
;}


function prev() {
$('#down').click(function() {
$("#two").next().animate({height:'80%'}, 500);
});
;}




Regarding Map pin points that should display dynamically in iphone

hi everyone i have a mapview where i have to drop pins on the map based on latitude and longitude where i used to get that from a webservice can any one help me out how to get and plot it on the map





move the focus from textbox to ajax combobox on enter key

I want to move the focus from the textbox to an ajax combobox on enter key



 <script type="text/javascript">
$(document).ready(function () {
$("#txtGroupSname").keydown(checkForEnter);
function checkForEnter(event) {

if (event.keyCode == 13) {
document.getElementById("cmbUnder").focus();
return false;
//$("#cmbUnder").focus();
}
}
});




txtGroupSname is my textbox and cmbUnder is the ajax combobox.



Any ideas or suggestions please.
Thanks,





Is it possible to generate XML file in gef

Is it possible to generate XML file from Shape example in GEF,Same as its getting generated in GMF?
Like in GMF if we select GMF Design page and open it with XML file,it provides all external information about model figures,same like i want to generate with GEF.





How to change the comment link text "Login or register to post comment" to be shorter eg " comment" in drupal


  1. I have created a Q&A type using
    Create Content in drupal.


  2. I have created a new content name
    Ask and Answer.


  3. Until this i don't have any issues.
    Now problem is i have enabled
    comments in content type.


  4. In this case i need to change the
    "Add new comment" or similar links
    related to comments as "Answer"
    without changing the core comment
    module.


  5. How can i do this?




Thanks in advance.





How to express more OOP in the Mars Rovers Program test

It's a interview problem, i was told to solve the problem Mars Rover.



The rover runs in a plane. As from (0,0) to (5,5).



The rover could proceed 3 movement which are Turn Left, Turn Right, and Move Forward.



The input of the program is a coordinate in the plane such as (1,1) and a sequence of the movement such as LMRMLMLM (L/R means turn left/right, M means move),
the output is the result coordinate of the rover in the end.



What I already done is I program the rover as a object, it has some method like turn left/right and move, and some attribute like the coordinate of the rover. And the whole map is also as a object.



BUT, the technical HR told me that is not good enough to express the OOP, SO, what I want to know is what can I should do in this small program test?



Thanks everyone in this Questions.





flickr api grab url php

In my local webserver, I'm trying to generate the text for pasting to my blog, followed by below question:
How to get static image url from flickr URL?



<a href="http://www.flickr.com/photos/53067560@N00/2658147888/" title="Chou fleurs by Nicolas de Fontenay, on Flickr"><img src="http://farm4.staticflickr.com/3221/2658147888_826edc8465.jpg" width="500" height="375" alt="Chou fleurs"></a>


I think it's good to use some API function and to designate $variables to:




  • 53067560@N00

  • 2658147888

  • "Chou fleurs by Nicolas de Fontenay, on Flickr"

  • "http://farm4.staticflickr.com/3221/2658147888_826edc8465.jpg"

  • "500"

  • "375"

  • "Chou fleurs"



, but don't know how to code in detail. Ideally, a function



getFlickrImageURLforGrab(name of Set, # of photos)


ex.) getFlickrImageURLforGrab(myset1, 10) returns first 10 photo's URLs in the Set myset1 are displayed. Would you please show a simple php example?





what is wrong with this assignment?

I have defined a class XX like this:



   public class XX extends RelativeLayout {
protected static final boolean DEBUG = true;

public XX(Context context) {
super(context);
// TODO Auto-generated constructor stub
}

public XX(Context context, AttributeSet attrs) {
super(context, attrs);
if (DEBUG)
Log.i(this.getClass().getSimpleName(), " ->2"
+ Thread.currentThread().getStackTrace()[2].getMethodName());
//getAttributes(context, attrs);

}

public XX(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
if (DEBUG)
Log.i(this.getClass().getSimpleName(), " ->3"
+ Thread.currentThread().getStackTrace()[2].getMethodName());
//getAttributes(context, attrs);

}

}


and in my code I write:



RelativeLayout v = (RelativeLayout) this.findViewById(R.id.switch_TCMyTB);
XX x = (XX) v; //<----- crashes here


but it crashes with the assignment. I assume the because XX extends View I can just assign the view (RelativeLayout) to an XX object.



But it crashes. What is wrong with the assignment?



EDIT:



I changed extends View to extends RelativeLayout. Also changed View v to RelativeLayout v.
But I still get a classCastException..???? Why?



While



RelativeLayout r = (RelativeLayout) v; 


certainly works fine.





Grid Border / Gap between cells

I've created a ControlTemplate that contains a Grid with two rows.



Sadly, there appears to be a single pixel gap between the cells.



How do I remove the gap?



Here's a screenshot showing the gap:



Gap between cells



...and here's the XAML:



<Window x:Class="MAQButtonTest.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="695" Width="996">
<Window.Resources>
<Style TargetType="TextBlock">
<Setter Property="OverridesDefaultStyle" Value="True"/>
</Style>
<ControlTemplate TargetType="Button" x:Key="ButtonTemplate">
<Grid Width="444" Margin="0" ShowGridLines="False">
<Grid.RowDefinitions>
<RowDefinition Height="51" />
<RowDefinition Height="36" />
</Grid.RowDefinitions>
<Grid Grid.Row="0" Background="#286c97">
<TextBlock>This is the first piece of text</TextBlock>
</Grid>
<Grid Grid.Row="1" Background="#5898c0">
<ContentPresenter Grid.Row="0" />
</Grid>
</Grid>
</ControlTemplate>
</Window.Resources>
<Grid>

<Grid.ColumnDefinitions>
<ColumnDefinition Width="300" />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<Grid Grid.Column="0" Background="#e9f1f6"></Grid>
<Grid Grid.Column="1" Background="#d2e3ed">
<StackPanel>
<TextBlock FontFamily="Segoe UI" FontSize="22" FontWeight="Medium" Margin="52,58,0,0" Foreground="#0c3d5d">Your Quizzes <TextBlock FontFamily="Segoe UI" FontSize="18" FontWeight="Medium" Foreground="#0c3d5d">(7)</TextBlock></TextBlock>
<Grid Margin="0,20,0,0">
<Button Width="444" Background="{x:Null}" BorderThickness="0" Template="{StaticResource ButtonTemplate}" Click="DoSomething" BorderBrush="#032135">
<TextBlock Margin="6,2.8,0,0" FontFamily="Segoe UI" FontSize="19" Foreground="#032135" FontWeight="Medium">This is a second piece of text</TextBlock>
</Button>
</Grid>
</StackPanel>
</Grid>

</Grid>
</Window>




C# Get true path of current directory

I have a project, built with Visual Web Developer 2008. I want to be able to extract (with C#), the current folder the project is in now. Until now I had to hard code the true path.



This project is hosted on my computer.



For example, the path I would like to generate:



C:\Users\Guy\Desktop\Project


Thanks! Guy





Multiple connections on the same port socket C++

I need to accept multiple connections to the same port.
I'm using socket in C++, i want to do something like the SSH do.
I can do an ssh user@machine "ls -lathrR /" and run another command to the same machine, even if the first one still running.



How can i do that?



Thanks.





How can I make bash tab completion behave like vim tab completion?

I've been meaning to find a solution for this for YEARS.



I am sooo much more productive in vim when manipulating files than bash for this reason.



if I have



file_12390983421
file_12391983421
file_12340983421
file_12390986421


In bash and type file_1->tab , it obviously lists:



file_12390983421 file_12391983421 file_12340983421 file_12390986421


And this is a horrible boar and painful to work with.



The same sequence in vim will loop through the files one at a time.



Please someone tell me how to do this in bash, or if there is another shell that can do this, I'll switch tomorrow.





What is the best position to sit and to place your hands while you program?

Recently I've been more concerned about the way I sit while I code, I don't think I have any kind of injury yet but one of my coworkers had to take a couple of days off because of his column and I began to worry about this.
So, how do you sit? how do you place your hands? Do you recommend any keyboard in special? any chair? I have been looking into a new keyboard and maybe I' ll ask for it at work. Also my chair isn't top-notch so any budget oriented option?
Thanks, Joaquin.



related: keyboard for programmers , what is the best keyboard mouse for ergonomics or to prevent wrist pain? , What is the best physical operating environment for a developer?





dlls in SysWOW64 not found by application

I'm developing a C#/WPF app that talks to a USB device using some custom 32 bit dlls. It's developed as an x86 app, and installed with WIX. When I install the package on a 64-bit machine, the program files get installed to Program Files (x86) as I expect.



The dlls are installed to the SystemFolder using WIX. On 32-bit machines, this means C:\Windows\System32. On 64-bit, they end up in C:\Windows\SysWOW64. This is ok, but when I run my app, it is unable to find the dlls (it uses them via [DllImport...]).



So, what is the right way to make my app find the dlls, whether they are in System32 or SysWOW64?



Thanks
Tom





jQuery how to reverse a remove() event

I have this code:



$(window).resize(function() {
if($(window).height() < 768) {
$('div#navigation ul li br').remove()
} else {
}
})


Is it possible to reverse the remove event on else? I need to have those
tags in the same place as before the action.





Update with a LIMIT in zend framework

I would like to do a update and place LIMIT 1 as precaution.
Here is my code:



$vals = array();
$vals['status'] = 'closed';
$where = $write->quoteInto('id =?', $orderID);

$write->update("order", $vals ,$where);


Where can i add a LIMIT into this query?



(looks like has been asked in the past but i hope someone out there has the answer)





Sybase Check Constraint Evaluation

I'm trying to formulate some check constraints in SQL Anywhere 9.0.



Basically I have schema like this:



CREATE TABLE limits (
id INT IDENTITY PRIMARY KEY,
count INT NOT NULL
);

CREATE TABLE sum (
user INT,
limit INT,
my_number INT NOT NULL CHECK(my_number > 0),
PRIMARY KEY (user, limit)
);


I'm trying to force a constraint my_number for each limit to be at most count in table.



I've tried



CHECK ((SELECT sum(my_number) FROM sum WHERE limit = limit) <= (SELECT count FROM limits WHERE id = limit))


and



CHECK (((SELECT sum(my_number) FROM sum WHERE limit = limit) + my_number) <= (SELECT count FROM limits WHERE id = limit))


and they both seem not to do the correct thing. They are both off by one (meaning once you get a negative number, then insertion will fail, but not before that.



So my question is, with what version of the table are these subqueries being executed against? Is it the table before the insertion happens, or does the subquery check for consistency after the insert happens, and rolls back if it finds it invalid?





Some starting pointer how to build a server application

I'm evaluating a project where we will have to implmenent a server application that allows client applications (not a browser) to transmit data to an database and download digital audio files.



Clients will be a custom application not a web browser.



We will have about 11 Downloads/minute with about 40MB per download.



I have written client-sever database applications, but without server side processing.



I'm experienced with C# and C++, so it would ne nice if I could realize the project without learning JAVA.



What are the topics I should look at?



Best
Tom





Storyboarding for Android

I was wondering if there are any storyboarding applications which can be used for Android development?



I've looked for something which can be used, but came up short in the end. Any help/suggestions would be most welcome.



EDIT -: It seems that there are no plans for Storyboarding - Source





Recommended approach for loading CouchDB design documents in Python?

I'm very new to couch, but I'm trying to use it on a new Python project, and I'd like to use python to write the design documents (views), also. I've already configured Couch to use the couchpy view server, and I can confirm this works by entering some simple map/reduce functions into Futon.



Are there any official recommendations on how to load/synchronize design documents when using Python's couchdb module?



I understand that I can post design documents to "install" them into Couch, but my question is really around best practices. I need some kind of strategy for deploying, both in development environments and in production environments. My intuition is to create a directory and store all of my design documents there, then write some kind of sync script that will upload each one into couch (probably just blindly overwriting what's already there). Is this a good idea?



The documentation for "Writing views in Python" is 5 sentences, and really just explains how to install couchpy. On the project's google code site, there is mention of a couchdb.design module that sounds like it might help, but there's no documentation (that I can find). The source code for that module indicates that it does most of what I'm interested in, but it stops short of actually loading files. I think I should do some kind of module discovery, but I've heard that's non-Pythonic. Advice?



Edit:



In particular, the idea of storing my map/reduce functions inside string literals seems completely hacky. I'd like to write real python code, in a real module, in a real package, with real unit tests. Periodically, I'd like to synchronize my "couch views" package with a couchdb instance.





How to set scheduled task?

Before this I asked a question. My service conifg is :



<proxy xmlns="http://ws.apache.org/ns/synapse" name="UnpayBilling_Task" transports="https,http" statistics="disable" trace="disable" startOnLoad="true">
<target>
<inSequence>
<class name="com.coship.mediator.UnpayBillingMediator"></class>
<log level="full" />
</inSequence>
<outSequence>
<log level="full" />
<send />
</outSequence>
<endpoint>
<address uri="http://172.21.13.153:18080/aaa/services/receiveMsg" />
</endpoint>
</target>
</proxy>


I write a extension mediator UnpayBillingMediator deal files. The class returns file name and send request to service http://172.21.13.153:18080/aaa/services/receiveMsg. The service no input message. I want service running every day at 13:30. I tried add New Scheduled Task.
soapAction:urn:mediate,to:http://localhost:8280/services/UnpayBilling?wsdl, Cron: 30 13 * * *. But it can not work? Anyone can tell me how to set this Scheduled Task?



SimpleQuartz Server name not in pinned servers list. Not starting Task


I also do not know how to set "pinned servers".





HttpWebRequest and connection lost

I'm using HttpWebRequest.BeginGetRequestStream to make POST requests to the remote server. Let's presume that the network connection is lost during this process and response was not received. Is there any way to detect whether the request was sent to the remote server or not? Thank you!





Google Maps API v3 repeats markers on custom map

I have this problem for a while now, I have searched the web for answers, but I could not find a good answer related to my problem.



screenshot of my problem



You can see that I render my own set of tiles. The problem is that the markers are repeated horizontally, because of the wrapped map. I can't use the zoom in trick to avoid this problem, because the map has to be dynamic so it supports multiple resolutions.



I hope someone knows how to deal with this problem! I would really appreciate it.



I use Google Maps API v3.



EDIT



Here is another screenshot:



another screenshot





Calling constexpr in default template argument

In C++11 I am using a constexpr function as a default value for a template parameter - it looks like this:



template <int value>
struct bar
{
static constexpr int get()
{
return value;
}
};

template <typename A, int value = A::get()>
struct foo
{
};

int main()
{
typedef foo<bar<0>> type;

return 0;
}


G++ 4.5 and 4.7 compiles this, but Clang++ 3.1 does not. The error message from clang is:



clang_test.cpp:10:35: error: non-type template argument is not a constant expression
template <typename A, int value = A::get()>
^~~~~~~~
clang_test.cpp:17:19: note: while checking a default template argument used here
typedef foo<bar<3>> type;
~~~~~~~~~^~
clang_test.cpp:10:35: note: undefined function 'get' cannot be used in a constant expression
template <typename A, int value = A::get()>
^
clang_test.cpp:4:23: note: declared here
static constexpr int get()
^
1 error generated.


Which one is correct?





How to get rid of 'Content-type: text/html' in PHP script output?

I am running a PHP script as a cron job. An email is fired iff the script generates an output. Unfortunately, even if it does not output anything, an email is fired with:



Content-type: text/html


How can I get rid of this automatic Content-type: text/html generation triggering an email?





Preventing spam submission via form using a hidden field

My boss hates captcha's and well, so do I even if they work. She instead suggests using a hidden field so that if it is filled out [by robots] that the form should not be submitted. Are there downsides to this method? Any specific ways to tie into this using jQuery validate which is already implemented for the user validation?





How to retrieve a GUID and value from a string in ruby

I have a string like this in Ruby



word=0 id=891efc9a-2210-4beb-a19a-5e86b2f8a49f


How can I get both the word and id values from that string?





How do i change image in UIImageView in iOS?

I have a lot of image to show in UIImageView in iOS.



I have two buttons in my app.



When i clicked Next button , next image will appear in UIImageView with Slide.



When i clicked Previous button , previous image will appear in UIImageView with Slide.



It's like photos app in built-in iOS.



How can i do that?



Thanks you for reading my question and hoping to answers.





ignore case in php

i am searching a text using in_array() function from the array which is fetching database value



$value is the array value.



How can i ignore case in this.



if(in_array($exp[$i],$value))




How to use the "Masked Input" module in Drupal 7

I am trying to build a form in Drupal 7, one of the fields needs to have an input mask. I found the plugin masked input it seems like what I am searching for . Only there is no documentation on how to implement it (I read about currency and this plugin, yet here it is only about getting it to work).



I am new to Drupal, but searching on forums I came up with the following code:



function report_expenses_form($form, &$form_submit) {
libraries_get_path('maskedinput') . '/misc/ui/jquery.maskedinput-1.3.js';
...
$form['cash_advance']['amount'] = array(
'#title' => t('Cash Advance : '),
'#type' => 'textfield',
'#default_value' => t('$ 00,00'),
'#required' => TRUE,
'#mask' => '$?999.999.999,99',
);
....


I installed the "Libraries" and "Masked Input" plugins in Drupal and flushed my caches.



I downloaded the jquery.maskedinput-1.3.js and put it in my {DRUPAL_HOME}/misc/ui/



any Ideas?



thank you in advance





ListView owner drawing and column auto-resizing

I have a ListView which is using owner drawing to draw additional content for some sub-items.



I've found that because this additional content takes up some additional space the list view now incorrectly calculates the column "auto resize" width, and so when someone auto-resizes some columns (e.g. by double clicking on the column resize handle) the column is resized so that it is too small, and the text in that list view is rendered with parenthases (...) at the end.



Is there a way that I can prompt the list view to ask me what size the columns should be during an auto-resize?





need to create array which prints maximum+location after taking 5 inputs

import java.util.Scanner;

public class Arraymaxloc {
public static void main(String args[]) {
Scanner s = new Scanner(System.in);
int[] a = new int[5];
int c = 1;
while (c < a.length) {
c = s.nextInt();
}
int max = a[0];
int loc = -1;
while (c < a.length) {
if (a[c] > max == true) {
max = a[c];
loc = c;
c++;
} else {
c++;
}
System.out.println("max found at" + loc);
}
}
}




Classic ASP suddenly giving me permissions (401.3) error

Background: I support a classic ASP environment. I have a development setup locally on my machine as part of that support. I am running IIS7.



To access my environment, I use "http://localhost:99999/" (port # faked for privacy purposes). I have not had a problem with this -- until today.



I built an application that is intended to run in this environment. The app is ASP.NET v.4.0 (for sake of example, I'll say it's called "http://localhost:99999/DotNetApp/"). Of course, in order to run this, I had to set up my environment application pool to support it (which it now does).



Problem: after configuring this, I am now getting:




Server Error in '/' Application.



Access is denied.
Description: An error occurred while accessing the resources required to serve this request. You might not have permission to view the requested resources.



Error message 401.3: You do not have permission to view this directory or page using the credentials you supplied (access denied due to Access Control Lists). Ask the Web server's administrator to give you access to '[filepath]\SourceFiles'.




I did NOT get this before I set my IIS configuration. Why am I getting this now?



Note: this ONLY happens with "http://localhost:99999/"; this does NOT happen if I try "http://localhost:99999/default.asp" (the page comes up with no problem).



Anyone have any insight?



Thanks in advance . . .



Edit: Additional symptoms: I tried playing with the application pool settings. The problem goes away if I change the .NET Framework version to either 2.0.50727 or to "No Managed Code." Changing it to 4.0.31319 breaks it. Of course, if I use any of the other two versions, my ASP.NET app won't run.



Edit #2: This problem occurs on ALL links that go to a folder or directory (e.g. "http://localhost:99999/somefolder/"), not just the web root.





Why can't one set an alias to a document.getElementById()?

My code would be more efficient if I could write



var min = window.document.getElementById;


and then call document.getElementById() using min().



I'm not trying to write minified code but in this particular case I can reduce scope lookup and shorten some lines.



Perhaps I'm using the wrong syntax?





uddi v2 client access to uddi v3

We have been asked to set-up a uddi v3 in our SOA governance infrastructure, but all the tools we have are only v2 compliant, and most of them are propietary.



I would like to know if anyone has come to this problem, and if there is some kind of gateway to map from v2 to v3 and back.



I know than manually we can get this, but it will be probably a reason for the dev teams to avoid using the uddi and ask directly to the people that are managing the governance.



Thanks in advance.



Regards.