Thursday, April 19, 2012

Runnable JAR not working with referenced libraries

I want to create a runnable JAR that include referenced libraries, namely jackson, in eclipse via the export. There used to be fat jar that seemed to be the goto solution before Eclipse offered to export to runnable JAR.



From this question, the first option would be what I'm looking for. Since it is for the moment a small project, it wouldn't be a problem to always have everything together (plus it's easier for me since I'm just starting with JARs, runnables and jnlp)



When I try to launch it, there's an alert window saying there was a problem and to try to find it in the console (which I can't get to open).



If I remove any use of this referenced library everything runs perfectly (except the part that it's not doing what I what at all). The window looks the way I designed it, but no functionality without the library.



I don't even have a stack trace to help with the problem. I've created other projects without any referenced libraries and everything is fine. So I've pretty much narrowed it down.



Since I let Eclipse handle the exporting and everything, I don't suppose you need the manifest to see if it is alright. Any questions you might have, I'll provide the informations you need. It goes without saying that the project runs directly from Eclipse.



Eclipse
Version: Indigo Service Release 2
Build id: 20120216-1857





POST request for file upload in Javascript InDesign, extendables

I'm trying to implement a file upload out of InDesign with it's built in JavaScript technology.



Basically the script exports an InDesign document to a PDF and then tries to upload the file to a webserver. For the upload I use the extendables plugin which handles the HTTP request.



I was able to make some basic GET and POST requests, but I'm failing to make a POST request for the file upload.



Here's the basic code:



   var req = new http.HTTPRequest("POST", "http://mysite.com);

var type = "application/pdf";
var boundary = "--012345678910";

var myTitle = "\r\nContent-Disposition: form-data; name=\"title\"\r\n\r\n"+title+"\r\n"+boundary;
var myFile= "\r\nContent-Disposition: form-data; name=\"file\"; filename=\""+pdfFileName+"\"\r\nContent-Type: "+type+"\r\n\r\n"+file_contents+"\r\n"+boundary+"--";

var myData = boundary + myTitle + myFile;
req.content(myData);

req.header("User-Agent", "MyUserAgent");
req.header("Content-Type", "multipart/form-data; boundary=012345678910");
// make request
res = req.do();


I was able to upload the same file with the same headers and so on from a Ruby script and some REST clients.



It seems that the form data is not included in the post parameters when I look at what arrives at the server.



So my question is if anyone has ever successfully uploaded a file using InDesign JavaScript and the extendables plugin. The extendables documentation is not really helpful, maybe I'm missing something. I'm also open for alternatives.





Super Rooting for Android

I read through various links about rooting and superrooting. And found that rooting your phone can help developers.



How can I use the rooted phone for my benefit?





Reading a table in PDF Itextsharp

I was trying to read a PDF using Itextsharp in .NET application. I am able to read individual word sccessfully . The challenge I am facing now is reading a table. I have a table structure like this:



enter image description here



Please note that here some of column names are two-lined. for example Department Code and Employee Identification Number.



So my requirement is to read the Employee Identification number and salary if the employee belongs to 'HR' department. For this I have to check whether a column named 'Department Code' exists in the PDF file.



When I read this table using iTextsharp, what happens is let us say 'Department' part of 'Department Code' column comes at poition 1 , but the 'Code' comes 5th position.This is because this column is displayed in two lines and there are other four words exists in the pdf before I read the 'Code'part of this column. I am totally stuck at this :(



Anybody has any idea how to make sure that a column name 'Department Code' exists and read corresponding values from this table.



Appreciate your help!



Regards,
Jaleel





Wait to untill page is ready to load all social media buttons

Currently i have this 'widget' to provide all this social media buttons to share the page,



This is the code:



    <div class="social_media social_media_button">
<div class="smCnt fbCnt">
<div class="fb-like" data-href="http://funcook.com/" data-send="true" data-layout="button_count" data-width="200" data-show-faces="false" data-font="verdana"></div>
</div>
<div class="smCnt gpCnt">
<g:plusone size="medium"></g:plusone>
</div>
<div class="smCnt ptCnt">
<a href="http://pinterest.com/pin/create/button/?url=http://funcook.com/'" class="pin-it-button" count-layout="horizontal"><img border="0" src="//assets.pinterest.com/images/PinExt.png" title="Pin It" /></a>
</div>
<div class="smCnt twCnt">
<a href="https://twitter.com/share" class="twitter-share-button" data-lang="es" >Twittear</a>
</div>
<div class="smCnt tmCnt">
<a href="http://www.tumblr.com/share" title="Share on Tumblr" style="display:inline-block; text-indent:-9999px; overflow:hidden; width:81px; height:20px; background:url('http://platform.tumblr.com/v1/share_1.png') top left no-repeat transparent;">Share on Tumblr</a>
</div>

</div>
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>
<script type="text/javascript" src="http://assets.pinterest.com/js/pinit.js"></script>
<script type="text/javascript">
window.___gcfg = {lang: 'es'};
(function() {
var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
po.src = 'https://apis.google.com/js/plusone.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
})();
</script>
<script>(function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return;
js = d.createElement(s); js.id = id;
js.src = "//connect.facebook.net/es_LA/all.js#xfbml=1&appId=121495767915738";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>


Wich works as expected but few resources are loaded during the page load, so i tried:



<script>
/* just include them in a $document.ready */
$(document).ready(function(){
!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");
window.___gcfg = {lang: 'es'};
(function() {
var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
po.src = 'https://apis.google.com/js/plusone.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
})();
(function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return;
js = d.createElement(s); js.id = id;
js.src = "//connect.facebook.net/es_LA/all.js#xfbml=1&appId=121495767915738";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
(function() {
var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
po.src = 'http://assets.pinterest.com/js/pinit.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
})();
$('.social_media').slideDown();
})

</script>


Wich also seems to work, but still seeing this items on the page load report:



http://tools.pingdom.com/fpt/#!/wZNCkPIsf/http://funcook.com/



How can i make sure this buttons won't affect the (initial) load time?





Updating a mysql text field with new values

i have a database with start date, end date and text field containing multiple strings, each of them starting with a mysql formatted date within the range of start and end date.



let's say i want to duplicate the record with a new start date and a new end date, i need to update those strings. no problem there. i extract them from the old record and update in the foreach loop with the new date range. except some strings can have the same dates.



$data_acc = explode(';',$record['details_accommodation'], -1);



foreach($data_acc as $row_acc)



            {

list($day,$name,$sgl,$dbl,$tpl,$nights,$status) = explode(',',$row_acc);

}


how can i detect within the loop all the same dates ($day) and update with the new values without incrementing automatically ?





Brain boiling from MySQL - How to do a complicated select from multiple tables?

I have two tables: Users and Groups



In my table "Users", there is a column called "ID" for all the user ids.



In my table "Groups" there is a column called "Participants", fields in this column are filled with all the user ids like this "PID_134,PID_489,PID_4784," - And there is a column "ID" that identifies a specific group.



Now what i want to do, i want to create a menu that shows all the users that are not yet in this particular group.



So i need to get all the user ids, that are not yet in the Participants column of a group with a particular ID.



It would be cool if there was a single mysql query for that - But any PHP + MySQL solutions are okay, too.



How does that work? Any guesses?



UPDATE:

i know, that's not code, but is there a way I could do something like this that would return me a list of all the users?



SELECT * 
FROM users, groups
WHERE groups.participants NOT LIKE '%PID_'users.id'%' AND groups.id = 1;




onCreate method is called after calling onConfigurationChanged method in an Activity class

I am a beginner in android programming, now i am working on an android application which displays the data in a sort order by default and also provides a search facility. For this i have written an activity called search that will search the contents and displays in a listview. My problem is when i rotate the device the onCreate method of the Activity class is called even after overridding the onConfigurationChanged method. I had also done the following changes in the manifest file to invoke the onConfigurationChanged method.



<activity
android:name=".Search"
android:configChanges="orientation|keyboardHidden"
android:screenOrientation="sensor" >
</activity>


my activity class snippet as follows.



public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
System.out.println("HERE AT ONCREATE");
}

@Override
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
System.out.println("HERE AT ON CONFIGURATION CHANGED");
if (newConfig.orientation == Configuration.ORIENTATION_PORTRAIT) {
setContentView(R.layout.search_port);
} else if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE) {
setContentView(R.layout.search_land);
}
}


So the output while rotating the device will be
HERE AT ON CONFIGURATION CHANGED
HERE AT ONCREATE



I dont want to get the ONCREATE method called while rotating the device. Please help me to solve this issue. I am using Android 2.2 SDK with samsung Galaxy Tab (7 inch display).





Fortran GCC interface compiler bug?

Why does GCC not warn me when I forget to specify the return type of a interface function? For me this behavior seams unexpected. What do you say to this?



This is the test-program (uncoment Line 6 and it works as it should):



program returntest
implicit none
interface
function givehalf(Y)
double precision :: Y
!double precision :: givehalf !<-- Uncomment this line
end function givehalf
end interface
double precision :: temp

temp=givehalf(5.151515d0)
print*, 'result= ',temp

end program returntest

function givehalf(Y)
implicit none
double precision :: Y
double precision :: givehalf

print*, 'Y= ',Y
givehalf=Y/2.0d0
print*, 'return Y/2',givehalf

return
end function givehalf


The result is this:



user@bapf028dl:/media/disk> gfortran44 -Wall return-test.f90
user@bapf028dl:/media/disk> ./a.out
Y= 5.1515149999999998
return Y/2 2.5757574999999999
result= -1.0579199790954590
user@bapf028dl:/media/disk> ifort return-test.f90
user@bapf028dl:/media/disk> ./a.out
Y= 5.15151500000000
return Y/2 2.57575750000000
result= 2.57575750350952




i am trying to build a registration form by Django using forms.py

here Every time i enter any data nothing happen except that the page is reloaded and password and verify password are empty even if i didn't write them typically the same the raise.ValidationError is not displayed any advice ?



Views.py



    from django.contrib.auth.models import User
from django.http import HttpResponse
from django.http import HttpResponseRedirect
from django.shortcuts import render_to_response
from shoghlanah.forms import SignUpForm
from django.template import RequestContext
from django.views.decorators.csrf import csrf_exempt
from django.contrib.auth import authenticate, login
from django.contrib.auth import logout
from shoghlanah.models import *



def EmployerRegistration(request):
if request.user.is_authenticated():
return HttpResponseRedirect('/profile/')
if request.method == 'POST':
form = SignUpForm(request.POST)
if form.is_valid():
user=User.objects.create_user(username=form.cleaned_data["username"],password= form.cleaned_data['password'],first_name=form.cleaned_data['first_name'],last_name=form.cleaned_data['last_name'],email=form.cleaned_data['email'],address=form.cleaned_data['address'],mobile=form.cleaned_data['mobile'])
user.save()
employer =Employer(user=user,first_name=form.cleaned_data['first_name'],last_name=form.cleaned_data['last_name'],email=form.cleaned_data['email'],address=form.cleaned_data['address'],mobile=form.cleaned_data['mobile'])
employer.save()
#Employer=user.get_profile()
#Employer.first_name=form.cleaned_data['first_name']
#Employer.last_name=form.cleaned_data['last_name']
#Employer.address=form.cleaned_data['address']
#Employer.mobile =form.cleaned_data['mobile']
#Employer.save()
return HttpResponseRedirect('/login/')

#else:
# return render_to_response('Sign_up_Employer.html',{'form':form},context,context_instance=RequestContext(request))

else:
#user is not submitting show them the registeration form
form= SignUpForm()
context = {'form':form}
return render_to_response('Sign_up_Employer.html',context,context_instance=RequestContext(request))


forms.py



from django.contrib.auth.forms import UserCreationForm
from django.contrib.auth.models import User
from django import forms
from django.forms import ModelForm
from shoghlanah.models import *


class SignUpForm(ModelForm):
username = forms.CharField(label=(u'Username'))
first_name = forms.CharField(label=(u'First name'))
last_name = forms.CharField(label=(u'Last name'))
address = forms.CharField(label=(u'Address'))
email = forms.EmailField(label=(u'Email Address'))
password = forms.CharField(label=(u'Password'),widget=forms.PasswordInput(render_value=False))
password1 = forms.CharField(label=(u'Verify Password'),widget=forms.PasswordInput(render_value=False))
mobile = forms.IntegerField(label=(u'Mobile'))

class Meta:
model = Employer

exclude =('user',)

def clean_username(self):
username = self.cleaned_data['username']
try:
User.objects.get(username=username)
except User.DoesNotExist:
return username

raise forms.ValidationError("That username already exists. Please select another")




def clean(self):
if self.cleaned_data['password'] != self.cleaned_data['password1']:
raise forms.ValidationError("not matched")
return self.cleaned_data


sign_up_Employer.html



{%block content%}
<form action ="" method ="post">
{% csrf_token %}
{% if form.errors %}<p>Please Correct </p> {% endif %}
<div class ="register_div">
{%if form.username.errors%}<p class= "error">{{form.username.errors}}</p>{% endif %}
<p> <label for ="username"{% if form.username.errors %} class= "error"{% endif %}> Username</label></p>
<p>{{form.username}}</p>
</div>
<div class ="register_div">
{%if form.first_name.errors%}<p class= "error">{{form.first_name.errors}}</p>{% endif %}
<p> <label for ="first_name"{% if form.first_name.errors %} class= "error"{%endif%}>First name</label></p>
<p>{{form.first_name}}</p>
</div>
<div class ="register_div">
{%if form.last_name.errors%}<p class= "error">{{form.last_name.errors}}</p>{% endif %}
<p> <label for ="last_name"{% if form.last_name.errors %} class= "error"{%endif%}>Last name</label></p>
<p>{{form.last_name}}</p>
</div>
<div class ="register_div">
{%if form.address.errors%}<p class= "error">{{form.address.errors}}</p>{% endif %}
<p> <label for ="address"{% if form.address.errors %} class= "error"{%endif%}>Address'</label></p>
<p>{{form.address}}</p>
</div>
<div class ="register_div">
{%if form.email.errors%}<p class= "error">{{form.email.errors}}</p>{% endif %}
<p> <label for ="email"{% if form.email.errors %} class= "error"{%endif%}>Email Address</label></p>
<p>{{form.email}}</p>
</div>
<div class ="register_div">
{%if form.password.errors%}<p class= "error">{{form.password.errors}}</p>{% endif %}
<p> <label for ="password"{% if form.password.errors %} class= "error"{%endif%}>Password</label></p>
<p>{{form.password}}</p>
</div>

<div class ="register_div">
{%if form.password1.errors%}<p class= "error">{{form.password1.errors}}</p>{% endif %}
<p> <label for ="password1"{% if form.password1.errors %} class= "error"{%endif%}>Verify Password</label></p>
<p>{{form.password1}}</p>
</div>

<div class ="register_div">
{%if form.mobile.errors%}<p class= "error">{{form.mobile.errors}}</p>{% endif %}
<p> <label for ="mobile"{% if form.mobile.errors %} class= "error"{%endif%}>Mobile</label></p>
<p>{{form.mobile}}</p>
</div>
<p><input type =submit alt =register></p>
</form>
{% endblock %}


models.py



from django.db import models
class Employer(models.Model):#Employer inherits from User
user = models.OneToOneField(User)
employer_verified = models.BooleanField(default=False)
profile_picture = models.ImageField(upload_to='ProfilePictureDB', null=False , blank=False)
#profile pictures will be uploaded to ProfilePictureDB
hidden_values = models.CharField(max_length=200)
#hidden_values will contain all the attributes that the employer/contractor wants to hide
signature = models.OneToOneField(Signature)
mobile = models.IntegerField(max_length=20)
address = models.CharField(max_length=100)
def __unicode__(self):
return self.name




Telerik RadGrid using an array of data

I want to print a table dynamically based on an array I have, using the RadGrid. The problem is that I am new to telerik and to ASP.NET.



What I would do in PHP is:



<?php 
$data = stuff;
?>
<table>
<?php foreach($data as $dataOne): ?>
<tr><td><?php echo $dataOne; ?></td></tr>
<?php endforeach; ?>
</table>


Now I want to do the same in ASP.NET using RadGrid.



Thanks.





Dealing with Instagram APIs (JSON + PHP)

I'm new to PHP and I can't figure out how to deal with Instagram APIs in order to (for example) extract a list of links to the standard resolution images by recent 3 items published by the user_id 3.



Here's what I created till now:



<?php
function get_instagram($user_id,$count)
{
$user_id = '3';
$count = '3';
$url = 'https://api.instagram.com/v1/users/'.$user_id.'/media/recent/?access_token=13137.f59def8.1a759775695548999504c219ce7b2ecf&count='.$count;
$jsonData = $json_decode((file_get_contents($url)));
$data = $jsonData->data;
$result = '<ul>';
foreach ($data as $key => $value) {
$result .= '<li><a href='.$value->link.' ><img src="'.$value->images->standard_resolution->url.'" width="70" height="70" /></a></li> ';
}
$result .= '</ul>';
return $result;
}


The result is a blank page though.. can you help me?





Using Floyd-Warshall algorithm to count number of paths between 2 vertices

Given an directed unweighted acylic graph, I am trying to adapt Floyd-Warshall algorithm to count the number of paths between 2 vertices. My code currently looks like this:



   for all k in 1 to n
for all i in 1 to n
for all j in 1 to n
Aij = Aij + ( Aik * Akij).


Therefore, instead of checking and replacing for min distance, I am doing the following:



count of paths between (i,j) without k + ( count of paths from i to k * count of paths from k *j )



My final array, should have the number of paths between any 2 vertices.



I am not able to prove that this does not give me the count of simple paths between 2 vertices, but there are no suggestions to use this approach elsewhere.



Can someone provide a counter example where this fails?



PS: This is not my homework, but just a programming exercise I picked up.





How to slide down after clicking link?

This is the webpage that I'm working on.



http://www.getdeco.com/agent_locator/



What I want is when I click on the "state" Ex: CA I want the page to be slid down and show the results. Now it shows up the results but it doesn't slide down.





riak search result excerpt

Doeas anybody know if riaksearch has the ability to generate excerpt with highlight points in it similar to lucene does?





Paypal SetExpressCheckout prefill address does not work java

I have the latests nvp sdk for java (76.0) and am I sending the params to paypal in the following way:



NVPEncoder encoder = new NVPEncoder();
encoder.add("VERSION", "76.0");
encoder.add("METHOD","SetExpressCheckout");
encoder.add("RETURNURL",returnURL);
encoder.add("CANCELURL",cancelURL);
encoder.add("AMT",request.getParameter("paymentAmount"));
encoder.add("PAYMENTACTION",request.getParameter("paymentType"));
encoder.add("CURRENCYCODE",request.getParameter("currencyCodeType"));

encoder.add("LANDINGPAGE","Billing");
encoder.add("PAYMENTREQUEST_0_SHIPTOSTREET", "345/3 Moomy St.");
encoder.add("PAYMENTREQUEST_0_SHIPTOCITY", "Umpa Lumpa");
encoder.add("PAYMENTREQUEST_0_SHIPTONAME","Johnny Walker");
encoder.add("PAYMENTREQUEST_0_SHIPTOSTATE", "NSW");
encoder.add("PAYMENTREQUEST_0_SHIPTOZIP","2673");
encoder.add("PAYMENTREQUEST_0_SHIPTOCOUNTRYCODE", "AU");
encoder.add("PAYMENTREQUEST_0_SHIPPINGAMT","56.00");
encoder.add("NOSHIPPING", "0");


I am getting to the "billing" landing page however I do not get a prefilled address. I have also tried exchanging:
encoder.add("PAYMENTACTION",request.getParameter("paymentType"));
with:
encoder.add("PAYMENTREQUEST_0_PAYMENTACTION",request.getParameter("paymentType"));



since the former seems to be deprecated.



I am using the same parameters as in:
Is it possible to pass a shipping address via SetExpressCheckout when using PayPal Checkout Express?



There, an api upgrade seems to be the answer, however I have the latest. At least that is what System.out.println("API VERSION: "+caller.getAPIVersion()); is telling me (76.0)



Thanks for the help in advanced.





set ipython as interpreter for pydev

I would like to use IPython as interpreter in Pydev eclipse plugin.



I have IPython 0.10 and Pydev 2.5.0, running on linux (opensuse).



When I go into Pydev preferences and try to set the IPython path (as explained on this page : http://pydev.org/manual_101_interpreter.html) , I get the following error



"Python stdlib not found or stdlib found without .py files"



The ipython interpreter works fine from a bash terminal, and i get the path from the command "which ipython".



Can someone help me ?



Thanks !



The interpreterInfo.py output is :



python /home/softs/eclipse/plugins/org.python.pydev_2.5.0.2012040618/PySrc/interpreterInfo.py 


<xml>
<version>2.7</version>
<executable>/usr/bin/python</executable>
<lib path="out">/home/softs/eclipse/plugins/org.python.pydev_2.5.0.2012040618/PySrc</lib>
<lib path="ins">/usr/local/lib64/python2.7/site-packages/scikits.timeseries-0.91.3-py2.7-linux-x86_64.egg</lib>
<lib path="ins">/usr/local/lib64/python2.7/site-packages/distribute-0.6.19-py2.7.egg</lib>
<lib path="ins">/usr/local/lib64/python2.7/site-packages/MeshPy-2011.1-py2.7-linux-x86_64.egg</lib>
<lib path="out">/data/dvp/python</lib>
<lib path="out">/home/mayet</lib>
<lib path="ins">/usr/lib/python27.zip</lib>
<lib path="ins">/usr/lib64/python2.7</lib>
<lib path="ins">/usr/lib64/python2.7/plat-linux2</lib>
<lib path="ins">/usr/lib64/python2.7/lib-tk</lib>
<lib path="ins">/usr/lib64/python2.7/lib-old</lib>
<lib path="ins">/usr/lib64/python2.7/lib-dynload</lib>
<lib path="ins">/usr/lib64/python2.7/site-packages</lib>
<lib path="ins">/usr/lib64/python2.7/site-packages/PIL</lib>
<lib path="ins">/usr/local/lib64/python2.7/site-packages</lib>
<lib path="ins">/usr/local/lib/python2.7/site-packages</lib>
<lib path="ins">/usr/lib64/python2.7/site-packages/gtk-2.0</lib>
<lib path="ins">/usr/lib/python2.7/site-packages</lib>
<lib path="ins">/usr/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg-info</lib>
<lib path="ins">/usr/lib64/python2.7/site-packages/wx-2.8-gtk2-unicode</lib>
<forced_lib>__builtin__</forced_lib>
<forced_lib>__main__</forced_lib>
<forced_lib>_ast</forced_lib>
<forced_lib>_codecs</forced_lib>
<forced_lib>_sre</forced_lib>
<forced_lib>_symtable</forced_lib>
<forced_lib>_warnings</forced_lib>
<forced_lib>errno</forced_lib>
<forced_lib>exceptions</forced_lib>
<forced_lib>gc</forced_lib>
<forced_lib>imp</forced_lib>
<forced_lib>marshal</forced_lib>
<forced_lib>posix</forced_lib>
<forced_lib>pwd</forced_lib>
<forced_lib>signal</forced_lib>
<forced_lib>sys</forced_lib>
<forced_lib>thread</forced_lib>
<forced_lib>xxsubtype</forced_lib>
<forced_lib>zipimport</forced_lib>
</xml>Traceback (most recent call last):
File "/home/softs/eclipse/plugins/org.python.pydev_2.5.0.2012040618/PySrc/interpreterInfo.py", line 142, in <module>
raise RuntimeError('Ok, this is so that it shows the output (ugly hack for some platforms, so that it releases the output).')
RuntimeError: Ok, this is so that it shows the output (ugly hack for some platforms, so that it releases the output).




How to pass option into HTML select

I want different behaviors depending on which <option> element is selected:



<select name="colorSelector" onchange="handleColorChange();">
<option value="">- select -</option>
<option value="1">Red</option>
<option value="2">Blue</option>
</select>

function handleColorChange() {
// Behave different depending on which <option> was just selected
}


What do I need to pass into the handleColorChange() method from inside the onchange listener in order to accomplish this?





CSS and jQuery issues with height of drop down menus

So I've made some drop down menus. The drop downs are ul nested in li. For style reasons I need have the drop down height set to 0px with some padding when the page first loads. All my drop downs have different heights. When I put 100% in as the height to animate too, it does not work.



Here is a link: http://www.jasonfoumberg.com/test/writing.html



How do I get the drop downs to animate to the proper height. Each drop down has a different number of items.



jQuery



$(document).ready(function () {
var defHeight = $('ul:first', this).height();
console.log(defHeight);

$("ul li").hover(

function () {

$('ul:first', this).animate({
height: "100%"
});
}, function () {
$('ul:first', this).animate({
height: "0px"
});
});
});?


HTML



<div id="mainWrapperContent">
<div id="writingMenu">
<ul>
<li><a href="">critical reviews</a>
<ul>
<li><a href="">frieze</a></li>
<li><a href="">Modern Painters</a></li>
<li><a href="">photograph</a></li>
<li><a href="">sculpture</a></li>
<li><a href="">NewCity</a></li>
</ul>
</li>
<li><a href="">Exhibition Catalogs</a>
<ul>
<li><a href="">Catalog One</a></li>
<li><a href="">Catalog Two</a></li>
<li><a href="">Catalog Three</a></li>
<li><a href="">Catalog Four</a></li>
<li><a href="">Catalog Five</a></li>
</ul>
</li>
<li><a href="">BreakOut Artists</a>
<ul>
<li><a href="">2012</a></li>
<li><a href="">2011</a></li>
<li><a href="">2010</a></li>
<li><a href="">2009</a></li>
<li><a href="">2008</a></li>
</ul>
</li>
<li><a href="">Cover Stories</a>
<ul>
<li><a href="">Catalog One</a></li>
<li><a href="">Catalog Two</a></li>
<li><a href="">Catalog Three</a></li>
<li><a href="">Catalog Four</a></li>
<li><a href="">Catalog Five</a></li>
<li><a href="">Catalog One</a></li>
<li><a href="">Catalog Two</a></li>
<li><a href="">Catalog Three</a></li>
<li><a href="">Catalog Four</a></li>
<li><a href="">Catalog Five</a></li>
</ul>
</li>
</ul>
</div><!-- writing Menu -->
</div><!-- mainWrapper Content -->?


CSS



#writingMenu a {
margin: 0px 0px 0px 0px;
padding: 12px 5px 5px 5px;
text-align: right;
-webkit-transition: all .3s ease;
-moz-transition: all .3s ease;
-o-transition: all .3s ease;
-ms-transition: all .3s ease;
transition: all .3s ease;
background: #ffffff;
color: #B3B3B3;
min-width: 140px !important;
display: block;
}

#writingMenu a:hover {
color: #37342e;
}

#writingMenu ul li ul {
position: absolute;
width: 90%;
float: left;
overflow: hidden;
border-left: thin solid black;
border-bottom: thin solid black;
border-right: thin solid black;
margin-left: -5px;
padding-top: 5px;
background-image: url(images/speckled_backgrounddk.jpg);
display: block;
height: 0px;
}

