Monday, 30 September 2013

Minimum size for a /home partition?

Minimum size for a /home partition?

Here's how my partitions are currently set up:
500 GB HDD: [21 GB Free Space] [145 GB Windows partition - unfortunately I
can't move it so it starts at the beginning of the Hard disk] [175 GB Data
partition]* [145 GB Extended partition, containing / and Swap]
SDD: [30 GB used as a cache for the HDD in Windows]
*Note that my "My Documents." "My Downloads," etc. folders are relocaed to
the data partition. The "Documents," "Downloads," etc. folders in linux
are symlinked to the same folders.



I'd like to reinstall Ubuntu and put / on the SSD. I'd also like to make
use of the 21 GB on my HDD before the windows partition. Here's what I was
thinking:
HDD: [8 GB SWAP] [13 GB /home]** [145 GB Windoze] [320 GB Data]
SDD: [30 GB / ]
**Alternatively, I could make this 21 GB and move the SWAP partition to be
after the Windows Partition.



My question is: What's the minimum size I can make my /home partition so I
will probably never run out of space, given that all of my Documents,
Downloads, and Media will be on a seperate partition?

Labeling a three-dimensional plot – mathematica.stackexchange.com

Labeling a three-dimensional plot – mathematica.stackexchange.com

As the title says, I want to add some text in a three-dimensional plot,
thus labeling specific parts of it. Here is the corresponding Mathematica
code V = 1/2*(x^2 + y^2 + z^2) + (x^2*y^2 + x^2*z^2 + …

How Do I Give My C++ Application The File Path Of The File Clicked To Open Said Application

How Do I Give My C++ Application The File Path Of The File Clicked To Open
Said Application

I have an application that uses custom file types, and I have associated
these file types with my application (Windows File System). When I double
click the file my application opens, but I would like to be able to pass
in the data from the file.
I had hoped that the file path would have been sent to main, but no such
luck. Whenever I open the application by clicking on a file 'argc' reads
'0'. Opening the application normally give 'argc' as '1'.
Is there a way to pass in the file path used to open the application?

Sunday, 29 September 2013

null pointer exception for contextWrapper.getResources()? when using custom listener

null pointer exception for contextWrapper.getResources()? when using
custom listener

getting a strange null pointer exception for a common type of custom
listener that i have implemented before without any problems.
how do i fix this problem?
from the logcat:
09-30 10:55:15.360: E/AndroidRuntime(2207): FATAL EXCEPTION: main 09-30
10:55:15.360: E/AndroidRuntime(2207): java.lang.NullPointerException 09-30
10:55:15.360: E/AndroidRuntime(2207): at
android.content.ContextWrapper.getResources(ContextWrapper.java:81) 09-30
10:55:15.360: E/AndroidRuntime(2207): at
android.widget.Toast.(Toast.java:92) 09-30 10:55:15.360:
E/AndroidRuntime(2207): at android.widget.Toast.makeText(Toast.java:233)
09-30 10:55:15.360: E/AndroidRuntime(2207): at
StartActivity.onResultReturned(StartActivity.java:124) 09-30 10:55:15.360:
E/AndroidRuntime(2207): at
jp.co.forever.tankinspectionsystem.Synchronizer.sendInt(Synchronizer.java:215)
09-30 10:55:15.360: E/AndroidRuntime(2207): at
jp.co.forever.tankinspectionsystem.Synchronizer$SendOutMsgAndPack$2.run(Synchronizer.java:162)
code for the listener in the StartActivity class, this is utility class
that does not extend activity, and all the code here runs in a new thread
run method separate from the UI thread
in class variables declarations
public OnResultReturnedListener listener;
in oncreate
listener = new StartActivity();
listener is an interface as a nested subclass in this activity class
public interface OnResultReturnedListener {
public void onResultReturned(int result);
}
code in the other class that implements the listener, all code runs on UI
main thread, no additional thread are created
public class StartActivity extends Activity
implements Synchronizer.OnResultReturnedListener {
// method onResultReturned is override for custom listerner class
// OnResultReturnedListener interface inside of the Synchronizer class
@Override
public void onResultReturned(int result) {
// toast like this or any other method that touched the
// UI thread will result in a crash
Toast.makeText(StartActivity.this, "value returned "
+ result , Toast.LENGTH_SHORT).show();
// putting the Toast in a handler will not help, still results in crash
handler.post(new Runnable() {
@Override
public void run() {
Toast.makeText(StartActivity.this, "value returned "
+ result, Toast.LENGTH_SHORT).show();
}
});
//adding a handler.post to the other class, Synchronizer,
// that the method call comes from
// will not help and still causes crashes, for example
//handler.post(new Runnable() {
//@Override
//public void run() {
//fileTransferStatus = 1;
// listener.onResultReturned(fileTransferStatus);
// }
//});
// this statement will not cause crash
int x = 13;
}
}

Hashing password to SqlServer

Hashing password to SqlServer

I've been reading over and over the code again to see where the error is
being made but I'm unable to find it. I've copied this code from
stackoverflow an never really checked it or understood it perfectly as to
fix it. I'm receiving passwords from a webservice, hashing, salting and
saving it to a SqlServer 2008. The variables on the SqlServer are declared
as mail as nvarchar(64), hash as varbinary(128) and salt as
varbinary(128). The passwords are being saved but when I try to check if
the password are correct the method always returns false. This are my
methods.
public int InsertData(string mail,string Password)
{
int lineas;
UserData usuario = HashPassword(Password);
using (SqlConnection connection = new SqlConnection(Connection))
using (SqlCommand command = connection.CreateCommand())
{
command.CommandText = "INSERT INTO Usuarios (Mail,Hash,Salt)
VALUES (@mail,@hash,@salt)";
command.Parameters.AddWithValue("@mail", mail);
command.Parameters.AddWithValue("@hash", usuario.Password);
command.Parameters.AddWithValue("@salt", usuario.salt);
connection.Open();
lineas=command.ExecuteNonQuery();
}
usuario = null;
return lineas;
}
private UserData HashPassword(string Password)
{
//This method hashes the user password and saves it into the
object UserData
using (var deriveBytes = new Rfc2898DeriveBytes(Password, 20))
{
byte[] salt = deriveBytes.Salt;
byte[] key = deriveBytes.GetBytes(20); // derive a 20-byte key
UserData usuario = new UserData();
usuario.Password = key;
usuario.salt = salt;
return usuario;
}
}
And the next method is the one I use to validate de password, it always
returns false
private bool CheckPassword(string Password, byte[] hash, byte[] salt)
{
// load salt and key from database
using (var deriveBytes = new Rfc2898DeriveBytes(Password, salt))
{
byte[] newKey = deriveBytes.GetBytes(20); // derive a 20-byte
key
if (!newKey.SequenceEqual(hash))
return false;
else
return true;
}
}
This method receives the login info
public bool ValidateLogIn(string mail, string Password)
{
using (SqlConnection connection = new SqlConnection(Connection))
using (SqlCommand command = connection.CreateCommand())
{
command.CommandText = "Select * from Usuarios where Mail=@mail";
command.Parameters.AddWithValue("@mail",mail);
connection.Open();
using (SqlDataReader reader = command.ExecuteReader())
{
reader.Read();
byte[] hash = (byte[])reader["Hash"];
byte[] salt = (byte[])reader["Salt"];
if(CheckPassword(Password,hash,salt))
{
/
UpdateData(mail, Password);
return true;
}
else
{
return false;
}
}
}
}
Any ideas what could be wrong?

When Heap and Stack memory colloids, does the program terminate?

When Heap and Stack memory colloids, does the program terminate?

Read the below definition in a book:
"As Stack and Heap share the same memory space, if they collide then the
program will terminate."
Is it true?
And how does Stack and Heap memory "Collide"?

Video src with uri adress, as 'getVideo.do?fileId=xxxxx'

Video src with uri adress, as 'getVideo.do?fileId=xxxxx'

how to programming the code? as '\' In this case, how to export filestream
to html5 video to decode for playing. i didn't find related document or
the code. please help me.

Saturday, 28 September 2013

Form won't pop up

Form won't pop up

I put a "Jotform" form inside my script and it won't pop up. When I click
no the text (other 8b white) pops up but why isn't that the case for the
yes button? I just want my form to simply show when someone clicks yes.
Here's the JSFiddle: http://jsfiddle.net/rf8Ux/
Here's the where the problem occurs:
if (q1 == "Yes") {
document.getElementById("linkDiv").innerHTML = "<script
type=text/javascript
src=http://form.jotform.us/jsform/32217646901149 />";
} else if (q1 == "No") {
document.getElementById("linkDiv").innerHTML = "other 8b white";
}
What am I doing wrong?

Separate the alphabet and digit such that their relative order remains the same in O(n) time and O(1) space

Separate the alphabet and digit such that their relative order remains the
same in O(n) time and O(1) space

Given an array [a1b7c3d2] convert to [abcd1732] with 0(1) space and O(n)
time i.e. put the letters on the left and digits on the right such that
their relative order is the same. I can think of an O(nlogn) algorithm,
but not better. Can somebody please help?

Convert huge text file into Json format

Convert huge text file into Json format

I have a question. I have a text file with format as follow
product/productId: ID
review/userId: ID
review/profileName: Name
review/helpfulness: 2/2
review/score: 5.0
review/time: 1314057600
review/summary: Text_Summary
review/text: Text1

product/productId: ID
review/userId: ID
review/profileName: Name
review/helpfulness: 0/0
review/score: 5.0
review/time: 1328659200
review/summary: Text_Summary
review/text: text

.. so on and so forth
Is there any way i can convert it to any structured data such as JSON or
CSV ? My problem here is the repetion of the column name (
product/productID, review/xxx )
Thanks in advance

PHP code to round decimals up

PHP code to round decimals up

I am using
$p1 = 66.97;
$price1 = $row['Value']*$p1;
$price1 = number_format($price1, 2, '.', '');
To do a simple calculation and then show the price to 2 decimal places.
this works fine. I would like to round the result up to the nearest .05.
So 18.93 would be 18.95, 19.57 would be 19.60 etc. Any ideas on this - I
am struggling. Thanks.

Friday, 27 September 2013

Sorting gridview - can't find column

Sorting gridview - can't find column

Relative newbie here. Discovered that I have to write an event handler to
handle sorting of my data from an objectdatasource. Found most of what I
need, but when the code runs I get the message "Cannot find column xxx"
where xxx is the name of the column I'm trying to sort on.
I've verified that e.SortExpression is returning the proper column name. I
also verified that the datatable 'dt' is not empty. Also, I'm listing most
of the gridview definition in case that's helpful.
Protected Sub GridView1_Sorting(sender As Object, e As
GridViewSortEventArgs) Handles GridView1.Sorting
Dim dt As Data.DataTable = New Data.DataTable(GridView1.DataSource)
If Not dt Is Nothing Then
dt.DefaultView.Sort = e.SortExpression
GridView1.DataSource = dt
GridView1.DataBind()
End If
End Sub
ASPX snippet:
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
DataSourceID="ObjectDataSource1" CellPadding="4"
EmptyDataText="No records found for your search" ForeColor="#333333"
GridLines="None" Width="930px" BorderColor="#CCCCCC"
Font-Size="12px" AllowSorting="True">
<AlternatingRowStyle BackColor="White" ForeColor="#284775" />
<Columns>
<asp:BoundField DataField="CustName" HeaderText="CustName"
SortExpression="CustName" />
<asp:BoundField DataField="CustType" HeaderText="CustType"
SortExpression="CustType"
HeaderStyle-HorizontalAlign="Center"
ItemStyle-HorizontalAlign="Center" />
<asp:TemplateField HeaderText="Address" SortExpression="Addr1">
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%#
Bind("Addr1") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="TextBox1" runat="server" Text='<%#
Bind("Addr1") %>'></asp:TextBox>
</EditItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="Phone" HeaderText="Phone"
SortExpression="Phone" />
<asp:BoundField DataField="ContactName" HeaderText="ContactName"
SortExpression="ContactName" />
<asp:BoundField DataField="LastContactDate"
HeaderText="LastContact" SortExpression="LastContactDate"
dataformatstring="{0:d}" />
<asp:BoundField DataField="CustSince" HeaderText="CustSince"
SortExpression="CustSince"
dataformatstring="{0:MM/dd/yyyy}" />
<asp:BoundField DataField="Status" HeaderText="Status"
SortExpression="Status" ItemStyle-HorizontalAlign="Center"
HeaderStyle-HorizontalAlign="Center" />
<asp:BoundField DataField="Source" HeaderText="Source"
SortExpression="Source" />
<asp:BoundField DataField="RelMgr" HeaderText="RelMgr"
SortExpression="RelMgr" />
<asp:TemplateField HeaderText="RelMgrInfo">
<ItemTemplate>
<asp:HyperLink ID="RelMgrEmailLink" runat="server"
NavigateUrl='<%#Eval("RelMgrEmail", "mailto:{0}")%>'
Text='<%# Eval("RelMgrEmail") + "<br>" +
Eval("RelMgrPhone")%> '> </asp:HyperLink>
</ItemTemplate>
</asp:TemplateField>
</Columns>
Thanks!

MySQL Latest Timestamp + Other Field with Group By

MySQL Latest Timestamp + Other Field with Group By

I have a table that stores events and timestamps as they relate to tasks
being performed. A "report" task is a collection of "tests," each with its
own set of events and associated timestamps.
The structure is as follows:

reportID
testID
eventDateTime
eventType
Each eventType is something like "Start", "Pause", "Finish", etc. What I'm
trying to do is write a query that will tell me the last action taken on a
given reportID/testID combination and its timestamp.
My preliminary query is:

SELECT reportID, MAX(eventDateTime), eventType
FROM testtracker_event
GROUP BY reportID, testID
The result is very close to what I want, and I'm getting the latest
eventDateTime (which I want), but it's returning the first eventType (as
opposed to the eventType associated with the most recent timestamp.)
I realize similar questions have been asked, but I've searched and
searched and this seems much simpler than any similar questions I've
found. I want to believe this is possible without a subquery or join but
I'm getting the idea based on answers to similar questions with more
complicated logic that it's not.

