on-internet

mysql via subprocess doesn't work

import os import subprocess cmdline = ['mysql -u"username" -p"password" < query.sql'] p = subprocess.Popen(cmdline,stdout=subprocess.PIPE) stdout,stderr = p.communicate() retcode = p.wait() That's my code to connect to mysql and execute query.sql. Looks good to me, but it doesn't work and the bad thing is that I don't get any error message at all. retcode is 1 and from stdout, stderr I only get the mysql standard text "Usage mysql [OPTIONS] [Database] ..." so I thought my syntax is wrong. But it's not. I tested the line of code in terminal and it works. Does python have a problem to execute th

Join the discussion →

Center Fancybox within Iframe to the Parent's center

I've searched on here but it seems there was no question like this before. I have an iframe in a page. On the iframe, there is fancybox popup. But fancybox centers itself based on the iframe dimension, not the parent dimension. Can i make the fancybox to center by the parent's dimension? And click the "Click me" link, and the fancybox will be centered on the center of the iframe document..

Join the discussion →

Adding Dynamic Field to Forms (Chronoform)

I am using the popular ChoronoForm plugin for Joomla. I have created a form which contain dynamic fields. A javascript function is used to add multiple "items". A User clicks on the button "Add another item" and the item field is redisplayed for them to insert additional "items". Similar to the form on this website http://www.unclesmoney.co.uk/home3.php (Fill in the Item Details Section and click on "add another item"). When the form is submited the information is sent via email. The problem, only the item that was inserted last is sent and other itens are ignored (not sent) e.g. if I fill out

Join the discussion →

Kinect pattern recognition [closed]

I bought a Kinect to play around with on my PC in C#. (And what fun it is to program!) I'm using CLNUIDevice.dll to get the depth image from Kinect. This works fine and I'm able to read the depth through the RGB values in the image. Now I'm wondering what libraries there are to do different types of recognition. I've seen hand recognition, face recognition, skeleton, emotions, objects, etc. The image processing libraries don't have to be for Kinect (though that would be nice) and they don't have to be for .Net (though that would be nice). For instance: Any object tracking lib will work, but if

Join the discussion →

Python PIL: How to draw an ellipse in the middle of an image?

I seem to be having some trouble getting this code to work: import Image, ImageDraw im = Image.open("1.jpg") draw = ImageDraw.Draw(im) draw.ellipse((60, 60, 40, 40), fill=128) del draw im.save('output.png') im.show() This should draw an ellipse at (60,60) which is 40 by 40 pixels. The image returns nothing. This code works fine however: draw.ellipse ((0,0,40,40), fill=128) It just seems that when i change the first 2 co-ords (for where the ellipse should be placed) it won't work if they are larger than the size of the ellipse to be drawn. For example: draw.ellipse ((5,5,15,15), fill=128) Works

Join the discussion →

Git - how do I view the change history of a method/function?

So I found the question about how to view the change history of a file, but the change history of this particular file is huge and I'm really only interested in the changes of a particular method. So would it be possible to see the change history for just that particular method? I know this would require git to analyze the code and that the analysis would be different for different languages, but method/function declarations look very similar in most languages, so I thought maybe someone has implemented this feature. The language I'm currently working with is Objective-C and the SCM I'm curren

Join the discussion →

Undefined property error when calling CodeIgniter library by camelCase name while class is defined in PascalCase

I have a problem that I can't load my library in my controller. I got this error: Message: Undefined property: Profil::$profileWall My library: <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); class ProfileWall { private $CI; public function __construct() { $this->CI =& get_instance(); } public function wallShow() { $this->CI->load->model('profil_model'); return $this->CI->profil_model->wallGet($this->CI->uri->segment(3)); } } and my controller function index() { $this->load->model('profil_model'); $data['query'] = $this->profil_model->vis_profil($this->uri->segment(3

Join the discussion →

How to set a directory in PKG_CONFIG_PATH variable in ubuntu

I want to add a directory containing a .pc file, to the PKG_CONFIG_PATH variable, that is required for a certain program to run on Ubuntu. I tried to find out a solution from google but it didn't really work. I am pasting the log here. Please help. tasbeer@tasbeer-desktop:~/Android/pocketsphinx/swig$ make cc -g -Wall -DPIC -fPIC -I/usr/lib/jvm/default-java/include `pkg-config --cflags sphinxbase pocketsphinx` -c -o pocketsphinx_wrap.o pocketsphinx_wrap.c **Package sphinxbase was not found in the pkg-config search path. Perhaps you should add the directory containing `sphinxbase.pc' to the PKG_

Join the discussion →

Could not open Hibernate Session for transaction