#writingMenu ul li ul li {
background-image: none;
float: none;
}

#writingMenu ul li ul a {
margin: 0px;
padding: 0px;
text-align: left;
-webkit-transition: all .3s ease;
-moz-transition: all .3s ease;
-o-transition: all .3s ease;
-ms-transition: all .3s ease;
transition: all .3s ease;
color: #B3B3B3;
background-color: transparent;
background-image: none;
text-transform: lowercase;
color: #999999;
}?




How to order an array of arrays by index in javascript

I'm trying to order an array of arrays by it's 2nd index, so if I have something like:



a[0][0] = #
a[0][1] = $
a[1][0] = x
a[1][1] = y
a[1][2] = z
a[2][0] = qaz
a[2][1] = qwerty


I get:



a[0][0] = #
a[1][0] = x
a[2][0] = qaz
a[0][1] = $
a[1][1] = y
a[2][1] = qwerty
a[1][2] = z


Thanks in advance!!





OpenJPA - id field of an instance is returning null on query

I am using Apache CXF (version 2.5.2) to implement REST services that do add, update, delete, query single and list of records on database tables. I am using OpenJPA (version 2.2.0) in the persistence layer.



As an example, I have a table named Complaint, mapped to an entity class of the same name. The complaint entity is similar to this:



import java.io.Serializable;
import java.sql.Timestamp;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;



