Friday, April 20, 2012

Information returned by SoundCloud group recorder widget

I saw the SoundCloud group recording widget here (http://grouprecorder.soundcloudlabs.com) which looks great. I'm wondering if the widget returns the ID of a track once the user finishes uploading it. I'm asking because I want to put the widget in a larger form with fields for pictures, text, etc. and then associate the user's uploaded Soundcloud track with the other fields which are stored in my site's database.





compiling a small C++ program with Visual C++ Express

I opened hello.cpp. Why isn't there File -> Compile -> hello.cpp? What is an other easy way, if any?





Smoothly rotate and change size of UIView with shadow

I have a UIView with a shadow, and subview of the view is a UIImageView.



I want to resize the view when the iPad is rotated, and I'm trying to do this in willRotateToInterfaceOrientation.



If I set the shadow on the UIView in the basic way, the rotation is very choppy, so I'd like to use the suggestion by some people to set the shadow setting layer.shadowPath.



I have tried animating the frame size change using [UIView animateWithDuration:animations], and setting the new shadowPath in the same block, but the shadow path snaps to the new size.



And if I don't change the shadowPath in the animations block, it doesn't change.



From a few searches I've done, animating changes to layer stuff needs to be done with a CABasicAnimation.



So I think the question is, how do I animate a frame size and layer change simultaneously?





Hayes AT Commands: Detect Remote Hangup?

How are you supposed to programatically detect when the remote modem on your call hangs up? I am writing a C program which interfaces with a SoftModem device /dev/ttySL0 in Ubuntu linux. I am able to configure the modem using Hayes AT commands and communicate with the remote modem. However, I haven't been able to determine how I'm supposed to detect that the other end has hung up the line.



I have the modem configured so that when the other end hangs up, the device prints NO CARRIER and switches to command mode. However, I can't use the NO CARRIER string because I can't guarantee that the modem won't receive that string while in data mode.



How do you "listen" for remote hang up?





Drupal: how to set theme language programmatically?

How can i change drupal default language programmatically somewhere in code (like template.php)?
(i need to overwrite default language set by admin in some cases.)
i'm using drupal 6.



PS: please read my own answer for more detail. and if you may help solve that



PS: later i saw a module that was what i wanted. make sure take a look at it:



Administration Language Drupal Module





No Persistence provider for EntityManager named xx

I've searched entire SO, and although posts with the similar title exists this is a different scenario.



I've two projects in my eclipse 1) One JPA project 2) One Web project which consumes the entities from the JPA project. Both are OSGi and Maven enabled. I'm using the latest SpringFramework (3.1.1) for creating RESTful webservices in the Web project.



The project layouts are as follows:



1) JPA Project



com.demo.persistence 
|-src
|-com.demo.persistence
|-User
|-META-INF
|-MANIFEST.MF
|-persistence.xml
|-pom.xml





2) Web Project



com.demo.web
|-src
|-com.demo.web.controller
|-Controller.java
|-com.demo.web.dao
|-UserDAO.java
|-UserListDAO.java
|-com.demo.web.model
|-UserBean.java
|-com.demo.web.interfaces
|-UserDAOIntf.java
|-WebContent
|-META-INF
|-MANIFEST.MF
|-WEB-INF
|-classes
|-log4j.properties
|-rest-context.xml
|-rest-context-osgi.xml
|-rest-servlet.xml
|-web.xml
|-pom.xml





com.demo.persistence.User.java



@Entity
@XmlRootElement(name="user")
@Table(name = "T_USER")
@NamedQuery(name = "AllUsers", query = "select u from User u")
public class User {

@Id
@GeneratedValue
@Column(nullable = false)
private long id;

@Basic
@Column(nullable = false)
private String userName;

public void setUserName(String param) {
this.userName = param;
}

public String getUserName() {
return userName;
}
}





com.demo.web.dao.UserDAO



