Tuesday, April 10, 2012

How to receive children of input source?

My App must receive all input sources like Mac OS tool(with flag) at menubar. I have read Apple documentation, and I understood: I must use Carbon method TISCreateInputSourceList() for it. For the first parameter I use a dictionary like this:



NSDictionary *props = [NSDictionary dictionaryWithObjectsAndKeys:                           
[NSNumber numberWithBool:YES], kTISPropertyInputSourceIsEnabled,
[NSNumber numberWithBool:YES], kTISPropertyInputSourceIsSelectCapable,
kTISTypeKeyboardLayout, kTISPropertyInputSourceType,
nil];


and for the second parameter FALSE.



That works fine, but I can't see in my returned array the groups(categories) of input sources like Kotoeri, Tamil Input Method, Vietnamese UniKey, Hangul, Chinese Traditional, Chinese Simplified. The system tool shows only children of categories that I have listed. I need the same in my App.



How must I to change my dictionary to receive what I need? Or any other actions? Thanks for any help!





Umbraco : Active directory implementation

I'm looking to implement a higher amount of security to the CMS. So, when the site is live on the public domain, the site should check if the user is logged into our company network and is part of a certain group related to the site.



This is to prevent anyone just accessing the CMS Admin login page.



Is this possible? If so, does anyone have any good sites with tutorials or tips?



Thanks!





Solving a pipe puzzle [closed]

I am trying to find an algorithm to solve following puzzle:



I have got a list of pipes that I am allowed to use.



-I need to build a net of pipes that only has one entry/exit.



-Pipes cannot be turned



How pipes look like:



Each pipe can have an up to for ends.
ex. a pipe in the form of a T or an I or a
There are also pipes that are just an ending.



Image of those pipes: http://img.podnova.com/icons_pandroid/jpg/big/2/2982.jpg



Bruteforcing is to slow... any ideas?
Language: C#



Any idea of an algorithm that solves this problem without brute force?





How to model 'toggle' table in sql

I have a table with some columns



CREATE TABLE test (
testid INT,
field1 CHAR(10),
field2 CHAR(10),
field3 CHAR(10),
field4 CHAR(10));


Now I want to be able to have a setting in my app that will allow me to to either enable or disable some of those for particular users.



CREATE TABLE user (
userid INT
);


I was thinking about:



CREATE TABLE user_test_visible (
userid INT,
field1 BOOL,
field2 BOOL,
field3 BOOL,
field4 BOOL);


Also I was thinking about something like this :



CREATE TABLE user_test_visible (
userid INT,
field_name VARCHAR(30),
visible BOOL);


Are any of those approaches sensible?





replace traditional event call with javascript event listener

With the following code:



<head>
<script type="text/javascript">
function popupMsg(msg) {
alert(msg);
}
</script>
</head>

<body>
<a href="http://www.xyz.com" onClick="popupMsg('This is pop up message')">xyz.com</a>
</body>


How can I replace onClick with addEventListener within anchor tag ?



Can it be done without assigning ID to the anchor tag?



Probably something like this:



<a href="http://www.xyz.com" something.addEventListener('click',popupMsg(SomeMsg),false)>xyz.com</a>




How to create a a master slave server system?

I need to create 5 server programs such that one of it is the master server.



When a client tries to make a connection the master server checks which of the server has the least load(including itself) and makes a connection with the free server.



I guess i should use shared memory concepts where each server program writes to the memory its load and process id. But as I am new to this field I am do not even have a clue about solving the problem.



Any relevant links or ideas will help.



Ps: I am working in unix environment





IBM WESB/WAS JCA security configuration

I'm working with IBM tools. I have a Websphere ESB (WESB) and a CICS transaction gateway (CTG). The basic set-up is as follows:



A SOAP service needs data from CICS. The SOAP-service is connecting to service bus (WESB) to handle data and protocol transformation and then WESB calls the CTG which in turn calls CICS and the reply is handled vice verse (synchronously). WESB calls the CTG using Resource Adapter and JCA connector (or CICS adapter as it is called in WESB). Now, I have all the pieces in place and working.



My question is about the security, and even though I'm working with WESB, the answer is probably the same as in Websphere Application Server (WAS). The Resource Adaper is secured using JAAS - J2C authentication data. I have configured the security using J2C authentication data entry, so basically I have a reference in the application I'm running and at runtime the application does a lookup for the security attributes from the server. So basically I'm always accessing the CICS adapter with the same security reference.




My problem is that I need to access the resource in more dynamic way
in the future. The security cannot be welded into the application
anymore but instead given as a parameter.




Could some WESB or WAS guru help me out, how this could be done in WESB/WAS exactly?





How to create a calendar object within an Object within an ArrayList

Just working on my java assignment and I've hit a brick wall I just cant seem to find a solution for - I'm not necessarily looking for an answer, even some ideas to what tools might help me :) Anyway here goes:



As the title says, I am looking to create a calendar object within an object within an Arraylist. Basically, as per the code below - I thought that when an instance of the Appointment object was created the link between the calendar object and the appointment object would be severed and I could reuse the Calendar object for the next appointment object. Unfortunately each object retains its reference to the calendar object, rather than create its own instance of the Calendar object =/.