/**
* The persistent class for the "Complaint" database table.
*
*/
@Entity
@Table(name = "Complaint")
@NamedQueries({
@NamedQuery(name = "cmplById", query = "SELECT c FROM Complaint c WHERE c.id = ?1"),
@NamedQuery(name = "cmplBySearchCriteria", query = "SELECT c FROM Complaint c WHERE c.status = ?1 AND c.category = ?2 AND c.location = ?3 AND "
+ "c.reportDate BETWEEN ?4 AND ?5 ORDER BY c.id DESC")

})

public class Complaint implements Serializable {
private static final long serialVersionUID = 1L;

private Integer id;

private String description;

private String location;

private Timestamp reportDate;

private String reportedBy;

private String status;

private String category;

public Complaint() {
}

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "Id", nullable = false)
public Integer getId() {
return this.id;
}

public void setId(Integer id) {
this.id = id;
}

@Column(name = "Description")
public String getDescription() {
return this.description;
}

public void setDescription(String description) {
this.description = description;
}

@Column(name = "Location")
public String getLocation() {
return this.location;
}

public void setLocation(String location) {
this.location = location;
}

@Column(name = "ReportDate", nullable = false)
public Timestamp getReportDate() {
return this.reportDate;
}

public void setReportDate(Timestamp reportDate) {
this.reportDate = reportDate;
}