public class UserDAO implements UserDAOInterface {  
@PersistenceContext
private EntityManager em;

public User getUser(Long id) {
try{
return em.find(User.class, id);
} finally {
if(em != null)
em.close();
}
}

public List<User> getAllUsers() {
try {
List<User> users = em.createNamedQuery("AllUsers", User.class).getResultList();
return users;
} finally {
if(em != null)
em.close();
}
}

@Transactional
public User addUser(User user) {
try {
em.persist(user);
em.flush();
return user;
} finally {
if(em != null)
em.close();
}
}
}





com.demo.web.model



public class UserBean {
private UserDAO userDAO;
public void addUserDetails( String userName ) {
User user = new User();
user.setUserName(userName);
this.userDAO.addUser(user);
}

public List<User> getAllUsers() {
return this.userDAO.getAllUsers();
}

public User getUser(Long id) {
return this.userDAO.getUser(id);
}

public User addUser(User user) {
return this.userDAO.addUser(user);
}
}





com.demo.web.controller.Controller



@Controller
public class Controller {

private Jaxb2Marshaller jaxb2Marshaller;
private UserBean userBean;

public Jaxb2Marshaller getJaxb2Mashaller() {
return jaxb2Marshaller;
}

public void setJaxb2Mashaller(Jaxb2Marshaller jaxb2Marshaller) {
this.jaxb2Marshaller = jaxb2Marshaller;
}
@RequestMapping(method=RequestMethod.GET, value="/rest/users", headers="Accept=application/xml, application/json")
public @ResponseBody UserListDAO getUserList() {
return new UserListDAO(userBean.getAllUsers());
}

@RequestMapping(method=RequestMethod.GET, value="rest/user/{id}", headers="Accept=application/xml, application/json")
public @ResponseBody User getUser(@PathVariable Long id) {
return userBean.getUser(id);
}

@RequestMapping(method=RequestMethod.POST, value="rest/user/add", headers="Accept=application/xml, application/json")
public @ResponseBody User addUser(@RequestBody String userString) {
Source source = new StreamSource(new StringReader(userString));
User user = (User) jaxb2Marshaller.unmarshal(source);
return userBean.addUser(user);
}





web.xml



