lundi 1 janvier 2018

Inject a date into new entry in firebase db

My issue is to inject an actual date when push a data into firebase db.

When user registers himself, following code is being executed:

firebase.database().ref('users').push().set(userData);

Everything works well. However, I would like to display in user profile the date when he created his account.

I could do it just with pushing new Date() with user data to db, but it will fail if user has an incorrect date on his computer. I would prefer to use actual date coming from server (or firebase?).

Q: How to inject actual date into firebase entry?

Q2: Is there any date service/function in firebase, which will provide actual date?

Thanks!




Visual Studio does not open designer in WebApplication

I have the problem, that if I try to edit the design from any WebApplication, the designer does not open. After that i need to restart Visual Studio, because it "stuck", but only in this window. I tested this on several computers, but always the same problem.

Screenshots: I clicked on Design, but nothing happend. After that i open and close the Toolbox.




Image not showing in deployed vue.js app

I have created a vue.js app which works perfectly when run in localhost. when I build it and deploy to a website , the images don't display.

The images are in the src>assets folder.

I am using the (progressive-image plugin).

Is there anything I must do to ensure that the images are included in the build file?




invite user by username to telegram channel

i trying to add users by usernames to my channel. I am using python 3.6 telethon library and pythonanywhere server:

api_hash = 'b7**'
phone = '+7***'
client = TelegramClient('new_ses', api_id, api_hash)
client.connect()
client = TelegramClient('session_neworig', api_id, api_hash,)
client.connect()

from telethon.tl.functions.channels import InviteToChannelRequest
from telethon.tl.functions.contacts import ResolveUsernameRequest
from telethon.tl.types import InputPeerChannel ,InputPeerUser,InputUser
from telethon.tl.functions.channels import JoinChannelRequest

chann=client.get_entity('channelname') #its public channel
print(chann.id)
1161823752

print(chann.access_hash)
8062085565372622341

time.sleep(30)
chan=InputPeerChannel(chann.id, chann.access_hash)
user = client(ResolveUsernameRequest('Chai***'))


print(user.users[0].id)
193568760
print(user.users[0].access_hash)
-4514649540347033311
time.sleep(1*30)

user=InputUser(user.users[0].id,user.users[0].access_hash,)

client.invoke(InviteToChannelRequest(chan,[user]))

This dosent work and i get -telethon.errors.rpc_error_list.PeerFloodError: (PeerFloodError(...), 'Too many requests')

what am i doing wrong? how to avoid it ? this one code is worked for me , but i am gone to flood after added let's say 20 users :

 from telethon.helpers import get_input_peer

client.invoke(InviteToChannelRequest(
    get_input_peer(client.get_entity(chan),
    [get_input_peer(client.get_entity(user))]
))

Please help , how to add 200 users by username without any ban , maybe there is another way to do it by python ? another lib or by api ?




Vanilla JavaScript NPM web project starter

I'm looking for NPM toolset to help me to create baseline for Web projects with vanilla JS. So, as we set up Angular projects with angular-cli ng init command, React projects with create-react-app, is there any recommended NPM global tooling to set up all common toolchain (mainly Webpack, Babel and some development server with hot reloading/change detection) for non framework based projects?

Thank you for any suggestinos




While HTML-button pressed

I made a game in HTML for my website which works perfectly fine on PC, but now I would like it to be compatible with mobile devices too. Since you don't have a psysical keybaord to move the player around with, I would like a function to be triggered while one of four directional HTML-buttons is pressed. Is there a way to do this without the player constantly needing to re-press the same button? Something like: "while button pressed" --> "run this function"




Progressive Web App for Openlayers/Leaflet

I am trying to develop a Progressive App for Openlayers/ Leaflet based application. Is there any open-source template available for the same?