@Column(name = "ReportedBy", nullable = false)
public String getReportedBy() {
return this.reportedBy;
}

public void setReportedBy(String reportedBy) {
this.reportedBy = reportedBy;
}

@Column(name = "Status", nullable = false)
public String getStatus() {
return this.status;
}

public void setStatus(String status) {
this.status = status;
}

@Column(name = "Category", nullable = false)
public String getCategory() {
return category;
}

public void setCategory(String category) {
this.category = category;
}

}


All the services are working fine, except for an issue related to two query operations which return data.



The operations getComplaintById and getAllComplaint currently return the entity(s) with all the fields that have values available in database, but with the id field returning as null. I tried structuring the queries in these methods in three ways - using named queries, using native sql and using the find method on entity manager - all of these give the same result.



Just to test, if I try to set the value of id field based on null checking, it is not allowing me, saying the id field has value which is final.



I found same result running the code against both MySQL and Postgres database. Here is code for one of the query method.



public Complaint getComplaintById(Integer id) {     
Complaint cmpl;

//case-1: The NamedQueries as defined in the entity class Complaint --> @NamedQuery(name="cmplById", query="SELECT c FROM Complaint c WHERE c.id = ?1")
//Query query = em.createNamedQuery("cmplById");

//case-2: using NativeQuery
//Query query = em.createNativeQuery("SELECT * FROM COMPLAINT WHERE ID=?1", Complaint.class);

//query.setParameter(1, id);
//cmpl = (Complaint) query.getSingleResult();

//case-3: using find method on entity manager
cmpl = em.find(Complaint.class, id);

System.out.println("id = " + cmpl.getId());//returning null, but get method on all other fields returning their values as expected.

return cmpl;
}