Configure Eclipse logging for Exceptions and Errors

Configure Eclipse logging for Exceptions and Errors

Is there a good way, either by configuring the built-in console or using a
plugin, to configure and filter the logging output for Exceptions and
Errors and their stacktraces in Eclipse?
Example problem this would help with:
I use a web framework where Exceptions in the business logic always result
in a StackOverflowError ultimately being thrown by the framework when a
page is rendered, because the page rendering relied on that logic running
successfully.
This means when a problem occurs in the business logic, the Exception
stacktrace I want to look at can only be found by scrolling up above a
massive StackOverflowError stacktrace, which always occurs last and
contains no useful information.
I'd like to have the option to do one or more of the following
Do not log anything for StackOverflowErrors
Log only the fact a StackOverflowError has been thrown, with no stacktrace
limit the logging of StackOverflowError stacktrace to the top few lines
The dialog I get to from Right Click > Preferences in the console on
Eclipse Kepler does not offer any of the above.

Maximum value by ID return in excel

Maximum value by ID return in excel

I'm trying to only use the maximum value among IDs in my final table.
Ie:
I have data like this:
ID VALUE
1 237
1 255
2 365
2 322
2 209
3 113
and I want to return this:
ID VALUE
1 255
2 365
3 113

PHP SQL Select all where date is present of future only

PHP SQL Select all where date is present of future only

I know this code works:
$eventdate = new DateTime($event['date']);
$datenow = new DateTime();
if($eventdate->format('Y-m-d') < $datenow->format('Y-m-d')) ....
I need to do something similar in an SQL query.
Something like:
SELECT * FROM MyTable WHERE `date` = `$eventdate` or Future Date
How can I do this?

Thursday, 26 September 2013

How to import code from x code 5?

How to import code from x code 5?

I have started using new x code 5. I have added one new repository from
that. Now i want to import new code from my local directory to that remote
repository. I know how to do that in X code 4. But i am not fining any
option in new X code. Thanks in advance

Thursday, 19 September 2013

How to declare a variable named 'type' in Play/Scala?

How to declare a variable named 'type' in Play/Scala?

I want to declare a variable with name 'type' in a Play/Scala application,
since my data has this field name and I'm using JSON transforms. It just
makes more sense.
Fortunately I could just rename the field, but still curious if there is a
way to make the compiler ignore the type reserved word when declaring
variables.
Thank you!

Getting an odd result: mysqli_fetch_array() expects parameter 1 to be mysqli_result

Getting an odd result: mysqli_fetch_array() expects parameter 1 to be
mysqli_result

I keep getting weird results from this query.
Not that I am not using PDA because this is just a prototype. In
production I plan on tightening all of the screws and making it more
secure.
include ('../includes/DBConnect.php'); //exactly how it is in other
working files
$query = "SELECT * FROM CHARACTERS WHERE USER_ID=(SELECT ID FROM USERS
WHERE EMAIL='"+$_SESSION['user']+"') ORDER BY id DESC"; //I have copy
pasted this into mysql and it worked, switching the session variable with
a string
I get an error with the this line
while($row = mysqli_fetch_array($character_list)){
Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result,
boolean given in C:\xampp\htdocs\Node2\public\main.php on line 36
I know this has to be stupid. I can't figure it out. I just looked at
documentation and other files I have written that worked. And a few stack
overflow threads to no avail.
Thank you so much.

With handlebars.js, is it ok to call nested object properties that my be undefined?

With handlebars.js, is it ok to call nested object properties that my be
undefined?

I noticed that defining the following in my Handlebars.js templates works
fine:
<input name="username" value="{{user.name}}">
This works even when:
user is undefined; and/or
user.name is undefined
However, I'm questioning how appropriate it is to do this. What's going on
in the background? Wouldn't the following be more appropriate, albeit
adding more cluttering?
<input name="username" value="{{#if user}}{{#if
user.name}}{{user.name}}{{/if}}{{/if}}">
Thanks.

Jquery swip to proceed to next page

Jquery swip to proceed to next page

I use this function to enable swipe for navigation on my website.
Now it needs to read and proceed to the url with the class 'next'
<li class="next"><a href="/webcams/tirol/2/a/b">Next</a></li>
Here I need you help to create that.
$(function () {
$(document).on('mousedown', 'div', function (e) {
var ref = arguments.callee;
var handle = $(this);
var startX = e.clientX;
var startY = e.clientY;
handle.off('mousedown', ref);
handle.on('mouseup', function(e) {
handle.off('mouseup', arguments.callee);
handle.on('mousedown', ref);
var endX = e.clientX;
var endY = e.clientY;
var distanceX = Math.abs(endX - startX);
var distanceY = Math.abs(endY - startY);
if (distanceX > 50) {
handle.trigger((endX > startX) ? 'swipeRight' : 'swipeLeft');
}
if (distanceY > 50) {
handle.trigger((endY > startY) ? 'swipeDown' : 'swipeUp');
}
e.preventDefault();
return false;
});
});
$(document).on('swipeRight', 'div', function(e) {
});
$(document).on('swipeLeft', 'div', function(e) {
});
$(document).on('swipeUp', 'div', function(e) {
});
$(document).on('swipeDown', 'div', function(e) {
});
});

