NSSreamstatus if i am getting data or not - objective-c

I have NSInputStream , i want to check if i am getting data from other end , i read the NSStreamStatus , i cam across that "NSStreamStatusReading" is use to check the read data .
I tried to check that status but its not working can any one tell me how to check if i am getting data or not
..
code:
if([inputStream streamStatus]==NSStreamStatusReading)
{
NSlog(#"server is sending");
}
else
{
NSlog(#"no");
}
its working when its sending but when i stop server , its not updating .

Related

html2PDF work on local , but wont create a pdf on server (blank page)

I'm coding since 2 year and learning cakePHP since a few weeks , and i'm actually in internship trying to deploy a website.
I have trouble with Html2PDF , as it work well on the local version, but not on the server (a new page is opened , with the right url , but the pdf is blank).
the newly opened blank page contain this error message (displayed on the f12 debug console) :
Failed to load resource: the server responded with a status of 500 (Internal Server Error)
the Html2PDF code :
function exportFicheVie() {
$Equipement = $this->Equipement->getEquipement($_GET['Id']);
$PersonnesRessources = $this->Equipement->getPersonnesRessourcesOfEquipement($_GET['Id']);
$Prestataire = $this->Equipement->getPrestataireOfEquipement($_GET['Id']);
$Verifications = $this->Equipement->getVerif($_GET['Id']);
$Contrat = $this->Equipement->getContrat($_GET['Id']);
if (count($Contrat)==0)
$Contrat[0] = "Non";
$Vide = array(
"Prenom"=>"",
"Nom"=>"",
"NumPoste"=>"",
"Mail"=>"",
"Adresse"=>"",
"Fax"=>"",
"Telephone"=>""
);
if (count($PersonnesRessources)==0)
$PersonnesRessources = array($Vide, $Vide);
elseif (count($PersonnesRessources)==1)
$PersonnesRessources[] = $Vide;
if (count($Prestataire)==0)
$Prestataire = $Vide;
// convert in PDF
require_once(__DIR__.'/../webroot/theme/plugins/html2pdf/vendor/autoload.php');
try
{
$Html2pdf = new HTML2PDF('P', 'A4', 'fr');
$NbPages = $Html2pdf->pdf->getAliasNbPages();
$NumPage = $Html2pdf->pdf->getAliasNumPage();
include($Html2pdf->getHtmlFromPage(__DIR__.'/../View/Equipements/export_fiche_vie.ctp', $Equipement, $PersonnesRessources, $Prestataire, $NbPages, $NumPage));
$Content = ob_get_clean();
//$Html2pdf->setModeDebug();
$Html2pdf->addFont('Century Gothic', 'normal', __DIR__.'/../webroot/theme/plugins/html2pdf/vendor/tecnickcom/tcpdf/fonts/centurygothic.php');
$Html2pdf->addFont('Century Gothic Bold', 'normal', __DIR__.'/../webroot/theme/plugins/html2pdf/vendor/tecnickcom/tcpdf/fonts/centurygothic.php');
$Html2pdf->setDefaultFont('Century Gothic');
$Html2pdf->writeHTML($Content, isset($_GET['vuehtml']));
$Html2pdf->Output('\FS-'.$_GET['Id'].'.pdf');
}
catch(HTML2PDF_exception $e)
{
echo $e;
exit;
}
}
I don't expect an miracle answer , because this question appear a lot without any clear solution , but any hint, advice or supposition would be welcome .it's my first time putting a website on a real server they might be some obvious things I miss.

export data from bigquery to cloud storage- php client library - there is one extra empty new line in the cloud storage file

I followed this sample
https://cloud.google.com/bigquery/docs/exporting-data
public function exportDailyRecordsToCloudStorage($date, $tableId)
{
$validTableIds = ['table1', 'table2'];
if (!in_array($tableId, $validTableIds))
{
die("Wrong TableId");
}
$date = date("Ymd", date(strtotime($date)));
$datasetId = $date;
$dataset = $this->bigQuery->dataset($datasetId);
$table = $dataset->table($tableId);
// load the storage object
$storage = $this->storage;
$bucketName = 'mybucket';
$objectName = "daily_records/{$tableId}_" . $date;
$destinationObject = $storage->bucket($bucketName)->object($objectName);
// create the import job
$format = 'NEWLINE_DELIMITED_JSON';
$options = ['jobConfig' => ['destinationFormat' => $format]];
$job = $table->export($destinationObject, $options);
// poll the job until it is complete
$backoff = new ExponentialBackoff(10);
$backoff->execute(function () use ($job) {
print('Waiting for job to complete' . PHP_EOL);
$job->reload();
if (!$job->isComplete()) {
//throw new Exception('Job has not yet completed', 500);
}
});
// check if the job has errors
if (isset($job->info()['status']['errorResult'])) {
$error = $job->info()['status']['errorResult']['message'];
printf('Error running job: %s' . PHP_EOL, $error);
} else {
print('Data exported successfully' . PHP_EOL);
}
I have 37670 rows in my table1, and the cloud storage file has 37671 lines.
And I have 388065 my table2, and the cloud storage file has 388066 lines.
The last line in both cloud storage files is empty line.
Is this a Google BigQuery feature improvement request? or I did something wrong in my codes above?
What you described seems like an unexpected outcome. The output file should generally has the same number of lines as the source table.
Your PHP code looks fine and shouldn't be the cause of the issue.
I'm trying reproduce it but unable to. Could you double-check if the last empty line is somehow added by another tool like a text editor or something? How are you counting the lines of the resulting output.
If you have ruled that out and are sure the newline is indeed added by BigQuery export feature, please consider opening a bug using the BigQuery Issue Tracker as suggested by xuejian and include your job ID so that we can investigate further.

How to insert data in database after payment successful through instamojo

I have integrated instamojo payment api with my website on PHP.
I can also insert data into my database before payment api is called.
Now how can i insert data into my database after my payment is successful !
Thanks
You have to save this code as php file in your host and then set this file URL as web hook URL for Product/Payment link in Instamojo. You can also check whether this works on Web hook checking page in Instamojo.
<?php
/*
Basic PHP script to handle Instamojo RAP webhook.
*/
$data = $_POST;
$mac_provided = $data['mac']; // Get the MAC from the POST data
unset($data['mac']); // Remove the MAC key from the data.
$ver = explode('.', phpversion());
$major = (int) $ver[0];
$minor = (int) $ver[1];
if($major >= 5 and $minor >= 4){
ksort($data, SORT_STRING | SORT_FLAG_CASE);
}
else{
uksort($data, 'strcasecmp');
}
// You can get the 'salt' from Instamojo's developers page(make sure to log in first): https://www.instamojo.com/developers
// Pass the 'salt' without <>
$mac_calculated = hash_hmac("sha1", implode("|", $data), "<YOUR_SALT>");
if($mac_provided == $mac_calculated){
if($data['status'] == "Credit"){
// Payment was successful, mark it as successful in your database.
// You can acess payment_request_id, purpose etc here.
}
else{
// Payment was unsuccessful, mark it as failed in your database.
// You can acess payment_request_id, purpose etc here.
}
}
else{
echo "MAC mismatch";
}
?>

php-smpp Library not working and fails after two to three SMS

it is very first time i'm messing with sockets , and read many quotes that this is not for newbies.
so problem is i'm using php smpp library for sending SMS which works fine but after delivering two to three SMS delivery fails with following warning
Warning: stream_socket_sendto() [function.stream-socket-sendto]: An existing connection was forcibly closed by the remote host', and to make it work again i need to restart` apache.
Following is write function which throwing exception
public function write($buf) {
$null = null;
$write = array($this->handle_);
// keep writing until all the data has been written
while (strlen($buf) > 0) {
// wait for stream to become available for writing
$writable = #stream_select($null, $write, $null, $this->sendTimeoutSec_, $this->sendTimeoutUsec_);
if ($writable > 0) {
// write buffer to stream
$written = stream_socket_sendto($this->handle_, $buf);
if ($written === -1 || $written === false) {
throw new TTransportException('TSocket: Could not write '.$written.' bytes '.
$this->host_.':'.$this->port_);
}
// determine how much of the buffer is left to write
$buf = substr($buf, $written);
} else if ($writable === 0) {
throw new TTransportException('TSocket: timed out writing '.strlen($buf).' bytes from '.
$this->host_.':'.$this->port_);
} else {
throw new TTransportException('TSocket: Could not write '.strlen($buf).' bytes '.
$this->host_.':'.$this->port_);
}
}
}
Please anyone can put some light
It was the bug which i won't able to identify/ rectify. then i used an other library from http://www.codeforge.com/read/171085/smpp.php__html and it really saved me.

WCF-project will not return data with 64-bit Win Vista and VS2010

I thought I found the solution to my problem when I found this, but it didn't work for me.
When I run in debug mode, my WcfTestClient does not retrieve any data and I receive the error:
A first chance exception of type 'System.NotSupportedException' occurred in System.Data.Entity.dll
The thread '<No Name>' (0x1b50) has exited with code 0 (0x0).
The program '[7040] WCFTestClient.exe: Managed (v4.0.30319)' has exited with code 0 (0x0).....................................
What WILL retrieve data is the following method:
public List<WShortDeal> Test()
{
try
{
return entities.ProductInstance_Deal
.Select(d => new WShortDeal()
{
Id = d.Deal.Id
// ,
// Name = d.Deal.Deal_Language.SingleOrDefault(l => l.Language.Id == 1).Name**
,
NewPrice = (double)d.ProductInstance.Price * (1 - d.Deal.SalesPercentage / 100)
,
OldPrice = (double)d.ProductInstance.Price
,
Valuta = d.ProductInstance.Valuta.ValutaCode
,
Type = d.Deal.Type
,
IdCompanyAccount = d.ProductInstance.IdCompanyAccount
})
.ToList();
}
catch (Exception)
{
return null;
}
}
If I uncomment the two lines that are now commented out, though, I stop receiving data and receive the error message mentioned above in my output window.
Also if I add this line
,ProductCategory = d.ProductInstance.ProductType.ProductCategory.ProductCategory_Language.Where(pcl => pcl.IdLanguage == idLanguage).Single().Name
instead of the line
, Name = d.Deal.Deal_Language.SingleOrDefault(l => l.Language.Id == 1).Name
to my original SELECT-statement, it will also return no data. So I guess maybe it has something to do with all the tables that represent the many-to-many-relationship with my Language-table(??). Because whenever I forget about the join with the "ProductCategory_Language"-table, I can retrieve data again.
Could someone please help? Is there another solution for my problem? I've been struggling with this problem for days now :(
Thanks in advance.
What if the line returns a null before selecting the name?
Try
Name = d.Deal.Deal_Language.Where(l => l.Language.Id == 1)
.Select(s=>s.Name).SingleOrDefault()