Monday, May 21, 2012

rails - how to make a GET request to action with parameters

I'm hoping this problem is a fairly simple one as I am relatively new to rails development.
I am trying to make a get request from a controller with a specified action and pass required parameters. This is the relevant code in the helper class:



module ChartsHelper
def chart_tag (action, height, params = {})
params[:format] ||= :json
path = charts_path(action, params)
content_tag(:div, :'data-chart' => path, :style => "height: #{height}px;") do
image_tag('loading.gif', :size => '32x32', :class => 'spinner')
end
end
end


and the corresponding action in the ChartsController:



class ChartsController < ApplicationController

def week_events_bar_chart
days = (params[:days] || 30).to_i
render :json => {
:type => 'AreaChart',
:cols => [['string', 'Date'], ['number', 'subscriptions']],
:rows => (1..days).to_a.inject([]) do |memo, i|
date = i.days.ago.to_date
t0, t1 = date.beginning_of_day, date.end_of_day
subscriptions = Kpsevent.all.count
memo << [date, subscriptions]
memo
end.reverse,
:options => {
:chartArea => { :width => '90%', :height => '75%' },
:hAxis => { :showTextEvery => 30 },
:legend => 'bottom',
}
}
end
end


The routes file has the following:



resource :charts do
get 'week_events_bar_chart'
end


However I get the following output when trying to perform this request:



 Started GET "/charts.week_events_bar_chart?days=14" for 127.0.0.1 at Tue May 22 00:31:48 +1200 2012
Processing by ChartsController#index as
Parameters: {"days"=>"14"}


And the controller action is never called.
Is anyone able to help with this problem?



EDIT: rake routes output:



week_events_bar_chart_charts GET    /charts/week_events_bar_chart(.:format) {:controller=>"charts", :action=>"week_events_bar_chart"}
POST /charts(.:format) {:controller=>"charts", :action=>"create"}
new_charts GET /charts/new(.:format) {:controller=>"charts", :action=>"new"}
edit_charts GET /charts/edit(.:format) {:controller=>"charts", :action=>"edit"}
GET /charts(.:format) {:controller=>"charts", :action=>"show"}
PUT /charts(.:format) {:controller=>"charts", :action=>"update"}
DELETE /charts(.:format) {:controller=>"charts", :action=>"destroy"}




Open two jquery datepickers simultaneously

I have two input fields containing a class that triggers a datepicker to open. Both work fine independently, i.e when I click on one or the other but I want for both datepickers to open when either input field is clicked.



Here is the script part of the code



    $(document).ready(function() {

$( ".datefields" ).datepicker({ dateFormat: 'dd/mm/yy',numberOfMonths: 1, yearRange: "2012:2014", changeYear: true, changeMonth: true});


and this is the html



<div id="quoteformcollection">
<h1>Collection</h1>

<input type"text" class="startTbl locationfields" id="AutoLocStart" value="Please Type a Collection Location"onclick="clearVal(this);"/>
<input type="hidden" id="DepotStart" value=""/></td>

<input type="text" class="datefields" id="collectiondate" value="21/05/2012"/>
<input type"text" class="timefields" value="12:00" />
</div>

<div id="quoteformreturn">
<h1>Return</h1>

<input type"text" class="locationfields" value="Enter the city or location for return" />
<input type"text" id="returndate" class="datefields" value="21/05/2012" />
<input type"text" class="timefields" value="12:00" />
</div>


I have tried looking for an answer myself but am quite new to jquery and struggling a bit so any help would be much appreciated.



I would also like for whatever value is selected in the first datepicker, for the default date in the second to be incremented by x number of days, which again I am not sure of the best way to go about it.



Any advice would be hugely appreciated!





Edit all files in subdirectories with python

I am trying to recursively loop through a series of directories (about 3 levels deep). In each directory is a series of text files, I want to replace a line of text with the directory path if the line contains a certain string so for example.



/path/to/text/file/fName.txt


If a line in fName in fName.txt text contains the string 'String1' I want to replace this line with 'some text' + file where file is the last part of the path.



This seems like it should be easy in python but I can't seem to manage it.



Thanks.





Double and tripple button is shown (DOMNodeInserted)

I have a weird problem:



I am developing a chrome extension that adds a custom button beside the "like" button in facebook. Until now, with alot of help I found a way to run the script even when posts are added to the news feed (without a page refresh). But the problem is that in the timline/ ticker (live feed window in the right) the button duplicates itself over time.



My current script:



$(document).ready(function(){
$(".like_link,.cmnt_like_link").after(
'<span class="dot"> · </span>' +
'<button class="taheles_link stat_elem as_link" title="???? ???&acute;?" type="submit" name="taheles" onclick="apply_taheles()" data-ft="{&quot;tn&quot;:&quot;&gt;&quot;,&quot;type&quot;:22}">' +
'<span class="taheles_default_message">???&acute;?</span><span class="taheles_saving_message">?? ????</span>' +
'</button>'
);

$(".taheles_saving_message").hide();

$(document).bind('DOMNodeInserted', function(event) {
$(event.target).find(".like_link,.cmnt_like_link").after(
'<span class="dot"> · </span>' +
'<button class="taheles_link stat_elem as_link" title="???? ???&acute;?" type="submit" name="taheles" onclick="apply_taheles()" data-ft="{&quot;tn&quot;:&quot;&gt;&quot;,&quot;type&quot;:22}">' +
'<span class="taheles_default_message">???&acute;?</span><span class="taheles_saving_message">?? ????</span>' +
'</button>'
);
$(event.target).find(".taheles_saving_message").hide();
});
});


like_link is the button that is shown in posts/comments in the news feed/any other place. cmnt_like_link is the button that is shown in comments.



If I use #contentArea in the selectors, the custom button is not even added to the ticker. If I use document (current) it is shown in the ticker but duplicates itself. I am wondering what the problem is. I tried to look at the chrome developer panel but with no luck.





Typing generic interfaces

I'm trying to create two interface hierarchies, one for the business model objects and one for the ui. I know it's important to have loose coupling between the layers but part of the application will require drawing diagrams so I need the model objects to be readily available to their corresponding graphical representations and I have a common layer holding interfaces for the model objects..



Common class library code:

Public interface IBase {}
Public interface IBookObject : IBase {}
Public interface ITapeObject : IBase {}

Public class Book : IBookObject {}

Graphics layer code:

Public interface IModelObject<T>

{

T ModelObject { get; set; } // might be a book or tape , etc

}


Public class GraphicObject<T> : IModelObject<T>

{

Public T ModelObject { get; set; }

}


Code use:

IBookObject bk = new Book();

Var go = new GraphicObject<IBookObject>(); // will fail later

//var go = new GraphicObject<IBase>(); // will succeed later

go.ModelObject = bk;

If( go is IModelObject<IBase>) // can't use is IModelObject<IBookObject> as go might be GraphicObject<ITapeObject>

{
Debug.WriteLine("Success");
}


So if I want to test for IBase (and then access ModelObject), I have to make sure that the original object was created with IBase and not a derived interface, and this seems like a cause of bugs later. my questions are:



1) Am I doing something horrible?! :) I might be overlooking a better approach..