    <?xml version="1.0" encoding="UTF-8"?>
<web-app
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
xsi:schemaLocation=
"http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
id="WebApp_ID" version="2.5">

<display-name>com.demo.web</display-name>

<welcome-file-list>
<welcome-file>index.html</welcome-file>
</welcome-file-list>

<context-param>
<param-name>log4jConfigLocation</param-name>
<param-value>
/WEB-INF/classes/log4j.properties
</param-value>
</context-param>

<listener>
<listener-class>
org.springframework.web.util.Log4jConfigListener
</listener-class>
</listener>

<!-- The context params that read by ContextLoaderListener -->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
/WEB-INF/rest-context.xml
</param-value>
</context-param>

<!-- This listener will load other application context file in addition to springweb-servlet.xml -->
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>

<servlet>
<servlet-name>rest</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>

<servlet-mapping>
<servlet-name>rest</servlet-name>
<url-pattern>/service/*</url-pattern>
</servlet-mapping>
</web-app>





rest-context.xml



<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-2.0.xsd">

<context:annotation-config />
<context:component-scan base-package="com.demo.web.controller" />
<tx:annotation-driven transaction-manager="transactionManager" />

<bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalEntityManagerFactoryBean">
<property name="persistenceUnitName" value="com.demo.persistence" />
</bean>

<bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
<property name="entityManagerFactory" ref="entityManagerFactory" />
</bean>

<!-- Bean - DAO Mapping -->
<bean id="userDAO" class="com.demo.dao.UserDAO">
<property name="entityManagerFactory" ref="entityManagerFactory" />
</bean>

<!-- Bean Declarations -->
<bean id="userBean" class="com.demo.web.model.UserBean">
<property name="userDAO" ref="userDAO" />
</bean>

</beans>





rest-context-osgi.xml



<?xml version="1.0" encoding="UTF-8"?>
<beans
xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:osgi="http://www.springframework.org/schema/osgi"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/osgi
http://www.springframework.org/schema/osgi/spring-osgi-1.0.xsd">

<osgi:service interface="javax.persistence.EntityManager" ref="entityManagerFactory" />

</beans>





rest-servlet.xml



<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd">

<!-- To enable @RequestMapping process on type level and method level -->
<bean class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping" />
<bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter">
<property name="messageConverters">
<list>
<ref bean="marshallingConverter" />
<ref bean="jsonConverter" />
</list>
</property>
</bean>

<bean id="marshallingConverter" class="org.springframework.http.converter.xml.MarshallingHttpMessageConverter">
<constructor-arg ref="jaxbMarshaller" />
<property name="supportedMediaTypes" value="application/xml"/>
</bean>

<bean id="jsonConverter" class="org.springframework.http.converter.json.MappingJacksonHttpMessageConverter">
<property name="supportedMediaTypes" value="application/json" />
</bean>

<bean id="jaxbMarshaller" class="org.springframework.oxm.jaxb.Jaxb2Marshaller">
<property name="classesToBeBound">
<list>
<value>com.demo.persistence.User</value>
<value>com.demo.dao.UserListDAO</value>
</list>
</property>
</bean>

<bean id="users" class="org.springframework.web.servlet.view.xml.MarshallingView">
<constructor-arg ref="jaxbMarshaller" />
</bean>

<!--bean id="viewResolver" class="org.springframework.web.servlet.view.BeanNameViewResolver" /-->

<bean id="userController" class="com.demo.web.controller.Controller">
<property name="userDAO" ref="userDAO" />
<property name="jaxb2Mashaller" ref="jaxbMarshaller" />
</bean>
</beans>





Console - log4j



ERROR [org.springframework.web.context.ContextLoader] - Context initialization failed

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in ServletContext resource [/WEB-INF/rest-context.xml]: Invocation of init method failed; nested exception is javax.persistence.PersistenceException: No Persistence provider for EntityManager named com.demo.persistence

at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1455)

at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)

at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)

at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:294)

at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225)

at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:291)

at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)

at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:567)

at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:913)

at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:464)

at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:385)

at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:284)

at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:111)

at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4779)

at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5273)

at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)

at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:897)

at org.apache.catalina.core.ContainerBase.access$000(ContainerBase.java:131)

at org.apache.catalina.core.ContainerBase$PrivilegedAddChild.run(ContainerBase.java:154)

at org.apache.catalina.core.ContainerBase$PrivilegedAddChild.run(ContainerBase.java:143)

at java.security.AccessController.doPrivileged(Native Method)

at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:871)

at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:615)

at org.eclipse.gemini.web.tomcat.internal.TomcatServletContainer.startWebApplication(TomcatServletContainer.java:122)

at org.eclipse.gemini.web.internal.StandardWebApplication.start(StandardWebApplication.java:91)

at org.eclipse.gemini.web.extender.WebContainerBundleCustomizer.addingBundle(WebContainerBundleCustomizer.java:45)

at org.osgi.util.tracker.BundleTracker$Tracked.customizerAdding(BundleTracker.java:482)

at org.osgi.util.tracker.BundleTracker$Tracked.customizerAdding(BundleTracker.java:1)

at org.osgi.util.tracker.AbstractTracked.trackAdding(AbstractTracked.java:262)

at org.osgi.util.tracker.AbstractTracked.track(AbstractTracked.java:234)

at org.osgi.util.tracker.BundleTracker$Tracked.bundleChanged(BundleTracker.java:457)

at org.eclipse.osgi.framework.internal.core.BundleContextImpl.dispatchEvent(BundleContextImpl.java:847)

at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:230)

at org.eclipse.osgi.framework.eventmgr.ListenerQueue.dispatchEventSynchronous(ListenerQueue.java:148)

at org.eclipse.osgi.framework.internal.core.Framework.publishBundleEventPrivileged(Framework.java:1522)

at org.eclipse.osgi.framework.internal.core.Framework$7.run(Framework.java:1462)

at java.security.AccessController.doPrivileged(Native Method)

at org.eclipse.osgi.framework.internal.core.Framework.publishBundleEvent(Framework.java:1460)

at org.eclipse.osgi.framework.internal.core.Framework.publishBundleEvent(Framework.java:1453)

at org.eclipse.osgi.framework.internal.core.BundleHost.startWorker(BundleHost.java:391)

at org.eclipse.osgi.framework.internal.core.AbstractBundle.start(AbstractBundle.java:299)

at org.eclipse.osgi.framework.internal.core.PackageAdminImpl.resumeBundles(PackageAdminImpl.java:311)

at org.eclipse.osgi.framework.internal.core.PackageAdminImpl.processDelta(PackageAdminImpl.java:555)

at org.eclipse.osgi.framework.internal.core.PackageAdminImpl.doResolveBundles(PackageAdminImpl.java:251)

at org.eclipse.osgi.framework.internal.core.PackageAdminImpl$1.run(PackageAdminImpl.java:173)

at java.lang.Thread.run(Thread.java:722)

Caused by: javax.persistence.PersistenceException: No Persistence provider for EntityManager named com.demo.persistence

at javax.persistence.Persistence.createEntityManagerFactory(Unknown Source)

at org.springframework.orm.jpa.LocalEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalEntityManagerFactoryBean.java:92)

at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:310)

at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$6.run(AbstractAutowireCapableBeanFactory.java:1504)

at java.security.AccessController.doPrivileged(Native Method)

at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1502)

at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1452)

... 45 more





Sorry for the huge post. But I export my persistence package in the Manifest file and import the same in my web app.



And the persistence provider used is org.eclipse.persistence.jpa.PersistenceProvider.
This has been stopping my project from a month.. :( Please help.



Thanks in advance.






EDIT



persistence.xml



<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.0"
xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
<persistence-unit name="com.demo.persistence"
transaction-type="RESOURCE_LOCAL">
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
<class>com.sap.ganges.retailer.sales.persistence.Person</class>
<properties>
<property name="eclipselink.weaving" value="false" />
<property name="eclipselink.ddl-generation" value="create-tables" />
</properties>
</persistence-unit>
</persistence>




Vertical Align Wrapper

I'm messing around with a website out of boredom, and trying to figure out how to vertical align my wrap, which I am failing at lol. I've already horizontally aligned it, and just need help vertical aligning it. (Yes, I have tried vertical-align:middle, but it doesn't work).



    * { margin:0;  padding:0; }
html { height:100%; }
body { background:/*url(images/bg.jpg)*/#14181a; }
#wrap { width:960px; height:55%; margin:0 auto; background:#293033; }

<div id="wrap">
<div id="logo"></div>
<div id="navgation"></div>
<div id="content"></div>
<div id="footer"></div>
</div>




How to delay code kind of like "ping localhost..." except in C#

Is it possible to run some code in C# , wait a few seconds, then keep going? I know you can use a timer but is there an easier, quicker way? Like in batch you can do:



echo Hello
ping localhost -n 10 > nul
echo World
pause > nul


So can I do this in C# , and would it work with Winforms or just Console, because I need it for Winforms...





Running Python (Django Script)?

Php Scripts Can be Executed via Xampp or Wamp . But how do i execute Django Scripts on my PC for development Purpose?



I researched a bit but didn't found anything





Multiple entries for a specific content type in MODx?

I'm new to MODx and am just looking for the direction to go. Basically I'm looking for a way to manage many entires of the same type of content, for example, I have a page that shows all client reviews, I imagine theres a way for a site admin to add an individual review to the reviews page?



Thoughts?





MemoryCache always returns "null" after first expiration

I have the following problem, I have this kind of cache management:



public class CacheManager : ICacheManager {

private readonly ObjectCache cache;

public CacheManager() {
this.cache = MemoryCache.Default;
}

public void AddItem(string key, object itemToCache, double duration) {
var end = DateTime.Now.AddSeconds(duration);
this.cache.Add(key, itemToCache, end);
}

public T Get<T>(string key) where T : class {
try {
return (T)this.cache[key];
}
catch (Exception ex) {
return null;
}
}

public void Remove(string key) {
this.cache.Remove(key);
}
}


is quite simple.



edit



Problem: When the cache for any key expires, all the following calls to get any object in cache return "null". I check the keys and are always correct.



The problem occurs only in the client's server in my PC and my server works perfectly.



thanks.





Two different header files one implementation file

Header Files: SettingsVC.h ViewController.h



Implementation Files: SettingsVC.m ViewController.m



In ViewController.m, I imported SettingsVC.h using this line of code at the top



import "SettingsVC.h"
so I can obtain a value from a stepper from a different view.



In SettingsVC.h I have a line of code that says IBOutlet UIStepper *mainStepper;



that is assigned to a stepper.



When I try to access the value of the stepper from the ViewController.m by doing this mainStepper.value it doesn't work but it works in the Settings.m Thanks for any help.



EDIT FULL SECTIONS
SettingsVC.h FILE



@interface SettingsVC : UIViewController <UIPickerViewDataSource, UIPickerViewDelegate>     {

IBOutlet UILabel *mainTimeShow;
//IBOutlet UILabel *armTimeShow;
#import "ViewController.h"
#import "SettingsVC.h"

@interface ViewController ()

@end

@implementation ViewController

}


ViewController.m FILE



#import "ViewController.h"
#import "SettingsVC.h"

@interface ViewController ()

@end

@implementation ViewController


-(IBAction)onUpArmStart:(id)sender {

mainInt = mainStepper.value + 0003;

}

@end




UITableViewCell Selection Area - How to fill entire cell for top/bottom cells of a Grouped UITableView section?

I have a grouped-style UITableView. Within the tableView, I have rows arranged into sections, since the sections have variable numbers of rows. However, I have opted to push all of the sections together (for UI reasons) so that they look like one large section with multiple (expandable) rows.



The problem I am having is that I want the selection area for the top and bottom rows in each section to fill the entire cell - in other words, NOT to have the rounded corners.



I know that a plain tableview has full selection for the cells, but I cannot change from a grouped tableview to a plain tableview because that has other unwanted consequences.



I understand how to mask a the cell's selectedBackground to have rounded corners if it does not already have them, but I haven't been able to find a way to 'unround' the corners for the top and bottom cells of a section. I have created dummy rows for the bottom rows in each section, which seems to work, though it's tedious; but I can't do a dummy row for the top row since it makes that separator line too thick.



Is it possible to 'unround' the selection area of a top/bottom section row in a grouped UITableView?





Check if a check box is checked or not (js/jquery)

I want to check if a certain check box is selected using JavaScript/jQuery.



Here is the code I tried:



var a;
if ($("#add_desc").checked == 1){
a = "true";
}else{
a= "false";
}


I have also tried:



var a;
if ($("#add_desc").checked){
a= "true";
}else{
a= "false";
}


It always returns false once I alert the variable a.



Any idea why it won't work for me? Am I doing it wrong?



Thanks!





Hibernate 4.1Final

I was using Hibernate 3.6 where I have a code like this:



list =getSession().createSQLQuery(queryString)
.addScalar("UNAME",Hibernate.STRING)
.addScalar("COM",Hibernate.STRING)
.addScalar("COM_DATE",Hibernate.DATE)
.setString("id", Id).list();


now I change the jar from 3.6 to 4.1Final



it seems like the addScalar method is askying for Type in stead of Hibernate.STRING
I couldn't find any example hot to resolve this. if there is anyone that who know please help me thank you.





Generate public accessor class for java friendly/internal package classes and internal/friendly methods

I have a package with a single public facade , with two methods , start and stop.
Because this facade is for something like a 50+ internal/friendly classes package , I need a way to be able and test several of those inner classes directly.



I am using Eclipse and JUnit.



Reflection can be a good way , but why writing all this reflection code on my own , is there a good tool that generates wrapper public classes (like .net visual studio can ) ?



Second of all , can someone please explain how to manage a dual source tree for JUnit or refer me to a good article in that topic ?
I saw several blog posts but prefer to see if someone from here has a good explanation/reference.



and , most important -- either or not to test internal classes , is not my question here , this is my design and this is how I prefer to work .
Some think you should , some think you should not , so please dont post answers such as : you should test only public thus problem solved.
I searched in stackoverflow and could not find a good thread about it.



Thank you in advance ,



James .





The best way to execute copy constructor using .Copy?

So I need help executing this copy constructor in my object oriented program. The result should be to copy string 1: Hello World into string 2: This is a test.



In my .h file:



void Copy(MyString& one);


In my .cpp file:



void MyString::Copy(MyString& one)
{
one = String;
}


In my main.cpp file:



String1.Print();
cout << endl;
String2.Print();
cout << endl;
String2.Copy(String1);
String1.Print();
cout << endl;
String2.Print();
cout << endl;


The output:



Hello World
This is a test
is a test
This is a test


It should be:



Hello World
This is a test
Hello World
Hello World


Please explain to me what am I doing wrong?



Here is my entire .cpp file:



MyString::MyString()

{

char temp[] = "Hello World";

int counter(0);
while(temp[counter] != '') {
counter++;
}
Size = counter;
String = new char [Size];
for(int i=0; i < Size; i++)
String[i] = temp[i];

}

MyString::MyString(char *message)

{

int counter(0);

while(message[counter] != '') {

counter++;

}

Size = counter;

String = new char [Size];


for(int i=0; i < Size; i++)

String[i] = message[i];

}

MyString::~MyString()

{

delete [] String;

}

int MyString::Length()

{
int counter(0);

while(String[counter] != '')
{
counter ++;
}

return (counter);
}

void MyString:: Set(int index, char b)

{

if(String[index] == '')

{
exit(0);
}

else

{

String[index] = b;
}


}

void MyString::Copy(MyString& one)

{

one = String;


}

char MyString:: Get(int i)
{

if( String[i] == '')
{
exit(1);
}
else
{

return String[i];

}
}



void MyString::Print()

{

for(int i=0; i < Size; i++)

cout << String[i];

cout << endl;


}




Xcode won't run on device after deleting app

For some reason Xcode was running an old version of my app on the device. To fix it I deleted the app on my device after trying to reboot everyone. Now Xcode won't run on the device giving me:



error: failed to launch
No such file or directory (/Users/me/Library/Developer/Xcode/DerivedData/Foo-ebesorzwidboecgphqwmmzabjvoe/Build/Products/Debug-iphoneos/Foo.app/Foo)



EDIT - I added the directory. It is a directory on my Mac. Why would deleting the app from the iphone cause this?



EDIT2 - and its lying because the app is there. Runs fine on simulator.





TypeError: 'list' object is not callable /// In ex26 learning Python the hard Way

Here is the output I am receiving, and I am having trouble of what to check for when I re examine my code for the indicated lines.



Traceback (most recent call last):
File "ex27.py", line 93, in <module>
print_first_and_last_sorted(sentence)
File "ex27.py", line 35, in print_first_and_last_sorted
words = sort_sentence(sentence)
File "ex27.py", line 25, in sort_sentence
return sort_words(words)


Can anyone shed some light?





IOS DEV Tweet song that is currently playing

i had made a web app where you enter what your listening to and it tweets it... now I'm trying to make it into an app. My original app, a web view with reachibility was rejected for being too much like a web app, which apple recommended i make a web app instead. Now i am changing it do it can detect what song you are currently listening too and uses the built in twitter. I found some documentation for the twitter functions, and NONE for the music... if you could just tell me how i would detect what the person is listening to, and then how to tweet it with additional text before/after the name of the song their listening to... thanks! (Also, is it possible to have the app send the song name to a web server and then send the text that would be in the tweet back? Only because the web version has iTunes links that matches with the song if you wanna buy it, and the only way for that to work is through a php script on the web server...)





(Java) Not sure of the term, but basically how do I get the "opposite" of a number in a range?

What I mean is, let's say that I have number between 0 - 400. If I were to pass in 0, it would return 400, if I were to pass in 1 it would return 399, and so on and so forth. Is there an equation that will let me do this? (Yes, I know this isn't really java as much as it is plain Math)



