Thursday 3 October 2013

Background task - how to stop in a controlled manner?

Background task - how to stop in a controlled manner?

I'm developing a WPF application that will have an "indexing service"
running as a background task. The indexing service will utilise a
FileSystemWatcher that monitors a folder - when a file changes the
indexing service will read in the file contents and update an index (I'm
using Lucene.Net). My indexing service is a singleton, and will be started
during application startup like this:-
new TaskFactory().StartNew(_indexingService.StartService);
The StartService() method looks something like this:-
private readonly ManualResetEvent _resetEvent = new ManualResetEvent(false);
public void StartService()
{
var watcher = new FileSystemWatcher
{
// Set the properties
};
watcher.Changed += UpdateIndexes();
_resetEvent.WaitOne();
}
When the application is closing, I intend to call this method, which I
understand will end the indexing service background task:-
public void StopService()
{
_resetEvent.Set();
}
First of all, is this the right "pattern" for starting and stopping a
background task that should run for the lifetime of an application?
Second, how "graceful" would this shutdown be? Let's say that the watcher
Changed event handler has fired and is iterating through the files,
reading them and updating the indexes. If the task was stopped, will this
processing be aborted mid-flow, or will the event handler method run to
completion first?

Wednesday 2 October 2013

Opencv246 Visua Studio 2012 ! on windows 7

Opencv246 Visua Studio 2012 ! on windows 7