too much space between lines in a table

too much space between lines in a table

i have this code on jsfiddle www.jsfiddle.net/9EL5f/ and i have problems
with text align: as you can see there is a lot of space between the lines!
Why?
css
table {
width: 700px;
margin-left: 130px;
margin-right: 130px;
}
tr {
width: 500px;
float: center;
}
td {
display: table-cell;
width: 300px;
height: 100%;
padding: auto 30px auto 30px;
font-family: verdana,arial,sans-serif;
font-size:13px;
color:red;
line-height: -3;
text-align: right;
}
How can i solve this problem?

Is there any way in Elasticsearch to get results as CSV file in curl api?

Is there any way in Elasticsearch to get results as CSV file in curl api?

I am using elastic search. I need results from elastic search as a csv
file. Any curl url or any plugins to achieve this? Thanks in advance.

How to convert jar file into apk?

How to convert jar file into apk?

I have one jar file, when I clicked that jar file, it was opened one
window based application.
Now I would like to convert this jar file into apk file. That jar file
having 5 class files. How can I know the initial class file? and How could
I code on this in android?
Please do the needful.
Thanks in advance.

Wednesday, 18 September 2013

Why does my libGDX resize code break camera.unproject?

Why does my libGDX resize code break camera.unproject?

I'm using the following code in my resize method to maintain aspect ratio
across multiple screen sizes:
@Override
public void resize(int width, int height)
{
float aspectRatio = (float)width / (float)height;
float scale = 1f;
Vector2 crop = new Vector2(0, 0);
if (aspectRatio > globals.ASPECT_RATIO)
{
scale = (float)height / (float)globals.VIRTUAL_HEIGHT;
crop.x = (width - globals.VIRTUAL_WIDTH * scale) / 2f;
}
else if (aspectRatio < globals.ASPECT_RATIO)
{
scale = (float)width / (float)globals.VIRTUAL_WIDTH;
crop.y = (height - globals.VIRTUAL_HEIGHT * scale) / 2f;
}
else
{
scale = (float)width / (float)globals.VIRTUAL_WIDTH;
}
float w = (float)globals.VIRTUAL_WIDTH * scale;
float h = (float)globals.VIRTUAL_HEIGHT * scale;
viewport = new Rectangle(crop.x, crop.y, w, h);
}
VIRTUAL_WIDTH, VIRTUAL_HEIGHT and ASPECT_RATIO are set as follows:
public final int VIRTUAL_WIDTH = 800;
public final int VIRTUAL_HEIGHT = 480;
public final float ASPECT_RATIO = (float)VIRTUAL_WIDTH /
(float)VIRTUAL_HEIGHT;
This works perfectly with regards to maintaining the correct ratio when
the screen size changes. However, camera.uproject (which I call before all
touch events) doesn't work properly - touch positions are not correct when
the resize code changes the screen size to anything other than 800x480.
Here's how I setup my camera in my create() method:
camera = new OrthographicCamera(globals.VIRTUAL_WIDTH,
globals.VIRTUAL_HEIGHT);
camera.setToOrtho(true, globals.VIRTUAL_WIDTH, globals.VIRTUAL_HEIGHT);
And this is the start of my render() method:
camera.update();
Gdx.graphics.getGL20().glViewport((int)viewport.x, (int)viewport.y,
(int)viewport.width, (int)viewport.height);
Gdx.graphics.getGL20().glClearColor(0, 0, 0, 1);
Gdx.graphics.getGL20().glClear(GL20.GL_COLOR_BUFFER_BIT);
If I ignore the resize code and set the glViewport method call to
Gdx.graphics.getWidth() and Gdx.graphics.getHeight(), camera.unproject
works, but I obviously lose the maintaining of the aspect ratio. Anyone
have any ideas?
Here's how I perform the unproject on my touch events:
private Vector3 touchPos = new Vector3(0, 0, 0);
public boolean touchDown (int x, int y, int pointer, int newParam)
{
touchPos.x = x;
touchPos.y = y;
touchPos.z = 0;
camera.unproject(touchPos);
//touch event handling goes here...
}

Facebook Graph - What is the limit to send private messages from page to users?

Facebook Graph - What is the limit to send private messages from page to
users?

I am developing a chat robot that works with private messages on facebook.
The person sends a private message to a page that I own, and then I will
send an answer for each message.
Everything is working, but I need to be sure facebook won't complain about
the amount of messages I will send. This application will receive a lot of
interactions at the same time, but in some early tests one of my messages
were received like that:
http://cl.ly/image/1C1n0Z2L0R05
I am now using Batch Requests to send all messages, on an interval of 15s.
Do someone know some way to test it with multiple users and multiple
messages at the same time? How the process of identification of spam
messages work on facebook? How much messages can I send at the same time
and in what time range to prevent that kind of behavior?
Thanks.

Java Class Saved with another name?

Java Class Saved with another name?

enter code here
class Blog{
public static void main(String args[]){
System.out.println("overflow");
}
}
I am saving this file with name First.java and compiling it than it is
generating file with Blog.class and gives output:-overflow
If same program i am writing as given below:-
public class Blog{
public static void main(String args[]){
System.out.println("overflow");
}
}
it gives error after compiling
First.java:3: error: class Blog is public, should be declared in a file
named Blog.java
public class Java{
^

c++ : game of life?

c++ : game of life?

i am asked to create a base class named Cell from which two are derived a
ConwayCell and FredkinCell. i'm having a problem implementing a function
that calculates the number of alive neighboring cells given that the only
member variable is a character cell ( ' * ' or ' . ' ) provided with a
bool function that determines whether a cell is alive or dead respectively
and a function that prints the cell. is there a way to implement that
function without using an array?(c++ beginner) this is a class that
defines the behaiviour of a single cell.

Copying autofilter data to another column

Copying autofilter data to another column

The below code filtered the data based on column S & T. Then it writes the
"Resub UW" on visible data. Currently I am trying to copy the visible date
data in column K to the visible empty data in column AO. If anyone can
help me with this code.
`Sub ReSubmitted_UW()
Rows("1:1").Select
Selection.AutoFilter
With ActiveSheet
.Range("$A:$AN").AutoFilter Field:=19, Criteria1:="<>"
.Range("$A:$AN").AutoFilter Field:=20, Criteria1:="="
lastRow = .Range("F" & Rows.Count).End(xlUp).Row
If lastRow > 2 Then
.Range(.Range("E2"), .Range("E" & lastRow)). _
SpecialCells(xlCellTypeVisible).Value = "ReSub UW"
End If
.Range("$A:$AN").AutoFilter
End With
End Sub
`

Error with OnClickListener in my gallery

Error with OnClickListener in my gallery

Hi I have problem with ImageButton "strzalkaLewo" when i
setOnClickListener i have this error in logCat:
enter
pozycjaZdjecia = bundle.getInt("zdjecie");
imgPath = ExternalStorageDirectoryPath
+ "/DailyPhotos/"+nazwa_projektu;
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.pokaz_slajdow);
strzalkaLewo = (ImageButton) findViewById(R.id.strzalkal);
strzalkaLewo.setOnClickListener(new OnClickListener(){
@Override
public void onClick(View v) {
Toast.makeText(getApplicationContext(), "msg msg",
Toast.LENGTH_SHORT).show();
}
});
photoList = readFileList();
imageSwitcher = (ImageSwitcher)findViewById(R.id.switcher);
imageSwitcher.setFactory(this);
/*
*
*/
imageSwitcher.setInAnimation(AnimationUtils.loadAnimation(this,
android.R.anim.fade_in));
imageSwitcher.setOutAnimation(AnimationUtils.loadAnimation(this,
android.R.anim.fade_out));
imageSwitcher.setOnTouchListener(touchListener);
gallery = (Gallery)findViewById(R.id.gallery);
gallery.setAdapter(new ImageAdapter( photoList,this));
gallery.setOnItemSelectedListener(new
AdapterView.OnItemSelectedListener() {
public void onItemSelected(AdapterView<?> arg0, View arg1,
int position, long when) {
newFilePath = photoList.get(position);
Bitmap bm =
decodeSampledBitmapFromUri(photoList.get(position), 480,
360);
//Toast.makeText(getApplicationContext(), "msg msg",
Toast.LENGTH_SHORT).show();
// Bitmap bm = BitmapFactory.decodeFile(photoList.get(position));
BitmapDrawable bd = new BitmapDrawable(bm);
imageSwitcher.setImageDrawable(bd);
}
public void onNothingSelected(AdapterView<?> arg0) {}
});
gallery.setSelection(pozycjaZdjecia, true);
}
Also I use OnTouchListener to switch between images:
enter private OnTouchListener touchListener = new View.OnTouchListener() {
public boolean onTouch(View v, MotionEvent event) {
if(event.getAction()==MotionEvent.ACTION_DOWN) //lokalizacja
poczatkowa.
{
downX=(int) event.getX();//
return true;
}
else if(event.getAction()==MotionEvent.ACTION_UP)
//lokalizacja zakonczona
{
upX=(int) event.getX();//
int index = 0;
if(upX-downX>60)//?
{
//?
if(gallery.getSelectedItemPosition()==0)
index=gallery.getCount()-1;
else
index=gallery.getSelectedItemPosition()-1;
}
else if(downX-upX>60)//?
{
//?
if(gallery.getSelectedItemPosition()==(gallery.getCount()-1))
index=0;
else
index=gallery.getSelectedItemPosition()+1;
}
LogCat:
09-18 11:52:18.888: E/AndroidRuntime(6397): FATAL EXCEPTION: main
09-18 11:52:18.888: E/AndroidRuntime(6397): java.lang.NullPointerException
09-18 11:52:18.888: E/AndroidRuntime(6397): at
com.example.dailyphotos.GaleriaImg$1.onTouch(GaleriaImg.java:133)
09-18 11:52:18.888: E/AndroidRuntime(6397): at
android.view.View.dispatchTouchEvent(View.java:7122)
09-18 11:52:18.888: E/AndroidRuntime(6397): at
android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2170)
09-18 11:52:18.888: E/AndroidRuntime(6397): at
android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1905)
09-18 11:52:18.888: E/AndroidRuntime(6397): at
android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2176)
09-18 11:52:18.888: E/AndroidRuntime(6397): at
android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1877)
09-18 11:52:18.888: E/AndroidRuntime(6397): at
android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2176)
09-18 11:52:18.888: E/AndroidRuntime(6397): at
android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1877)
09-18 11:52:18.888: E/AndroidRuntime(6397): at
android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2176)
09-18 11:52:18.888: E/AndroidRuntime(6397): at
android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1877)
09-18 11:52:18.888: E/AndroidRuntime(6397): at
android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2176)
09-18 11:52:18.888: E/AndroidRuntime(6397): at
android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1877)
09-18 11:52:18.888: E/AndroidRuntime(6397): at
com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:1925)
09-18 11:52:18.888: E/AndroidRuntime(6397): at
com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1379)
09-18 11:52:18.888: E/AndroidRuntime(6397): at
android.app.Activity.dispatchTouchEvent(Activity.java:2396)
09-18 11:52:18.888: E/AndroidRuntime(6397): at
com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:1873)
09-18 11:52:18.888: E/AndroidRuntime(6397): at
android.view.View.dispatchPointerEvent(View.java:7307)
09-18 11:52:18.888: E/AndroidRuntime(6397): at
android.view.ViewRootImpl.deliverPointerEvent(ViewRootImpl.java:3172)
09-18 11:52:18.888: E/AndroidRuntime(6397): at
android.view.ViewRootImpl.deliverInputEvent(ViewRootImpl.java:3117)
09-18 11:52:18.888: E/AndroidRuntime(6397): at
android.view.ViewRootImpl.doProcessInputEvents(ViewRootImpl.java:4153)
09-18 11:52:18.888: E/AndroidRuntime(6397): at
android.view.ViewRootImpl.enqueueInputEvent(ViewRootImpl.java:4132)
09-18 11:52:18.888: E/AndroidRuntime(6397): at
android.view.ViewRootImpl$WindowInputEventReceiver.onInputEvent(ViewRootImpl.java:4224)
09-18 11:52:18.888: E/AndroidRuntime(6397): at
android.view.InputEventReceiver.dispatchInputEvent(InputEventReceiver.java:171)
09-18 11:52:18.888: E/AndroidRuntime(6397): at
android.os.MessageQueue.nativePollOnce(Native Method)
09-18 11:52:18.888: E/AndroidRuntime(6397): at
android.os.MessageQueue.next(MessageQueue.java:125)
09-18 11:52:18.888: E/AndroidRuntime(6397): at
android.os.Looper.loop(Looper.java:124)
09-18 11:52:18.888: E/AndroidRuntime(6397): at
android.app.ActivityThread.main(ActivityThread.java:4745)
09-18 11:52:18.888: E/AndroidRuntime(6397): at
java.lang.reflect.Method.invokeNative(Native Method)
09-18 11:52:18.888: E/AndroidRuntime(6397): at
java.lang.reflect.Method.invoke(Method.java:511)
09-18 11:52:18.888: E/AndroidRuntime(6397): at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
09-18 11:52:18.888: E/AndroidRuntime(6397): at
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
09-18 11:52:18.888: E/AndroidRuntime(6397): at
dalvik.system.NativeStart.main(Native Method)