I am getting this error. please help me. org.springframework.transaction.CannotCreateTransactionException: Could not open Hibernate Session for transaction; nested exception is org.hibernate.exception.GenericJDBCException: Cannot open connection org.springframework.orm.hibernate3.HibernateTransactionManager.doBegin(HibernateTransactionManager.java:599) org.springframework.transaction.support.AbstractPlatformTransactionManager.getTransaction(AbstractPlatformTransactionManager.java:374) org.springframework.transaction.interceptor.TransactionAspectSupport.createTransactionIfNecessary(TransactionA

Join the discussion →

Multiple markers with labels in Google Maps

I'd like to implement multiple markers with labels (documented here: http://google-maps-utility-library-v3.googlecode.com/svn/tags/markerwithlabel/1.0.1/docs/examples.html) and I'm having some problems with writing the code. For 2 markers for example you'd have to use the following code: var latlng1 = new google.maps.LatLng(49, -123); var latlng2 = new google.maps.LatLng(48, -123); var marker1 = new MarkerWithLabel({ position: latlng1, draggable: true, map: map, labelContent: "abcd", labelAnchor: new google.maps.Point(22, 0), labelClass: "labels", labelStyle: {opacity: 0.75} }); var marker2 =

Join the discussion →

How to deploy SNAPSHOT with sources and JavaDoc?

I want to deploy sources and javadocs with my snapshots. This means that I want to automize the following command: mvn clean source:jar javadoc:jar deploy Just to execute: mvn clean deploy I don't want to have javadoc/sources generation executed during the install phase (i.e. local builds). I know that source/javadoc plugins can be synchronized with the execution of the release plugin but I can't figure out how to wire it to the snapshots releases.

Join the discussion →

PHP: Assign null if not set

Is there a sort of assign-if-not-empty-otherwise-assign-null function in PHP? I'm looking for a cleaner alternative to the following: $variable = (!empty($item)) ? $item : NULL; It would also be handy if I could specify the default value; for instance, sometimes I'd like ' ' instead of NULL. I could write my own function, but is there a native solution? It should be noted that I'm trying to avoid a notice for undefined values.

Join the discussion →

language without if's?

A colleague said he heard of a language that did not have the concept of "if". Is that possible? If so, what language is it?

Join the discussion →

Javascript eval on global scope?

Is it possible to use the eval command to execute something with a global scope? For example, this will cause an error: <script> function execute(x){ eval(x); } function start(){ execute("var ary = new Array()"); execute("ary.push('test');"); // This will cause exception: ary is not defined } </script> <html><body onLoad="start()"></body></html> I know the 'with' keyword will set a specific scope, but is there a keyword for the global scope? Or is it possible to define a custom scope that would allow this to work? <script> var scope = {}; function execute(x){ with(scope){ eval(x); } } function

Join the discussion →

Set element width or height in Standards Mode

Is it possible to set width or height of HTML element (ex. <div>) in JavaScript in Standards Mode? Note the following code: <html> <script language="javascript" type="text/javascript"> function changeWidth(){ var e1 = document.getElementById("e1"); e1.style.width = 400; } </script> <body> <input type="button" value="change width" onclick="changeWidth()"/> <div id="e1" style="width:20px;height:20px; background-color:#096"></div> </body> </html> When user presses the change width button, the <div>'s width should change. It works fine when doctype declaration determines Quirks Mode. In Standards

Join the discussion →

One code certificate per deployment, or only one and sign them all with it

I have a number of different projects, which are maturing to the level that I will be buying code signing certificates for them. My understanding of a code-signing certificate is that it is meant to establish a trust relationship between my userbase, and the developer (me). To that end, it would make sense to buy one code-signing certificate and sign all my projects with the same certificate. However, I also am aware that another function of the code signing certificate is to encrypt parts of the deployment to ensure that the product is not tampered with prior to the userbase installing it. It

Join the discussion →

Nesting CSS selectors

Can I nest CSS selectors (specifically classes in my case)? Something like the following: .class1{some stuff} .class2{class1;some more stuff}

Join the discussion →

How to perform string concatenation in JavaScript?

I want to concatenate two strings in JavaScript i.e. $('#bio').css('color', result.titlecolor); I want to put the character “#” before the result.titlecolor i.e. $('#bio').css('color', '#' result.titlecolor); Is this right or wrong?

Join the discussion →

High-level server library for sharing data over network

I'd like to implement something similar to Etherpad - an online collaboration program. Do you know of a library for the server that takes care of incoming connections, manages a user list and distributes structured data between them? DRb is near to what I want, but as I understand it, but as I understand it, it repeatedly sends the whole object over the network, making it quite slow. It should only send updates. Ruby would be perfect, but I don't really care.

Join the discussion →

Count, size, length...too many choices in Ruby?

I can't seem to find a definitive answer on this and I want to make sure I understand this to the "n'th level" :-) a = { "a" => "Hello", "b" => "World" } a.count # 2 a.size # 2 a.length # 2 a = [ 10, 20 ] a.count # 2 a.size # 2 a.length # 2 So which to use? If I want to know if a has more than one element then it doesn't seem to matter but I want to make sure I understand the real difference. This applies to arrays too. I get the same results. Also, I realize that count/size/length have different meanings with ActiveRecord. I'm mostly interested in pure Ruby (1.92) right now but if anyone want

Join the discussion →

iReport - java.lang.ClassNotFoundException

Im using iReport 3.7.6. I have a Parameter with following parameter class: at.gv.domain.print.impl.ParameterClass. For using that class I did following: --> Extras --> Option --> Classpath --> Add Folder --> C:\Development\Projectname\workspace\DomainProject\target\classes Under C:\Development\Projectname\workspace\DomainProject\target\classes\at\gv\domain\print\impl there are my ParameterClass.class. Now if I wanna compile the .jrxml I get following error: net.sf.jasperreports.engine.design.JRValidationException: Report design not valid : 1. java.lang.ClassNotFoundException: at.gv.domain.prin

Join the discussion →

Excel unable to insert more than 255 chars?

I am using OLE DB driver to insert more than 255 characters into an Excel sheet, but I get the error: Exception Details: System.Data.OleDb.OleDbException: The field is too small to accept the amount of data you attempted to add. Try inserting or pasting less data. Seems from this thread that it's an Excel limitation. Even the Microsoft site seems to say so here. So does this mean I can't programmatically, but I can manually? Because I can enter more than 255 characters when I manually type them in Excel. So is it a Microsoft.ACE.OLEDB.12.0(AccessDatabaseEngine.exe) driver limitation?

Join the discussion →

MaintainScrollPositionOnPostback is not working - how to debug?

I inherited some web shop project (ASP.NET 3.5, Webforms, Visual Studio 2008 PRO). On one page I have MaintainScrollPositionOnPostback set to true. When shopping cart (user control loaded in master page) is empty, then asp.net is not generating Javascript code required for scroll position. When I add some items to the cart, then everything works fine. Can you give me any advice how to find part of the code which is responsible for this issue? I don't have an access to the 3rd party profilers.

Join the discussion →

How do I add a Marker to a jQuery UI Slider?

I have a simple jQuery UI slider that has a numerical range from 25 to 35. It works fine and the default value is 28. I'm hoping to add a simple tick mark to the slider to indicate that 28 is where the default is. Is there a simple way to add an indicator? $('#cycle_length').slider({ range: "min", value: 28, min: 25, max: 35, step: 1, slide: function( event, ui ) { $( "#amount" ).val( ui.value ); } }); $( "#amount" ).val( $( "#cycle_length" ).slider( "value" ) );

Join the discussion →

Why isn't the method toLowerCase(); working in my code?

import java.util.Scanner; public class Test { public static void main(String[] args) { char[] sArray; Scanner scan = new Scanner(System.in); System.out.print("Enter a Palindrome : "); String s = scan.nextLine(); sArray = new char[s.length()]; for(int i = 0; i < s.length(); i++) { s.toLowerCase(); sArray[i] = s.charAt(i); System.out.print(sArray[i]); } } }

Join the discussion →

Thread.CurrentPrincipal in .NET console application

Here is a trivial console application that I run in a command prompt: using System; using System.Threading; namespace Test { internal class Runner { [STAThread] static void Main(string[] args) { Console.WriteLine(Thread.CurrentPrincipal.GetType().Name); Console.WriteLine(Thread.CurrentPrincipal.Identity.Name); } } } The output is 'GenericPrincipal' and an empty string as identity name. Why is there the run time constructs GenericPrincipal instead of WindowsPrincipal? How do I force it to construct WindowsPrincipal from the security token of the starting process (cmd.exe in my case)?

Join the discussion →

HQL: Is an element of one collection in another collection?

I want to check whether at least one element of a collection (u.organisations) is contained in another collection (? = excludedOrganisations): select distinct u from SystemUser u join u.userGroups g join u.organisations o where 3 in elements(g.permissions) and EACH_ELEMENT_OF(o) not in (?) How can I express the EACH_ELEMENT_OF with HQL? My last trial is: select distinct u from SystemUser u join u.userGroups g where 3 in elements(g.permissions) and not exists ( select org from Organisation org where org in elements(u.organisations) and org not in (?) ) But I get the exception: IllegalArgumentEx

Join the discussion →
Older stories