I am desperate for an Answer with Opencv246, with Visual Studio 2012, on
Windows 7.
To Display an Image and on compiling this I am getting 212 syntax errors
for operations.hpp file. Please help
using namespace cv;
#include <stdio.h>
#include <algorithm>
#include<string>
#include<opencv2\opencv.hpp>
#include<opencv2\core\operations.hpp
void main()
{
Mat img;
img = imread("test.jpg");
namedWindow("t");
imshow("t",img);
cvWaitKey(0);`
}

Meteor publish - How to publish data and check using profile information

Meteor publish - How to publish data and check using profile information

My question is really simple but unfortunately I didn't found anywhere.
I have a collection of maps for example and I'm using
Meteor.user().profile.mapsId to check if that user is allowed to see that
maps.
First approach:
server/server.js
Meteor.publish('map', function (mapOwner) {
var user = Meteor.user();
var mapId = user.profile.mapId;
return Map.find({mapOwner: mapId});
});
Didn't work because publish don't accept Meteor.user();
Second approach:
server/server.js
Meteor.publish('map', function (mapOwner) {
return Map.find({mapOwner: Meteor.call('mapsCall')});
});
collections/maps.js
Map = new Meteor.SmartCollection('map');
Meteor.methods({
mapsCall: function() {
var user = Meteor.user();
var startupId = user.profile.startupId;
return startupId;
}
});
When I call Map.find().fetch() don't have anything..
What is the right approach?

The method put(Integer, MyClass) in the type Map is not applicable for the arguments (String, int)

The method put(Integer, MyClass) in the type Map is not applicable for the
arguments (String, int)

private Map<Integer,MyClass> calc()
{
Map<Integer,MyClass> closest = new HashMap<Integer,MyClass>();
//...
closest.put("index",(i+1));
closest.put("poi",myclass_element);
return closest;
}
The method put(Integer, MyClass) in the type Map is not applicable for the
arguments (String, int)
The function calc should return myclass_element and an integer value
(i+1). How to to do this?

Mysql; CASE; multiple WHEN ? THEN ?. How to create data for ? with foreach

Mysql; CASE; multiple WHEN ? THEN ?. How to create data for ? with foreach

Created this
$insertData = array();
foreach ($_POST['entry_id'] as $i => $entry_id) {
$when_then .= 'WHEN ? THEN ? ';
$insertData[] = $_POST['entry_id'][$i];
$insertData[] = $_POST['transaction_partner_name'][$i];
$insertData[] = $_POST['entry_id'][$i];
$insertData[] = $_POST['registration_number'][$i];
$insertData[] = $_POST['entry_id'][$i];
$placeholders_for_number_renamed .= '?,';
}
$placeholders_for_number_renamed = rtrim($placeholders_for_number_renamed,
',');
$sql = "
UPDATE 2_1_transactionpartners SET
CompanyName = CASE NumberRenamed
$when_then
END,
RegistrationNumber = CASE NumberRenamed
$when_then
END
WHERE NumberRenamed in ($placeholders_for_number_renamed)";
try {
$stmt = $db->prepare($sql);
$stmt->execute($insertData);
}
But can not match $insertData with ? (must replace ? with
corresponding/necessary $insertData)
qyery is this
UPDATE 2_1_transactionpartners SET
CompanyName = CASE NumberRenamed
WHEN ? THEN ? WHEN ? THEN ?
END,
RegistrationNumber = CASE NumberRenamed
WHEN ? THEN ? WHEN ? THEN ?
END
WHERE NumberRenamed in (?,?)
And array of $insertData is this
Array
(
[0] => 11
[1] => name 2
[2] => 11
[3] => number 2
[4] => 11
[5] => 10
[6] => name 1
[7] => 10
[8] => number 1
[9] => 10
)
Starting from [2] values goes to wrong place. [2] must go to the first ?
in RegistrationNumber = CASE NumberRenamed WHEN ? THEN ? but it (?) goes
to the third ? in CompanyName = CASE NumberRenamed WHEN ? THEN ? WHEN ?
I understand that in foreach must create $insertData in some other order,
but can not understand correct order.
Tried like $entry_id_for_company_name[] =
array_merge($_POST['entry_id'][$i],
$_POST['transaction_partner_name'][$i]); but this is not solution...
No idea at the moment. Please advice

Tuesday 1 October 2013

TextIO program not giving the desired output

TextIO program not giving the desired output

OK, time to give the noob a hard time. I am writing a program that is
supposed to use an algorithm to write all even integers from 1 to 100 to a
file, close the file, then display the results. Then id is supposed to
append the file with all of the odd integers from 1 to 100, close the
file, reopen and display the results. Something like: 1st list - 2, 4, 6,
8, ......., 98, 100 2nd list - 2, 4, 6, 8, ......., 98, 100, 1 , 3, 5,
...., 97, 99
I get the even(1st) list fine. The 2nd list displays just the odd numbers.
Sure it is something simple, usually is. My brain is mush right now and I
am not seeing it. Thanks for any help!!
package textFileIO;
import java.io.*;
public class TextFileIO {
public static void main(String[] args) throws Exception {
//Create newFile
File newFile = new File("numbers.dat");
newFile.createNewFile();
int evenNum = 0;
int oddNum = 0;
try{
BufferedWriter writer = new BufferedWriter(new FileWriter(newFile));
//Loop from 1 to 100
for (int i = 2; i <= 100; i+=2)
{
evenNum += i + 1;
writer.write("" + i + ", ");
}
writer.newLine();
writer.close();
BufferedReader reader = new BufferedReader(new FileReader(newFile));
System.out.println(reader.readLine());
reader.close();
BufferedWriter writer2 = new BufferedWriter(new FileWriter(newFile));
for(int i = 1; i < 100; i +=2) {
oddNum += i;
writer2.write("" + i + ", ");
}
writer2.newLine();
writer2.close();
BufferedReader reader2 = new BufferedReader(new FileReader(newFile));
System.out.printf(reader2.readLine());
}
catch (Exception e){
}
}
}

Is the function $f(x)= {\sin x \over x}$ uniformly continuous over $\mathbb{R}$?

Is the function $f(x)= {\sin x \over x}$ uniformly continuous over
$\mathbb{R}$?

Is the function $$f(x)= {\sin x \over x}$$ Uniformly continuous over $R$
How do i approach this ? I need some hints.

Prove that $(0,1)$ is cardinally equivalent to $[0,1)$

Prove that $(0,1)$ is cardinally equivalent to $[0,1)$

How's this done?
Also, I am wondering, are all subsets of $\mathbb{R}$ cardinally
equivalent to each other? If not, why not?

Counter examples for the following regarding sepation axioms. [on hold]

Counter examples for the following regarding sepation axioms. [on hold]

Please provide examples of the following: 1. A regular space which is not
T1. 2. A regular space which is not normal (other than the Sorgenfrey
plane). 3. A normal space which is not T1.

Monday 30 September 2013

How can I find out if my installed OS is a 32-bit or a 64-bit?

How can I find out if my installed OS is a 32-bit or a 64-bit?

I am a newbie so maybe my question is not so shiny. I wont to install
something (virtualbox) but I have to chose between the 32-bit version and
the 64-bit version according to my OS. Problem is that I don't know/don't
remember what type of OS it is from that point of view.
So my question is the following: Is there any fast and easy way (for a
beginner like me) to find out what kind of OS is using? Thank you!

Touchpad and parts of keyboard frozen after boot on Macbook

Touchpad and parts of keyboard frozen after boot on Macbook

I'm experiencing an issue where, after booting a MacBookAir4-2 (Ubuntu
13.04), the touchpad won't work. Furthermore, the better part of the
keyboard doesn't work either. External USB keyboards and mouses work, and
I have to use them to disable and re-enable the trackpad in the settings
to get the on-laptop one to work, which also enables the keyboard for some
reason.
I do not experience any issues during the reFIND menu or in OS X. Is there
a way to fix this or a script that I can run at startup that can enable
and disable the touchpad?

Jquery Sortable, items inside li are able to be dragged and dropped

Jquery Sortable, items inside li are able to be dragged and dropped

I'm using jquery sortable.
<ul id="gallery">
<li class="image-item gallery-image-item"><i class="btn-comment
icon-comment icon-2x"></i><i class="btn-youtube icon-youtube-play
icon-2x"></i><i class="btn-delete icon-remove"></i></li>
//...more similar li's
</ul>
The problem is, I can drag and drop each li, but the icons situated inside
each li are able to be dragged and dropped as well, separately to it's
parent li. Is there a way to stop this?

Round to 1 decimal places in C#

Round to 1 decimal places in C#

i would like to round my answer 1 decimal places. for example : 6.7,
7.3...etc But when I use Math.round...the answer always come up with no
decimal places ...for example: 6, 7
here is my code that i used:
int [] nbOfNumber = new int[ratingListBox.Items.Count];
int sumInt = 0;
double averagesDoubles;
for (int g = 0; g < nbOfNumber.Length; g++)
{
nbOfNumber[g] = int.Parse(ratingListBox.Items[g].Text);
}
for (int h = 0; h < nbOfNumber.Length; h++)
{
sumInt += nbOfNumber[h];
}
averagesDoubles = (sumInt / ratingListBox.Items.Count);
averagesDoubles = Math.Round(averagesDoubles, 2);
averageRatingTextBox.Text = averagesDoubles.ToString();

Sunday 29 September 2013

How cassandra replicates data in virtual nodes?

How cassandra replicates data in virtual nodes?

How cassandra replicates data in virtual nodes?
(1) cassandra replicates data randomly in virtual nodes.
http://www.datastax.com/documentation/cassandra/1.2/webhelp/index.html#cassandra/architecture/architectureDataDistributeVnodesUsing_c.html#concept_ds_lmw_gnf_fk
"Ring with virtual nodes" image shows like as if cassandra replicates data
randomly in virtual nodes.
or
(2) according to the replication strategy
How cassandra replicates data
If you use virtual nodes, the same idea is used but virtual nodes will be
skipped as replicas if the physical node has already received the key.

Separating multiple email messages in same thread PHP

Separating multiple email messages in same thread PHP

I have a ticketing system on my website in which I need to automatically
send the user an email when I submit a response.
In the email response I send them, I would like to be able to show a
threaded message like:
my response.....
SEPARATOR
FROM ....
ORIGINAL MESSAGE
What should I use for the SEPARATOR so that it will likely be recognized
by most email programs as a threaded message?
Note: I am using the PHP mail() method and am not going to use anything
else at this time.

why can't I create a method in the main method

why can't I create a method in the main method

Hello I am a want create method into main? So this is code where i want
crete method:
import java.io.*;
import java.util.Random;
class input{
public static void main (String args[]){
void Randomises() {
int writabledata;
Random a=new Random();
writabledata=a.nextInt();
}
}}

How can i load the css file in views/css/stylesheet.css in CI? My index file is in views/firstView.php

How can i load the css file in views/css/stylesheet.css in CI? My index
file is in views/firstView.php

I am completely new to code igniter. Thought editing the config.php like
this would work:
$config['index_page'] =
'localhost/Projects/first_CI/application/views/firstView.php';
but its not working :( . Can any one suggest anything

Saturday 28 September 2013

How to clean the sandbox every time I run the applications?

How to clean the sandbox every time I run the applications?

I am wondering if I could clean up sandbox everytime I run the
application. I don't want to clean and rebuild every time since it takes
long time.

Visual Studio 2012 Design view out of sync

Visual Studio 2012 Design view out of sync

When I'm on the split view of Visual Studio 2012 and I make some changes
on the Code window, the design window does not show the changes and
instead gives me this message "Design view is out of sync with Code view.
Click here to synchronize views".
Is there a way configure Visual Studio to have Design view seamlessly
updated as I write code?

advice/help to finish this algorithn

advice/help to finish this algorithn

/
write a program that reads in a number between 5/95 and calculates change
**********************************************************************************
*************Author:Emma OostryckDate:20/9/13purpose:calculates and prints
out the
change
***************************************************************************
*********************/
Start _algorithm
int cents
int num
module main (void )
print "name" ()
cents = getnum()
end module main
module getnum () /*prompts the user for a number*/
int num
print"please enter a number between 5 and 95 "
scan "num"
if (num < 5 OR >95 ) THEN
print"this is an invalid number please try again "
else if (num != * 5 ) THEN
print"this is not a valid amount"
END IF
return (cents);
end module getnum
module calculatesum (num) /*calculates the change needed*/
int num,int change
change=num/50
num%=50
change=num/20
num%=20
change=num/10
change=num/5
num%=5
end module calculatesum
getnum
module printsum /*prints the change */
print"your total change is /intchange "
end module printsum end_algorithm

Caused by: java.lang.ClassCastException: java.lang.String cannot be cast to java.sql.Timestamp ireport

Caused by: java.lang.ClassCastException: java.lang.String cannot be cast
to java.sql.Timestamp ireport

WARNING: net.sf.jasperreports.engine.fill.JRExpressionEvalException: Error
evaluating expression : Source text : $F{cre_templ_date} Caused by:
java.lang.ClassCastException: java.lang.String cannot be cast to
java.sql.Timestamp
This is my JRXL
http://jasperreports.sourceforge.net/xsd/jasperreport.xsd"
name="sse_template_audit" pageWidth="1100" pageHeight="842"
columnWidth="1060" leftMargin="20" rightMargin="20" topMargin="20"
bottomMargin="20">

Friday 27 September 2013

Rotate Cropped Image using Angular Directive

Rotate Cropped Image using Angular Directive

I use jcrop to crop an image and below is the directive I use to utilize
the jcrop library. HOw do I rotate the image? I rotated the div around the
image already but instead I want to rotate the actual jcrop image itself.
How do I do that ? Thanks
directive.js
. directive('imgCropped', function() {
return {
restrict: 'E',
replace: true,
scope: {src: '@', selected: '&'},
link: function(scope, element, attr) {
var myImg;
var clear = function() {
if (myImg) {
myImg.next().remove();
myImg.remove();
myImg = undefined;
}
};
scope.$watch('src', function(nv) {
clear();
if (nv) {
element.after('<img degrees="angle" rotate/>');
myImg = element.next();
myImg.attr('src', nv);
$(myImg).Jcrop({
trackDocument: true,
onSelect: function(x) {
/*if (!scope.$$phase) {
scope.$apply(function() {
scope.selected({cords: x});
});
}*/
scope.selected({cords: x});
},
keySupport: false,
trueSize: [1,1],
aspectRatio: 1,
boxWidth: 400, boxHeight: 400,
setSelect: [0, 0, 400, 400]
}, function(){
jcrop_api = this;
});
//$(myImg).rotate(90);
}
});
scope.$on('$destroy', clear);
}
};
})
index.html
<div rotate degrees="angle" class="cropping-box">
<img-cropped
src='{{baseurl_api}}photo/retrieve_temp_photo'
selected='selected(cords)'/>
</div>

What's the most efficient way to serve external data (tsv or json) to Ruby on Rails?

What's the most efficient way to serve external data (tsv or json) to Ruby
on Rails?

d3 allows to load external data into javascript to generate SVG data
visualization. But working with Rails (4.0) is tricky because I can't get
an external data file, like a .tsv or a .json served so that the
javascript can pull the data. It's not practical to add it manually to the
js file, as an arrow or something, because of data quantity. But is not
easy to find a solution to serve the static file either. I was trying to
make the browser read the .tsv and then set the javascript to read from
the URL, but no luck.
I have my javascripts in the right place (it's served in the browser) :
app/assets/javascripts/data.js and I'm trying to get it with :
d3.tsv("data.tsv", function(error, data) {...
thanks!

Invalid Connection File on RDP launch from VB app (some work, some don't)

Invalid Connection File on RDP launch from VB app (some work, some don't)

I have a a VB Express 2010 application that allows users to select a Hotel
we manage from a database. This is an access database. It then displays
the all of the info for the hotel. Everything works well. Except! the link
to the RDP. All of the RDP's are stored in a public root folder on our
shared network drive. The file path for each is Column in the database. I
put a label in to test that the correct filepath was being pulled. Then I
hid the label and use its text property to call the RDP session. Most
connections just launch the RDP but some say "INVALID CONNECTION FILE
(lastpart of name.RDP) Specified."
Here's a bit of code:
RDPtext is a label that shows (when not hidden) the file path pulled from
the database
If RDPtext.Text = "" Then MessageBox.Show("This Property Uses A Different
Connection Method" & vbCrLf & "Check SHAREPOINT DOCUMENTATION for more
info.", "Site Does Not Use RDP") Else Shell("C:\Windows\System32\mstsc.exe
" & RDPtext.Text, vbMaximizedFocus)
End If
The filepath is all the same folder just different RDPs. The path may be
S:\shared\MyProgram\RDPs\NAMEofRDP.RDP
again some work and some cast an error.
Thanks in advance!
-Dave

how to debug requests library?

how to debug requests library?

I'm trying to convert my python script from issuing a curl command via
os.system() to using requests. I thought I'd use pycurl, but this question
convinced me otherwise. The problem is I'm getting an error returned from
the server that I can see when using r.text (from this answer) but I need
more information. Is there a better way to debug what's happening?
for what it's worth I think the issue revoles around converting my --data
flag from curl/pycurl to requests. I've created a dictionary of the params
i was passing to --data before. My guess is that one of those isn't valid
but how can I get more info to know for sure?

How do you refresh your assigned team list in XCode 5?

How do you refresh your assigned team list in XCode 5?

I've just been added to another iOS dev team and in the 'old' Xcode (4)
there was a simple refresh button in the Organizer pane.
Now, that has disappeared and there appears to be no way of manually
asking XCode 5 to refresh your Apple ID credentials to find the new team
and then in turn do all the whizzy automatic profiling stuff.
Anyone got any tips on how to enable this team? My other teams all sit in
there fine and can be refreshed individually without any issues.
Help!

status bar is hidden in iOS 7 for application which was written for iOS 6

status bar is hidden in iOS 7 for application which was written for iOS 6

I wrote an application for iOS 6. Now when I run the application from
xcode 5 on iOS 7, the status bar hides automatically on app launch. Its
showing up in all other applications that were written on xcode 5 but not
for the one wriiten on xcode 4, what should i do?

Thursday 26 September 2013

how can i obtain visual studio 2005 express registration key

how can i obtain visual studio 2005 express registration key

I was able to register and get the key for vs 2005 express but now how can
I retrieve the old one or obtain a new one?
I tried to open the link from email but site is not existing anymore.

Wednesday 25 September 2013

loading javascript file accordingly

loading javascript file accordingly

I am trying to load from different javascript (.js) file accordingly. e.g.
when button 1 click, then load 1.js, when other one click, then load the
relevant .js file. (e.g. 2.js)
I've just know would be the usual way to load a js file. is there any
other way could achieve that with the same effect but provide the
possibilities to load different .js accordingly?? any jquery function
would also do that?
Reagrds

Thursday 19 September 2013

multiple functions onclick addeventlistener

multiple functions onclick addeventlistener

I have the following code that works when triggered by an onclick for
example: onClick="change('imgA');"
function change(v) {
var target = document.getElementById("target");
if (v == "imgA") {target.className = "cast1";}
else if (v == "imgB") {target.className = "cast2";}
else if (v == "imgC") {target.className = "cast3";}
else if (v == "imgD") {target.className = "cast4";}
else {target.className = "chart";}
}
as soon as this result is stored to the id 'target', How do I perform this
same function again but with different classNames ('bio1' instead of
'cast1', etc). then save the results to a different id?
Everytime I've tried hasn't worked to this point.

Event Listener Help (making one button/element do multiple things)

Event Listener Help (making one button/element do multiple things)

Hi I have this issue where I cant get more than one event from my code.
the goal is to have this display both functions in order....any help would
be awesome!!!
var button = document.getElementById("button element");
//only clicks once:
button.addEventListener("click", function, false);
button.addEventListener("click", function2, false);

Link one record to multiple records in separate table

Link one record to multiple records in separate table

Background Info
I have a database with two tables: Phones, and Carriers
Phones -> Carriers
Phones (Primary key: Phones.ID; Foreign Key: Phones.CarrierID) is linked to
Carriers (Primary key: Carriers.ID; Foreign Key: Carriers.RegionID).
The data types for both Phones.CarrierID and Carriers.ID are bigint. Sorry
if that's confusing!
Problem
I have a record in my Phones table called Nokia Lumia 1020. I need to be
able to link it to multiple records in the Carriers Table via the
Phones.CarrierID column. How would I do this without creating multiple
records for the Nokia Lumia 1020 in the Phones table?

Setting up Hudson extracting war file

Setting up Hudson extracting war file

I am setting up hudson, i have been able to extract the file once, but is
there way of dictating where the files from the war are extracted to?
I want the files to be extracted to my H drive but they are by default
extracted to c when executing java -jar hudson.war.
Any help would be awesome!

Returning local variable by copy - how does it work

Returning local variable by copy - how does it work

Given the sample program below, retlocal1 works while retlocal2 doesn't. I
know the rule about not returning a reference or pointer to a local
variable but I was wondering how it works.
When retlocal1 returns it copies its value to EAX? But EAX is a register
with enough space to hold an integer? So how does EAX hold the entire copy
of the std::string (which could of course be a long long string).
There must be something going on under the hood that I don't understand?
This example is C++, but I assume C works exactly in the same way?
#include <string>
std::string retlocal1() {
std::string s;
s.append(3, 'A');
return s;
}
std::string& retlocal2() {
std::string s;
s.append(3, 'A');
return s;
}
int main(int argc, char* argv[]){
std::string d = retlocal1();
std::string e = retlocal2();
return 0;
}

would like to know why the super class method is called

would like to know why the super class method is called

class One {
public void doThing(One o) {System.out.println("One");}
}
class Two extends One{
public void doThing(Two t) {System.out.println("Two");}
}
public class Ugly {
public static void main(String[] args) {
Two t = new Two();
One o = t;
o.doThing(new Two());
}
}
I know that at runtime, even though the object reference is of the super
class type, the actual object type will be known and the actual object's
method will be called. But if that is the case, then on runtime the
doThing(Two t) method should be called but instead the super class method
doThing(One o) is called. I would be glad if somebody explained it

Parsing the DateTime format

Parsing the DateTime format

I would like to be able to get the date time format string from a date
time string.
e.g.
2012-12-08 15:00:00" => "yyyy-MM-dd HH:mm:ss
Is this possible?

validation alert message for zip code

validation alert message for zip code

Hi I am not getting my alert message correctly and my code is:
function isNumberKey( event ) {
var charCode = (event.which)? event.which: event.keyCode;
var ctrl = event.ctrlKey;
var shift1=event.shiftKey;
var zipcode=document.getElementById(zipCode).value;
if ( ctrl ) {
return true;
}
if ( ( charCode >= 95 && charCode <= 105) || (charCode >= 106 &&
charCode <= 123 ) ) {
return true;
}
if ( charCode == 36 || charCode == 35 || charCode == 45 || charCode ==
46 || charCode == 144 || charCode == 145 ) {
return true;
}
if ( charCode >= 106 && charCode <= 123 ) {
return true;
}
if ( ( shift1 ) || charCode > 41 && (charCode < 48 || charCode > 57 ) ) {
alert("The ZIP Code entered is invalid. Please enter a 5 digit ZIP
Code.");
return true;
}
}
can anyone help for this ?

Wednesday 18 September 2013

Replace all quotes in a string with escaped quotes? python

Replace all quotes in a string with escaped quotes? python

Given a string in python, such as:
s = 'This sentence has some "quotes" in it\n'
I want to create a new copy of that string with any quotes escaped (for
further use in Javascript). So, for example, what I want is to produce
this:
'This sentence has some \"quotes\" in it\n'
I tried using replace(), such as:
s.replace('"', '\"')
but that returns the same string. So then I tried this:
s.replace('"', '\"')
but that returns double-escaped quotes, such as:
'This sentence has some \\"quotes\\" in it.\n'
How to replace " with \"?

Automatically updating Highcharts with Mysql values

Automatically updating Highcharts with Mysql values

I'm going to be honest, jquery isn't my strong point. What I'm trying to
do is update the graph every second and use the animation of the graph to
update with any changes using the data from the mysql database. I have
been trying to do this with ajax but have yet to be able to get the graph
to generate any proper values. Here is what I have been able to get from
searching through the internet (and stackoverflow obviously).
PHP:
$sql = "SELECT timeDate, value FROM table ORDER BY id DESC LIMIT 1";
$query = mysql_query($sql)or die(mysql_error());
$row = mysql_fetch_array($query);
$x = $row['timeDate']; //I have also tried strtotime($row['timeDate'])
//timeDate format is 2004-04-04 02:00:00
$y = intval($row['value']); //Prints 20
$arrayTest = array($x, $y);
echo json_encode($arrayTest);
JQUERY:
<script type="text/javascript" src="libs/highcharts.js" ></script>
<script type="text/javascript" src="libs/themes/gray.js"></script>
<script type="text/javascript">
var chart;
function requestData() {
$.ajax({
url: 'databaseProxy.php',
success: function(point) { //point = "['2004-04-04 02:00:00',20]"
var series = chart.series[0],
shift = series.data.length > 20; // shift if the series is
longer than 20
// add the point
chart.series[0].addPoint(point, true, shift);
// call it again after one second
setTimeout(requestData, 1000);
},
cache: false
});
}
$(document).ready(function() {
chart = new Highcharts.Chart({
chart: {
renderTo: 'cellsTest',
type: 'spline',
height: 500,
marginRight: 25,
marginBottom: 25,
marginLeft: 80,
events: {
load: requestData
}
},
title: {
text: 'Live random data'
},
xAxis: {
type: 'datetime',
tickPixelInterval: 100,
maxZoom: 20 * 1000
},
yAxis: {
minPadding: 0.2,
maxPadding: 0.2,
title: {
text: 'Value',
margin: 80
}
},
series: [{
name: 'Random data',
data: []
}]
});
});
</script>
Just to be clear, the graph does appear, it simply doesn't have any
points. When it is running I see a random curved line that keeps changing
even when the values don't change. I don't really know what to make of it.
Also the values in the database are expected to change every second which
is why I want the graph to do the same.
Sorry if this is just a really simple fix, It's a little beyond me given
the current deadline and my amount of time to work on it. I have spent the
past three days trying to figure out how it all works and really I'm not
any closer.

Google Analytics not tracking ecommerce events from Bigcommerce

Google Analytics not tracking ecommerce events from Bigcommerce

I setup the tracking code from google in bigcommerce and the goal in
google analytics. I can see the store pages in google analytics but not
conversion or ecommerce data. This is the code I have in Bigcommerce.
Thanks for the help!
<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl."
:"http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost +
"google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
try{
var pageTracker = _gat._getTracker("UA-20920360-1");
pageTracker._setDomainName('.molecularrecipes.com');
pageTracker._setAllowLinker(true);
pageTracker._setAllowHash(false);
pageTracker._trackPageview();
} catch(err) {}</script>

Can someone point out why mailx/gmail results in an Error?

Can someone point out why mailx/gmail results in an Error?

Based on various articles, we're testing Mailx from the command line
The test is running (Fedora/Centos). We run into the
Error in certificate: Peer's certificate issuer is not recognized.
Mailx is installed. Per articles, we're using the mozilla/firefox dir.
The command we're using from the cli is:
echo "test data" | mailx -s "test sub1" -S smtp-use-starttls
-S ssl-verify=ignore -S smtp=smtps://smtp.gmail.com:587
-S smtp-auth=login -S smtp-auth-user=abc -S smtp-auth-password=marsaa
-S from="aaa@yahoo.com"
-S nss-config-dir=/root/.mozilla/firefox/kbatbh5m.default/ bbb@yahoo.com
The emails go through/get sent, but we still get the certificate error.
The test is running FF 23.0.1, centos 6.
Any pointers to resolve this would be useful.
Thanks!!

c# msi will not execute with processStart

c# msi will not execute with processStart

Running install programs from the c# code I can successfuly install .exe
files and uninstall both exe and msi files... however whenever launching
an msi for installation it just sits there and never does anything....
start = new ProcessStartInfo("msiexec.exe", "/i \"" + tempDir + "/" +
s.executable + "\"");
start.WindowStyle = ProcessWindowStyle.Hidden;
start.CreateNoWindow = true;
Process.Start(start).WaitForExit();
can anyone spot my mistake. I understand the wait for exit will wait
indefinatly and that is fine as there will be 10-12 installs going
synchronously but It never actually installs.....

First module in prestashop 1.5

First module in prestashop 1.5

I'm following this tutorial and i have problem with integration of my
module inside the theme. If i call parent initcontent() i get 500 error.
if not i got the page , but it's disordered and the other modules are not
loaded.
hahaha is the content of my display.tpl :

This is my front controller:
<?php
class nameofmoduledisplayModuleFrontController extends ModuleFrontController
{
public function initContent()
{
parent::initContent();//probleme here
$this->setTemplate('display.tpl');
}
}
Any suggestions ?

HTTPS connection between client and server SSL handshake

HTTPS connection between client and server SSL handshake

I've got an HTTPS client and a HTTPS server coded in java, i need to make
a SSL connection to the HTTPS server to get a message based on the
condition that the client should accept the connection if the certificate
hash of the server's certificate during SSL handshake equals to the one
I've declared already in my client.
Here is my code
package testsimulation;
import java.io.InputStream;
import java.net.InetSocketAddress;
import java.net.Proxy;
import java.net.URL;
import java.net.URLConnection;
import javax.net.ssl.*;
import javax.security.auth.x500.X500Principal;
import org.bouncycastle.util.encoders.Hex;
public class HTTPclient extends akande {
private static String urlString;
public String k = a9 09 50 2d d8 2a e4 14 33 e6 f8 38 86 b0 0d 42 77
a3 2a 7b
public static void main(String[] args) throws Exception
{
//set necessary truststore properties - using JKS
System.setProperty("javax.net.ssl.trustStore",
"FiddlerKeystore.jks");
System.setProperty("javax.net.ssl.trustStorePassword", "codedfar");
//
System.setProperty("java.protocol.handler.pkgs","com.sun.net.ssl.internal.www.protocol");
//
System.setProperty("java.protocol.handler.pkgs","com.sun.net.ssl.internal.www.protocol");
SSLContext sslContext = createSSLContext();
// sslContext.init(null, null, null);
SSLSocketFactory fact = sslContext.getSocketFactory();
// SSLSocketFactory fact =
(SSLServerSocketFactory)SSLServerSocketFactory.getDefault();
URL url = new URL("https://localhost:9990");
System.setProperty("proxySet","true");
System.setProperty("https.proxyHost", "127.0.0.1");
System.setProperty("https.proxyPort", "8888");
//-Djavax.net.ssl.trustStore=<path\to\FiddlerKeystore>
//-Djavax.net.ssl.trustStorePassword= codedfar;
Proxy proxy = new Proxy(Proxy.Type.HTTP, new
InetSocketAddress("127.0.0.1", 8888));
HttpsURLConnection connection =
(HttpsURLConnection)url.openConnection(proxy);
connection.setSSLSocketFactory(fact);
connection.setHostnameVerifier(new Validator());
connection.connect();
InputStream in = connection.getInputStream();
int ch=0;
while((ch = in.read()) >= 0)
{
System.out.println((char)ch);
}
in.close();
// int th =1;
// th.force(0);
}
}
I want to compare the server's certificate thumbprint collected from
another server which is declared in my class against the server's
thumbprint obtained in the SSL handshake to know if it is the same.

KendoNumericTextBox russian localization

KendoNumericTextBox russian localization

I use KendoNumericTextBox to read real numbers.
When keyboar switched to russian, i cann't enter russian ',' or
'.'(english key '/' or '?') but can enter 'á' or 'þ' (english key ',' or
'.')
<script
src="http://cdn.kendostatic.com/<version>/js/cultures/kendo.culture.en-GB.min.js"></script>
<input id="numeric" type="number" value="17" min="0" max="100" step="1" />
<script type="text/javascript">
kendo.culture("ru-RU");
$("#numeric").kendoNumericTextBox();
</script>

Group countries together and count

Group countries together and count

I have a table like this:

-------------------------------
EMP ID|Country |Emp Level |
------|-----------|-----------|
102 |UK |Staff |
103 |US |Admin Staff|
104 |CA |Staff |
105 |NL |Admin Staff|
106 |MN |Intern |
107 |IN |Staff |
108 |UK |Staff |
109 |US |Admin Staff|
110 |IN |Admin Staff|
------------------------------
I need to count number of employees in each category in each country given
following condition: If country is not in ('UK' or 'US' or 'CA') then
consider it as 'Global'. SO our answer should be:

------------------------------
|Country |Emp Level |Count|
|-----------|-----------|-----
|UK |Staff |2
|US |Admin Staff|2
|CA |Staff |1
|Global |Admin Staff|2
|Global |Intern |1
|Global |Staff |1
So far I can count number of staff in each category, in each country but
cannot club the countries not in given set and count & display them as
global.

How do you make an object move opposite direction?

How do you make an object move opposite direction?

I need to make a boat move in its opposite direction when it hits out of
bounds (8, -8).
The boat moves but adding its current velocity to its current position. If
the boat hits a boundary it turns around and moves in the opp.
direction...
}
public void move(int direction)
{
this.position = position + direction;
this.velocity = velocity + position;
if ( position > 5)
{
direction = - 1;
}
else if ( position < -5)
{
direction = + 1;
}
}
}
It does not work.. Any help would be great.
Thank you :)

Tuesday 17 September 2013

Does Spring use Java Reflection Proxy?

Does Spring use Java Reflection Proxy?

As for the Spring's EL resolving, it's obvious that it uses Reflection
API. But when it comes to AOP part of Spring, does it use reflect.Proxy
and reflect.InvokationHandler? Seems that it does, as the native Spring's
AOP capabilities are narrowed to method operations. But I'm not sure.

error: ISO C forbids comparison between pointer and integer

error: ISO C forbids comparison between pointer and integer

I am brand new to programming and I have just finished reading the Book C
for Dummies by Dan Gookin. But I thought I am trying to make tiny programs
to get a feel of the language.
I learned that there is a random counter in C (which is not that random),
and apparently using the computers internal clock helps making the random
counter more random. I saw a code example in the book and it work when I
want to printf() random numbers in a grid. But now I would like the
program to limit it to only 3 numbers but instead of printing out the
numbers in digits I'm interested in learning how to have the computer
return printf() functions in a random manner. It doesn't have to be
printf() it really can be any function, but this seems to be the easiest
way to check.
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int rnd(int range);
void seedrnd(void);
int main()
{
int x;
seedrnd();
for(x=0;x<1;x++)
// printf("%i\t" ,rnd(3));
if(seedrnd==0)
printf("Zero");
else if(seedrnd==1)
printf("One");
else
printf("Two");
return(0);
}
int rnd(int range)
{
int r;
r=rand()%range;
return(r);
}
void seedrnd(void)
{
srand((unsigned)time(NULL));
}

Number of peoples in circles on google plus

Number of peoples in circles on google plus

I try get number of peoples in circles on google plus
$gplus_data =
wp_remote_get('https://www.googleapis.com/plus/v1/people/'.$googleplus_user.'?key='.$api_key);
$gplus_data = json_decode($gplus_data['body'],true);
$gplus_count = $gplus_data['circledByCount'];
and i get error in last line
json object looks like http://pastebin.com/U7heUjB3
whats wrong?

JS: How to get two IDs

JS: How to get two IDs

This won't work:
<a onclick="if(document.getElementById('div2','div1')
.style.display=='none') {document.getElementById('div2','div1')
.style.display=''}else
{document.getElementById('div2','div1') .style.display='none'}">
this1 ~~
</a>
<div id="div1" style="display:none">
1
</div>
<a onclick="if(document.getElementById('div2') .style.display=='none')
{document.getElementById('div2') .style.display=''}else
{document.getElementById('div2') .style.display='none'}">
this2 ~~
</a>
<div id="div2" style="display:none">
2
</div>
How do I show div2 and div1 when I click on this1~~? It only shows div2 on
click instead of showing both. Why isn't it working?

file corrupted when I post it to the servlet using GZIPOutputStream

file corrupted when I post it to the servlet using GZIPOutputStream

I tried to modify @BalusC excellent tutorial here to send gziped
compressed files. This is a working java class :
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;
import java.util.zip.GZIPOutputStream;
public final class NetworkService {
// *** EDIT THOSE AS APROPRIATE
private static final String FILENAME = "C:/Dropbox/TMP.txt";
private static final String URL =
"http://192.168.1.64:8080/DataCollectionServlet/";
// *** END EDIT
private static final CharSequence CRLF = "\r\n";
private static boolean isServerGzip = true; // ***
private static String charsetForMultipartHeaders = "UTF-8";
public static void main(String[] args) {
HttpURLConnection connection = null;
OutputStream serverOutputStream = null;
try {
File file = new File(FILENAME);
final String boundary = Long
.toHexString(System.currentTimeMillis());
connection = connection(true, boundary);
serverOutputStream = connection.getOutputStream();
try {
flushMultiPartData(file, serverOutputStream, boundary);
} catch (IOException e) {}
System.out.println(connection.getResponseCode()); // 200
} catch (IOException e) {
// Network unreachable : not connected
// No route to host : probably on an encrypted network
// Connection timed out : Server DOWN
} finally {
if (connection != null) connection.disconnect();
}
}
private static HttpURLConnection connection(boolean isMultiPart,
String boundary) throws MalformedURLException, IOException {
HttpURLConnection connection = (HttpURLConnection) new URL(URL)
.openConnection();
connection.setDoOutput(true); // triggers POST
connection.setUseCaches(false); // *** no difference
connection.setRequestProperty("Connection", "Keep-Alive");
connection.setRequestProperty("User-Agent",
"Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.3) "
+ "Gecko/20100401"); // *** tried others no difference
connection.setChunkedStreamingMode(1024); // *** no difference
if (isMultiPart) {
if (boundary == null || "".equals(boundary.trim()))
throw new IllegalArgumentException("Boundary can't be "
+ ((boundary == null) ? "null" : "empty"));
connection.setRequestProperty("Content-Type",
"multipart/form-data; boundary=" + boundary);
}
return connection;
}
//
=========================================================================
// Multipart
//
=========================================================================
private static void flushMultiPartData(File file,
OutputStream serverOutputStream, String boundary)
throws IOException {
PrintWriter writer = null;
try {
// true = autoFlush, important!
writer = new PrintWriter(new
OutputStreamWriter(serverOutputStream,
charsetForMultipartHeaders), true);
appendBinary(file, boundary, writer, serverOutputStream);
// End of multipart/form-data.
writer.append("--" + boundary + "--").append(CRLF);
} finally {
if (writer != null) writer.close();
}
}
private static void appendBinary(File file, String boundary,
PrintWriter writer, OutputStream output)
throws FileNotFoundException, IOException {
// Send binary file.
writer.append("--" + boundary).append(CRLF);
writer.append(
"Content-Disposition: form-data; name=\"binaryFile\";
filename=\""
+ file.getName() + "\"").append(CRLF);
writer.append(
"Content-Type: " // ***
+ ((isServerGzip) ? "application/gzip" : URLConnection
.guessContentTypeFromName(file.getName())))
.append(CRLF);
writer.append("Content-Transfer-Encoding: binary").append(CRLF);
writer.append(CRLF).flush();
InputStream input = null;
OutputStream output2 = output;
if (isServerGzip) {
output2 = new GZIPOutputStream(output);
}
try {
input = new FileInputStream(file);
byte[] buffer = new byte[1024]; // *** tweaked, no difference
for (int length = 0; (length = input.read(buffer)) > 0;) {
output2.write(buffer, 0, length);
}
output2.flush(); // Important! Output cannot be closed. Close of
// writer will close output as well.
} finally {
if (input != null) try {
input.close();
} catch (IOException logOrIgnore) {}
}
writer.append(CRLF).flush(); // CRLF is important! It indicates
end of
// binary boundary.
}
}
You have to edit FILENAME and URL fields and set up a servlet in the URL -
its doPost() method is :
@Override
protected void doPost(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
Collection<Part> parts = req.getParts();
for (Part part : parts) {
File save = new File(uploadsDirName, getFilename(part) + "_"
+ System.currentTimeMillis() + ".zip");
final String absolutePath = save.getAbsolutePath();
log.debug(absolutePath);
part.write(absolutePath);
sc.getRequestDispatcher(DATA_COLLECTION_JSP).forward(req, resp);
}
}
Now when isServerGzip field is set to true the FILENAME is compressed
alright and send to the server but when I try to extract it it is
corrupted (I use 7z on windows which opens the gzip file as archive but
when I try to extract the file inside the gzip archive it says it is
corrupted - though it does extract the (corrupted indeed) file). Tried
with various files - the larger ones end up corrupted at some point the
smaller ones extract as empty - the reported size of the larger files
inside the archive is much larger than the real size while of the smaller
ones 0. I marked the parts that need attention as // ***. I might miss
some connection configuration or my way of gzipping the stream might be
plain wrong or...?
Tried tweaking connection properties, the buffers, caches etc to no avail

Razor syntax bugging out

Razor syntax bugging out

It is saying I need to properly close my div tags. But they are opened and
closed properly unless I am just completely missing something here.
Anyone familiar with why I might be getting this error?
<div id="attachments" class="popoversample">
<h3>
Attachments</h3>
<div class="peoplelist">
@foreach (var item in Model.documents)
{
<div class="peoplewrapper">
<div class="thumb">
<img src="../../Images/thumbs/doc.png" alt="" /></div>
<div class="peopleinfo">
<h4>
<a href="~/Documents/@Html.DisplayFor(modelItem =>
item.path)" target="_blank">
</h4>
<img src="../../Images/thumbs/doc.png" alt="" /></a>
<span class="filename">@item.filename</span>
<ul>
<li><span>Followers:</span> 10 &nbsp;/&nbsp;
<span>Following:</span> 21</li>
<li><span>Member:</span> April 2011</li>
<li><span>Skype:</span> johndoe</li>
<li><span>Phone:</span> +44033 0400 332</li>
<li><span>Address:</span> Something St., Some
City, Place 4023</li>
</ul>
</div>
</div>
<!--peoplewrapper-->
}
</div>
</div>
Error: Parser Error Message: Encountered end tag "div" with no matching
start tag. Are your start/end tags properly balanced?

Sunday 15 September 2013

How to make button and table cell coexist on android using MVVMCross?

How to make button and table cell coexist on android using MVVMCross?

I have a MVXListView with bunch items and when I click one of the items(a
cell), I want it to go to detail screen. But the problem is I want to add
a button in the list item(cell) too. I followed the following post to make
it work so that the button in the list item can fire the event to the
viewmodel no problem. But, I can't get the item clicked event anymore
after adding the button.
Binding button click in ListView template MvvMCross
It works on the iOS part I can get button click event AND list item
selected event. But on android, as soon as I added the button to the list
item, I can no longer get the item selected event.
Thanks in advanced!

jQuery - preserve html elements after change

jQuery - preserve html elements after change

I'm using Ruby on Rails to implement a simple edit/submit button to
replace the content of h4 that has class named "special-content".
Here is my code for rhtml:
<div class="modal-body" style="height: 280px !important;">
<%= image_tag("special/turkey.png", :alt => "turkey", :class =>
"special-img") %><br>
<h4 class="special-content">#93 Turkey, Avocado &
Cheese</h4><h4>&nbsp;with Small Sized Drink & Chip</h4>
</div>
and here is my code for jQuery, which is implemented right above the rhtml
code:
<script type="text/javascript">
$(document).ready(function() {
$("body").on("click", "#edit", function() {
$('#edit').replaceWith('<a class="btn" id="submit">Submit</a>');
$('.special-content').replaceWith('<input class="special-content-edit"
type="text" value="' + $('.special-content').html() + '">');
$('.special-img').replaceWith('<input class="special-img-edit"
type="text" value="' + $('.special-img').attr('src') + '">');
});
$("body").on("click", "#submit", function() {
$('#submit').replaceWith('<a class="btn" id="edit">Edit</a>');
$('.special-img-edit').replaceWith('<img class="special-img" src="' +
$('.special-img- edit').val() + '">');
$('.special-content-edit').replaceWith('<h4 class="special-content">'
+ $('.special-content-edit').val() + '</h4>');
});
});
</script>
The jQuery should allow users to replace the h4 content. Everything works
fine. However, if I navigate to another link and come back to the page,
the h4 content changes back to the original content ("#93 Turkey, Avocado
& Cheese"). How can I preserve the changed element?

Mysql Error 1192 while importing from mysqldump backup

Mysql Error 1192 while importing from mysqldump backup

We are trying to clone Mysql Cluster (ClusterDB) database on same instance
by taking backup with Mysqldump and then restoring it with mysql as
following:
mysqldump -u masterdb1 -p --single-transaction db_master_1 >
db_master_1_bk.sql
mysql -u testdev -p db_testdev_1 < db_master_1_bk.sql
How ever while restoring it throws Error:
Enter password: ERROR 1192 (HY000) at line 112: Can't execute the given
command because you have active locked tables or an active transaction
Any Help..?
Thanks,

Parentheses, brackets, braces

Parentheses, brackets, braces

In Python (and I assume other programming languages), there are many
different uses for parentheses, brackets, and braces. It's overwhelming
and confusing, since I'm a beginner. When do I use parentheses, when do I
use brackets, and when do I use braces? Is there any sense, purpose to
this, any reason why one is used over the other? Any way I can know when
to use what more easily?

Generate DataTables Dynamically from json array

Generate DataTables Dynamically from json array

I am getting JSON data from a php file and want to display it with
DataTables. So I am creating DataTables dynamically. But I am getting
problem in making following data from the data coming in JSON.
var aDataSet = [
['Trident','Internet Explorer 4.0','Win 95+','4','X'],
['Trident','Internet Explorer 5.0','Win 95+','5','C']
];
I want each entry in this Dataset dynamically. I am using "for loop".
for(i=0;i<count;i++)
{
}
JSON Data coming from PHP file:
{
"data": [
{
"staff_id": "1",
"staff_name": "Chinu",
"rig_days": "80",
"manager_id": "2",
"grade": "8",
},
{
"staff_id": "2",
"staff_name": "John",
"rig_days": "90",
"manager_id": "3",
"grade": "10",
}
]
}
How it should be placed in for loop so that it works well ?

DataMapper create not working

DataMapper create not working

I have a model like:
class Person include DataMapper::Resource property :id, Serial property
:name, String end
Person.finalize Person.auto_migrate!
now if I do person = Person.create(name: "Jack")
There are no new entries in the table.
But the following works person = Person.new person.save This gives me one
new record.
Why this strange behaviour?

Keep showing context menu when a popup window is opened

Keep showing context menu when a popup window is opened

I am trying to show a calendar from a context menu. At first, I included
it as a Gtk.MenuItem, but after reading this answer, I am now showing the
calendar as a popup window when the user hovers over a menu item.
When the user hovers over 'Set due date', the calendar is supposed to show
up right beside it. It is shown when activate signal (
on_set_due_via_calendar ) fires from the 'Set due date' menu item. Here's
the code for it -
def on_set_due_via_calendar(self, widget):
rect = widget.get_allocation()
x, y = widget.window.get_origin()
menu_width, menu_height = widget.get_toplevel().window.get_size()
calendar_width, calendar_height = self.calendar.get_size()
self.calendar.show_at_position(x + rect.x + calendar_width + menu_width,
y + rect.y + calendar_height)
The problem I'm facing is that the menu disappears as soon as the window
is shown ( Perhaps it works that way ). I want it to keep getting
displayed until the user clicks somewhere else ( i.e. - Treat the calendar
as a submenu ).
Here are the screens showing the issue -

"%s ", string not printing space after string

"%s ", string not printing space after string

In this code snippet here:
printf("shell> ");
fgets(input, MAX_INPUT_SIZE, stdin);
//tokenize input string, put each token into an array
char *space;
space = strtok(input, " ");
tokens[0] = space;
int i = 1;
while (space != NULL) {
space = strtok(NULL, " ");
tokens[i] = space;
++i;
}
//copy tokens after first one into string
strcpy((char*)cmdargs, ("%s ",tokens[1]));
for (i = 2; tokens[i] != NULL; i++) {
strcat((char*)cmdargs, ("%s ", tokens[i]));
}
printf((char*)cmdargs);
With the input: echo hello world and stuff, the program prints:
helloworldandstuff
It seems to me that the line strcat((char*)cmdargs, ("%s ", tokens[i]));
should concatenate the string at tokens[i] with a space following it. Does
strcat not work with string formatting? Any other ideas what might be
going on?

Saturday 14 September 2013

Set an RGB color value as default in My.Settings

Set an RGB color value as default in My.Settings

VB2010. I have setup some settings in MyProject.Settings. One of them
being being a color variable. However I cant seem to figure out how I can
set a specific RGB value as the default. The My.Settings designer only
lets you pick predetermined colors. How can I set the default to be
RGB(214, 133, 137).

Create an Executable That Creates A MsgBox

Create an Executable That Creates A MsgBox

I'm trying to make a program, that'll allow the user to type in a message
like hi and it'll use a save file dialog box to save the executable
wherever the user specifies.
Then when the user opens it it'll display the message box.
I heard something called CodeDOM, and did some 2 day research on it, and I
don't understand the MSDN Documentation at all, can someone help me
please?

College assignment help (part 1 of lindenmayer system)

College assignment help (part 1 of lindenmayer system)

Ok so I am struggling in this computer programming class, as I am totally
new to computer programming. let me post my actual assignment and then see
if anyone could help get me started with it.
assignment: This Lab is Part 1 of building a type of fractal called a
Lindenmayer system. In this first part, you will just be implementing
symple set of draw commands.
Write a program that takes 3 inputs: 1) Draw String: This must be a string
of draw commands (see the table below). 2) Length: This must be an integer
equal greater than 0 and less than or equal to 100. It defines the length
variable used in some of the draw commands. 3) Angle: This must be a
floating point number equal greater than 0.0 and less than or equal to
360.0. It defines the angle variable used in some of the draw commands.
Character Draw Commands h Draw a straight line segment length pixels long
in the current heading. f Same as h g Move, without drawing, a straight
line segment length pixels long in the current heading. +
Turn the heading clockwise by angle.
Turn the heading counter-clockwise by angle. A Each of these color
commands must change the turtle color to color that is different form the
background and different from the other 5 color commands. Pick colors that
you think look good together. B C D E F any other character Ignore
So, that is the assignment, sorry it's so long. I have been reading my
textbook, and unfortunately it gives very little info on how to actually
do this assignment. It also didn't help that our professor showed us all
these cool things fractals could do, but didn't actually tell us anything
about how to do the assignment (don't ask me why?)
I am really at a loss as to how to even begin to code this thing, if
someone could help me or at least point me in the right direction, at
starting to go about coding for this stuff, it would really help me out. I
don't expect anyone to do it all for me, just maybe help show me where to
begin.
PS. There is one other thin our professor wrote that is probably important.
Now that you have the "if" statement at your command, you do need to check
for bad input. If the user inputs bad data, print an error message and
exit the program.

Only let users input positive integers (no decimals or strings)?

Only let users input positive integers (no decimals or strings)?

I know how to ask the user to input positive integers, but I don't know
how approach the code to avoid an input error such as a decimal or string
input.
int seedValue;
double angle, gunpowder;
System.out.println("Please enter a positive integer seed value: ");
seedValue = input.nextInt();
while (seedValue <= 0) {
System.out.println("Please enter a positive integer seed value: ");
seedValue = input.nextInt();
}
System.out.println("That target is " +
threeDec.format(gen.nextDouble() * 1000) + "m away.");

Push ViewController

Push ViewController

I have added UINavigationBar in appDelegate method. Please check my
atatched screen shots. In bottom is i have used UINavigationBar. In middel
of the page history button is there.
Here when i click the history button its cant go to historyviwcontrooler.
Because i cant push the view. Can you please tell me how i can push here.
When i click history its called only one calls after only thet called
another class there only i given UI. How i handel here . please help me
#import "UICallButton.h"
#import "LinphoneManager.h"
#import <CoreTelephony/CTCallCenter.h>
@implementation UICallButton
@synthesize addressField;
#pragma mark - Lifecycle Functions
- (void)initUICallButton {
[self addTarget:self action:@selector(touchUp:)
forControlEvents:UIControlEventTouchUpInside];
}
- (id)init {
self = [super init];
if (self) {
[self initUICallButton];
}
return self;
}
- (id)initWithFrame:(CGRect)frame {
self = [super initWithFrame:frame];
if (self) {
[self initUICallButton];
}
return self;
}
- (id)initWithCoder:(NSCoder *)decoder {
self = [super initWithCoder:decoder];
if (self) {
[self initUICallButton];
}
return self;
}
- (void)dealloc {
[addressField release];
[super dealloc];
}
#pragma mark -
- (void)touchUp:(id) sender {
NSString *address = [addressField text];
NSString *displayName = nil;
ABRecordRef contact = [[[LinphoneManager instance] fastAddressBook]
getContact:address];
if(contact) {
displayName = [FastAddressBook getContactDisplayName:contact];
}
[[LinphoneManager instance] call:address displayName:displayName
transfer:FALSE];
}
@end

How to get the clicked button in notification.confirm() in phonegap application

How to get the clicked button in notification.confirm() in phonegap
application

I have used the Phonegap notification.confirm as like below,
navigator.notification.confirm(
'Do you want to continue ?',
function() {
console.log("Called");
},
'Game Over',
'Continue,Exit'
);
How can i trace the clicked button ?

Why is it that I can't use == in a For loop?

Why is it that I can't use == in a For loop?

I don't know if that's been asked before, but I haven't been able to find
an answer, nonetheless. My question is this; in For loops, this is
acceptable.
int k = 0;
for (int i = 0; i <= 10; i++)
k++;
But this is NOT:
int k = 0;
for (int i = 0; i == 10; i++)
k++;
Why is it that I cannot use '==' to determine whether the condition has
been met? I mean, both expressions return true or false depending on the
situation and the latter would be appropriate for, say, an If loop.
int k = 10;
if (k == 10)
{
// Do stuff.
}
The answer to this question has been bothering me for a good while now
during my time as a hobbyist programmer, but I hadn't searched for it till
now.

Friday 13 September 2013

Execute a New Call to a Flash Object only AFTER a Flash callback completes

Execute a New Call to a Flash Object only AFTER a Flash callback completes

Note: This is very similar to the requirement of this question (Execute a
method AFTER a callback completes) - I couldn't add a comment to that one,
so I am asking a new question with a new circumstance, so hopefully
someone will have the answer.
My C# program has an embedded Flash SWF file that communicates to my C#
program using flash.external.ExternalInterface in AS3, specifically using
ExternalInterface.call(). In this case, the user is entering a PIN in
Flash and my C# program is validating that PIN. If it is invalid, I want
to tell flash to show "invalid pin" to the user. But if I try to execute a
CallFunction() on that flash object within the function that is processing
the communication from Flash, I get a COM exception. However, at any other
time outside of this function, I can execute the same CallFunction()
without a problem.
So, like the other questioner, all I need is the ability to execute the
CallFunction() only after the FlashCallback is done executing.
I know that I could put a function pointer or delegate on a timer and have
it call sometime 'later' but I'd rather have a more precise way to know
that my call to Flash will occur very soon after the Flash to C# callback
is done.
Is there a more 'built in' way in C# to put a delegate or function pointer
on some system 'stack' that then gets called like another windows event?
Ideas?

rror C2228: left of '.visitFile' must have class/struct/union type

rror C2228: left of '.visitFile' must have class/struct/union type

Visitor.h
class Visitor{
public:
virtual ~Visitor() {}
virtual void visitNode(Node*) = 0;
virtual void visitFile(File*) = 0;
virtual void visitDirectory(Directory*) = 0;
virtual void visitLink(Link*) = 0;
protected:
Visitor();
Visitor(const Visitor&);
};
//realize those visit function
void Visitor::visitNode(Node* n) {
//common default behavior
cerr << "It is not a directory! " << endl;
}
void Visitor::visitDirectory(Directory* d) {
Visitor::visitNode(d);
}
void Visitor::visitFile(File* f) {
Visitor::visitNode(f);
}
void Visitor::visitLink(Link* l) {
Visitor::visitNode(l);
}
File.h
class File : public Node {
public:
File();
//redeclare common interface here
void setName(string& name);
string& getName();
void setCDate(char* cDate);
char* getCDate();
long size();
virtual void accept(Visitor*) = 0;
private:
string& name;
char* cDate;
};
//realize the function accept
void File::accept(Visitor* v) {
v.visitFile(this);
}
The problem is the function accept(Visitor* v){}, my compiler always tell
me: d:\win7 data\data\c\filemanage\file.h(20) : error C2228: left of
'.visitFile' must have class/struct/union type How can I deal with it?

Django OperationalError 2019 Can't initialize character set utf8mb4

Django OperationalError 2019 Can't initialize character set utf8mb4

I have struggled with this all day and have not been able to find a
solution or even the root cause of the error. When I run my app locally it
works fine. My production instance is using Heroku cedar stack and Amazon
RDS MySQL databases.
In my settings file I have: 'OPTIONS': {'charset': 'utf8mb4'}
When I push to Heroku it crashes with the error:
_mysql_exceptions.OperationalError: (2019, "Can't initialize character set
utf8mb4 (path: /usr/share/mysql/charsets/)")
The exception location:
/app/.heroku/python/lib/python2.7/site-packages/MySQLdb/connections.py in
set_character_set, line 298
I have created the appropriate Data Base parameters with Amazon RDS MySQL
and are currently set as follows:
+--------------------------+-------------------------------------------+
| Variable_name | Value |
+--------------------------+-------------------------------------------+
| character_set_client | utf8mb4 |
| character_set_connection | utf8mb4 |
| character_set_database | utf8mb4 |
| character_set_filesystem | binary |
| character_set_results | utf8mb4 |
| character_set_server | utf8mb4 |
| character_set_system | utf8 |
| character_sets_dir | /rdsdbbin/mysql-5.6.13.R1/share/charsets/ |
+--------------------------+-------------------------------------------+
I am running:
MySQL 5.6.13
MySQL-python==1.2.4
Thanks in advance for your help. Let me know if there are more details
that I am missing.

Jquery not working on ajax loaded content div

Jquery not working on ajax loaded content div

I'm having trouble getting a page with jquery and ajax to work. I'm trying
to make this example as simple as possible. The jquery works when it's on
a single page but I cannot get it to work after the call.
2 pages, first page:



<!DOCTYPE html>
<html>
<head>
<script src="../js/jquery-1.8.2.min.js"></script>
<style type='text/css'>
#one {
width: 200px;
height: 200px;
background: red;
}
#two{
width: 200px;
height: 200px;
background: blue;
}
.show {
display: none;
background: yellow;
}
</style>
<script>
$(document).ready(function() {
$("button").click(function() {
$("#div1").load("definition.jsp");
});
});
</script>
<script type="text/javascript">
$('#wrapper').on('mouseenter', '.touch', function() {
$(this).next('.show').fadeIn(800);
}).on('mouseleave', '.touch', function() {
$(this).next('.show').delay(800).fadeOut(800);
});
</script>
</head>
<body>
<div id="div1"><h2>jQuery AJAX Test</h2></div>
<button>Get External Content</button>
</body>
Second page:
<div id="wrapper">
<div id="parent_one">
<div class="touch" id="one">Enter</div>
<div class="show">Works</div>
</div>
<div id="parent_two">
<div class="touch" id="two">Enter</div>
<div class="show">Second Works</div>
</div>
Any ideas? Help please!

Is there anything like mfactory's mtropolis for web programming?

Is there anything like mfactory's mtropolis for web programming?

I used to author CD's with mTropolis back before I jumped on the web
development bandwagon. Quite frankly, I'm tired of the IBM-esque rattling
off at the keys in a text editor to create online interactive websites; it
just seems so stupid.
Quark bought out mTropolis and unceremoniously killed it shortly after.
Why hasn't such a programming environment been developed? Had you authored
with mTropolis, you'd be wondering this yourself. The current
'instruments' of creating website interactivity is just so 80's. Each IDE
I've seen so far is essentially a super version of notepad.
And, all these great php programmers (as an example) seem to brag about,
'oh, I use notepad in lieu of [enter-name-of-IDE-here]. Seriously, super
lame. Not the claimant, just the fact that that is what is considered the
'gold standard' of web-programming-ability: Notepad.
And, no, I don't want to learn Flash or some other lame adobe product.
Flash is that bastard child of Director, which was only supposed to be an
animation creation package at inception. Yea, because there's nothing like
having to step back into BASIC programming to do graphic UI interfacing.
I suppose I've digressed a bit... a few times. But, the question still
stands.

How to use a variable in img tag in Django Templates

How to use a variable in img tag in Django Templates

I have started using Django templates for web programming. I am using
templates, and while giving the img src as a variable, it is not showing
the image. Even when i hard-code the image path, it is still not showing
the image. can somebody help me out here.
Below is my code snippet..
{%extends 'temp1_pr1.html'%}
{%block title%} {{t_name}} Team Sheet{%endblock%}
{%block content%}
<!-- <div
style="color:{{color_v}};width:200px;height:125px;text-align:center" >
<img src =
'D:/Train-files/Django-apps/Project1/Pr1_templates/sachin.jpg'
width = 200 height = 100 >
</div> -->
<p>
<img src =
'D:/Train-files/Django-apps/Project1/Pr1_templates/sachin.jpg'
width = 200 height = 100 >
</p>
{%if list %}
<h2> Below is the team sheet of {{t_name}} </h2>
{%for name in list %}
<h1>{{name}}</h1>
{%endfor%}
{%endif%}
{{some_content}}
{%endblock%}
In image src, i have also used src= {{variable}}, but it is also not
working. I am facing the same problem for background-image as well...

Thursday 12 September 2013

In regression, is functional confidence bound influenced by the std err of each yi?

In regression, is functional confidence bound influenced by the std err of
each yi?

I am trying to fit {(xi,yi)} to a curve y = f(x) + ep(x).
Each yi has std err SEi. I use weighted regression, wi = 1/SEi^2/Ni, where
Ni is the number of measurements used to get yi.
If I amplified each SEi by a factor of 10, the functional confidence band
of the fitted curve remains the same, because the relative weights are
still the same. However, according to intuition, the functional confidence
band should be greater now since the uncertainty SEi of each data point is
greater.
Could someone explain this?
Thanks!

Reading Excel File in C#

Reading Excel File in C#

Anyone can help me to correct my coding ? why is it I cant read my excel
file in C# ?
Did I miss anything ? need help !!! thanks in advance!
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;
using System.Data.OleDb;
namespace ReadExcel
{
public partial class Form1 : Form
{
private DataTable ReadExcelFile(string Sheet1, string path)
{
using (OleDbConnection conn = new OleDbConnection())
{
DataTable dt = new DataTable();
string Sample = @"E:\Sample.xlsx";
string fileExtension = Path.GetExtension(Sample);
if (fileExtension == ".xls")
conn.ConnectionString =
"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Sample +
";" + "Extended Properties='Excel 8.0;HDR=YES;'";
if (fileExtension == ".xlsx")
conn.ConnectionString =
"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + Sample
+ ";" + "Extended Properties='Excel 12.0 Xml;HDR=YES;'";
using (OleDbCommand comm = new OleDbCommand())
{
comm.CommandText = "Select * from [" +Sheet1 + "$]";
comm.Connection = conn;
using (OleDbDataAdapter da = new OleDbDataAdapter())
{
da.SelectCommand = comm;
da.Fill(dt);
return dt;
}
}
}
}

Generating a 4 columns by 13 row table

Generating a 4 columns by 13 row table

I am currently generating a table in the following manner:
A A1 A2 B
B C C1 D
I'd like to do:
A C
A1 C1
A2 D
B
So basically make it progress vertically with 13 rows and 4 columns.
Current code:
<table cellspacing="2px">
<?php
# display products in 4 column table #
$i=0;
while ($data=mysqli_fetch_array($result)){
if($i > 0 and $i % 4 == 0) {
echo '<tr></tr>';
}
//passing id in link to retrieve product details
echo '<td><a
href="displayProduct.php?product_id='.$data['product_id'].'"
class="myButton">'.$data['name'].'</a></td>';
$i++;
}
?>
</table>
Can someone point me in the right direction to accomplish this? I'm
shooting blanks atm.

How can I improve the performance of this huge nested loop? (Fortran 90)

How can I improve the performance of this huge nested loop? (Fortran 90)

I'll post the whole code segment here, but the only issue really is the
nested loop at the end. All read-in matrices are of dimension 180x180 and
the loop is unbearably slow. I don't see an easy way to simplify the
calculation, since the index-wise multiplications to get the matrix
"AnaInt" are no simple matrix products due to the threefold occurance of
the indices. Any thoughts? Thanks!
program AC
implicit none
integer, parameter :: dp = selected_real_kind(15, 307)
integer :: n, ndim, k, j, i, o, l, m, steps
real(dp) :: emax, omega, pi, EFermi, auev
complex(dp) :: Grs,Gas, ACCond, tinyc, cunit, czero, cone
complex(dp), allocatable :: GammaL(:,:)
complex(dp), allocatable :: GammaL_EB(:,:)
complex(dp), allocatable :: GammaR(:,:)
complex(dp), allocatable :: R(:,:)
complex(dp), allocatable :: Yc(:,:)
complex(dp), allocatable :: Yd(:,:)
complex(dp), allocatable :: AnaInt(:,:)
complex(dp), allocatable :: H(:,:)
complex(dp), allocatable :: HamEff(:,:)
complex(dp), allocatable :: EigVec(:,:)
complex(dp), allocatable :: InvEigVec(:,:)
complex(dp), allocatable :: EigVal(:)
complex(dp), allocatable :: ctemp(:,:)
complex(dp), allocatable :: ctemp2(:,:)
complex(dp), allocatable :: S(:,:)
complex(dp), allocatable :: SelfL(:,:)
complex(dp), allocatable :: SelfR(:,:)
complex(dp), allocatable :: SHalf(:,:)
complex(dp), allocatable :: InvSHalf(:,:)
complex(dp), allocatable :: HEB(:,:)
complex(dp), allocatable :: Integrand(:,:)
!Lapack arrays and variables
integer :: info, lwork
complex(dp), allocatable :: work(:)
real(dp), allocatable :: rwork(:)
integer,allocatable :: ipiv(:)
!########################################################################
!Constants
auev = 27.211385
pi = 3.14159265359
cunit = (0,1)
czero = (0,0)
cone = (1,0)
tinyc = (0.0, 0.000000000001)
!System and calculation parameters
open(unit=123, file="ForAC.dat", action='read', form='formatted')
read(123,*) ndim, EFermi
lwork = ndim*ndim
emax = 5.0/auev
steps = 1000
allocate(HEB(ndim,ndim))
allocate(H(ndim,ndim))
allocate(Yc(ndim,ndim))
allocate(Yd(ndim,ndim))
allocate(S(ndim,ndim))
allocate(SelfL(ndim,ndim))
allocate(SelfR(ndim,ndim))
allocate(HamEff(ndim,ndim))
allocate(GammaR(ndim,ndim))
allocate(GammaL(ndim,ndim))
allocate(AnaInt(ndim,ndim))
allocate(EigVec(ndim,ndim))
allocate(EigVal(ndim))
allocate(InvEigVec(ndim,ndim))
allocate(R(ndim,ndim))
allocate(GammaL_EB(ndim,ndim))
allocate(Integrand(ndim,ndim))
!################################################
read(123,*) H, S, SelfL, SelfR
close(unit=123)
HamEff(:,:)=(H(:,:) + SelfL(:,:) + SelfR(:,:))
allocate(SHalf(ndim, ndim))
allocate(InvSHalf(ndim,ndim))
SHalf(:,:) = (cmplx(real(S(:,:),dp),0.0_dp,dp))
call zpotrf('l', ndim, SHalf, ndim, info)
InvSHalf(:,:) = SHalf(:,:)
call ztrtri('l', 'n', ndim, InvSHalf, ndim, info)
call ztrmm('l', 'l', 'n', 'n', ndim, ndim, cone, InvSHalf, ndim,
HamEff, ndim)
call ztrmm('r', 'l', 't', 'n', ndim, ndim, cone, InvSHalf, ndim,
HamEff, ndim)
call ztrmm('l', 'l', 'n', 'n', ndim, ndim, cone, InvSHalf, ndim,
GammaL, ndim)
call ztrmm('r', 'l', 't', 'n', ndim, ndim, cone, InvSHalf, ndim,
GammaL, ndim)
call ztrmm('l', 'l', 'n', 'n', ndim, ndim, cone, InvSHalf, ndim,
GammaR, ndim)
call ztrmm('r', 'l', 't', 'n', ndim, ndim, cone, InvSHalf, ndim,
GammaR, ndim)
deallocate(SHalf)
deallocate(InvSHalf)
!In the PDF: B = EigVec, B^(-1) = InvEigVec, Hk = EigVal
allocate(ctemp(ndim,ndim))
ctemp(:,:) = HamEff(:,:)
allocate(work(lwork),rwork(2*ndim))
call zgeev('N', 'V', ndim, ctemp, ndim, EigVal, InvEigVec, ndim,
EigVec, ndim, work, lwork, rwork, info)
if(info/=0)write(*,*) "Warning: zgeev info=", info
deallocate(work,rwork)
deallocate(ctemp)
InvEigVec(:,:)=EigVec(:,:)
lwork = 3*ndim
allocate(ipiv(ndim))
allocate(work(lwork))
call zgetrf(ndim,ndim,InvEigVec,ndim,ipiv,info)
if(info/=0)write(*,*) "Warning: zgetrf info=", info ! LU decomposition
call zgetri(ndim,InvEigVec,ndim,ipiv,work,lwork,info)
if(info/=0)write(*,*) "Warning: zgetri info=", info ! Inversion by LU
decomposition (Building of InvEigVec)
deallocate(work)
deallocate(ipiv)
R(:,:) = 0.0_dp
do j=1,ndim
do m=1,ndim
do k=1,ndim
do l=1,ndim
R(j,m) = R(j,m) + InvEigVec(j,k) * GammaR(k,l) * conjg(InvEigVec(m,l))
end do
end do
end do
end do
!!!THIS IS THE LOOP IN QUESTION. MATRIX DIMENSION 180x180, STEPS=1000
open(unit=125,file="ACCond.dat")
!Looping over omega
do o=1,steps
omega=real(o,dp)*emax/real(steps,dp)
AnaInt(:,:) = 0.0_dp
do i=1,ndim
do n=1,ndim
do j=1,ndim
do m=1,ndim
Grs =
log((EFermi-(EigVal(j)+tinyc)+omega)/(EFermi-(EigVal(j)+tinyc)))
Gas =
log((EFermi-conjg(EigVal(m)+tinyc))/(EFermi-omega-conjg(EigVal(m)+tinyc)))
Integrand =
(Grs-Gas)/(EigVal(j)-tinyc-omega-conjg(EigVal(m)-tinyc))
AnaInt(i,n)= AnaInt(i,n) + EigVec(i,j) * R(j,m)
* Integrand(j,m) * conjg(EigVec(n,m))
end do
end do
end do
end do
Yc = 1/(2.0*pi*omega) * matmul(AnaInt,GammaL)
Yd(:,:) = - 1/(2.0*pi) * cunit * AnaInt(:,:)
ACCond = czero
do k=1,ndim
ACCond=ACCond+Yc(k,k) + 1/(2.0) * Yd(k,k)
end do
write(125,*) omega, real(ACCond,dp), aimag(ACCond)
end do
!#############################################
deallocate(Integrand)
deallocate(HEB)
deallocate(Yc)
deallocate(Yd)
deallocate(HamEff)
deallocate(GammaR)
deallocate(GammaL)
deallocate(AnaInt)
deallocate(EigVec)
deallocate(EigVal)
deallocate(InvEigVec)
deallocate(H)
deallocate(S)
deallocate(SelfL)
deallocate(SelfR)
deallocate(R)
deallocate(GammaL_EB)
end program AC

Wednesday 11 September 2013

TeraValidate contains "checksum" output

TeraValidate contains "checksum" output

I'm running TeraGen + TeraSort + TeraValidate jobs on Hadoop 1.x and
Hadoop 2.x
On TeraVal's API it says ANY output generated from the run suggests an
error occurred.
That was true on Hadoop 1.x: TeraVal created two files:
_SUCCESS (job ended successfully - even if the validation itself failed)
r-part-00000 (of size 0 if validation succeeded, otherwise its bigger than 0)
So naturally my automation scripts looked for this "r-part" file of size 0.
But now on Hadoop 2.x TeraValidate generates output also on success.
This "r-part" file contains around 24 bytes of data, which is basically
one line saying "checksum 2387cf87987sd"
What does this output mean, and does it suggest failure of the validation?

How to find Web Service is in Running status

How to find Web Service is in Running status

We are using a AXIS2 web services. When user click on button a web service
will be called, I need to show a message saying 'Please wait...' till I
get the response from web service.
How I can identify that Web service current status?
It will be appreciated for any help.
Thanks in advance!

Unordered List with checkmarks list-style-positions-outside Text aligned on the left vertically

Unordered List with checkmarks list-style-positions-outside Text aligned
on the left vertically

I am trying to have an unordered list with check-marks and have my text
line up in the left and not have my second line of text float to the left
and go under the check-marks.
Does anyone know how to make this work?
here is my page with my sample code:
http://www.pctechsupporthelp.com/ul-checkmarks-list-style-positions-outside.html
I appreciate any help with this one very much.
Best regards, Tony

Billing Invoice Service API - Which one do you recommend?

Billing Invoice Service API - Which one do you recommend?

I am new to the this and not sure why it's not reaching my controller. I
enter an ID and nothing happens, my breakpoint in the controller isn't
hit. Did I miss something?
CONTROLLER
[HttpPost]
public ActionResult Schedule(int id = 0)
{
if (Request.IsAjaxRequest())
{
Customer customer = _customerRepository.Find(id);
return PartialView("Schedule", customer);
}
return View();
}
VIEW ~/Views/Appointment/Schedule.cshtml
@model Customer
@{
ViewBag.Title = "Schedule";
}
<h2>Schedule</h2>
@using (Ajax.BeginForm("Schedule", "Appointment",
new AjaxOptions()
{
HttpMethod = "POST",
InsertionMode = InsertionMode.Replace,
UpdateTargetId = "Customer"
}))
{
<label>ID Search</label>
<input type="search" name="customerSearch" placeholder="ID" />
<input type="submit" value="Continue" />
}
<div id="Customer">
@Html.Partial("~/Views/Customer/_Customers.cshtml", Model)
</div>

Unable to set named parameter with CakePHP

Unable to set named parameter with CakePHP

I'm using the CakePHP pagination helper with a custom route however it
seems to be ignoring the page number. I believe this is because the named
parameter page doesn't exist in the request, which I've verified using
debug($this->request->params);:
array(
'plugin' => null,
'controller' => 'things',
'action' => 'index',
'named' => array(),
'pass' => array(),
'page' => '2'
)
As you can see, it's putting page outside of the named array. This is the
route I've defined for the custom pagination URLs:
Router::connect('/things/:page', array('controller' => 'skins', 'action'
=> 'index'), array('page' => '[0-9]+'));
Obviously, this means that no matter what page number I click on only the
first results show.
How can I modify the route to insert the page into the named parameters
array properly? I'd rather not directly modify
$this->request->params['named'] from the controller directly.

Best way to display only distinct value from multiple div tags with same class name

Best way to display only distinct value from multiple div tags with same
class name

How can i display only distinct value from multiple div tags with same
class name
<div class="categories">cat 1</div>
<div class="categories">cat 1</div>
<div class="categories">cat 2</div>
<div class="categories">cat 2</div>
<div class="categories">cat 2</div>
<div class="categories">cat 3</div>
<div class="categories">cat 3</div>
I would like to display only distinct value and hide the rest
cat 1
cat 2
cat 3

How to update the view of an app on ios device b from device a

How to update the view of an app on ios device b from device a

I have built a webservice that handles all data inputted and outputted for
two seperate apps yet closely related: 'Sales' app, and an 'Admin' app for
a particular company.
Every time a sales assistant takes an order over the phone and inputs it
into the sales app closing the deal the admin app should be notified that
a sale has been made. (sales are not made frequently since they are bulk
sales). The first thing that popped up in my head was to use Apple's push
notification service since this would alert the admin app if the admin was
closed. Im sure that is correct.
Here is where I start to feel uncertain. What happens in the situation
where the admin app is already open, how can the admin app be updated as
soon as a sale is made? I understand that push notifications can still be
received when the admin app is open and therefor be notified right away
when a sale is made on the 'sales' app.
Talking only in terms of when the application is open, is there a way for
when the admin application to be notified straight away as soon as a sale
has been made; without using apple's push notification service; and
without regularly refreshing the admin's app page where a webservice
function would be called at regular intervals to see if any recent sales
have been made, which i feel is not a good way forward?
Or is the correct and appropriate way to use only the push notification
service?

How to remove vertical space between divs in Bootstrap 3 grid layout?

How to remove vertical space between divs in Bootstrap 3 grid layout?

My BS3 grid layout renders as follows:

However, I don't want the space between the 1st div (yellow) and the 3rd
div (red).
Here's my code:
<div class='row'>
<div class="col-xs-12 col-sm-6"
style='background-color:yellow;height:100px'>1st div</div>
<div class="col-xs-12 col-sm-6"
style='background-color:blue;height:200px'>2nd div</div>
<div class="col-xs-12 col-sm-6"
style='background-color:red;height:100px'>3rd div</div>
</div>
Any ideas please?

Sql server - dealing with new data?

Sql server - dealing with new data?

A rock band has currently 100 songs :
select count(songName) from bands where name='Beatles'
result : 100.
I display those songs in my app via paging ( each time - 10 results)
How do I get the relevant page and its rows ?
like this : (SP)
declare @pageItems int=10
declare @pagenum int=1
select * from (SELECT [id] , row_number() over ( order by songName) as n
FROM Bands where name='Beatles') a
where a.n > (@pagenum-1)*@pageItems and a.n<= (@pagenum)*@pageItems
But there is a problem.
Suppose a user is at page 3.
And the beatles publish a new song named : "aaa"
So now , there will be a mismatch because there is a new row which is
inserted at the top ( and pushes all rows below).
I dont want to get all the rows into my app.
What is the correct way / (feature?) to get the first criteria results ?
I could use a temp table but it will be only for the current connection. (
and each time a user press "next" at paging - it's a new session).