2) failing that, is there some way of using the new contravariance c# 4 techniques to make the is line test for any interface deriving from IBase? Alternatively I think it would work if IBook didn't inherit from IBase, but Book (and Tape) implemented both IBook and IBase separately.



3) failing that, is there any way to prevent construction of GraphicObject<IBookObject>() and GraphicObject<ITapeObject>()?



Thank you!





Is const_cast(iterator->second) safe?

I want to know if this code is safe and doesnt have any undefined behavior.



 QueueMap::const_iterator it = m_3playersQueue.find(s->m_GameCode);
if(it == m_3playersQueue.end())
{
std::deque<Session*> stack;
stack.push_back(s);

m_3playersQueue[s->m_GameCode] = stack;
return;
}

const_cast<std::deque<Session*>&>(it->second).push_back(s);

QueueMap is of type std::tr1::unordered_map< uint32, std::deque<Session*> >


Thanks





How to insert a block into a node or template in Drupal 7?

In Drupal 6, it was easy to insert a block into a template with the following code:



$block = module_invoke('views', 'block', 'view', 'block_name');
print $block['content'];


However, using the same instructions in Drupal 7 does not seem to work. I have looked around and cannot find the new method.



Does Drupal 7 have a routine that can allow for pro grammatically inserting a block into a template or node?





Finding the right way to store data

I had planned on using a Dictionary or SortedList for this but as the project evolved while planning it, I'm not sure what to do.



My site will load a bunch of results from a DB Query and I need to be able to store these results somewhere.



Here's how the results look like:



What type of Dictionary/List should be used for this?



So, here's what I am storing:



Result #1 (int) > Name > Value
> Title > Value
> Message > Value
> Date > Value
> Email > Value

Result #2 (int) > Name > Value
> Title > Value
> Message > Value
> Date > Value
> Email > Value

Result #3 (int) > Name > Value
> Title > Value
> Message > Value
> Date > Value
> Email > Value

Result #4 (int) > Name > Value
> Title > Value
> Message > Value
> Date > Value
> Email > Value


... and so on. My main concern is that most of the Dictionaries and Lists and Sorted/Linked lists cannot have dupliate keys or values. So I can't use them for this, because each Result will have all the same Key names, like Name, Title, Message, etc. Values may differ, though many of the values such as Name and Date and other ones will be dupes. So I'm kinda stuck with not knowing which kind of Dictionary/List to choose which allows duplicate keys/names and _not knowing how to get that 'one to many' relationship thing going on so i can store these results properly.



Can someone please help me with what would be the best way to go about this?





Create function that accepts function

I have a function that runs some fairly generic code that does a lot of work connection to a database and setting up different configuration variables. Lets not get into the ethics of this, please bare with me. I have within a couple of if statements of this top-level function code that I run that is actually different from function to function.



This is how it looks now.



function get_users(){
// config
// set application keys
// connect to database
// retrieve user data
// authentication to foreign api
if(something){
// some more red-tape
if(something){
//more more
if(something){
/* finally the good stuff */

// the code here varies from function to function
// eg. get users
// probably will run: inner_get_users();

}
}
}
}

