Skip to content

Instantly share code, notes, and snippets.

View kuhel's full-sized avatar

Gleb Vorontsov kuhel

  • VK
  • St. Petersburg, Russia
View GitHub Profile
function downloadImage(imageSrc, fileName) {
const link = document.createElement('a');
link.href = imageSrc;
link.download = fileName || 'download';
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
}
function downloadImages(delay) {
@kuhel
kuhel / wallPhoto.js
Last active December 14, 2019 11:06
import fetchStream from 'fetch-readablestream';
const CORS_PROXY = "https://cors-anywhere.herokuapp.com/";
const APP_ID = 9999999;
async function fetchFileStream(fileAddress, filename, imgType) {
return fetchStream(fileAddress)
.then(response => readAllChunks(response.body))
.then(chunks => new File(chunks, filename, {type: imgType}));
};
@kuhel
kuhel / MiniApp
Created September 27, 2019 16:36
import React, { useState, useEffect } from 'react';
import connect from '@vkontakte/vk-connect';
import { View, ScreenSpinner } from '@vkontakte/vkui';
import '@vkontakte/vkui/dist/vkui.css';
import Home from './panels/Home';
import Persik from './panels/Persik';
const App = ({ vkConnect }) => {
const [activePanel, setActivePanel] = useState('home');
const crypto = require('crypto') //модуль для криптографии Nodejs
const { stringify } = require('querystring') //методы для парсинга строки
const url = require('url')
const URL =
'https://example.com/?vk_user_id=494075&vk_app_id=6736218&vk_is_app_user=1&vk_are_notifications_enabled=1&vk_language=ru&vk_access_token_settings=&vk_platform=android&sign=exTIBPYTrAKDTHLLm2AwJkmcVcvFCzQUNyoa6wAjvW6k',
CLIENT_SECRET = 'wvl68m4dR1UpLrVRli'
const checkVKQueryParamsSign = params => {
import * as VKConnect from '@vkontakte/vkui-connect';
VKConnect.send('VKWebAppInit');
if (VKConnect.supports('VKWebAppCallAPIMethod')) {
VKConnect.send('VKWebAppCallAPIMethod');
} else {
launchModalDialog('Обновите клиент!');
}
@kuhel
kuhel / index.js
Created February 17, 2019 13:55
VK UI Connect Init
import 'core-js/es6/map';
import 'core-js/es6/set';
import connect from '@vkontakte/vkui-connect';
connect.send('VKWebAppInit', {});
@kuhel
kuhel / index.js
Last active January 11, 2019 17:01
import 'core-js/es6/map';
import 'core-js/es6/set';
import connect from '@vkontakte/vkui-connect';
// Init VK App
connect.subscribe((e) => {
switch (e.detail.type) {
case 'VKWebAppGetUserInfoResult':
console.log('User: \n', e.detail.data);
break;
@kuhel
kuhel / demo.1.html
Last active December 29, 2018 14:01
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no, user-scalable=no, viewport-fit=cover">
<meta name="theme-color" content="#000000">
<meta content="IE=Edge" http-equiv="X-UA-Compatible">
<title>VK App Demo</title>
</head>
<body>
@kuhel
kuhel / qr.js
Last active December 25, 2018 12:38
QR code canvas
function QR8bitByte(e) {
this.mode = QRMode.MODE_8BIT_BYTE;
this.data = e
}
function QRCode(e, t) {
this.typeNumber = e;
this.errorCorrectLevel = t;
this.modules = null;
this.moduleCount = 0;
this.dataCache = null;
@kuhel
kuhel / transition.css
Created February 15, 2018 10:18
Nice transition
.transition {
transition: transform .294s cubic-bezier(.19,1,.22,1);
}