In the log I see that the query statement which OpenJPA is executing includes all other fields but not the id field in the select clause as below.



1720 ramsjpa TRACE ["http-bio-8080"-exec-3] openjpa.jdbc.SQL - executing prepstmnt 14227847 SELECT t0.Category, t0.Description, t0.Location, t0.ReportDate, t0.ReportedBy, t0.Status FROM Complaint t0 WHERE t0.Id = ? [params=?]



I am working with CXF and OpenJPA for the first time, and I may be making a basic mistake, all help appreciated.





How can I have bigger imageview for larger screen size layout?

I am looking at my android design for medium and large screen. I have designed my layout for mdeium screen (viewing it on the eclipse editor and emulator) and making sure it is good. My design involves textview and images view. I have create the 3 drawable folders for different density sizes so the picture can occupies the rough space on different densities.



Now, I am looking at the large screens (and even xtra large screens) but my textviews and images views looks very small (compared to the size of the screen). Therefore I would like to make use ofd the extra space by enlarging everything.



I know how to do it for text views, basically I would make textsize bigger (ie. instead of 12 sp I can make it 16sp)



But How can I do it for ImageView? The Imageview displays the image according to its size. And the size of the image is really meant for medium screen. How can I make it bigger? Should I provide the same image with a bigger size and a different name?