Tuesday, 17 September 2013

How to detect/intercept application life cycle events without using the conventional activity life cycle events

How to detect/intercept application life cycle events without using the
conventional activity life cycle events

I wanted to know are there any legal ways to get information about the
activity/application life cycle events from a back ground service / Thread
. Actually , I have a library project where i want to intercept these
calls so that i handle the scenarios when the app using my library goes in
back ground or comes up in life again .
This problem arises because my library does not provide any activities by
default , it intern returns view objects so that the app devs can use the
same in their activities .
So i have no access to the activity life cycle callbacks .
One Possible ways is this :
I make a listener registered to each of the activity created by the app
devs and listener callbacks are needed to called from the onResume ,
onPause() by the app dev , By this way i can have this callbacks
intercepted by a back ground service and hence i will be able to control
the application behavior in onResume , onPause etc .
I wanted to know is there any other efficient/better way to handle this
use case .
Thanks

about jquery ajax it work but don't send data in form

about jquery ajax it work but don't send data in form

the function than i use in my work
$(function(){
$('#group2').change(function(){
var url='jtsprocess2.php';
var dataSet={ go2: $('#group2').val() };
$.post(url,dataSet,function(data){
//alert(data);
$('#all6').html(data);
});
});
});
i call out at tag : <tr id=all6></tr>
it send databack to first page but when i submit form it doesn't go. other
value in form go but not this function.

how do I run doxywizard?

how do I run doxywizard?

I have successfully downloaded and installed doxygen. I am trying to run
doxygen but am a little overwhelmed by the configuration file. I see that
there is a utility called doxywizard that guides you through the creation
of a configuration file. How do I run this wizard? I see that there is a
folder called Doxywizard. Do I run one of the files in this folder?

HTML KickStart - restore default style for input fields

HTML KickStart - restore default style for input fields

The HTML KickStart framework has a nice default theme. However, I would
like to restore the default style for input fields. How do I go about this
by overwriting the kickstart theme?? THanks

InvalidOperationException when using String.compare in foreach loop

InvalidOperationException when using String.compare in foreach loop

I simply want to compare a list of strings to a certain value. Here's my
code:
foreach (string s in myList)
{
int comp = String.Compare(s, line_to_delete);
if (comp == 0)
{
myList.Remove(s);
}
}
The thing is that whenever I use 'comp == 1' I get no exception, but I
want it to check if the strings are the same..

Regex to split string

Regex to split string

