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
@kuhel
kuhel / 0_reuse_code.js
Last active August 29, 2015 14:22
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
const fs = require('fs');
const request = require('request');
fs.readFile('./config.json', 'utf-8', (err, data) => {
if (err) {
throw new Error(err);
}
request('http://www.google.com', (error, response, body) => {
console.log('statusCode:', response.statusCode); // Print the response status code if a response was received
});
const net = require('net');
const client = new net.Socket();
client.connect(9191, '127.0.0.1', function() {
console.log('Connected');
client.write('2 + 4');
});
client.on('data', function(data) {
console.log('Received: ' + data);
client.destroy(); // kill client after server's response
@kuhel
kuhel / transition.css
Created February 15, 2018 10:18
Nice transition
.transition {
transition: transform .294s cubic-bezier(.19,1,.22,1);
}
@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 / 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 / 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 / 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', {});
import * as VKConnect from '@vkontakte/vkui-connect';
VKConnect.send('VKWebAppInit');
if (VKConnect.supports('VKWebAppCallAPIMethod')) {
VKConnect.send('VKWebAppCallAPIMethod');
} else {
launchModalDialog('Обновите клиент!');
}
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 => {