Please help, btw plz dont point me to the android develoment supporting mutliple screens cause I read it and I couldn't find what I need unless I missed a certain line that answers my question.
Thank you for your help





Sharepoint 2010 does not invoke ProcessRequest of my custom HttpHandler

Well, I know it's IIS which is supposed to invoke it. Anyway; I have a Sharepoint solution which is supposed to return a special string when files with particular extensions are clicked on document libraries.



In the corresponding web.config file I have following to run this HTTP Handler:



<system.webServer>
<handlers>
...
<add name="MyFileHandler" path="*.bar" verb="*" type="Foo.Example.MyHandler, Foo.Example, Version=1.0.0.0, Culture=neutral, PublicKeyToken=3b53a24010893ac2" resourceType="File" />
...
</handlers>
</system.webServer>


And the HttpHandler class is something like this:



namespace Foo.Example
{
public class MyHandler : IHttpHandler
{
public MyHandler(){} //For breakpoint

public void ProcessRequest(HttpContext context)
{
//Do stuff and write to response.
}

public bool IsReusable
{
get { return false; }
}
}
}


When I try to open a file with '.bar' extension on Sharepoint, it returns 404. What I do in ProcessRequest is not relevant because when I debug the handler, I can see that the handler's constructor is invoked but not the 'ProcessRequest'. Besides the debugger I have also put debug lines(File.AppendAll), again only the constructor gets invoked according to the debug output.



