2018-04-03

Git - how to clone a project


git clone https://github.com//.git


Or, adding the username and password parameters to the previous command, instead of entering them afterwards:

git clone https://username:password@github.com//.git

2015-06-03

How to POST data (file included) using Zend Framework 2

Using "normal" PHP, this could be achieved using curl, like this:

$filepath = '/var/www/vhosts/domain.com/http/filename.pdf';
$data = array(
 'field1'=>'value1',  
 'field2'=>'value2',         
 'field3'=>"@$filepath"
);

/*
or, instead of using the @, that is deprecated in more recent PHP versions, replace with:
'file' =>  new CURLFile($filepath,'application/pdf', basename($filepath))
*/

$url = 'www.domain.org/post/address';
try{ $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_HEADER, false); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $data); $response = curl_exec($ch); curl_close($ch); } catch (Exception $e) { $error = $e->getMessage(); return false; } ?>



Using Zend Framework 2:

use Zend\Http\Client;


$data = array(
 'field1'=>'value1',  
 'field2'=>'value2'
);

$filepath = '/var/www/vhosts/domain.com/http/filename.pdf';
$url = 'www.domain.com/post/address';


$client = new Client();
$client->setUri($url);
$client->setParameterPost($data);
$client->setMethod('POST');
$client->setFileUpload($filepath,'field3');
$response = $client->send();

if ($response->isSuccess() === true) {
    $content = $response->getBody();
}
?>



2014-08-05

Javascript: how to scroll automatically to a certain area of the page

document.getElementById("anchor-div").scrollIntoView();

Skeleton AJAX call with JQuery

var array_info = {};
  array_info['key1'] = $("#field1").val();
  array_info['key2'] = $("#field2").val();
  var array_info_json = JSON.stringify(array_info);
 
 //ajax call
 $.ajax({
        url: "file.php",
        type: "POST",
        data: {
            action: "parameter",
            field_data: array_info_json
        },
  
        success: function (data) {
            console.log(data);
            if (data != '') {
                $('#div_container').html('Sucess');
                dataArray = JSON.parse(data);   
            }
            else{
            
                alert('No data');
            

            }
        },
        error: function (a,b) { 
                alert('Error');
      }
    });

2013-07-11

Tweetdeck notifications

Problem: the TweetDeck extension for Chrome suddenly stops popping up notifications

Cause: the browser has updated and now has enabled the "Rich Notifications" flag, which the TweetDeck extension can't yet use

Solution: 
1) Type chrome://flags into your address bar on Chrome
2) Scroll down to Enable Rich Notifications and set it "Disabled"
3) Scroll to bottom where it says to relaunch chrome to save changes and relaunch.


2010-06-28

The drive could not be mapped because no network was found

Symptom: 
When trying to map a network drive, you may receive this error: “The drive could not be mapped because no network was found”

Causes and solutions:

1. The workstation service is missing from the computer's list of services. Install the Workstation service by enabling the Client for MS network.

2. The Workstation service is stopped. Restart it and make sure the Status setup as automatic.


2010-06-08

Notes: Database is much bigger than expected

Symptoms:

A database with a very big size, does not have the number of documents (and/or attachments) that would justify it.


Possible cause:

Deletion stubs. When documents are deleted they are stored internally for a x number of days (depends on the database configuration), therefore they still occupy disk space. If the database has frequent deletion operations on a large number of documents, this can easily add up to it's size.


Solution:

How to remove the deletion stubs immediately? Follow this steps:

  1.  go to the Replication Options of that database
  2. select the Space Savers Tab and on the first option * ("Remove documents not modified in the last [x] days" replace the number displayed (usually 90) by 0.  WARNING: do NOT select the checkbox before this option!!!
  3. enter the database, exit and go back to the Replication Options and set that option back to the number of days it had before
  4. compact the database.


The deletion stubs will have been deleted and, after compacting, the database's size should diminish visibly.

For more information see the IBM's Technote nÂș technote 1095683.

2010-05-04

Notes: Border appearing around image, even though hotspot's border is disabled

Scenario:

An image, with a action hotspot around it, displays a border, even though the hotspot property "Show border around hotspot" is not set:



Solution:

Place the cursor to the left of the image and hit "enter" to add a line above it. The border will be gone.