Some background on the work:



Basically this piece of java code, scans the file and extracts the information out of it, makes sure its valid then creates an instance of the appropriate object within the one of the two arraylists. I'm working within constraints of my tutor who has specified that I must use an arraylist. Any help would greatly appreciated.



The constructor for the appointment class:
public Appointment (Patient patient, Provider provider, GregorianCalendar date, boolean standard, boolean attended)



Example Appointment Data
Appointment#84736254193#123456AF#22.30#20/12/2012#false#True



public AppointmentsManager (String path) {

this.path = path;
String[] fileLine;
boolean throwError = false;
DateFormat df = new SimpleDateFormat ("HH.mm dd/MM/yyyy");
df.setLenient(false);
GregorianCalendar calendar = new GregorianCalendar();

try {
Scanner input = new Scanner(new File(path));
String line;

while (input.hasNext()) {

line = input.nextLine();
fileLine = line.split("#");

if (fileLine.length < 0)
throw new IllegalArgumentException("Error: the data in the file is has not been delimited correctly. Please review");

if (fileLine[0].matches("Provider")) {
if (fileLine.length < 7)
throw new IllegalArgumentException("Error: the provider data in the file is incomplete. Please review");

persons.add(new Provider(fileLine[1], fileLine[2], fileLine[3], fileLine[4], fileLine[5],
fileLine[6]));
}
else if (fileLine[0].matches("Patient")) {
fileLine = line.split("#");

if (fileLine.length < 11)
throw new IllegalArgumentException("Error: the patient data in the file is incomplete. Please review");


for (int i = 0; i < persons.size(); i++) {


if (persons.get(i).getMedicare().matches(fileLine[10])) {

persons.add(new Patient(fileLine[1], fileLine[2], fileLine[3], fileLine[4], fileLine[5],
fileLine[6], fileLine[7], fileLine[8], Integer.parseInt(fileLine[9]),(Provider)persons.get(i)));
throwError = true;
}
}
if (throwError!=true) {
throw new IllegalArgumentException("Error: the provided Provider does not exist for Patient: " + fileLine[2]+", "+fileLine[1] +". Please review");
}
}
else if (fileLine[0].matches("Appointment")) {
fileLine = line.split("#");


if (fileLine.length < 7)
throw new IllegalArgumentException("Error: the appointment data in the file is incomplete. Please review");

if (!"true".equals(fileLine[5].toLowerCase()) && !"false".equals(fileLine[5].toLowerCase()))
throw new IllegalArgumentException("Error: the appointment data in the file is incorrect. Please review");

if (!"true".equals(fileLine[6].toLowerCase()) && !"false".equals(fileLine[6].toLowerCase()))
throw new IllegalArgumentException("Error: the appointment data in the file is incorrect. Please review");


//parse the fileLine parameters
calendar.setTime(df.parse(fileLine[3] + " " + fileLine[4]));



for (int i = 0; i < persons.size(); i++) {
if (persons.get(i).getMedicare().matches(fileLine[1])) {

for (int j = 0; j < persons.size(); j++) {
if (persons.get(j).getMedicare().matches(fileLine[2])) {

appointments.add(new Appointment((Patient) persons.get(i), (Provider) persons.get(j), calendar,
Boolean.parseBoolean(fileLine[5]), Boolean.parseBoolean(fileLine[6])));
throwError = true;
}
}
}
}
if (throwError!=true) {
throw new IllegalArgumentException("Error: the provided Provider or Patient does not exist in the system. Please review");
}
}
else
throw new IllegalArgumentException("Error: the data provided does not match a person, provider or appointment. Please review");
}
input.close();
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (ParseException pe) {
// TODO Auto-generated catch block
throw new IllegalArgumentException("Error: the appointment date and time in the file is incorrect. Please review");
}
}




Issue with uploadify witj asp.net in a content place holder

Here's my issue.
I'm using uploadify. When I use it without master page it's working fine.
Now I'm trying to make it works in a content place holder (and a master page)



My problem is I can't call uploadify methods anymore... For instance if I set 'auto:true' it will work.
But I want it to be false and then call uploadifyUpload(). And that's the problem... It won't be called with the masterpage but it will without...



Anyone has an idea?





infinite scroll of images when Ipad is tilted

I to make an image that moves sideways when Ipad is tilted. when the image reaches one of it's end (left or right). I want it to duplicate itself to create an endless flow.
I've written the following code following some explanations on the subject. I've manage to make the image move from one side to another but I don't know how to duplicate it once it reaches the end to create the endless flow.
Can someone help me?
(the page is meant to be seen in landscape view (1024x768) of the Ipad (using Safari).



link: http://mgolan.com/temp/ipad/



thanks in advance.
Michael





Core Plot:Memory Issue Core animation failed to allocate so many bytes

I am using core plot for generation various types of graphs using webservices.But after generating around 60 graphs the graph scren appears to be blank giving a message in the device log as "Core animation failed to allocate 9997432 bytes"
we are facing this issue only on the device where as the app runs fine on simulator.



The following is the code snippet,We are passing data to the below class from an another class.
.h file



//
// LineGraph.h
// Graphs
//
// Created by Pawan on 12/12/11.
// Copyright 2011 __MyCompanyName__. All rights reserved.
//

#import <UIKit/UIKit.h>
#import "CorePlot-CocoaTouch.h"


@interface LineGraph1 : UIViewController<CPTPlotDataSource,UIPopoverControllerDelegate,CPTScatterPlotDelegate,CPTPlotSpaceDelegate> {

NSMutableArray *xAxisValuesArray;
NSMutableArray *yAxisValuesArray;
NSMutableArray *identifierArray;
NSMutableArray *xAxisScaleArray;
NSMutableArray *formattedDataLabelArray;

NSString *graphTitleLabel;
NSString *lineType;
NSString *xAxisTitleLabel;
NSString *yAxisMin;
NSString *yAxisMax;
NSString *yAxisIntervalLength;
NSString *yAxisTitle;
NSString *yAxisTitleLocation;
UILabel *valueLabel2;


float xAxiscount;
float intervalLength;

@private

CPTXYGraph *lineGraph;
CPTMutableTextStyle *titleTextStyle;
CPTLayerAnnotation *symbolTextAnnotation;

NSMutableArray *plotSymbolColoursArray;
NSMutableArray *plotLineColoursArray;

IBOutlet CPTGraphHostingView *lineGraphtView;
IBOutlet UILabel *lineGraphLabel;
IBOutlet UISlider *lineGraphValueSlider;
IBOutlet UIButton *drillUpButton;
IBOutlet UIButton *drillDownButton;
IBOutlet UIButton *helpButton;
}
@property(nonatomic,retain) IBOutlet CPTGraphHostingView *lineGraphtView;
@property(nonatomic,retain) CPTXYGraph *lineGraph;
@property(nonatomic,retain) NSMutableArray *xAxisValuesArray;
@property(nonatomic,retain) NSMutableArray *yAxisValuesArray;
@property(nonatomic,retain) IBOutlet UILabel *lineGraphLabel;
@property(nonatomic,retain) NSString *graphTitleLabel;
@property(nonatomic,retain) NSString *lineType;
@property(nonatomic,retain) NSString *xAxisTitleLabel;
@property(nonatomic,retain) NSString *yAxisTitleLocation;
@property(nonatomic,retain) NSString *yAxisMin;
@property(nonatomic,retain) NSString *yAxisMax;
@property(nonatomic,retain) NSString *yAxisIntervalLength;
@property(nonatomic,retain) NSString *yAxisTitle;
@property(nonatomic,retain) NSMutableArray *identifierArray;
@property(nonatomic,retain) NSMutableArray *plotSymbolColoursArray;
@property(nonatomic,retain) NSMutableArray *plotLineColoursArray;
@property(nonatomic,retain) NSMutableArray *xAxisScaleArray;
@property(nonatomic,retain) NSMutableArray *formattedDataLabelArray;
@property(nonatomic,retain) CPTMutableTextStyle *titleTextStyle;

- (void)constructLineGraphForSingleLineGraph:(NSString *)type;
-(IBAction)helpButtonPressed:(id)sender;
-(void)plotDataActionSlider:(id)sender;
-(void)setplotDataActionSlider;

@end



.m file




// LineGraph.m
// Graphs
//
// Created by Pawan on 12/12/11.
// Copyright 2011 __MyCompanyName__. All rights reserved.
//

#import "LineGraph1.h"
#import "CommonMethodForGraphs.h"
#import "GraphDescription.h"

@implementation LineGraph1

@synthesize lineGraph;
@synthesize xAxisValuesArray;
@synthesize yAxisValuesArray;
@synthesize graphTitleLabel;
@synthesize lineGraphLabel;
@synthesize lineType;
@synthesize xAxisTitleLabel;
@synthesize yAxisMin;
@synthesize yAxisMax;
@synthesize yAxisIntervalLength;
@synthesize yAxisTitle;
@synthesize yAxisTitleLocation;
@synthesize identifierArray;
@synthesize plotLineColoursArray;
@synthesize plotSymbolColoursArray;
@synthesize xAxisScaleArray;
@synthesize formattedDataLabelArray;
@synthesize titleTextStyle;
@synthesize lineGraphtView;
//Implement viewDidLoad to do additional setup after loading the view, typically from a nib.


- (void)viewDidLoad {
[super viewDidLoad];
[self setplotDataActionSlider];
self.lineGraphLabel.text=self.graphTitleLabel;
NSMutableArray *identifierLocalArray=[[NSMutableArray alloc]init];

[identifierLocalArray insertObject:@"Port In" atIndex:0];
self.identifierArray=identifierLocalArray;
[identifierLocalArray release];

NSMutableArray *plotSymbolColoursLocalArray =[NSMutableArray arrayWithObjects:[CPTColor redColor],[CPTColor greenColor],nil];
NSMutableArray *plotLineColoursLocalArray =[NSMutableArray arrayWithObjects:[CPTColor greenColor],[CPTColor redColor],nil];
self.plotSymbolColoursArray=plotSymbolColoursLocalArray;
self.plotLineColoursArray=plotLineColoursLocalArray;

if ([self.xAxisValuesArray count]<=10)
{
xAxiscount = 10.0f;
}
else
{
xAxiscount = 31.0f;
}

[self constructLineGraphForSingleLineGraph:self.lineType];

}
#pragma mark -
#pragma mark constructLineGraphForSingleLineGraph



- (void)constructLineGraphForSingleLineGraph:(NSString *)type
{

// Create lineGraph from theme

CPTXYGraph *lineGraphLocalObject = [[CPTXYGraph alloc] initWithFrame:CGRectZero];
self.lineGraph = lineGraphLocalObject;
[lineGraphLocalObject release];
CPTTheme *theme = [CPTTheme themeNamed:kCPTPlainWhiteTheme];
self.lineGraph = (CPTXYGraph *)[theme newGraph];

/*
UIImage *image = [UIImage imageNamed:@"BackgroundforGraph.png"];
CGImageRef mycgimage = [image CGImage];
CPTImage *image1 = [CPTImage imageWithCGImage:mycgimage];
self.lineGraph.fill=[CPTFill fillWithImage:image1];
self.lineGraph.borderLineStyle = nil;
image = [UIImage imageNamed:@"PlotAreaImageNew.png"];
mycgimage = [image CGImage];
image1 = [CPTImage imageWithCGImage:mycgimage];

self.lineGraph.plotAreaFrame.fill = [CPTFill fillWithImage:image1];
*/
lineGraphtView.hostedGraph = self.lineGraph;
lineGraphtView.allowPinchScaling = NO;
self.lineGraph.plotAreaFrame.masksToBorder = NO;
//padding for plot area
self.lineGraph.paddingLeft = 110.0;
self.lineGraph.paddingTop = 20.0;
self.lineGraph.paddingRight = 10.0;
self.lineGraph.paddingBottom = 100.0;

// Add plot space for line graph
CPTXYPlotSpace *plotSpace = (CPTXYPlotSpace *)self.lineGraph.defaultPlotSpace;
plotSpace.yRange = [CPTPlotRange plotRangeWithLocation:CPTDecimalFromString(self.yAxisMin) length:CPTDecimalFromString(self.yAxisMax)];
plotSpace.xRange = [CPTPlotRange plotRangeWithLocation:CPTDecimalFromFloat(0.0f) length:CPTDecimalFromFloat(xAxiscount)];

CPTXYAxisSet *axisSet = (CPTXYAxisSet *)self.lineGraph.axisSet;

CPTXYAxis *x = axisSet.xAxis;
x.majorIntervalLength = CPTDecimalFromString(@"1");
x.orthogonalCoordinateDecimal = CPTDecimalFromString(self.yAxisMin);
x.title =self.xAxisTitleLabel;
x.titleLocation = CPTDecimalFromFloat(5.0f);
x.titleOffset = 65.0f;
x.labelOffset=0.0f;

//text style initialized for both x and y axis....
CPTMutableTextStyle *titleTextStyleLocalObject = [[CPTMutableTextStyle alloc] init];
self.titleTextStyle = titleTextStyleLocalObject;
[titleTextStyleLocalObject release];
self.titleTextStyle.fontSize = 15;
x.titleTextStyle = self.titleTextStyle;
self.titleTextStyle.fontSize = 12;
x.labelTextStyle = self.titleTextStyle;

// Define some custom labels for the data elements
x.labelRotation = M_PI/4;
x.labelingPolicy = CPTAxisLabelingPolicyNone;
int labelLocation = 0;
NSMutableArray *customLabelsForXaxis = [NSMutableArray arrayWithCapacity:[self.xAxisScaleArray count]];

for (NSNumber *tickLocation in self.xAxisScaleArray)
{
CPTAxisLabel *newLabel = [[CPTAxisLabel alloc] initWithText: [self.xAxisScaleArray objectAtIndex:labelLocation++] textStyle:x.labelTextStyle];
newLabel.tickLocation = [[NSNumber numberWithInt:labelLocation] decimalValue] ;//[tickLocation decimalValue];
newLabel.offset =0.0;
newLabel.rotation = M_PI/4;

[customLabelsForXaxis addObject:newLabel];
[newLabel release];
}

x.axisLabels = [NSSet setWithArray:customLabelsForXaxis];

NSNumberFormatter *yAxisFormat = [[NSNumberFormatter alloc] init];
[yAxisFormat setNumberStyle:NSNumberFormatterNoStyle];
CPTXYAxis *y = axisSet.yAxis;
y.axisLineStyle = nil;
y.majorIntervalLength = CPTDecimalFromString(self.yAxisIntervalLength);
y.orthogonalCoordinateDecimal = CPTDecimalFromString(@"0");
y.titleOffset = 50.0f;
y.titleLocation = CPTDecimalFromString(self.yAxisTitleLocation);
y.labelOffset = 0.0f;
y.labelFormatter=yAxisFormat;
[yAxisFormat release];
y.title = self.yAxisTitle;
y.labelTextStyle = self.titleTextStyle;

CPTScatterPlot *dataSourceLinePlot = [[[CPTScatterPlot alloc] init] autorelease];
dataSourceLinePlot.identifier = [self.identifierArray objectAtIndex:0];

CPTMutableLineStyle *lineStyle = [[dataSourceLinePlot.dataLineStyle mutableCopy] autorelease];
lineStyle.lineWidth = 2.0f;
lineStyle.lineColor = [ self.plotLineColoursArray objectAtIndex:0];//[CPTColor clearColor];for scatterplot
dataSourceLinePlot.dataLineStyle = lineStyle;
dataSourceLinePlot.labelOffset=8.0f;
dataSourceLinePlot.dataSource = self;
dataSourceLinePlot.delegate = self;

// Add plot symbols

CPTPlotSymbol *plotSymbol = [CPTPlotSymbol ellipsePlotSymbol];
plotSymbol.fill = [CPTFill fillWithColor:[ self.plotSymbolColoursArray objectAtIndex:0]];
plotSymbol.size = CGSizeMake(10.0, 10.0);
dataSourceLinePlot.plotSymbol = plotSymbol;



// Put an area gradient under the plot above
CPTColor *areaColor = [CPTColor colorWithComponentRed:0.3 green:0.8 blue:0.3 alpha:0.6];
CPTGradient *areaGradient = [CPTGradient gradientWithBeginningColor:areaColor endingColor:[CPTColor clearColor]];
areaGradient.angle = -90.0;
CPTFill* areaGradientFill = [CPTFill fillWithGradient:areaGradient];
dataSourceLinePlot.areaFill = areaGradientFill;
dataSourceLinePlot.areaBaseValue = CPTDecimalFromString(@"0.0");



[self.lineGraph addPlot:dataSourceLinePlot];
y.labelingPolicy = CPTAxisLabelingPolicyNone;
intervalLength = [CommonMethodForGraphs formattedIntervalLengthForgraph:self.yAxisIntervalLength];


double j=[self.yAxisMin intValue];
NSMutableArray *customTickLocationsForYaxis = [[NSMutableArray alloc]init];
NSMutableArray *yAxisLabels =[[NSMutableArray alloc]init];

for (int h=0; h<=10; h++)
{
[customTickLocationsForYaxis insertObject:[NSDecimalNumber numberWithLongLong:j] atIndex:h];
[yAxisLabels insertObject:[[NSNumber numberWithLongLong:j/intervalLength]stringValue] atIndex:h];
j=j+[self.yAxisIntervalLength longLongValue];
}
labelLocation = 0;
NSMutableArray *customLabelsForYaxis = [[NSMutableArray alloc] initWithCapacity:[yAxisLabels count]];

for (NSNumber *tickLocationForYaxis in customTickLocationsForYaxis)
{
CPTAxisLabel *newLabel = [[CPTAxisLabel alloc] initWithText: [yAxisLabels objectAtIndex:labelLocation++] textStyle:x.labelTextStyle];
newLabel.tickLocation = [tickLocationForYaxis decimalValue];
newLabel.offset = y.labelOffset + y.majorTickLength;
[customLabelsForYaxis addObject:newLabel];
[newLabel release];
}

y.axisLabels = [NSSet setWithArray:customLabelsForYaxis];

[customLabelsForYaxis release];
[customTickLocationsForYaxis release];
[yAxisLabels release];

}


#pragma mark -
#pragma mark delegates for Line graph

-(NSUInteger)numberOfRecordsForPlot:(CPTPlot *)plot
{
int recordCount = 0;

for (int i=0; i<[self.identifierArray count]; i++)
{
if ( [plot.identifier isEqual:[self.identifierArray objectAtIndex:i] ])
{
recordCount= [self.yAxisValuesArray count];
}

}
return recordCount;
}

-(NSNumber *)numberForPlot:(CPTPlot *)plot field:(NSUInteger)fieldEnum recordIndex:(NSUInteger)index
{
NSNumber *num = nil;

if( [plot.identifier isEqual:[self.identifierArray objectAtIndex:0] ])
{
switch (fieldEnum)
{
case CPTScatterPlotFieldX:
num = [self.xAxisValuesArray objectAtIndex:index];
break;

case CPTScatterPlotFieldY:
num = [self.yAxisValuesArray objectAtIndex:index];
break;
}

}

return num;
}


-(CPTLayer *)dataLabelForPlot:(CPTPlot *)plot recordIndex:(NSUInteger)index
{

static CPTMutableTextStyle *whiteText = nil;

if ( !whiteText)
{
whiteText = [[CPTMutableTextStyle alloc] init];
whiteText.color = [CPTColor blackColor];
whiteText.fontSize=12.0f;
}

CPTTextLayer *newLayer = nil;
if (index%2==0)
{
plot.labelOffset=-0.5;

}
else
{
plot.labelOffset=0.5;
}


if ( [plot.identifier isEqual:[self.identifierArray objectAtIndex:0]])
{
newLayer = [[[CPTTextLayer alloc] initWithText:[NSString stringWithFormat:@"%.1f%",[[self.formattedDataLabelArray objectAtIndex:index]floatValue]] style:whiteText] autorelease];
[whiteText release];
}

return newLayer;

}

-(void)scatterPlot:(CPTScatterPlot *)plot plotSymbolWasSelectedAtRecordIndex:(NSUInteger)index
{

if ( symbolTextAnnotation ) {
[self.lineGraph.plotAreaFrame.plotArea removeAnnotation:symbolTextAnnotation];
symbolTextAnnotation = nil;
}

// Setup a style for the annotation
CPTMutableTextStyle *hitAnnotationTextStyle = [CPTMutableTextStyle textStyle];
hitAnnotationTextStyle.color = [CPTColor redColor];
hitAnnotationTextStyle.fontSize = 16.0f;
hitAnnotationTextStyle.fontName = @"Helvetica-Bold";

// Determine point of symbol in plot coordinates
NSNumber *x = [self.xAxisValuesArray objectAtIndex:index];

NSString *y = [self.yAxisValuesArray objectAtIndex:index];

NSArray *anchorPoint = [NSArray arrayWithObjects:x, y, nil];



// Now add the annotation to the plot area
CPTTextLayer *textLayer = [[[CPTTextLayer alloc] initWithText:y style:hitAnnotationTextStyle] autorelease];

symbolTextAnnotation = [[CPTPlotSpaceAnnotation alloc] initWithPlotSpace:self.lineGraph.defaultPlotSpace anchorPlotPoint:anchorPoint];

symbolTextAnnotation.contentLayer = textLayer;
symbolTextAnnotation.displacement = CGPointMake(0.0f, 20.0f);
[self.lineGraph.plotAreaFrame.plotArea addAnnotation:symbolTextAnnotation];
[textLayer release];
[symbolTextAnnotation release];
}

#pragma mark -
#pragma mark method for slider action


-(void)plotDataActionSlider:(id)sender
{


if (lineGraphValueSlider.value<=[self.yAxisValuesArray count]+1)
{
//code to remove added imageView
[[self.view viewWithTag:50] removeFromSuperview];
//code to remove added label
[[self.view viewWithTag:100] removeFromSuperview];
for (int d=0; d<[self.yAxisValuesArray count]; d++)
{
if ((int)lineGraphValueSlider.value==[[self.xAxisValuesArray objectAtIndex:d]intValue])
{



int x=300;
valueLabel2=[[UILabel alloc]init];
valueLabel2.frame=CGRectMake(x, 620, 300, 40);
valueLabel2.tag=100;
NSNumberFormatter *formatter = [[NSNumberFormatter alloc] init];
[formatter setNumberStyle:NSNumberFormatterDecimalStyle];
NSLocale *locale = [[NSLocale alloc] initWithLocaleIdentifier:@"en_US"];
[formatter setLocale:locale];
valueLabel2.text= [[[self.xAxisScaleArray objectAtIndex:d] stringByAppendingString:@" : "] stringByAppendingString:[formatter stringFromNumber:[NSNumber numberWithLongLong:[[self.yAxisValuesArray objectAtIndex:d]longLongValue]]]];
[self.view addSubview:valueLabel2];
[valueLabel2 release];
[formatter release];

}
}
}
else
{
[[self.view viewWithTag:50] removeFromSuperview];
[[self.view viewWithTag:100] removeFromSuperview];

}



}

-(void)setplotDataActionSlider
{
UIImage *minImage = [UIImage imageNamed:@"SliderRoll.png"];
UIImage *tumbImage= [UIImage imageNamed:@"SliderArrow.png"];
minImage=[minImage stretchableImageWithLeftCapWidth:0 topCapHeight:0];
// Setup the slider
[lineGraphValueSlider setMinimumTrackImage:minImage forState:UIControlStateNormal];
[lineGraphValueSlider setThumbImage:tumbImage forState:UIControlStateNormal];
lineGraphValueSlider.minimumValue = 0.0;

if ([self.xAxisValuesArray count]<=10)
{
lineGraphValueSlider.maximumValue = 10.0;
}
else
{
lineGraphValueSlider.maximumValue = 31.0;
}


lineGraphValueSlider.continuous = YES;
[lineGraphValueSlider addTarget:self action:@selector(plotDataActionSlider :) forControlEvents:UIControlEventValueChanged];

minImage = nil;
tumbImage = nil;


}

#pragma mark -
#pragma mark method for help drill up and drill down

-(IBAction)helpButtonPressed:(id)sender{
[CommonMethodForGraphs helpButtonActionForAllGraphs:self.view];


}
#pragma mark -

//Override to allow orientations other than the default portrait orientation.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
// Return YES for supported orientations.
return ((interfaceOrientation == UIInterfaceOrientationLandscapeLeft) ||(interfaceOrientation == UIInterfaceOrientationLandscapeRight));
}


- (void)didReceiveMemoryWarning {
// Releases the view if it doesn't have a superview.
[super didReceiveMemoryWarning];

// Release any cached data, images, etc. that aren't in use.
}

- (void)viewDidUnload {
[super viewDidUnload];

// Release any retained subviews of the main view.
// e.g. self.myOutlet = nil;
self.lineGraphLabel = nil;
self.lineGraphtView = nil;
}


- (void)dealloc {

[lineGraph release];
[xAxisValuesArray release];
[yAxisValuesArray release];
[xAxisTitleLabel release];
[graphTitleLabel release];
[lineGraphLabel release];
[lineType release];
[yAxisMin release];
[yAxisMax release];
[yAxisIntervalLength release];
[yAxisTitle release];
[yAxisTitleLocation release];
[identifierArray release];
[plotLineColoursArray release];
[plotSymbolColoursArray release];
[xAxisScaleArray release];
[formattedDataLabelArray release];
[lineGraphtView release];
[super dealloc];

}



@end




In GWT, how can I serialize/unserialize a Place using JSON in its tokenizer?

I would like to create a standard Tokenizer for my places in GWT.



To do so, I would like to use the json format. Something like this :



public String getToken(T place) {
return transformToJSON(place);
}

public T getPlace(String token) {
return (T)transformJSONToObject(token);
}


I can't find a way to implements transformToJSON and transformJSONToObject. I've tried to use the JSONParser of GWT but it's quite limited to JavascriptObject (and Places are not JavascriptObject).



How can I achieve it ?





jquery conflict prototype.js and jquery.js

I am trying to use jquery and prototype libraries in same page but both are not working together. In this case either one or the other is working.



Detail are:

prototype.js

jquery.js



Can anyone help me? I need help very urgently. Thanks in advance.





IndexOutOfRangeException - Windows Phone (C#)

I am getting know with Windows Phone, and C# as well. I found out that there is an
IndexOutOfRangeException in my Coloring() function:



public void Coloring()
{
szinek_base.Add(Color.FromArgb(255, 0, 171, 169));
szinek_base.Add(Color.FromArgb(255, 140, 191, 38));
szinek_base.Add(Color.FromArgb(255, 160, 80, 0));
szinek_base.Add(Color.FromArgb(255, 230, 113, 184));
szinek_base.Add(Color.FromArgb(255, 240, 150, 9));
szinek_base.Add(Color.FromArgb(255, 27, 161, 226));
szinek_base.Add(Color.FromArgb(255, 229, 20, 0));
szinek_base.Add(Color.FromArgb(255, 51, 153, 51));
int remove;
Color szin = new Color();
Random generator = new Random();
List<int> lapok = new List<int>();
for (int l = 0; l < 16; l++)
{
lapok.Add(l);
}

for (int i = 0; i < 8; i++)
{
szin = szinek_base[generator.Next(0, szinek_base.Count)];

remove = lapok[generator.Next(0, lapok.Count)];
szinek[remove] = szin;
lapok.Remove(remove);
szinek_base.Remove(szin);

remove = lapok[generator.Next(0, lapok.Count)];
szinek[remove] = szin;
lapok.Remove(remove);
szinek_base.Remove(szin);
}
}


Using try-catch i also found out that the second for() cycle contains the bug.
However if i split into half the block and using try-catch, it wont find error nor in the first part
neither the second. This code works fine under windows 7 as part of a memory game by the way, i am out of ideas.
Thanks for the help, and sorry for grammatic and other mistakes, i am not aware of StackOverflow protocol, yet.



Edit: Forgot to mention, the main namespace contains them:



public List<Color> szinek_base = new List<Color>();
Color[] szinek = new Color[8];




how tosend unlimited json data from jquery ajax to mvc razor controller

I have to send unlimited JSON data from ajax J query to MVC razor controller.
The method is triggered once we send limited data. if i send more data the method is not triggered and Am getting 500 Internal error.



        $.ajax({
url: '../Offline/Save',
data: JSON.stringify(Item),
data: "{'Id':" + Results.rows.item(m).Id + ",'Item':" + JSON.stringify(Item) + "}",
type: 'POST',
dataType: "json",
contentType: "application/json; charset=utf-8",
success: function (data, status) {
alert(data);
}
},
error: function (xhr, ajaxOptions, thrownError) {
console.log(xhr.status);
console.log(thrownError);
}
});


[HttpPost]
[ValidateInput(false)]
public JsonResult SaveFinding(int Id, SyncItem Item)
{
Result result = new DB().Process(Id, Item);
return Json(result);
}




JQuery Radio Button Value Check

I need to have the number of 'yes's' selected from a set of radio buttons shown in a hidden field.



I have a form with several sets of radio buttons.



The first radio set:



    <input type="radio" name="number_of_sets_to_count" id="number_of_sets_to_count_1" value="1">
<input type="radio" name="number_of_sets_to_count" id="number_of_sets_to_count_2" value="2">
<input type="radio" name="number_of_sets_to_count" id="number_of_sets_to_count_3" value="3">
<input type="radio" name="number_of_sets_to_count" id="number_of_sets_to_count_4" value="4">
<input type="radio" name="number_of_sets_to_count" id="number_of_sets_to_count_5" value="5">


Subject to the value selected above (ie 1,2,3,4,5) then to calculate the radio buttons selected yes from below radio buttons. ie if selected 2 in radio button above then the first two radio button sets need to check for yes. If 4 selected the the first 4 radio sets below need to be checked for yes values.



This is the next five radio sets



<input type="radio" name="set1" id="set1_no" value="no">
<input type="radio" name="set1" id="set1_yes" value="yes">

<input type="radio" name="set2" id="set2_no" value="no">
<input type="radio" name="set2" id="set2_yes" value="yes">

<input type="radio" name="set3" id="set3_no" value="no">
<input type="radio" name="set3" id="set3_yes" value="yes">

<input type="radio" name="set4" id="set4_no" value="no">
<input type="radio" name="set4" id="set4_yes" value="yes">

<input type="radio" name="set5" id="set5_no" value="no">
<input type="radio" name="set5" id="set5_yes" value="yes">


<input type="hidden" name="number_of_yes" value="">


Thanks to the community help I have this JQuery code that calculates the number of yes's in the form and puts the number into the hidden text box 'number_of_yes' on submit.



<script type="text/javaScript">
$(document).ready(function() {
$("#yourFormsId").submit(function() {
$('input[name="number_of_yes"]').val(
$('input:checked[type="radio"][value="yes"]').length);
});
});
</script>


But, this checks for all yes's selected and I need this limited to the first, second, third, fourth or fifth radio sets (ie set1, set2, set3, set4, set5) depending on what is selected from the number_of_sets_to_count radio button (ie 1,2,3,4,5).



Thanks





Program terminates if I use scanf

I am trying to implement the timer in code, All the example that I found are using while(1) or for(;;) but when I tried with using scanf my program terminates. Is it getting any value on stdin because if I use scanf two times then timer is called two time before exiting from program.
Here is my sample code:



#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <signal.h>
#include <netinet/in.h>
#include <signal.h>
#include <time.h>

#include <linux/socket.h>
#include <time.h>


#define SIGTIMER (SIGRTMAX)
#define SIG SIGUSR1
static timer_t tid;
static timer_t tid2;

void SignalHandler(int, siginfo_t*, void* );
timer_t SetTimer(int, int);

int main(int argc, char *argv[]) {

int t;

printf("SIGRTMAX %d\n", SIGRTMAX);
printf("SIGRTMIN %d\n", SIGRTMIN);

struct sigaction sigact;
sigemptyset(&sigact.sa_mask);
sigact.sa_flags = SA_SIGINFO;
sigact.sa_sigaction = SignalHandler;
// set up sigaction to catch signal
if (sigaction(SIGTIMER, &sigact, NULL) == -1) {
perror("sigaction failed");
exit( EXIT_FAILURE );
}

// Establish a handler to catch CTRL+c and use it for exiting.
sigaction(SIGINT, &sigact, NULL);
tid=SetTimer(SIGTIMER, 1000);

struct sigaction sa;
sigemptyset(&sa.sa_mask);
sa.sa_flags = SA_SIGINFO;
sa.sa_sigaction = SignalHandler;
// set up sigaction to catch signal
if (sigaction(SIG, &sa, NULL) == -1) {
perror("sa failed");
exit( EXIT_FAILURE );
}

// Establish a handler to catch CTRL+c and use it for exiting.
sigaction(SIGINT, &sa, NULL);
tid2=SetTimer(SIG, 1000);

// for(;;); or while(1) Working properly

scanf("%d", &t); /// Program terminates
return 0;
}

void SignalHandler(int signo, siginfo_t* info, void* context)
{


if (signo == SIGTIMER) {
printf("Command Caller has ticked\n");

}else if (signo == SIG) {
printf("Data Caller has ticked\n");

} else if (signo == SIGINT) {
timer_delete(tid);
perror("Crtl+c cached!");
exit(1); // exit if CRTL/C is issued
}
}
timer_t SetTimer(int signo, int sec)
{
static struct sigevent sigev;
static timer_t tid;
static struct itimerspec itval;
static struct itimerspec oitval;

// Create the POSIX timer to generate signo
sigev.sigev_notify = SIGEV_SIGNAL;
sigev.sigev_signo = signo;
sigev.sigev_value.sival_ptr = &tid;

if (timer_create(CLOCK_REALTIME, &sigev, &tid) == 0)
{

itval.it_value.tv_sec = sec / 1000;
itval.it_value.tv_nsec = (long)(sec % 1000) * (1000000L);
itval.it_interval.tv_sec = itval.it_value.tv_sec;
itval.it_interval.tv_nsec = itval.it_value.tv_nsec;



if (timer_settime(tid, 0, &itval, &oitval) != 0)
{
perror("time_settime error!");
}
}
else
{
perror("timer_create error!");
return NULL;
}
return tid;
}


So, How can I resolve this problem ?
Any help would be Appreciated.
Thanks, Yuvi





Facebook - How to Connect a Facebook Profile / Training Resources

I am new to Facebook API,



Are there video training resources somewhere that can get me started with Facebook API?



I want to learn to connect to a Facebook Profile.



Adam





Data error (cyclic redundancy check)

It's the first time I see this error. Anyone know what this mean? (and if there's a fix)




System.IO.IOException: Data error (cyclic redundancy check).



at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
at System.IO.Directory.DeleteHelper(String fullPath, String userPath, Boolean recursive)
at System.IO.Directory.Delete(String fullPath, String userPath, Boolean recursive)






How to send JSON request to service with parameters in Objective-C

I'm creating a iPhone app, and im trying to figure out how to create a JSON request to the webserice that contains parameters. In Java this would look like this



HashMap<String, String> headers = new HashMap<String, String>();

JSONObject json = new JSONObject();

json.put("nid", null);
json.put("vocab", null);
json.put("inturl", testoverview);
json.put("mail", username); // something@gmail.com
json.put("md5pw", password); // donkeykong

headers.put("X-FBR-App", json.toString());


The header has to contain a JSON object and "X-FBR-App" before the service recognizes the request. How would this be implemented in Objective-C ?