function get_data(){
// config
// set application keys
// connect to database
// retrieve user data
// authentication to foreign api
if(something){
// some more red-tape
if(something){
//more more
if(something){
/* finally the good stuff */

// the code here varies from function to function
// eg. get data
// probably will run: inner_get_data();

}
}
}
}


How I want it to work:



function instance($inner){
// config
// set application keys
// connect to database
// retrieve user data
// authentication to foreign api
if(something){
// some more red-tape
if(something){
//more more
if(something){
/* finally the good stuff */

Call inner

}
}
}
}

function get_data(){


instance(function(
// get the data
));

}


or maybe



function get_users(){

$var = function(
// get the users
);

instance($var);

}


I'm looking for better, dryer, and more maintainable code.





how to solve this error of Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Source type 1 not available'

I have working on pick the photo from gallery and save in gallery



my code is



-(void)onclicksave:(id)sender
{
NSLog(@"onclicksave");
UIImagePickerController *picker=[[UIImagePickerController alloc]init];
picker.delegate=self;

if((UIButton *)sender== openLibrary)
{
picker.sourceType=UIImagePickerControllerSourceTypeSavedPhotosAlbum;

}
else
{
picker.sourceType=UIImagePickerControllerSourceTypeCamera;
}

[self presentModalViewController:picker animated:YES];

}

-(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
[picker dismissModalViewControllerAnimated:YES];
imagedisplay.image=[info objectForKey:@"UIImagePickerControllerOriginalImage"];

}


but in this code run time error like



Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Source type 1 not available'



so give any suggestion and source code which is apply in my code





SQL Server 2005 RANK function

I have a problem in SQL Server 2005:



Suppose I have the table PLAYER (string player, int score, bool Active) and the this query :



SELECT PLAYER.player AS NAME,
PLAYER.score AS SCORE,
POSITION = CASE WHEN PLAYER.Active THEN RANK()OVER(ORDER BY score desc) else NULL end
from PLAYER


The problem is that when the player is not active, the positions generated are not consecutive.



For example :



JOHN,10000,1
PETER,5000,NULL (NOT ACTIVE)
CHARLES,2500,3 (SHOULD HAVE POSITION 2, NOT 3)


Sorry for my terrible English, I hope I have explained my point





EXTJS, Unable to bind event handler to controller

I'm using EXTJS with Node.JS and am having difficulty with handling events in the context of the EXTJS MVC framework.



I've been able to easily register click events when defining the Event Listener in the Class Definition of the view, but can't seem to move this code into the controller.



Here's a look at my current code:



//Icon.JS (VIEW)

Ext.define('GeekFlicks.view.Icon', {
extend: 'Ext.button.Button',
alias: 'widget.icon',
height: 48,
width: 48,
text: 'icon',
draggable: true
});


//Icon.JS (CONTROLLER)



Ext.define('GeekFlicks.controller.Icon', {
extend: 'Ext.app.Controller',

models: ['Icon'],
stores: ['Icons'],
views: ['Icon'],

init: function () {
this.control({
'listener': {
click: function(c) {
alert('working');
}
}
});
},
});


Any help or explanations around how EXTJS deals with these sort of events is will be extremely helpful and much appreciated! Thanks.





convert ant script into gradle script

How do you convert ant script into gradle script?
Hi,
Can you please help me to convert ant script into gradle script. I am new user of gradle.







<property name="pm-dir"                value="${PM-DIR}/${BUILD_NUM}" />
<property name="leis-dir" value="${LEIS_DIR}/${BUILD_NUM}" />

<property name="proxy-name" value="${PROXY_JAR_NAME}"/>
<property name="proxy-client-name" value="${PROXY_CLIENT_JAR_NAME}"/>

<property environment="env"/>
<property name="java-home" value="${env.JAVA_HOME}"/>

<condition property="build-pm">
<equals arg1="True" arg2="${BUILD_PM}" />
</condition>

<condition property="build-LEIS">
<equals arg1="True" arg2="${BUILD_LEIS}" />
</condition>


<target name="build-LEIS-components" if="build-LEIS">

<ant antfile="build.xml"
target="clean"
dir="${leis-dir}/LEIS"
inheritAll="false"/>
<ant antfile="build.xml"
target="ejbdoclet"
dir="${leis-dir}/LEIS/BusinessServices"
inheritAll="false"/>
<ant antfile="build.xml"
target="jar"
dir="${leis-dir}/LEIS"
inheritAll="false"/>

<ant antfile="build.xml"
target="clean"
dir="${leis-dir}/ETS/trunk/Entitlements"
inheritAll="false"/>
<ant antfile="build.xml"
target="build"
dir="${leis-dir}/ETS/trunk/Entitlements"
inheritAll="false"/>

<mkdir dir="${leis-dir}/JARS/APP-INF/lib/"/>

<jar jarfile="${leis-dir}/JARS/APP-INF/lib/LEISConfig.jar">
<fileset dir="LEIS/" includes="datetime.properties"/>
<fileset dir="LEIS/" includes="log4j.properties"/>
<manifest>
<attribute name="Built-By" value="${user.name}"/>
</manifest>
</jar>
</target>