I have this code which prints:
[( ?Random =
<http://www.semanticweb.org/vassilis/ontologies/2013/5/Test#Hello> ), (
?Random = <http://www.semanticweb.org/vassilis/ontologies/2013/5/Test#Bye>
)]
I tried to split at [#] but it didnt work.
What should i put in split so that I can get as a result the part after #
only: Hello, Bye
Scanner input = new Scanner(System.in);
final String inputs;
inputs = input.next();
final String[] indices = inputs.split("\\s*,\\s*");
final List<QuerySolution> selectedSolutions = new ArrayList<QuerySolution>(
indices.length) {
{
final List<QuerySolution> solutions = ResultSetFormatter
.toList(results2);
for (final String index : indices) {
add(solutions.get(Integer.valueOf(index)));
}
}
};
System.out.println(selectedSolutions);

Sunday, 15 September 2013

How to perform replay attack?

How to perform replay attack?

I wish to write a program that takes the packet capture file, the URL of
my website, and launches a replay attack on my website to access the
restricted content as the legitimate user. Please guide me through this.
And if I had to implement it as a browser add-on how do I get about that?

A good approach for handling overriding multiple CSS backgrounds?

A good approach for handling overriding multiple CSS backgrounds?

I love that CSS3 has introduced multiple background images... but the
method of just having comma-separated images is kind of, well, not very
cascading, if you know what I mean.
Is there any approach out there to take this:
.a {
background: url(a.png) no-repeat center center;
}
.b {
background: url(b.png) repeat-x 0 bottom;
}
And apply it to an element such as this:
<div class="a b"></div>
Such that the computed style is:
background-image: url(a.png), url(b.png);
background-repeat: no-repeat, repeat-x;
background-position-x: center, 0;
background-position-y: center, bottom;
(I get that if the above CSS did this, it would be wrong. But it'd be
great if there were a solution like a property background-add or
something.)
I'm looking for any hope of a future solution to this... a spec, a
solution that only works in some browsers, the use of jQuery, whatever...
because there are a couple of other similar issues with the CSS3 spec as
well. For instance, you can't separate out the properties of text-shadow,
etc. It's rather frustrating.
Thanks....

Android won't install freshly created appliction

Android won't install freshly created appliction

today I made Android application without writing any code. I just made new
application and when I started it via the emulator and the installation
failed. My emulator is higher version than the minimum SDK.
Minimum SDK: 8
Emulator SDK 18
My friend tested it on his phone and it failed again. So the problem is in
the application. I have no errors/warnings. The phone just prints:
App not installed.
PS: I am using Eclipse.

php - custom variable href value does not work

php - custom variable href value does not work

I am editing the code page of a wordpress post.
Now here is the full page code:
<?php
add_action( 'init', 'create_recipes' );
function create_recipes() {
//$portfolio_translation =
get_option(THEME_NAME_S.'_cp_portfolio_slug','portfolio');
$labels = array(
'name' => _x('Recipes', 'Recipe General Name', 'crunchpress'),
'singular_name' => _x('Recipe Item', 'Recipe Singular Name',
'crunchpress'),
'add_new' => _x('Add New', 'Add New Event Name', 'crunchpress'),
'add_new_item' => __('Add New Recipe', 'crunchpress'),
'edit_item' => __('Edit Recipe', 'crunchpress'),
'new_item' => __('New Recipe', 'crunchpress'),
'view_item' => __('View Recipe', 'crunchpress'),
'search_items' => __('Search Recipe', 'crunchpress'),
'not_found' => __('Nothing found', 'crunchpress'),
'not_found_in_trash' => __('Nothing found in Trash',
'crunchpress'),
'parent_item_colon' => ''
);
$args = array(
'labels' => $labels,
'public' => true,
'publicly_queryable' => true,
'show_ui' => true,
'query_var' => true,
'menu_icon' => CP_PATH_URL . '/framework/images/recipe-icon.png',
'rewrite' => true,
'capability_type' => 'post',
'hierarchical' => false,
'menu_position' => 5,
'supports' =>
array('title','editor','author','thumbnail','excerpt','comments'),
'rewrite' => array('slug' => 'recipes', 'with_front' => false)
);
register_post_type( 'recipes' , $args);
register_taxonomy(
"recipe-category", array("recipes"), array(
"hierarchical" => true,
"label" => "Recipe Categories",
"singular_label" => "Recipe Categories",
"rewrite" => true));
register_taxonomy_for_object_type('recipe-category', 'recipes');
register_taxonomy(
"recipe-tag", array("recipes"), array(
"hierarchical" => false,
"label" => "Recipe Tag",
"singular_label" => "Recipe Tag",
"rewrite" => true));
register_taxonomy_for_object_type('recipe-tag', 'recipes');
}
add_action('add_meta_boxes', 'add_recipes_option');
function add_recipes_option(){
add_meta_box('recipe-option', __('Recipes Options','crunchpress'),
'add_recipe_option_element',
'recipes', 'normal', 'high');
}
function add_recipe_option_element(){
$recipe_price = '';
$recipe_social = '';
$sidebars = '';
$right_sidebar_recipe = '';
$left_sidebar_recipe = '';
$recipe_detail_xml = '';
$select_chef = '';
$recipe_url = '';
foreach($_REQUEST as $keys=>$values){
$$keys = $values;
}
global $post;
$recipe_detail_xml = get_post_meta($post->ID, 'recipe_detail_xml', true);
$ingredients_settings = get_post_meta($post->ID,
'ingredients_settings', true);
$nutrition_settings = get_post_meta($post->ID, 'nutrition_settings',
true);
if($recipe_detail_xml <> ''){
$cp_recipe_xml = new DOMDocument ();
$cp_recipe_xml->loadXML ( $recipe_detail_xml );
$recipe_price =
find_xml_value($cp_recipe_xml->documentElement,'recipe_price');
$recipe_url =
find_xml_value($cp_recipe_xml->documentElement,'recipe_url');
$recipe_social =
find_xml_value($cp_recipe_xml->documentElement,'recipe_social');
$sidebars =
find_xml_value($cp_recipe_xml->documentElement,'sidebars');
$left_sidebar_recipe =
find_xml_value($cp_recipe_xml->documentElement,'left_sidebar_recipe');
$right_sidebar_recipe =
find_xml_value($cp_recipe_xml->documentElement,'right_sidebar_recipe');
}
?>
<div class="event_options">
<ul class="recipe_class top-bg">
<li><h2>Recipe Options and Social Sharing</h2></li>
</ul>
<ul class="recipe_class">
<li class="panel-title">
<label for="recipe_social" > <?php _e('SOCIAL
NETWORKING', 'crunchpress'); ?> </label>
</li>
<li class="panel-input">
<label for="recipe_social"><div class="checkbox-switch
<?php
echo ($recipe_social=='enable' || ($recipe_social==''
&& empty($default)))? 'checkbox-switch-on':
'checkbox-switch-off';
?>"></div></label>
<input type="checkbox" name="recipe_social"
class="checkbox-switch" value="disable" checked>
<input type="checkbox" name="recipe_social"
id="recipe_social" class="checkbox-switch" value="enable"
<?php
echo ($recipe_social=='enable' || ($recipe_social==''
&& empty($default)))? 'checked': '';
?>>
</li>
<li class="description"><p>Turn On/Off Social Sharing on
Event Detail.</p></li>
</ul>
<div class="clear"></div>
<ul class="recipe_class">
<li class="panel-title">
<label for="recipe_price" > <?php _e('RECIPE PRICE',
'crunchpress'); ?> </label>
</li>
<li class="panel-input">
<input type="text" name="recipe_price"
id="recipe_price" value="<?php if($recipe_price <>
''){echo $recipe_price;};?>" />
</li>
<li class="description"><p>Please enter your recipe
price.</p></li>
</ul>
<div class="clear"></div>
<!--david-->
<ul class="recipe_class">
<li class="panel-title">
<label for="recipe_url" > <?php _e('RECIPE URL',
'crunchpress'); ?> </label>
</li>
<li class="panel-input">
<input type="text" name="recipe_url" id="recipe_url"
value="<?php if($recipe_url <> ''){echo
$recipe_url;};?>" />
</li>
<li class="description"><p>Please enter your url</p></li>
</ul>
<div class="clear"></div>
<!--david end-->
<?php echo
show_sidebar($sidebars,'right_sidebar_recipe','left_sidebar_recipe',$right_sidebar_recipe,$left_sidebar_recipe);?>
<ul class="recipe_class">
<li class="panel-title">
<label><?php _e('Add Ingredients', 'crunchpress');
?></label>
</li>
<li class="panel-input">
<input type="text" id="add-more-ingre" value="type
title here" rel="type title here">
<div id="add-more-ingre" class="add-more-ingre"></div>
</li>
<li class="description"><p>Add Ingredients for this
recipe.</p></li>
<div class="clear"></div>
<ul class="nut_table">
<li>
<div>SrNo</div>
<div>Name</div>
<div class="panel-delete-cc">&nbsp;</div>
</li>
</ul>
<ul id="selected-ingre" class="selected-ingre
nut_table_inner">
<li class="default-ingre-item" id="ingre-item">
<div class="ingre-item-counter"></div>
<div class="ingre-item-text"></div>
<div class="panel-delete-ingre"></div>
<input type="hidden" id="ingredients">
</li>
<?php
//Sidebar addition
if($ingredients_settings <> ''){
$ingre_xml = new DOMDocument();
$ingre_xml->loadXML($ingredients_settings);
$counter = 0;
foreach( $ingre_xml->documentElement->childNodes as
$ingre_name ){
$counter++;
?>
<li class="ingre-item" id="ingre-item">
<div class="ingre-item-counter"><?php echo
$counter;?></div>
<div class="ingre-item-text"><?php echo
$ingre_name->nodeValue; ?></div>
<div class="panel-delete-ingre"></div>
<input type="hidden" name="ingredients[]"
id="ingredients" value="<?php echo
$ingre_name->nodeValue; ?>">
</li>
<?php }
}
?>
</ul>
</ul>
<div class="clear"></div>
<ul class="recipe_class">
<li class="panel-title">
<label> <?php _e('Add Nutrition', 'crunchpress'); ?>
</label>
</li>
<li class="panel-input">
<input type="text" id="add-more-nutrition" value="type
title here" rel="type title here">
<div id="add-more-nutrition"
class="add-more-nutrition"></div>
</li>
<li class="description"><p>Add Nutrition for this
recipe.</p></li>
<div class="clear"></div>
<ul class="nut_table">
<li>
<div>SrNo</div>
<div>Name</div>
<div class="panel-delete-cc">&nbsp;</div>
</li>
</ul>
<br class="clear">
<ul id="selected-nutrition" class="selected-nutrition
nut_table_inner">
<li class="default-nutrition-item" id="nutrition-item">
<div class="nut-item-counter"></div>
<div class="nutrition-item-text"></div>
<div class="panel-delete-nutrition"></div>
<input type="hidden" id="nutrition">
</li>
<?php
//Sidebar addition
if($nutrition_settings <> ''){
$ingre_xml = new DOMDocument();
$ingre_xml->loadXML($nutrition_settings);
$counter = 0;
foreach( $ingre_xml->documentElement->childNodes as
$ingre_name ){
$counter++;
?>
<li class="nutrition-item" id="nutrition-item">
<div class="nut-item-counter"><?php echo
$counter;?></div>
<div class="nutrition-item-text"><?php echo
$ingre_name->nodeValue; ?></div>
<div class="panel-delete-nutrition"></div>
<input type="hidden" name="nutrition[]"
id="nutrition" value="<?php echo
$ingre_name->nodeValue; ?>">
</li>
<?php }
}
?>
</ul>
</ul>
<div class="clear"></div>
<ul class="recipe_class">
<li class="panel-title">
<label for="select_chef"><?php _e('SELECT CHEF',
'crunchpress'); ?></label>
</li>
<li class="panel-input">
<div class="combobox">
<select name="select_chef" id="select_chef">
<option>-- Select Chef --</option>
<?php
foreach(get_title_list_array('teams') as
$our_team){?>
<option <?php if($select_chef ==
$our_team->post_name){echo 'selected';}?>
value="<?php echo
$our_team->post_name;?>"><?php echo
$our_team->post_title?></option>
<?php }?>
</select>
</div>
</li>
<li class="description"><p>Please select Chef of this
recipe.</p></li>
</ul>
<div class="clear"></div>
<input type="hidden" name="nutrition_type" value="nutrition">
<div class="clear"></div>
</div>
<div class="clear"></div>
<?php }
add_action('save_post','save_recipe_option_meta');
function save_recipe_option_meta($post_id){
$recipe_social = '';
$sidebars = '';
$right_sidebar_recpie = '';
$left_sidebar_recpie = '';
foreach($_REQUEST as $keys=>$values){
$$keys = $values;
}
if(defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE) return;
if(isset($nutrition_type) AND $nutrition_type == 'nutrition'){
$new_data = '<recipe_detail>';
$new_data = $new_data . create_xml_tag('recipe_price',$recipe_price);
$new_data = $new_data . create_xml_tag('recipe_url',$recipe_url);
$new_data = $new_data .
create_xml_tag('recipe_social',$recipe_social);
$new_data = $new_data . create_xml_tag('sidebars',$sidebars);
$new_data = $new_data .
create_xml_tag('right_sidebar_recipe',$right_sidebar_recipe);
$new_data = $new_data .
create_xml_tag('left_sidebar_recipe',$left_sidebar_recipe);
$new_data = $new_data . '</recipe_detail>';
//Saving Sidebar and Social Sharing Settings as XML
$old_data = get_post_meta($post_id, 'recipe_detail_xml',true);
save_meta_data($post_id, $new_data, $old_data, 'recipe_detail_xml');
$recipe_setting_xml = '<recipe_ingredients>';
if(isset($_POST['ingredients'])){$ingredients =
$_POST['ingredients'];
foreach($ingredients as $keys=>$values){
$recipe_setting_xml = $recipe_setting_xml .
create_xml_tag('ingredients',$values);
}
}else{$ingredients = '';}
$recipe_setting_xml = $recipe_setting_xml . '</recipe_ingredients>';
//Saving Sidebar and Social Sharing Settings as XML
$old_data_ingre = get_post_meta($post_id,
'ingredients_settings',true);
save_meta_data($post_id, $recipe_setting_xml, $old_data_ingre,
'ingredients_settings');
$nutrition_setting_xml = '<recipe_nutrition>';
if(isset($_POST['nutrition'])){$nutrition = $_POST['nutrition'];
foreach($nutrition as $keys=>$values){
$nutrition_setting_xml = $nutrition_setting_xml .
create_xml_tag('nutrition',$values);
}
}else{$nutrition = '';}
$nutrition_setting_xml = $nutrition_setting_xml .
'</recipe_nutrition>';
//Saving Sidebar and Social Sharing Settings as XML
$old_data_nut = get_post_meta($post_id, 'nutrition_settings',true);
save_meta_data($post_id, $nutrition_setting_xml, $old_data_nut,
'nutrition_settings');
}
}
//FRONT END RECIPE LAYOUT
$recipe_div_size_num_class = array(
"Full-Image" => array("index"=>"1", "class"=>"sixteen ",
"size"=>array(300,110), "size2"=>array(300,110),
"size3"=>array(300,110)),
"Small-Thumbnail" => array("index"=>"2", "class"=>"sixteen",
"size"=>array(445,175), "size2"=>array(445,175),
"size3"=>array(445,175)));
// Print Recipe item
function print_recipe_item($item_xml){
wp_reset_query();
global
$paged,$sidebar,$recipe_div_size_num_class,$post,$wp_query,$counter;?>
<!--<script src="<?php echo
CP_PATH_URL;?>/frontend/js/jquery-filterable.js"
type="text/javascript"></script>-->
<?php
if(empty($paged)){
$paged = (get_query_var('page')) ? get_query_var('page') : 1;
}
//echo '<pre>';print_r($item_xml);die;
//print_r($event_div_size_num_class);
//$item_type = find_xml_value($item_xml, 'recipe-thumbnail-type');
$item_type = 'Full-Image';
// get the item class and size from array
$item_class = $recipe_div_size_num_class[$item_type]['class'];
$item_index = $recipe_div_size_num_class[$item_type]['index'];
$full_content = find_xml_value($item_xml, 'show-full-news-post');
if( $sidebar == "no-sidebar" ){
$item_size = $recipe_div_size_num_class[$item_type]['size'];
}else if ( $sidebar == "left-sidebar" || $sidebar ==
"right-sidebar" ){
$item_size = $recipe_div_size_num_class[$item_type]['size2'];
}else{
$item_size = $recipe_div_size_num_class[$item_type]['size3'];
}
// get the blog meta value
$header = find_xml_value($item_xml, 'header');
$num_fetch = find_xml_value($item_xml, 'num-fetch');
$num_excerpt = find_xml_value($item_xml, 'num-excerpt');
$category = find_xml_value($item_xml, 'category');
$show_filterable = find_xml_value($item_xml, 'show-filterable');
$category_name = '';
$category = ( $category == 'All' )? '': $category;
if( !empty($category) ){
$category_term = get_term_by( 'name', $category ,
'recipe-category');
$category = $category_term->term_id;
$category_name = $category_term->name;
}
?>
<h2 class="heading"><?php echo $header;?></h2>
<?php
//Filterable Recipe Script start
if($show_filterable == 'Yes'){?>
<script>
jQuery(window).load(function() {
var filter_container = jQuery('#portfolio-item-holder<?php
echo $counter?>');
filter_container.children().css('position','absolute');
filter_container.masonry({
singleMode: true,
itemSelector: '.portfolio-item:not(.hide)',
animate: true,
animationOptions:{ duration: 800, queue: false }
});
jQuery(window).resize(function(){
var temp_width =
filter_container.children().filter(':first').width() + 20;
filter_container.masonry({
columnWidth: temp_width,
singleMode: true,
itemSelector: '.portfolio-item:not(.hide)',
animate: true,
animationOptions:{ duration: 800, queue: false }
});
});
jQuery('ul#portfolio-item-filter<?php echo $counter?>
a').click(function(e){
jQuery(this).addClass("active");
jQuery(this).parents("li").siblings().children("a").removeClass("active");
e.preventDefault();
var select_filter = jQuery(this).attr('data-value');
if( select_filter == "All" ||
jQuery(this).parent().index() == 0 ){
filter_container.children().each(function(){
if( jQuery(this).hasClass('hide') ){
jQuery(this).removeClass('hide');
jQuery(this).fadeIn();
}
});
}else{
filter_container.children().not('.' +
select_filter).each(function(){
if( !jQuery(this).hasClass('hide') ){
jQuery(this).addClass('hide');
jQuery(this).fadeOut();
}
});
filter_container.children('.' +
select_filter).each(function(){
if( jQuery(this).hasClass('hide') ){
jQuery(this).removeClass('hide');
jQuery(this).fadeIn();
}
});
}
filter_container.masonry();
});
});
</script>
<ul id="portfolio-item-filter<?php echo $counter?>"
class="category-list">
<li><a data-value="all" class="gdl-button active"
href="#">All</a></li>
<?php
$categories = get_categories( array('child_of' => $category,
'taxonomy' => 'recipe-category', 'hide_empty' => 0) );
//$categories = get_the_terms( $post->ID, 'recipe-category' );
if($categories <> ""){
foreach($categories as $values){?>
<li><a data-value="<?php echo $values->term_id;?>"
class="gdl-button" href="#"><?php echo
$values->name;?></a></li>
<?php
}
}?>
<div class="clear"></div>
</ul>
<?php }else{?>
<h2 class="heading"><?php echo $category_name; ?></h2>
<?php }?>
<ul class="lightbox gallery_filterable" id="portfolio-item-holder<?php
echo $counter?>">
<?php
$category = find_xml_value($item_xml, 'category');
$category = ( $category == 'All' )? '': $category;
if( !empty($category) ){
$category_term = get_term_by( 'name', $category ,
'recipe-category');
$category = $category_term->slug;
}
if($show_filterable == 'Yes'){
query_posts(array(
'posts_per_page' => -1,
'post_type' => 'recipes',
'recipe-category' => $category,
'post_status' => 'publish',
'order' => 'ASC',
));
}else{
query_posts(array(
'posts_per_page' => $num_fetch,
'paged' => $paged,
'post_type' => 'recipes',
'recipe-category' => $category,
'post_status' => 'publish',
'order' => 'ASC',
));
}
while( have_posts() ){
global $post;
the_post(); ?>
<li class="all portfolio-item item alpha
<?php
$categories = get_the_terms( $post->ID,
'recipe-category' );
if($categories <> ''){
foreach ( $categories as $category ) {
echo $category->term_id." ";
}
}
?>">
<h3 class="heading">
<a href="<?php echo get_permalink();?>">
<?php
echo substr($post->post_title, 0, 20);
if ( strlen($post->post_title) > 20 ) echo "...";
?>
</a>
</h3>
<a href="<?php echo get_permalink();?>" class="caption">
<?php echo get_the_post_thumbnail($post->ID,
$item_size);?>
<span class="hover-effect big zoom"></span>
</a>
<!--david-->
<article class="menu-det">
<p><?php echo
strip_tags(mb_substr(get_the_content(),0,$num_excerpt));?>
<a class="c-link" href="<?php echo
$recipe_url;?>"><?php _e('Read More...',
'crunchpress'); ?></a></p>
</article>
</li>
<?php }//End While?>
</ul>
<div class="clear"></div>
<?php
if( find_xml_value($item_xml, "pagination") == "Yes" AND
$show_filterable == 'No'){
pagination();
}
}
?>
Now, at the bottom of this page above, you will see a readmore link with
the following content:
<article class="menu-det">
<p><?php echo
strip_tags(mb_substr(get_the_content(),0,$num_excerpt));?> <a
class="c-link" href="<?php echo $recipe_url;?>"><?php _e('Read M...',
'crunchpress'); ?></a></p>
</article>
Now the part giving me issues, is this one:
<?php echo $recipe_url;?>
So I basically only registered a new variable: $recipe_url;, and I
replaced the original link href value of:
href="<?php echo get_permalink()?>"
with my new variable:
href="<?php echo $recipe_url;?>"
Now the url is empty on the webpage, even though a value is set. I even
used some of the original variables included in the theme:
href="<?php echo $recipe_price;?>"
but it also does not populate a any url or href value..
Why is this? Am I calling it wrong?
Thanks

