Telegram Bot API with Google Sheets I HAVE PROBLEM IN CODE
when run telegram bot and press on show last expenses
if i put in chart in google sheet bot stack and never show result
here is the code below
var expenseSheet = SpreadsheetApp.openById(ssId);
var expenses = [];
var expensesSheet = expenseSheet.getSheetByName("Requests");
var lr = expensesSheet.getDataRange().getLastRow();
var counter = 0;
for (var i = lr; i > 1; i--)
{
var date = expensesSheet.getRange(i, 1).getValue();
date = Date.parse(date);
date = new Date(date).toLocaleDateString(locale, {timeZone: timeZone});
var description = expensesSheet.getRange(i, 2).getValue();
var cost = expensesSheet.getRange(i, 3).getValue();
var category = expensesSheet.getRange(i, 4).getValue();
var detalis = expensesSheet.getRange(i, 5).getValue();
var status = expensesSheet.getRange(i, 9).getValue();
var ticketid = expensesSheet.getRange(i,10).getValue();
expenses.push("\n---------\n"
+ "šļø Date: <b>" + date
+ "</b>\nš Category: <b>" + category
+ "</b>\nš Description: <b>" + description
+ "</b>\n Value: <b>& " + cost
+ "</b>\nšµ Details: <b>" + detalis
+ "</b>\nšµ Ticket ID: <b>" + ticketid
+ "</b>\nš status: <b>" + status+"</b>");
counter++;
if (counter >= 1)
break;
Related
PostGIS has this function ST_GeomFromGeoHash to get the bounding box geometry of the geohash area (https://postgis.net/docs/ST_GeomFromGeoHash.html), but it has not been ported to BigQuery yet. Is there any workaround?
I've implemented the following BigQuery UDF that converts a geohash of arbitrary precision to a bounding box geometry:
CREATE OR REPLACE FUNCTION dataset.geohash_to_bbox(geohash STRING)
RETURNS STRING
LANGUAGE js AS """
var BASE32_CODES = "0123456789bcdefghjkmnpqrstuvwxyz";
var BASE32_CODES_DICT = {};
for (var i = 0; i < BASE32_CODES.length; i++) {
BASE32_CODES_DICT[BASE32_CODES.charAt(i)] = i;
}
var ENCODE_AUTO = 'auto';
var MIN_LAT = -90;
var MAX_LAT = 90;
var MIN_LON = -180;
var MAX_LON = 180;
var decode_bbox = function (hash_string) {
var isLon = true,
maxLat = MAX_LAT,
minLat = MIN_LAT,
maxLon = MAX_LON,
minLon = MIN_LON,
mid;
var hashValue = 0;
for (var i = 0, l = hash_string.length; i < l; i++) {
var code = hash_string[i].toLowerCase();
hashValue = BASE32_CODES_DICT[code];
for (var bits = 4; bits >= 0; bits--) {
var bit = (hashValue >> bits) & 1;
if (isLon) {
mid = (maxLon + minLon) / 2;
if (bit === 1) {
minLon = mid;
} else {
maxLon = mid;
}
} else {
mid = (maxLat + minLat) / 2;
if (bit === 1) {
minLat = mid;
} else {
maxLat = mid;
}
}
isLon = !isLon;
}
}
return "POLYGON (( " + minLon + " " + minLat + ", " + maxLon + " " + minLat + ", " + maxLon + " " + maxLat + ", " + minLon + " " + maxLat + ", " + minLon + " " + minLat + "))";
};
return decode_bbox(geohash);
""";
Example usage:
select <dataset>.geohash_to_geom("ttnfv2u");
>> POLYGON((77.2119140625 28.6083984375, 77.2119140625 28.65234375, 77.255859375 28.65234375, 77.255859375 28.6083984375, 77.2119140625 28.6083984375))
BigQuery has ST_GEOGPOINTFROMGEOHASH which returns the central point. There is currently no function that returns the box though. The UDF in another answer is often a reasonable workaround, but you should be aware of its usage limitation.
GeoHash normally represents a rectangle on a flat 2D map. BigQuery works with Geography, with geodesic edges, so an edge between two points with same latitude does not follow the parallel, but being geodesic line is a shorter route closer to the pole. So the BigQuery polygon is a bit different from 2D box. You can often ignore the differences, but it might give you wrong results depending on how you use this polygon.
I'm trying to convert the Milliseconds date from Server to valid datetime but for some reason the code is not working on react native as expected on my other applications
const ToValidDateTime = (date: string) => {
console.log(date); //HERE Date Returned by server is ( /Date(1617048540000)/ )
date = date.replace(/\D/g, ''); //removing everything just taking digits
var fullDate = new Date(date);
console.log(fullDate); //here is just giving me Date { NaN }
var twoDigitMonth = fullDate.getMonth() + 1 + "";
if (twoDigitMonth.length == 1) twoDigitMonth = "0" + twoDigitMonth;
var twoDigitDate = fullDate.getDate() + "";
if (twoDigitDate.length == 1) twoDigitDate = "0" + twoDigitDate;
var currentDate =
twoDigitMonth + "/" + twoDigitDate + "/" + fullDate.getFullYear();
return currentDate;
}
any ideas what am I doing wrong here?
Convert String to Number when you extract it from /Date(1617048540000)/
This should work
var fullDate = new Date(Number(date));
var date = "Date(1617048540000)"
console.log(date); //HERE Date Returned by server is ( /Date(1617048540000)/ )
date = date.replace(/\D/g, ''); //removing everything just taking digits
console.log(date)
var fullDate = new Date(Number(date));
console.log(fullDate.toDateString()); //here is just giving me Date { NaN }
var twoDigitMonth = fullDate.getMonth() + 1 + "";
if (twoDigitMonth.length == 1) twoDigitMonth = "0" + twoDigitMonth;
var twoDigitDate = fullDate.getDate() + "";
if (twoDigitDate.length == 1) twoDigitDate = "0" + twoDigitDate;
var currentDate =
twoDigitMonth + "/" + twoDigitDate + "/" + fullDate.getFullYear();
I am trying to move subforms in a standard pdf file (not a dynamic XML). I have an old copy of LiveCycle (ES2) and have produced the following code
xfa.host.setFocus(clearArrows);
var gridX = xfa.layout.x(gridPICK);
var gridY = xfa.layout.y(gridPICK);
var gridW = xfa.layout.w(gridPICK);
var gridH = xfa.layout.h(gridPICK);
var markerDim = 0;
var mouseX = event.target.mouseX;
var newX = (mouseX + "points").toString();
var mouseY = xfa.layout.h(Page3) - event.target.mouseY;
var newY = (mouseY + "points").toString();
for (var i = 0; i < 10; i++){
var indicatorObject = xfa.resolveNode("Indicator[" + i.toString() + "]");
var indicatorX = xfa.layout.x(indicatorObject);
if (indicatorX < gridX) {
var pointIndicator = indicatorObject;
pointIndicator.presence = "visible";
xfa.host.setFocus(pointIndicator.Description);
xfa.host.openList("Indicator[" + i.toString() + "].Description");
i = 10;
}
}
if (mouseX <= gridX + markerDim)
{
pointIndicator.x = (gridX + markerDim + "points").toString();
}
else if (mouseX >= gridX + gridW - markerDim)
{
pointIndicator.x = (gridX + gridW - markerDim + "points").toString();
}
else
{
pointIndicator.x = newX;
}
if (mouseY >= gridY + gridH - markerDim)
{
pointIndicator.y = (gridY + gridH - markerDim + "points").toString();
}
else if (mouseY <= gridY + markerDim)
{
pointIndicator.y = (gridY + markerDim + "points").toString();
}
else
{
pointIndicator.y = newY;
}
This works fine if I extend the features and use it on a PC or mac however if I try to use it on an ipad it does not work. Essentially this code is placed on the click event of a large button in a grid square.
Any help would be greatly appreciated.
I'm afraid I don't think you'll be able to get this to work.
The iPad version of Adobe Reader does not support XFA forms designed in LiveCycle Designer.
Got this code from #MichaelSaiz and altered it slightly, and the calendar widget looks/works great with the Calendar.css that comes with dojo 1.5.x on the Domino server.
However, I need to refresh a Calendar view when the user clicks on a date, and although fields are being refreshed OK, the view is behaving strangely, and I can't see why?
XSP.addOnLoad(function(){
dojo.require("dojox.widget.Calendar");
dojo.require("dojo.date","dijit.registry");
dojo.require("dojo.date.locale");
dojo.require("dijit.Calendar");
dojo.ready(function(){
// create the Calendar:
var selectedDate = null;
var calendar_body = new dojox.widget.Calendar({
value: new Date(),
onValueSelected: function(date){calendarDateClicked(date);
}
}, "calendar_body");
//create Click action
function calendarDateClicked(date){
var d = new Date(date);
var month = '' + (d.getMonth() + 1);
var day = '' + d.getDate();
var year = d.getFullYear();
if (month.length < 2) month = '0' + month;
if (day.length < 2) day = '0' + day;
var dateString = [day,month,year].join("/");
var y = dojo.date.locale.format(d, {datePattern:"dd/MM/yyyy", selector: 'date'});
//dojo.byId('#{id:hiddenCalWidgetSelectedDate}').value = dateString
dojo.byId('#{id:hiddenCalWidgetSelectedDate}').value = y;
dojo.byId('#{id:calDate}').value = y;
//dojo.byId('#{id:calDate}').value = dateString;
XSP.partialRefreshGet("#{id:dayPanel1}",{});//Post Value to server
}
});
});
This fires when the user clicks the calendar and it updates a field (calDate) and then updates the viewPanel (dayPanel1).
The view is filtered based on a calDate field which clicking on the calendar sets.
Any ideas how I can get the view refreshed when the user clicks on the calendar? Seems basic but it's driving me nuts!!
Graeme
The date format was incorrect (as #MichaelSaiz surmised). Got it sorted now.
XSP.addOnLoad(function(){
dojo.require("dojox.widget.Calendar");
dojo.require("dojo.date","dijit.registry");
dojo.require("dojo.date.locale");
dojo.require("dijit.Calendar");
dojo.ready(function(){
// create the Calendar:
var selectedDate = null;
var calendar_body = new dojox.widget.Calendar({
value: new Date(),
onValueSelected: function(date){calendarDateClicked(date);
}
}, "calendar_body");
//Set month in correct format
function setMonth(month){
switch(month)
{
case 1:
month = "Jan";
break;
case 2:
month = "Feb";
break;
}
return month;
}
//create Click action
function calendarDateClicked(date){
var d = new Date(date);
var month = (d.getMonth() + 1);
month = setMonth(month);
var day = '' + d.getDate() + ",";
var year = d.getFullYear();
//if (month.length < 2) month = '0' + month;
if (day.length < 2) day = '0' + day;
var dateString = [month,day,year].join(" ");
//var y = dojo.date.locale.format(d, {datePattern:"dd/MM/yyyy", selector: 'date'});
dojo.byId('#{id:hiddenCalWidgetSelectedDate}').value = dateString
//dojo.byId('#{id:hiddenCalWidgetSelectedDate}').value = y;
//dojo.byId('#{id:calDate}').value = y;
dojo.byId('#{id:calDate}').value = dateString;
XSP.partialRefreshPost("#{id:mainPanel}",{});//Post Value to server
}
});
});
I am currently working on a project to plot the activities of my day out by placing them around a 24 hr clock face. the final out come of this is a time management app that allows you to find spaces in your day that could be used more proficiently; however; I have hit a bit of a snafu and that is assigning each movie clip (each of which represents an activity) to its correct place of on the clock face.
I am using an XML file to pull the times from and the calculation of the angle where the movie clip should be placed on the clock is done in relation to a central movie clip.
for (i = 0; i < TimeSheet.length; i++) {
var counter = i + 1;
sortXML(TimeSheet);
}
}
};
function sortXML(TimeSheet){
var activity = TimeSheet[i].firstChild.nodeValue;
var description = TimeSheet[i].firstChild.nextSibling.childNodes;
var HrStart = TimeSheet[i].firstChild.nextSibling.nextSibling.childNodes;
var MinStart = TimeSheet[i].firstChild.nextSibling.nextSibling.nextSibling.childNodes;
var HrEnd = TimeSheet[i].firstChild.nextSibling.nextSibling.nextSibling.nextSibling.childNodes;
var MinEnd = TimeSheet[i].firstChild.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.childNodes;
var place = TimeSheet[i].firstChild.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.childNodes;
var creativity = TimeSheet[i].firstChild.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.childNodes;
var usefulness = TimeSheet[i].firstChild.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.childNodes;
var enjoyment = TimeSheet[i].firstChild.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.childNodes;
var focus = TimeSheet[i].firstChild.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.nextSibling.childNodes;
category = TimeSheet[i].nodeName;
HourStart = parseInt(HrStart, 10);
MinuteStart = parseInt(MinStart, 10);
HourEnd = parseInt(HrEnd, 10);
MinuteEnd = parseInt(MinEnd, 10);
Creativity = parseInt(creativity, 10);
Focus = parseInt(focus, 10);
Usefulness = parseInt(usefulness, 10)
var TimeSpent = ((HourEnd*60)+MinuteEnd) - ((HourStart*60)+MinuteStart) ;
//var ActivityMinutes = (HourStart*60)+MinuteStart;
var TimeStart = (HourStart*60)+MinuteStart;
var BobPlacement = ((TimeStart/1440)*360) // where the bob gets blaced on the circle
//var BobPlacement = (360/1440)*TimeStart;
//var radius = 150 + Usefulness;
var radius = 200 + (Usefulness/2);
var xcenter = _root.bobCentral._x;
var ycenter = _root.bobCentral._y;
var degree = (BobPlacement + 180)*-1;;
var radian;
radian = (degree/180)*Math.PI;
newBob._x = xcenter+Math.cos(radian)*radius;
newBob._y = ycenter-Math.sin(radian)*radius;
/*trace("-----------------------------------");
trace("category = "+category);
trace("activity = " + activity);
trace("Description = " + description);
trace("time start = " + HourStart + ":" + MinuteStart);
trace("time end = " + HourEnd + ":" + MinuteEnd);
trace("Duration of activity = "+TimeSpent);
trace("place = "+ place);
trace("creativity = "+ creativity);
trace("usefulness = "+ usefulness);
trace("enjoyment = "+ enjoyment);
trace("focus = "+ focus);
trace("Time Started = "+ TimeStart);
trace("palce on circle = "+ BobPlacement);
*/
dupeMC(TimeSheet, category, activity, description, HourStart, MinuteStart, TimeSpent, Creativity, Focus, Usefulness);
}
function dupeMC(TimeSheet, category, activity, description, HourStart, MinuteStart, TimeSpent, Creativity, Focus, Usefulness){
bob.duplicateMovieClip("bob"+i, i);
newBob = eval("bob"+i);
Any help would be much appreciated
I apologies in advance if the way I have put this question forward is confusing in any way.