IIS 7.5.7600



Sharepoint 2010 Foundation





how can I change the date of window scheduler task via a admin webpage?

how can I create window scheduler task via a c# webpage ?



I have an Exe that I want to run once or twice a week.
this task should run even if the website is down.





jquery check variable values

In Jquery I have the following 4 variables.



    var add
var city
var state
var zip


I need to check to see that any one of the above have a value.
If none have a value that is OK.
If all of them have a value that is OK.



Just need to check that at least one of them do not have a value.
Not sure what is the most efficient way of doing this.





Redirecting logs to a file instaed of console on tomcat?

Guys posted the new question with more and updated details. As content has been change completely posting the new question





AS3 Movieclip center rotation and top left X,Y points

I am creating a flash image cropper. I can resize and move a movieclip containing my image. This movieclip can also be rotated.



The problem I am having is that in order to crop the image properly I need the original X,Y coordinates at the point where the image is at 0 degrees. This is the moveable movieclip I am talking about.



Is there anyway I can take the rotation degree and the current top left X,Y and get the original point at 0 degrees?



Thanks for the assistance





WebBrowser control does not complete loading when javascript:void(0) called

I have an application in C# which uses a WebBrowser control.



On one page the user can click a button to process some information and navigate to a new page. The issue is that when the user clicks this button the WebBrowser just seems to stop.