unable to parse users query results using titanium cloud

unable to parse users query results using titanium cloud

I am performing a query on users(titanium cloud service) as such:
Cloud.Users.query({
page: 1,
per_page: 5,
where: {
email: 'example@example.com'
}
}, function(e) {
if (e.success) {
alert(JSON.parse(e.users));
} else if (e.error) {
alert(e.message);
} else {}
});
after executing the query i am unable to parse e.users on success, alert
returns nothing. Any thoughts?

What methods can reduce JDBC thread pauses?

What methods can reduce JDBC thread pauses?

We are running a Java server application which needs to fetch information
from a MySQL database in order to display data to the connected client.
However, due to the many clients connected at a single time, it has to
perform many queries in a short amount of time.
As a result of this, there is major lag/delay and threads will deadlock
and pause until the query is complete...
Are there any methods that we can use to prevent the thread from locking
up whilst waiting for the database apart from making it async, because we
need the data in sync?
I've seen things such as connection pooling however we need a way to fetch
data from the database in sync, without making the rest of the server
application lag.
It should be when a user hits x, y will happen instead of user hits x, the
program locks up and pauses for 2 seconds then y will happen once
complete.

how to make a table from xml tags and get access to different tags

how to make a table from xml tags and get access to different tags

How to get access to "td check it /td" second td, and create from all
second td columb? from all results which are in xml. For example make "td
2 /td" link to ar id=0 and ar id=1, Context;
<result number="001">
<table>
<tr num="0">
<td>0</td>
<td>check it</td>
<td>Unknown</td>
<td>2</td>
<td>
<array id="0" br="54">
<ar id="0">
<![CDATA[
Mistake
]]>
</ar>
<ar id="1">
<![CDATA[Second mistake ]]>
</ar>
</array>
</td>
</tr>
</table>