<!--========================================================================
Builds pm using the supplied RE build files, modified by us.
========================================================================-->
<target name="build-pm" if="build-pm">




<!-- SPPResourceBundle Overrides -->
<mkdir dir="${pm-dir}/pm2/deploy/propertyoverrides"/>
<copy todir="${pm-dir}/pm2/deploy/propertyoverrides" overwrite="true">
<fileset dir="olwpmconfig/propertyoverrides"/>
</copy>

<!-- copy build.properties into pm dir, complete with kodo key -->
<copy file="olwpmconfig/build.properties" todir="${pm-dir}/pm2/" overwrite="true">
<filterchain>
<replacetokens>
<token key="LOGGINGFLOOR" value="${PERFORMANCE_LOGGING_FLOOR}"/>
<token key="BEADIR" value="${BEA_HOME}"/>
</replacetokens>
</filterchain>
</copy>

<!--the actual Retail Express build scripts to create the pm-main.ear-->
<echo message="Calling pm Build Script"/>
<ant antfile='${pm-dir}/pm2/build/build.xml' target='clean-build' inheritAll="false"/>

<!--delete the extra copy of jdo.dtd-->
<delete file="jdo.dtd" />

<fileset id="required-pm-client-libs" dir="${pm-dir}/pm2/deploy/lib">
<include name="*.jar"/>
<include name="client/*.jar"/>
<exclude name="*tests.jar"/>
</fileset>

<!-- Used to populate value of MANIFEST.MF Class-path attribute. Turns our set of "required" libs
into a nice space separated string to place in the MANIFEST.MF. Property is used in the "dist"
task's jar command. -->
<pathconvert property="client-classpath"
refid="required-pm-client-libs"
pathsep=" "
dirsep="/">
<map from="${pm-dir}/pm2/deploy/lib/" to=""/>
</pathconvert>

<jar update="true" jarfile="${pm-dir}/pm2/deploy/lib/pm-core.jar">
<manifest>
<attribute name="Class-Path" value="${client-classpath}"/>
<attribute name="Main-Class" value="com.retailexp.pm.ui.util.SPPClientStartUp"/>
</manifest>
</jar>

<!-- Creates a file Marimba/BigFix/WhatEver can use to track the version of pm installed on a machine -->
<echo message="${pm_MAJOR_VERSION}.${BUILD_NUM}" file="${pm-dir}/pm2/deploy/lib/version.txt" append="false"/>

<!-- Remove files we place on classpath from ears, Mantis 10624 -->
<!-- pm -->
<move file="${pm-dir}/pm2/deploy/dist/pm-main.ear" tofile="${pm-dir}/pm2/deploy/dist/old-pm-main.ear"/>
<unzip src="${pm-dir}/pm2/deploy/dist/old-pm-main.ear" dest="${pm-dir}/pm2/deploy/dist/">
<patternset>
<include name="lib/pm-server-conf.jar"/>
</patternset>
</unzip>
<move file="${pm-dir}/pm2/deploy/dist/lib/pm-server-conf.jar" tofile="${pm-dir}/pm2/deploy/dist/lib/old-pm-server-conf.jar"/>
<zip file="${pm-dir}/pm2/deploy/dist/lib/pm-server-conf.jar">
<zipfileset src="${pm-dir}/pm2/deploy/dist/lib/old-pm-server-conf.jar">
<exclude name="log4j.properties"/>
<exclude name="ehcache-transactional.xml"/>
</zipfileset>
</zip>
<zip file="${pm-dir}/pm2/deploy/dist/pm-main.ear">
<zipfileset src="${pm-dir}/pm2/deploy/dist/old-pm-main.ear">
<exclude name="lib/pm-server-conf.jar"/>
</zipfileset>
<zipfileset dir="${pm-dir}/pm2/deploy/dist/lib/" includes="pm-server-conf.jar" fullpath="lib/pm-server-conf.jar"/>
</zip>
<!-- EDM -->
<move file="${pm-dir}/pm2/deploy/dist/pm-edm.ear" tofile="${pm-dir}/pm2/deploy/dist/old-pm-edm.ear"/>
<unzip src="${pm-dir}/pm2/deploy/dist/old-pm-edm.ear" dest="${pm-dir}/pm2/deploy/dist/">
<patternset>
<include name="lib/pm-server-conf.jar"/>
</patternset>
</unzip>
<move file="${pm-dir}/pm2/deploy/dist/lib/pm-server-conf.jar" tofile="${pm-dir}/pm2/deploy/dist/lib/old-pm-server-conf.jar"/>
<zip file="${pm-dir}/pm2/deploy/dist/lib/pm-server-conf.jar">
<zipfileset src="${pm-dir}/pm2/deploy/dist/lib/old-pm-server-conf.jar">
<exclude name="log4j.properties"/>
</zipfileset>
</zip>
<zip file="${pm-dir}/pm2/deploy/dist/pm-edm.ear">
<zipfileset src="${pm-dir}/pm2/deploy/dist/old-pm-edm.ear">
<exclude name="lib/pm-server-conf.jar"/>
</zipfileset>
<zipfileset dir="${pm-dir}/pm2/deploy/dist/lib/" includes="pm-server-conf.jar" fullpath="lib/pm-server-conf.jar"/>
</zip>
</target>

