Skip to content

Instantly share code, notes, and snippets.

View avorona's full-sized avatar

Vitalii Parshykov avorona

View GitHub Profile
from telethon import TelegramClient, sync
# Use your own values here
api_id = '123456'
api_hash = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
channel = 'channel_name'
client = TelegramClient('Session_details', api_id, api_hash)
phone_number='0000000000'
@avorona
avorona / moment-timezone-display.js
Last active October 16, 2019 09:04
Display moment time in a provided format
const cutoffString = '2017-12-12 10:20:20';
const utcCutoff = moment.utc(cutoffString, 'YYYYMMDD HH:mm:ss');
const displayCutoff = utcCutoff.clone().tz('America/New_York');
{
// Place your snippets for javascriptreact here. Each snippet is defined under a snippet name and has a prefix, body and
// description. The prefix is what is used to trigger the snippet and the body will be expanded and inserted. Possible variables are:
// $1, $2 for tab stops, $0 for the final cursor position, and ${1:label}, ${2:another} for placeholders. Placeholders with the
// same ids are connected.
// Example:
// "Print to console": {
// "prefix": "log",
// "body": [
// "console.log('$1');",
@avorona
avorona / appsync-iam-policy.json
Last active January 18, 2019 09:05
IAM policy for the IAM auth in AppSync
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"appsync:GraphQL"
],
"Resource": [
"arn:aws:appsync:<AWS region>:<AWS account ID>:apis/<app sync endpoint ID>/*"
@avorona
avorona / aws_apollo.js
Created January 9, 2019 12:00
AWS+APOLLO: link, cache-inmemory
import * as React from "react";
import * as ReactDOM from "react-dom";
import { BrowserRouter } from "react-router-dom";
import Amplify, { Auth } from "aws-amplify";
import { ApolloProvider } from "react-apollo";
import { ApolloLink } from "apollo-link";
import { InMemoryCache } from "apollo-cache-inmemory";
import AWSAppSyncClient, { createAppSyncLink } from "aws-appsync";
import { withClientState } from "apollo-link-state";
@avorona
avorona / s3-format-file-name.js
Created December 25, 2018 09:59
Function to prepare file before uploading to the s3 bucket
formatFilename = filename => {
const date = moment().format("YYYYMMDD");
const randomString = Math.random()
.toString(36)
.substring(2, 7);
const cleanFileName = filename.toLowerCase().replace(/[^a-z0-9]/g, "-");
const newFilename = `images/${date}-${randomString}-${cleanFileName}`;
return newFilename.substring(0, 60);
};
@avorona
avorona / storage.js
Created November 21, 2018 12:57 — forked from MichalZalecki/storage.js
Simple sessionStorage/localStorage wrapper factory
import storageFactory from "./storageFactory";
export const localStore = storageFactory(localStorage);
export const sessionStore = storageFactory(sessionStorage);
import ApolloClient from 'apollo-client';
import { HttpLink } from 'apollo-link-http';
import { ApolloLink } from 'apollo-link';
import { InMemoryCache } from 'apollo-cache-inmemory';
import { onError } from 'apollo-link-error';
import { setContext } from 'apollo-link-context';
import { onLogout } from '../containers/App/actions';
import firebase from '../firebase';
@avorona
avorona / file-structure
Last active August 1, 2018 14:33
How to add custom font to the Storybook
.storybook
--webpack.config.js
app
--package.json
----assets
------fonts
--------Lato-Regular.woff
--------Lato-Regular.woff2
import React, { PureComponent, Fragment } from 'react';
import PropTypes from 'prop-types';
import { Text, View, Image } from 'react-native';
import s from './styles';
class AvatarWithFallback extends PureComponent {
getFirstCharFromString = string => string.substring(0, 1).toUpperCase();
render() {