Saturday, 14 September 2013

array_merge(): Argument #2 is not an array laravel 4

array_merge(): Argument #2 is not an array laravel 4

How can i properly loop this
If i tick one checkbox, it works properly, but if i tick more than 1, not
even one will be updated.
array_merge(): Argument #2 is not an array laravel 4
(Caused by array_merge(): Argument #2 is not an array)
Controller
if (Input::has('orderIds'))
{
**foreach(Input::get('orderIds') as $orderid)**{
Order::whereIn('id', $orderid)->update(array('top_up_id' =>
$topUp->id));
}
}
javascript
$('#top-up-pending-payment-table tbody
input:checkbox:checked').each(function(){
orderIdsHtml += '<input type="hidden" name="orderIds[]" value="' +
$(this).data('id') + '">';
});
Debug Post Data
orderIds Array ( [0] => 79 [1] => 80 )

WP8 Sending JSON to Server

WP8 Sending JSON to Server

I am trying to POST some JSON data to my Server. I am using simple code
which I have attained from: Http Post for Windows Phone 8
Code:
string url = "myserver.com/path/to/my/post";
// HTTP web request
var httpWebRequest = (HttpWebRequest)WebRequest.Create(url);
httpWebRequest.ContentType = "text/plain; charset=utf-8";
httpWebRequest.Method = "POST";
// Write the request Asynchronously
using (var stream = await
Task.Factory.FromAsync<Stream>(httpWebRequest.BeginGetRequestStream,
httpWebRequest.EndGetRequestStream,
null))
{
//create some json string
string json = "{ \"my\" : \"json\" }";
// convert json to byte array
byte[] jsonAsBytes = Encoding.UTF8.GetBytes(json);
// Write the bytes to the stream
await stream.WriteAsync(jsonAsBytes, 0, jsonAsBytes.Length);
}
I am getting an error though on await and Task:

Anyone see the obvious error?

Chrome inspect element using jquery

Chrome inspect element using jquery

i wanted to create somthing similar to the inspect dom feature in chrome's
devtools which when onhover a - preset list of doms - a div.shadow is
created on top of the dom with the same width/height covering it,and when
mouse leave shadow its hidden or in case a new selected dom is hovered it
changes place and dimensions,
dom.mouseover(function(e) {
shadow.css({
display: "block",
width: dom.width+"px",
height: dom.height+"px",
top: dom.top+"px",
left: dom.left+"px"
});
});
shadow.mouseleave(function() {
$(this).css('display', 'none');
});;
but the problem arise when having parent/children in the selected dom
lists like "body" where it put the shadow on the body but then ignore any
mouseover/mouseenter from childrens

Not getting albums of some users in facebook sdk graph api

Not getting albums of some users in facebook sdk graph api

I am querying in graph api like this
userid/albums
i am getting response of most users successful but i am though not getting
response of some users.
it give me blank response
{
"data": [ ]
}

Jigsaw Puzzle Piece not moving in Android device

Jigsaw Puzzle Piece not moving in Android device

I am using http://www.raymondhill.net/puzzle-rhill/jigsawpuzzle-rhill.php
jigsaw puzzle code for developing jigsaw puzzle but puzzle pieces not
moving in android device, it's working only on ios deice, please help...

setup virtual host using wamp server and apache

setup virtual host using wamp server and apache

i installed wamp server and it work then i want ed to create a virtual
host to make it easy to test websites and apps .
for this i look at many and many of videos tutorials and read articles
about how to setup a virtual host with wamp but none of it it work for
because after i tried these steps the wamp server stop working and just
turn to the orange color and stop can anyone help me and give me the right
steps to accomplish this task ???
i will appreciate any help

Friday, 13 September 2013

Jquery move element from center to left and left to center

Jquery move element from center to left and left to center

Please help me to solve this problem. I have a code which will move the
div from center to left if click moveLeft and left to center when I click
moveCenter using jquery animate(); here's my code below:
<html>
<head>
<script type='text/javascript'
src='https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js'></script>
<script type="text/javascript">
// Store offset before any animations
// (using .each here, but it could also be done in a click handler,
// before starting the animation)
$(document).ready(function(e) {
// Retrieve the offsets later
var element = $('.page-container');
$('.moveLeft a').on('click', function(){
element.data("originalOffset", element.offset());
$('.page-container').animate({left:-element.offset().left*2},'slow');
});
$('.moveCenter a').on('click', function(){
var offsetBack = element.data("originalOffset");
$('.page-container').animate({left:offsetBack.left},'slow');
});
});
</script>
<style type="text/css">
.page-container
{
width:700px;
height:1000px;
background:#000;
position:absolute;
margin:0px auto;
left:0;
right:0;
}
</style>
</head>
<body>
<div class="moveLeft"><a href="#">MoveLeft</a></div>
<div class="moveCenter"><a href="#">MoveCenter</a></div>
<div class="page-container"></div>
</body>
</html>
Above code, never worked for me. I tried also to used jquery data() but
doesn't work too.
Do I need to use another function instead of animation()?
Thanks

PHP/.htaccess - Redirect visitor when accessing page with .php extension

PHP/.htaccess - Redirect visitor when accessing page with .php extension

I want my visitors to get redirected when they access pages with .php
extension name. To make it a bit clearer:
I currently have .htaccess set to remove .php extension from URL in which
when visitor types in www.mysite.com/about/ it loads the
www.mysite.com/about.php content. I basically want the same thing happen
in reverse like:
When visitor enters www.mysite.com/about.php into the address bar, I want
to load the same content, but redirect/change the URL to
www.mysite.com/about/ and appear in the address bar.
Thanks in advanced! Paul G.

Nesta CMS on linux not show latest articles

Nesta CMS on linux not show latest articles

Anyone experience an inability for Nesta CMS to show the latest articles
on linux? Running Ubuntu 12.04.
I can navigate to the article localhost:9393/filename and it shows up
fine. I have tried running under both shotgun and rackup with no
difference.
But despite having a defined Date: 03 Sept 2013 it still won't show. On
the actual page, the published is correctly showing the date, as well as
the category. But neither on the home page/category page, will the
article's title/summary show up.
The odd thing is, pulling the same project down on a windows machine,
adding a new article will allow it to show up properly on the home page
for latest articles as well as the associated category page.
I have tinkered with different dates with no effect. Any suggestions?

intel cpp compiler integration in visual studio 2012

intel cpp compiler integration in visual studio 2012

I want to do parallel programming using thread building blocks(tbb). Intel
cpp compiler provides tbb so can any one help me how to integrate that
compiler into visual studio 2012

Could not enter data You have an error in your SQL syntax; check the manual?

Could not enter data You have an error in your SQL syntax; check the manual?

I Dont know why it'll give me this error when i do (When).i cant realize
where is my error.could you help me out with this?
$sql = "INSERT INTO addevent ( Title, Category, Further_Spec,`When`,
Venue, wAddress, wCity, wZipcode, Name, Address, City, Zipcode, Mobile,
Landline, Email, Fax, Website, image)".
"VALUES
('$_POST[title]','$_POST[category]','$_POST[description]','$_POST[reservation]','$_POST[venue]','$_POST[waddress]','$_POST[wcity]','$_POST[wzipcode]','$_POST[name]','$_POST[address]','$_POST[city]','$_POST[zipcode]','$_POST[mobile]','$_POST[landline]','$_POST[email]','$_POST[fax]','$_POST[website]','$image')";
And non of the above are Reserved Keyword rather than When so i dont know
what should i do...