EDIT: WOW, I'm and idiot. How did I NOT realize that this was subtraction?





Storing the configuration data - which way?

I'm in progress with developing my new website with Codeigniter framework. The key is that, I'd like to have most things to be configurable in my admin panel.



I haven't got much experience about storing the data, so which way its going to be better: PHP configuration files or MySQL table?



There will be pretty a high amount of configurations, so I would like to access it as fast as possible: for example with the MVC's model , but none said I can't do the same with the helper (for the PHP configuration files) ... So it all depends on which way its going to be: accessable faster, better to update. In my opinion, MySQL will be a better choice for this, since all I need there is just a little query - but I would first listen to your opinions guys, as most of you have a great experience related to this kind of stuff.





PHP - Group Array by Key Value

Trying to group an array depending on whether it's index is divisible by there. I've tried various combinations of for loops and foreach loops and if($i % 3 == 0) ... But, it's not outputting the way I need it.



Here is a greatly simplified array (the original data contains a lot of highly sensitive information...)



The original array looks similar to this:



$item[0]['Section 1']['Item 2'] => 1334;
$item[1]['Section 2']['Item 3'] => 15454;
$item[2]['Section 3']['Item 4'] => 1452;
$item[3]['Section 4']['Item 5'] => 1341;
$item[4]['Section 5']['Item 6'] => 1788655;
$item[5]['Section 6']['Item 7'] => 13;
$item[6]['Section 7']['Item 8'] => 142;
$item[7]['Section 8']['Item 9'] => 15678;
$item[8]['Section 9']['Item 10'] => 15542;
$item[9]['Section 10']['Item 11'] => 16578;
$item[10]['Section 11']['Item 12'] => 18452;
$item[11]['Section 12']['Item 13'] => 16565;


