Skip to content

Instantly share code, notes, and snippets.

View vishwapriyanatha's full-sized avatar

B.A.Vishwa Priyanatha vishwapriyanatha

View GitHub Profile
@vishwapriyanatha
vishwapriyanatha / server-side-ga-events.php
Created October 27, 2021 09:49 — forked from chrisblakley/server-side-ga-events.php
PHP functions to send data to Google Analytics
//Parse the GA Cookie
function gaParseCookie() {
if (isset($_COOKIE['_ga'])) {
list($version, $domainDepth, $cid1, $cid2) = explode('.', $_COOKIE["_ga"], 4);
$contents = array('version' => $version, 'domainDepth' => $domainDepth, 'cid' => $cid1 . '.' . $cid2);
$cid = $contents['cid'];
} else {
$cid = gaGenerateUUID();
}
return $cid;
@vishwapriyanatha
vishwapriyanatha / README.md
Created April 3, 2018 06:45 — forked from hofmannsven/README.md
My simply Git Cheatsheet
@vishwapriyanatha
vishwapriyanatha / download_csv_file_from_php
Last active April 27, 2017 06:22
create and download a csv file from php script
$con = mysqli_connect("localhost","my_user","my_password","my_db");
$query = "select * from user table";
$result = mysqli_query($con,$query);
$array_key = ((array) $result[0]);
$headers = (object) array_keys($array_key);
$delimiter = ",";
$filename = 'process.csv';
$f = fopen('php://memory', 'w');
fputcsv($f, (array)$headers, $delimiter);
foreach ($result as $line) {
@vishwapriyanatha
vishwapriyanatha / angular-datatables-cell-button
Created April 27, 2017 06:11
Angular DataTables add button in a cell (Row Edit button)
$scope.dtOptions = DTOptionsBuilder.fromSource('data.json')
.withDOM("<'row'<'col-sm-4'l><'col-sm-4 text-center'B><'col-sm-4'f>>tp")
.withButtons([
// {extend: 'copy',className: 'btn-sm'},
// {extend: 'csv',title: 'ExampleFile', className: 'btn-sm'},
// {extend: 'pdf', title: 'ExampleFile', className: 'btn-sm'},
// {extend: 'print',className: 'btn-sm'}
])
;