<!--========================================================================
Builds LEIS
========================================================================-->
<target name="build-proxy" if="build-LEIS">

<!--copy deploy.properties with the proper jar names and locations-->
<copy file="LEIS/deploy.properties" todir="${leis-dir}/proxy/config/build/" overwrite="true">
<filterchain>
<replacetokens>
<token key="pmCORE" value="${pm_CORE_NAME}"/>
<token key="pmTRANSFER" value="${pm_TRANSFER_NAME}"/>
<token key="PROXYJARNAME" value="${PROXY_JAR_NAME}"/>
<token key="PROXYCLIENTJARNAME" value="${PROXY_CLIENT_JAR_NAME}"/>
<token key="PROXYLIBSDIR" value="${leis-dir}/JARS/"/>
</replacetokens>
</filterchain>
</copy>

<ant antfile="build.xml" target="clean" dir="${leis-dir}/proxy" inheritAll="false" />
<ant antfile="build.xml" target="prod-dist" dir="${leis-dir}/proxy" inheritAll="false">
<property name="build.name" value="${pm_MAJOR_VERSION}.${BUILD_NUM}"/>
</ant>

<ear destfile="${ear-name}" appxml="LEIS/application.xml">
<metainf dir="${leis-dir}/LEIS/conf/EAR/META-INF" includes="weblogic-application.xml"/>
<fileset dir="${leis-dir}/JARS/" includes="*.jar"/>
<fileset dir="${leis-dir}/JARS/" includes="APP-INF/**" excludes="APP-INF/lib/wlfullclient.jar"/>
</ear>

<!-- Place the proxy-client jar in the pm ear-->
<zip update="true" destfile="${pm-dir}/pm2/deploy/dist/pm-main.ear">
<zipfileset dir="${leis-dir}/proxy/dist/" includes="${proxy-client-name}" fullpath="APP-INF/lib/${proxy-client-name}"/>
</zip>

</target>

<target name="build-cpc">
<copy file="${pm-dir}/pm2/deploy/lib/${pm_TRANSFER_NAME}" todir="${leis-dir}/cpc-web-app/webapp/lib/cpc"/>
<ant antfile="build.xml" target="build-all-environments" dir="${leis-dir}/cpc-web-app/webapp" inheritAll="false"/>
</target>

<target name="build-all">
<antcall target="build-LEIS-components"/>
<antcall target="build-pm"/>
<antcall target="build-proxy"/>
<antcall target="build-cpc"/>
</target> </condition>

<condition property="build-LEIS">
<equals arg1="True" arg2="${BUILD_LEIS}" />
</condition>


<target name="build-LEIS-components" if="build-LEIS">

<!--Go through and build the LEIS modules-->
<ant antfile="build.xml"
target="clean"
dir="${leis-dir}/LEIS"
inheritAll="false"/>
<ant antfile="build.xml"
target="ejbdoclet"
dir="${leis-dir}/LEIS/BusinessServices"
inheritAll="false"/>
<ant antfile="build.xml"
target="jar"
dir="${leis-dir}/LEIS"
inheritAll="false"/>



<ant antfile="build.xml"
target="clean"
dir="${leis-dir}/ETS/trunk/Entitlements"
inheritAll="false"/>
<ant antfile="build.xml"
target="build"
dir="${leis-dir}/ETS/trunk/Entitlements"
inheritAll="false"/>


<mkdir dir="${leis-dir}/JARS/APP-INF/lib/"/>


<jar jarfile="${leis-dir}/JARS/APP-INF/lib/LEISConfig.jar">
<fileset dir="LEIS/" includes="datetime.properties"/>
<fileset dir="LEIS/" includes="log4j.properties"/>
<manifest>
<attribute name="Built-By" value="${user.name}"/>
</manifest>
</jar>
</target>


<target name="build-pm" if="build-pm">



<mkdir dir="${pm-dir}/amp2/deploy/propertyoverrides"/>
<copy todir="${pm-dir}/amp2/deploy/propertyoverrides" overwrite="true">
<fileset dir="olwAMPconfig/propertyoverrides"/>
</copy>

<ant antfile='${pm-dir}/amp2/build/build.xml' target='clean-build' inheritAll="false"/>

<!--delete the extra copy of jdo.dtd-->
<delete file="jdo.dtd" />

<fileset id="required-amp-client-libs" dir="${pm-dir}/amp2/deploy/lib">
<include name="*.jar"/>
<include name="client/*.jar"/>
<exclude name="*tests.jar"/>
</fileset>

<!-- Used to populate value of MANIFEST.MF Class-path attribute. Turns our set of "required" libs
into a nice space separated string to place in the MANIFEST.MF. Property is used in the "dist"
task's jar command. -->
<pathconvert property="client-classpath"
refid="required-amp-client-libs"
pathsep=" "
dirsep="/">
<map from="${pm-dir}/amp2/deploy/lib/" to=""/>
</pathconvert>