Thursday, 12 September 2013

Android facebook contacts birthday details retrieve

Android facebook contacts birthday details retrieve

I tried to get facebook contacts birthday details..But unfortunetely i
couldn't able to retrieve.It saying to give permission..But i have added
permission already in it..
I can able to get my friends name but not birthday date.
how can i get my friends birthday date !
private static final String[] PERMISSIONS =
new String[] {"friends_birthday","read_stream", "offline_access"};
link 1

jquery next () and setInterval ()

jquery next () and setInterval ()

<div class='parent'>
<div class='item'>1</div>
<div class='item'>2</div>
<div class='item'>3</div>
<div class='item'>4</div>
</div>
$('.parent .item').each (function () {
var current = $(this);
setInterval (function () {
$(current).fadeOut (function () {
$(this).next ().fadeIn ();
});
}, 2000); //rotate every 2 seconds
});
I want to do the following: Show each "item" for 2 seconds and after that
fadeOut and fadeIn the next item. When there are no more items then
fadeOut and start from the beginning. The code seems like it would work
but it is having timing issues and doesn't move automatically through all
items. Any help would be appreciated.

LDAP Authentication pass credentials

LDAP Authentication pass credentials

I need to pass LDAP credentials to a web-service to authenticate in C#.
I've got everything setup to get the user using DirectoryEntry, however,
for obvious reasons I can't get the password.
I authenticate to a third-party web service in C# by passing the
username/password like:
j_username=me%40domain.com&j_password=mypassword%21
I know getting the LDAP password is impossible but is there a better way
to go about what I'm doing?

Jquery fadeout of item, item doesn't reappear

Jquery fadeout of item, item doesn't reappear

I have my main page that contains a DIV that in turn contains an IFRAME.
When the user clicks the OK button in the IFRAME, I call a function in the
parent page that fades out the div with a Jquery fadeOut command. When I
try to make the DIV fade in once again, it doesn't. What am I doing wrong?
MAIN PHP PAGE:
<div id="regcontainer">
<iframe id="registration" src="register.html" frameborder="0"
allowtransparency="true" scrolling="auto"></iframe>
</div>
JQUERY COMMAND IN JS FILE INCLUDED IN THE MAIN PAGE, THAT FADES OUT THE DIV:
var closeIFrame = function() {
$('#regcontainer').fadeOut("fast");
}
Fade In:
$('#register').click(function() { $('#regcontainer').fadeIn("fast"); });

java Math.atan( Math.tan() ) useless?

java Math.atan( Math.tan() ) useless?

On windows 7, look at the file
c:\windows\winsxs...\weather.js
There is a function computeSunRiseSunSet(Latitude, Longitude, TimeZone,
Year, Month, Day).
They don't cite the source of the algorithm.
One line of code is
var C2=RD*(Math.atan(Math.tan(L0+C)) - Math.atan(.9175*Math.tan(L0+C))-C);
Why is there Math.atan( Math.tan( L0+C )) ?
Is it the same as ( L0+C ) or there are corner cases ?

Wednesday, 11 September 2013

Apk Expansion File Downloading occurs frequently in anrdroid.why so happens?

Apk Expansion File Downloading occurs frequently in anrdroid.why so happens?

I've developed an android application using expansion library.
I've used required strategy to create and upload expansion file.I've
uploaded the apk and main expansion file in play store.And they're saved
as draft,not published.While I installed this apk and tested it in my
device sometimes after it being uploaded apk expansion file downloading
occurs.But when I tried after sometimes it shows "Download failed because
the resources could not be found".
I used only main expansion file.My app version code is 5 and expansion
file is 17509413 bytes in size.
My code snippet is as follows:
private static final XAPKFile[] xAPKS = { new XAPKFile(
true,
5,17509413L
)
};
Can anyone help me please?
Thanks in advance.

How to properly keep a DB connection from a Connection Pool opened in JBoss

How to properly keep a DB connection from a Connection Pool opened in JBoss

I'm using JBoss AS 7.1 as a server and I have my DataSource configured
with pooling. I'm quite new to this so please excuse any rookie
mistakes... after all I'm here to learn.
When a client logs-in it gets a connection to the database and I need to
keep that connection(from the pool) open until the user logs-out or the
HttpSession expires. This is an absolute requirement coming from our DB
Admin. who says that he needs the DB session variables. I am using a
servlet for all this.
Playing with the possibilities I have encountered 2 major problems:
As far as I see JBoss automatically closes unused connections => my opened
connection returns to the pool. So this might not be the right path.
If I try to store/recall the Connection object like this:
private Hashtable<String, Connection> connections = new Hashtable<String,
Connection>();
try {
String strDSName1 = "java:/OracleDSJNDI";
ctx = new InitialContext();
ds1 = (javax.sql.DataSource) ctx.lookup(strDSName1);
System.out.println("Got 1'st ds.");
} catch (Exception e) {
System.out.println("ERROR getting 1'st DS : " + e);
}
connection = ds1.getConnection();
connections.put(session.getId(), connection);
conn = (Connection) connections.get(sessionID);
it throws this exception:
java.sql.SQLException: Connection is not associated with a managed
connection.org.jboss.jca.adapters.jdbc.jdk6.WrappedConnectionJDK6@dee1f37


My question is: How do I properly keep my connection opened?
Thanks

C# XNA Texture2D Collision?

C# XNA Texture2D Collision?

I'm currently working on a simple lightning system for an isometric game
and after few hours of thinking I came up with a solution which looks like
this : http://puu.sh/4oHR8.jpg
So , I draw a texture (a simple form like a triangle,circle etc) above the
tiles and I want to check which tiles intersects the image and light them.
The problem is that I don't know how to do it properly.I tried pixel
collision because the tiles are represented by a texture but it didn't
work at all.
Do you have any suggestions which could help me?
Thank you in advance.
Edit This is the code I used for pixel collision.
enter code here
static bool IntersectPixel(Rectangle rect1, Color[] data1,
Rectangle rect2, Color[] data2)
{
int top = Math.Max(rect1.Top, rect2.Top);
int bottom = Math.Min(rect2.Top, rect2.Bottom);
int left = Math.Max(rect1.Left, rect2.Left);
int right = Math.Min(rect1.Right, rect2.Right);
for (int y = top; y < bottom; y++)
{
for (int x = left; x < right; x++)
{
Color color1 = data1[(x - rect1.Left) + (y - rect1.Top) *
rect1.Width];
Color color2 = data2[(x - rect2.Left) + (y - rect2.Top) *
rect2.Width];
if (color1.A != 0 && color2.A != 0)
{
return true;
}
}
}
return false;
}

Batch rename files

Batch rename files

I want to batch re-name a number of files in a directory so that the
preceding number and hypen are stripped from the file name.
Old file name: 2904495-XXX_01_xxxx_20130730235001_00000000.NEW
New file name: XXX_01_xxxx_20130730235001_00000000.NEW
How can I do this with a linux command?

Bad test if file on ftp exist

Bad test if file on ftp exist

I have this problem: when i testing if file exist on ftp,I have exception
and the program write file dont exist...But when I write adress in
variable REQUEST into mozilla the file exist and in right format...Have
any idea where is the problem? My code:
private void TestGenerOrders()
{
//Testuje, zda-li soubor existuje
var c2 = (counter2).ToString().PadLeft(5, '0');
var request = (FtpWebRequest)WebRequest.Create((FtpZmeny) +
"orders" + (c2) + ".xml");
request.Credentials = new NetworkCredential(FtpNOHELJmeno,
FtpNOHELHeslo);
request.Method = WebRequestMethods.Ftp.GetFileSize;
try
{
FtpWebResponse response =
(FtpWebResponse)request.GetResponse();
}
catch (WebException ex)
{
FtpWebResponse response = (FtpWebResponse)ex.Response;
if (response.StatusCode ==
FtpStatusCode.ActionNotTakenFileUnavailable)
{
MessageBox.Show("Error");
Prijem();
}
else
{
Prijem2();
}
}
}

File on FTP exist before download

File on FTP exist before download

i have code, where i downloading file from FTP..I try to check if the file
exist...Have you any idea? This is sample of my code:
var c2 = (counter2).ToString().PadLeft(5, '0');
FtpWebRequest request =
FtpWebRequest)WebRequest.Create((FtpNOHELZmeny) + "o" + (c2) + ".xml");
request.Method = WebRequestMethods.Ftp.DownloadFile;
request.Credentials = new NetworkCredential(**, **);
FtpWebResponse response = (FtpWebResponse)request.GetResponse();
Stream responseStream = response.GetResponseStream();
StreamReader reader = new StreamReader(responseStream);
StreamWriter writer = new StreamWriter((backup) + "o" + (c2) + ".xml");
writer.Write(reader.ReadToEnd());
FileInfo f = new FileInfo((backup) + "o" + (c2) + ".xml");
long original_vel = f.Length;
long ftp_vel = request.ContentLength;
if (original_vel == ftp_vel)
{
Console.WriteLine("OK{0}", response.StatusDescription);
reader.Close();
writer.Close();
response.Close();
XDocument doc = XDocument.Load((backup) + "orders" + (c2) + ".xml");
var NUMBER = doc.Descendants("NUMBER");
......
Console.ReadLine();
Console.WriteLine("message... {0}", response.StatusDescription);
counterchyba2 = 0;
counter2++;
}