I'm trying to group every 3 records, like this:



$newitem[0]['Section 1']['Item 2'] => 1334;
$newitem[0]['Section 2']['Item 3'] => 15454;
$newitem[0]['Section 3']['Item 4'] => 1452;
$newitem[1]['Section 4']['Item 5'] => 1341;
$newitem[1]['Section 5']['Item 6'] => 1788655;
$newitem[1]['Section 6']['Item 7'] => 13;
$newitem[2]['Section 7']['Item 8'] => 142;
$newitem[2]['Section 8']['Item 9'] => 15678;
$newitem[2]['Section 9']['Item 10'] => 15542;
$newitem[3]['Section 10']['Item 11'] => 16578;
$newitem[3]['Section 11']['Item 12'] => 18452;
$newitem[3]['Section 12']['Item 13'] => 16565;




jQuery datepicker multiple parameters

I want to have my localized datepicker not allow certain dates picking.
Localization:



$("#datepicker").datepicker($.datepicker.regional[fr"]);


No weekends :



$("#datepicker").datepicker({ beforeShowDay: $.datepicker.noWeekends })


How can I combine both ? Cannot figure it out. Thanks!





SSRS TextRun value not populating correctly

Hey all i am new to SSRS and i am trying to create this link in my SSRS report:
http://nasmsutils01/picview/pv.asp?jobid=1652214&theDate=04-03-2012



and this is the report XML code:



<TextRun>
<Value>="http://nasmsutils01/picview/pv.asp?jobid=" &amp; Fields!Job_ID.Value &amp; "&amp;theDate=" &amp; Format(Fields!Inserted_DT.Value, "MM-dd-yyyy")</Value>
<Style>
<FontSize>8pt</FontSize>
<FontWeight>Bold</FontWeight>
</Style>
</TextRun>


However, when i run the report and click on the link all i get is this:




http://nasmsutils01/picview/pv.asp?jobid=1652214




What would i be doing wrong?



Any help would be great to solve this!



Thanks.





UIAlertView button action? Xcode

I have a UIALertView that shows with this code that asks you to rate the application in the appstore.



UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"Rate on the Appstore!"message:@""delegate:self cancelButtonTitle:@"Later"otherButtonTitles:@"OK",nil];
[alert show];


But i cannot figure out how to add a action to the OK button that takes you to the app in the appstore.





Macro define about cxxtest

I'm using cxxtest4.0.3 under vc6 to do a test. At first, the compiler report strcmp is not a member of std. After I added the CXXTEST_OLD_STD macro to project settings, the compiler report missing type info of string at the line "CXXTEST_STD(string) _s;".



How should I set the macro define? thanks in advanced.





Filter Items from JSON Objects in PHP

I have this Function/Method for filtering out a Blacklist of words in an ARRAY() using array_filter but I need to do something similar to my Objects in this code below...



JSON Objects



// Get JSON Object
$obj = json_decode($out);

// Iterate JSON Object
foreach($obj as $index => $user) {
echo $user->id;
echo $user->screen_name;
echo $user->language;
echo $user->location;
echo $user->time_zone;
echo $last_status_date;
echo $user->status->text;


// Filter out Objects that match the Blacklist


// insert remainning into database here

}


My current Blacklist Filter Function



public function blacklistFilter($raw_array){

//$data1 = array('Phillyfreelance' , 'PhillyWebJobs', 'web2project', 'cleanname');
$data1 = array_filter($data1, function($el) {
$bad_words = array('job', 'freelance', 'project', 'gig', 'word', 'news', 'studio');
$word_okay = true;

foreach ( $bad_words as $bad_word ) {
if ( stripos($el, $bad_word) !== FALSE ) {
$word_okay = false;
break;
}
}

return $word_okay;
});
}





So I am curious if there is a simialr function for filtering objects as array_filter does for ARRAYS?



Ultimately my goal is to be able to pass hundreds of JSON Objects through a function and be able to filter out ones that match a set of words in the username, filter out ones that match a language, and filter ones out that match a location or time zone





AS3: Function and variables

What i am basically looking to do is change the name of the outputted instance.



But the problem i have is how to send variables passed thought the function 'find_name' to the 'Event.Complete' function loadNameInfo?



Code Below:



    // Finds a persons name using the ID
private function find_name(page_Name='search.php',instance_name='name',get1='g1=1',get2='g2=2',get3='g3=3'):void
{
var randomParam:String = "?p=" + Math.floor(Math.random() * (10000000));
var create_URL = (URL + page_Name + randomParam + '&'+ get1 + '&' + get2 + '&' + get3);
_loader = new URLLoader();
_request = new URLRequest(create_URL);
_request.method = URLRequestMethod.POST;
_loader.addEventListener(Event.COMPLETE, loadNameInfo);
_loader.load(_request);
}
// Loads the name into the correct place
public function loadNameInfo(e:Event)
{
instance_name.text = e.target.data;
}


Is this kinda thing possible?



Eli





Can someone explain this short portion of XHR code?

I'm learning XMLHttpRequest from w3schools. I don't understand the following snippet of code. What does "window.XMLHttpRequest" signify? What makes it true or false? Is this entire if/else structure only there to account for ie6 and ie5, and if so can it all be replaced by one line which reads xmlttp=new XMLHttpRequest()?



 if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}