Skip to content

Instantly share code, notes, and snippets.

View udithishara's full-sized avatar
🏠
Working from home

Udith Ishara Madusanka udithishara

🏠
Working from home
View GitHub Profile
@udithishara
udithishara / vue-tel-input-customized.vue
Created September 19, 2023 14:52 — forked from danielsmykowski1/vue-tel-input-customized.vue
A vue-tel-input component that is customized to get the look-and-feel of Vuetify components.
<template>
<div :class="topContainerClasses">
<div
v-click-outside="clickedOutside"
:tabindex="dropdownOptions && dropdownOptions.tabindex ? dropdownOptions.tabindex : 0"
:class="['vti__dropdown', { open: open }]"
@keydown="keyboardNav"
@click="toggleDropdown"
@keydown.esc="reset"
>
@udithishara
udithishara / sheets-api-test-part2.php
Created November 20, 2015 05:02 — forked from karlkranich/sheets-api-test-part2.php
(obsolete due to Google changes) PHP code to use the Google Spreadsheets API with an OAuth Service Account. For more info, see http://karl.kranich.org/google-sheets-api-php
<?php
// Section 5: edit a row
// You'll need to get the etag and row ID, and send a PUT request to the edit URL
$rowid = 'cre1l'; // got this and the etag from the table data output from section 3
$etag = 'NQ8VCRBLVCt7ImA.';
$url = "https://spreadsheets.google.com/feeds/list/$fileId/od6/private/full/$rowid";
$method = 'PUT';
$headers = ["Authorization" => "Bearer $accessToken", 'Content-Type' => 'application/atom+xml', 'GData-Version' => '3.0'];
$postBody = "<entry xmlns=\"http://www.w3.org/2005/Atom\" xmlns:gsx=\"http://schemas.google.com/spreadsheets/2006/extended\" xmlns:gd=\"http://schemas.google.com/g/2005\" gd:etag='&quot;$etag&quot;'><id>https://spreadsheets.google.com/feeds/list/$fileid/od6/$rowid</id><gsx:gear>phones</gsx:gear><gsx:quantity>6</gsx:quantity></entry>";
$req = new Google_Http_Request($url, $method, $headers, $postBody);
@udithishara
udithishara / get_google_spreadsheet.php
Created November 18, 2015 06:46 — forked from uppfinnarjohnny/get_google_spreadsheet.php
A simple way of getting the data from a Google Docs Spreadsheet in PHP
<?php
function get_google_spreadsheet($key) {
$url = "https://spreadsheets.google.com/feeds/list/{$key}/od6/public/values";
$google_sheet = file_get_contents($url);
$xml = simplexml_load_string($google_sheet);
$data = array();
foreach($xml->entry as $entry) {
$row = array();
// The fields are in the gsx: namespace, so we need to specify that to be able to access them through SimpleXML.
@udithishara
udithishara / gspreadsheet.php
Created November 16, 2015 12:09 — forked from felladrin/gspreadsheet.php
Listing Google Spreadsheet answers with PHP (Parsing JSON)
<?php
$key = '0AsfENoKj1ir7dE8yR6U0aUtpdTVNM20wRlNJOhZaclG';
$json_string = file_get_contents("https://spreadsheets.google.com/feeds/list/$key/od6/public/values?alt=json");
$obj = json_decode($json_string);
foreach ($obj->{'feed'}->{'entry'} as $entry)
{
echo "<p>";
$num_column = 0;
$answer = explode(', ', $entry->{'content'}->{'$t'});
foreach ($answer as $a)
@udithishara
udithishara / example.html
Created November 16, 2015 12:09 — forked from rilinweb/example.html
Get Google Spreadsheet Data
<?php
$spreadsheetID = '1pO7BBOkhWL2TcBPYkDTlWZ0Gbw4mAUSadK_8NOn0Ij8';
$urlPath = 'http://spreadsheets.google.com/feeds/list/' . $spreadsheetID . '/od6/public/values?alt=json';
$file = file_get_contents($urlPath);
$json = json_decode($file);
$rows = $json->{'feed'}->{'entry'};
?>
<!DOCTYPE html>
<html lang="en">
<head>
@udithishara
udithishara / google-spreadsheet-reader.php
Created November 16, 2015 12:08 — forked from kosinix/google-spreadsheet-reader.php
Google spreadsheet reader in PHP
<?php
// URL to spreadsheet. Make sure to append ?alt=json to return contents in JSON format
$url = 'https://spreadsheets.google.com/feeds/list/0Ah0xU81penP1dFNLWk5YMW41dkcwa1JNQXk3YUJoOXc/od6/public/values?alt=json';
$file= file_get_contents($url);
$json = json_decode($file);
echo '<pre>'.print_r($json, 1).'</pre>';
// Includes functions for exporting active sheet or all sheets as JSON object (also Python object syntax compatible).
// Tweak the makePrettyJSON_ function to customize what kind of JSON to export.
var FORMAT_ONELINE = 'One-line';
var FORMAT_MULTILINE = 'Multi-line';
var FORMAT_PRETTY = 'Pretty';
var LANGUAGE_JS = 'JavaScript';
var LANGUAGE_PYTHON = 'Python';