<jar update="true" jarfile="${pm-dir}/amp2/deploy/lib/amp-core.jar">
<manifest>
<attribute name="Class-Path" value="${client-classpath}"/>
<attribute name="Main-Class" value="com.retailexp.amp.ui.util.SPPClientStartUp"/>
</manifest>
</jar>

<!-- Creates a file Marimba/BigFix/WhatEver can use to track the version of AMP installed on a machine -->
<echo message="${AMP_MAJOR_VERSION}.${BUILD_NUM}" file="${pm-dir}/amp2/deploy/lib/version.txt" append="false"/>

<!-- Remove files we place on classpath from ears, Mantis 10624 -->
<!-- AMP -->
<move file="${pm-dir}/amp2/deploy/dist/amp-main.ear" tofile="${pm-dir}/amp2/deploy/dist/old-amp-main.ear"/>
<unzip src="${pm-dir}/amp2/deploy/dist/old-amp-main.ear" dest="${pm-dir}/amp2/deploy/dist/">
<patternset>
<include name="lib/amp-server-conf.jar"/>
</patternset>
</unzip>
<move file="${pm-dir}/amp2/deploy/dist/lib/amp-server-conf.jar" tofile="${pm-dir}/amp2/deploy/dist/lib/old-amp-server-conf.jar"/>
<zip file="${pm-dir}/amp2/deploy/dist/lib/amp-server-conf.jar">
<zipfileset src="${pm-dir}/amp2/deploy/dist/lib/old-amp-server-conf.jar">
<exclude name="log4j.properties"/>
<exclude name="ehcache-transactional.xml"/>
</zipfileset>
</zip>
<zip file="${pm-dir}/amp2/deploy/dist/amp-main.ear">
<zipfileset src="${pm-dir}/amp2/deploy/dist/old-amp-main.ear">
<exclude name="lib/amp-server-conf.jar"/>
</zipfileset>
<zipfileset dir="${pm-dir}/amp2/deploy/dist/lib/" includes="amp-server-conf.jar" fullpath="lib/amp-server-conf.jar"/>
</zip>
<!-- EDM -->
<move file="${pm-dir}/amp2/deploy/dist/amp-edm.ear" tofile="${pm-dir}/amp2/deploy/dist/old-amp-edm.ear"/>
<unzip src="${pm-dir}/amp2/deploy/dist/old-amp-edm.ear" dest="${pm-dir}/amp2/deploy/dist/">
<patternset>
<include name="lib/amp-server-conf.jar"/>
</patternset>
</unzip>
<move file="${pm-dir}/amp2/deploy/dist/lib/amp-server-conf.jar" tofile="${pm-dir}/amp2/deploy/dist/lib/old-amp-server-conf.jar"/>
<zip file="${pm-dir}/amp2/deploy/dist/lib/amp-server-conf.jar">
<zipfileset src="${pm-dir}/amp2/deploy/dist/lib/old-amp-server-conf.jar">
<exclude name="log4j.properties"/>
</zipfileset>
</zip>
<zip file="${pm-dir}/amp2/deploy/dist/amp-edm.ear">
<zipfileset src="${pm-dir}/amp2/deploy/dist/old-amp-edm.ear">
<exclude name="lib/amp-server-conf.jar"/>
</zipfileset>
<zipfileset dir="${pm-dir}/amp2/deploy/dist/lib/" includes="amp-server-conf.jar" fullpath="lib/amp-server-conf.jar"/>
</zip>
</target>

<!--=============== Builds LEIS ========================================================================-->
<target name="build-proxy" if="build-LEIS">


<ant antfile="build.xml" target="clean" dir="${leis-dir}/proxy" inheritAll="false" />
<ant antfile="build.xml" target="prod-dist" dir="${leis-dir}/proxy" inheritAll="false">
<property name="build.name" value="${AMP_MAJOR_VERSION}.${BUILD_NUM}"/>
</ant>

<!--copy the proxy jar to the LEIS jars library-->
<copy todir="${leis-dir}/JARS" flatten="true">
<fileset dir="${leis-dir}/proxy/dist/" >
<include name="${proxy-name}"/>
</fileset>
</copy>

<!--create a directory to hold the LEIS ear contents-->
<property name="ear.dir" value="${leis-dir}/bin"/>
<property name="ear-name" value="${ear.dir}/LEIS_AMP.ear"/>
<mkdir dir="${ear.dir}"/>

<!--create the ear from the directories contents-->
<ear destfile="${ear-name}" appxml="LEIS/application.xml">
<metainf dir="${leis-dir}/LEIS/conf/EAR/META-INF" includes="weblogic-application.xml"/>
<fileset dir="${leis-dir}/JARS/" includes="*.jar"/>
<fileset dir="${leis-dir}/JARS/" includes="APP-INF/**" excludes="APP-INF/lib/wlfullclient.jar"/>
</ear>