I handle the Navigating, Navigated and DocumentCompleted events in my code and I see the Navigating event but then nothing else.



This is the HTML for the button being clicked:



<div class="right button-wrapper">
<div class="clearfix right">
<span id="nextbutton"
class="button-link button-link btn-reg btn-blue-reg">
<span class="hasHover"><a id="btnPay"
href="javascript:void(0);" class="buttons">Next:Pay and Print</a>
</span>
</span>
</div>
</div>


Buttons on other pages can be clicked with no issues.



I am assuming it has something to do with the href="javascript:void(0);" portion of the HTML but do not know why. In a browser such as IE or Firefox when this button is clicked something like a progress bar appears and say "Processing" for a few seconds and then the next page loads.
I should mention that the Navigating handler fires twice and then the page freezes.





VBScript. Error on data set return

I don't have any experience programming with VB Script and i'd like to use some OOP approach. If you'll look at my code below, you will see that I'm trying to create DB access class with a set of methods, that returns data sets. Have no idea why, but receiveing error:



Microsoft VBScript runtime error '800a01c2'

Wrong number of arguments or invalid property assignment

/TrashCan/library/BLL/CreditBLLClass.asp, line 18


I have an .asp page:



<body>
<!-- #INCLUDE FILE="library\BLL\CreditBLLClass.asp" -->
<%
Dim creditBLL
Dim reader
creditBLL = new CreditBLLClass

reader = creditBLL.GetData()
If reader.EOF = False Then
Do While reader.EOF = False
Response.Write(reader.Fields("a").Value)
reader.MoveNext
Loop
End If
%>
</body>


CreditBLLClass.asp:



<!-- #INCLUDE FILE="DatabaseConnectionClass.asp" -->
<%
Class CreditBLLClass
'Private variables
Dim connection

Public Default Function Init()
Set Init = Me
End Function

Public Function GetData ()
connection = new DatabaseConnectionClass
GetData = connection.DBGetRecords("select a from b")
End Function
End Class

%>


And database connection class



<% 

Class DatabaseConnectionClass

'Private variables
dim pConnection

Public Default Function Init()

Set Init = Me
End Function

Public Function DBGetRecords ( sSQL )

Set pConnection = Server.CreateObject( "ADODB.Connection" )
With pConnection
.ConnectionString = "string"
.Open
End With
DBGetRecords = pConnection.Execute ( sSQL )
End Function

End Class

%>


Please tell me what I'm doing wrong? Maybe there is a common approach of how to build data access layer?



Great thanks.





Is returning an IEnumerable<> thread-safe?

I have a Visual Studio 2008 C# .NET 3.5 project where I want to have a thread-safe pool of Foo objects.



public class FooPool
{
private object pool_lock_ = new object();
private Dictionary<int, Foo> foo_pool_ = new Dictionary<int, Foo>();

// ...

public void Add(Foo f)
{
lock (pool_lock_)
{
foo_pool_.Add(SomeFooDescriminator, f);
}
}

public Foo this[string key]
{
get { return foo_pool_[key]; }
set { lock (pool_lock_) { foo_pool_[key] = value; } }
}

public IEnumerable<Foo> Foos
{
get
{
lock (pool_lock_)
{
// is this thread-safe?
return foo_pool_.Select(x => x.Value);
}
}
}
}


Is the public IEnumerable<Foo> Foos { get; } function thread-safe? Or, do I need to clone the result and return a new list?



Thanks