<!-- Place the proxy-client jar in the amp ear-->
<zip update="true" destfile="${pm-dir}/amp2/deploy/dist/amp-main.ear">
<zipfileset dir="${leis-dir}/proxy/dist/" includes="${proxy-client-name}" fullpath="APP-INF/lib/${proxy-client-name}"/>
</zip>

</target>

<target name="build-cpc">
<copy file="${pm-dir}/amp2/deploy/lib/${AMP_TRANSFER_NAME}" todir="${leis-dir}/cpc-web-app/webapp/lib/cpc"/>
<ant antfile="build.xml" target="build-all-environments" dir="${leis-dir}/cpc-web-app/webapp" inheritAll="false"/>
</target>

<!--========================================= Build AMP and LEIS --!>

<target name="build-all">
<antcall target="build-LEIS-components"/>
<antcall target="build-pm"/>
<antcall target="build-proxy"/>
<antcall target="build-cpc"/>
</target>






FormClosing shutdown event doesnt write to a file

I have a backup power supply for my computer which is attacted inline with it and the wall. When I pull the power cord from the wall, I have 2-5 minutes before the backup supply shuts down the computer. It is during this time that I want to write data to a file with the code below:



private void Form1_FormClosing(object sender, FormClosingEventArgs e)
{
if (e.CloseReason.Equals(CloseReason.WindowsShutDown))
{
writeContents("Interrupted");
sendMessage("PWR - The Spring Test Machine has stopped"); return;

}



if (e.CloseReason.Equals(CloseReason.UserClosing))
{
if (MessageBox.Show("You are closing this application.\n\nAre you sure you wish to exit ?", "Warning: Not Submitted", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Stop) == DialogResult.Yes)
{
writeContents("Interrupted");
return;
}

else
e.Cancel = true;
}

}


The problem is that it didn't work. I dont think the the closing event ever got called. Any ideas would greatly be appreciated. Thank you.





Unable to convert string (containing a number) to int?

I have a very silly problem .. I have a string containing "800.0000" (without the quotes), which I'm trying to convert to the number 800. I'm using this command, but its not working:



int inputNumber = Int32.Parse(inputString);



I get the FormatException, with the message "Input string was not in a correct format."





From where to upload app binary file on App store

I have followed all the steps to upload my first application on "https://itunesconnect.apple.com/WebObjects/iTunesConnect.woa"



at last i had uploaded the Large image & Screenshots.



I had not an option to upload the Binary file.



Now application status is "Waiting For Upload".



I am right now confuse about to upload my binary file, from where & how i can upload it?



is appliacation under review? is everything ok? or I will have to do any change?



Please, help me out, i am new to upload application.



All related helps are appreciated & thanks in advance.





How do I undeploy a meteor application?

I've deployed an application with:
meteor deploy a-meteor-app.meteor.com.



Is there a way for me to undeploy from meteor.com?





How to print multi-digit numbers like a 7-segment display

I am just wondering whether is it possible to display in digital format.
In this we are accepting number from console.



For example:



123 should be display in following format, and in one line.
_ _
| _| _|
| |_ _|


I tried using switch case but not got appropriate method



"arg" is char array;
char c;
for(i=0;i<3;i++)
{
c=arg[i];
switch(char)
{

case '1' : System.out.println("|");
System.out.println("|");
break;
case '2' : System.out.println("-");
System.out.println(" "+"|");
System.out.println("-");
System.out.println("|");
System.out.println("-");
break;

same for all digit
}
}


I know this is not a correct solution to display.



Is it any alternative for this using java.





powershell or .net - how to receive domain accounts with domain names

I was asking few days ago how to combine Lotus Notes data with data from Active Directory. I was sure, that there will be no problem with retrieving user accounts from AD, but actually, there is one problem. I used the Get-QADUser to receive user names, but as I later realize, there are no user accounts. I have only winxp and win2003 server, so I can't use Active Directory Module for PowerShell and it's Search-ADAccount cmdlet.



I'm trying Get-QADUser, but with no effect. This command lists domain names in this form:



Markus Elen                user            CN=Markus Elen,OU=Users,OU=CENTRAL,DC=pb,DC=sk


but I need name of user and his domain account.



Is it possible to do it with QADUser or other cmdlet other than Search-ADAccount? Thank you!





Retrieve Vertex Coordinates

My question is:



Is there a way to retrieve the coordinates of a vertex after translations or rotation?



Example: x = 10, y = 10, z = 0



After a series of calls to glTranslate or glRotate how can I know the actual status of x, y and z?



Thanks.





Redirect all pages except some folders

I want to redirect all links except few folders
www.example.com www.example.com/foo should be redirected, but

www.example.com/bar should not be redirected.



RewriteCond %{HTTP_HOST}    ^(.*)(example|example1)\.com$
RewriteCond %{REQUEST_URI} !^/bar(.*)$
RewriteCond %{REQUEST_URI} !^(.*)(sitedown.html)(.*)$
RewriteRule ^(.*)$ http://www.example.com/sitedown.html [R=307,L]


I tried with above lines in my virtual hosts file (httpd-vhosts.conf) but these are not working.
I get redirected to sitedown.html for all links.





Replace blank spaces with null values

I am rolling up a huge table by counts into a new table, where I want to make all the empty strings as null, and typecast some columns as well. I read through some of the posts and I could not find a query, which would let me do it across all the columns in a single query, without using multiple statements.



Let me know if it is possible for me to iterate across all columns and replace cells with empty strings with null.



Ref: convert empty space to null





fancybox and links

i've searched the forums for a solution, but i couldn't find anything :)
i have a fancybox with a div inside it. inside this div i have things such as images, text and an external link ( tag ) to a website (ex. yahoo)
what i would like is, when i click the link, yahoo will open up in a new tab/window ( target:_blank ) but all i get is "the requested content cannot be loaded. please try again later"



here's the code:



<a class="fancybox" href="#content"></a>
<div id="content">
<img.... />
<p>......</p>
<a href="www.yahoo.com" target="_blank">yahoo.com</a>
</div>


thanks a lot for helping me out :)





RingTonePicker throwing SecurityException?

there is an error in my Developer console and it says that it cannot start RingTonePickerActivity because I dont have the WRITE_SETTINGS permission in the manifest. why would I need that permission to show the RingTonePicker? I tested this on several devices without having that in the manifest and had not problems at all so what gives?



java.lang.RuntimeException: Unable to start activity ComponentInfo{android/com.android.internal.app.RingtonePickerActivity}:
java.lang.SecurityException: Permission Denial: writing com.android.providers.settings.SettingsProvider uri content://settings/system from pid=24760, uid=10108 requires android.permission.WRITE_SETTINGS
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1647)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
at android.app.ActivityThread.access$1500(ActivityThread.java:117)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:123)
at android.app.ActivityThread.main(ActivityThread.java:3683)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:864)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:622)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.SecurityException: Permission Denial: writing com.android.providers.settings.SettingsProvider uri content://settings/system from pid=24760, uid=10108 requires android.permission.WRITE_SETTINGS
at android.os.Parcel.readException(Parcel.java:1322)
at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:160)
at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:114)
at android.content.ContentProviderProxy.insert(ContentProviderNative.java:408)
at android.content.ContentResolver.insert(ContentResolver.java:604)
at android.provider.Settings$NameValueTable.putString(Settings.java:576)
at android.provider.Settings$System.putString(Settings.java:772)
at android.media.RingtoneManager.setActualDefaultRingtoneUri(RingtoneManager.java:655)
at android.media.RingtoneManager.setDefaultNotificationToProvider(RingtoneManager.java:764)
at com.android.internal.app.RingtonePickerActivity.onCreate(RingtonePickerActivity.java:166)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)




Converting scientific notation to fixed notation in java using DecimalFormat

Is there any way to convert scientific notation to fixed notation in Java.
Currently I have got the following code:



DecimalFormat dfmt=new DecimalFormat("######:#######");
print(dfmt.format((new BigDecimal((Math.pow(10,-3)*3000),MathContext.Decimal64)).stripTrailingZero()));


The above code does converts scientific notation to fixed notation,however if the result is greater than zero the decimal place is ignored.
In the above example it prints 3; instead of 3.0





Weird Switch error in Obj-C

I have this switch statement in my code:



switch(buttonIndex){
case 0:
[actionSheet dismissWithClickedButtonIndex:buttonIndex animated:YES];
break;
case 1:
UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init];
imagePicker.delegate = self;
imagePicker.sourceType = UIImagePickerControllerSourceTypeCamera;
[self presentModalViewController:[imagePicker autorelease] animated:YES];
break;
default:
[self openEmailViewInViewController:self];
}


And at the UIImagePickerController instantiation in Case 1 I am getting an error:



error:expected expression before 'UIImagePickerController'


and I have no idea what I am doing wrong. Thoughts?



Oh, and buttonIndex is an NSInteger





How to not clean fields in CreditPayShipForm on unsuccessful form.is_valid?

There are pretty difficult form processing in satchmo with lots of magic and I cannot find why if form.is_valid is false it displayd completely empty with right validation errors. But even fields without errors are empty. Why this can be? Does calling form.is_valid() twice might cause this?





Link native items in my HTML project?

I have build an webapplication. And now i would like a link to the navigation function (like maps). This is a native feature of the mobile or tablet, so how do i link it in an HTML project? Is it even possible?





system() call in cocoa app

In my cocoa app I have to call system() function to launch an external app. The command I use is:



system("./main &");


If I run the app from Xcode, it works fine, because I know the folder where to put main.



If I create an archive, and distribute my .app application, system() can't find "main". Where I have to put it?? Or otherwise, how can I run an app using "./" when I'm not in the folder the application is?



Thanks





HTML select option control when disabled is not submitted with the form

I have the following HTML code. I need to gray out this control depending on the selection in another client-side control. I do it like so using jQuery:



$('#dropDown1').attr('disabled', 'disabled');


The problem is that this control, if disabled, is not submitted with the form. Is there any way to overcome this?



Again, I need to somehow be able to prevent user from editing control in certain situations (not all the time) but still be able to submit it with the form.



<select name="dropDown1" id="dropDown1">
<option value="1">1</option>
<option value="2">2</option>
</select>