Skip to content

Instantly share code, notes, and snippets.

View Zapix's full-sized avatar

Aibulatov Alex Zapix

  • Epam Systems
  • Malaga, Spain
  • X @Zapix
View GitHub Profile
import { tag, encode, decode } from './paddedIntermidiate';
import getObfuscation from './obfuscation';
/**
* Base class to work with telegram websocket
*/
export default class Connection extends EventTarget {
constructor(url) {
super();
this.url = url;
/**
* Encrypts by AES-CTR
* @param {ArrayBuffer} buffer
* @param {ArrayBuffer} key
* @param {ArrayBuffer} iv
*/
export function encryptCtr(buffer, key, iv) {
const bufferView = new Uint8Array(buffer);
const keyView = new Uint8Array(key);
const ivView = new Uint8Array(iv);
(function() {
var current = createMyObj();
function createMyObj() {
var newFigure = new myobj('red');
return newFigure;
}
function start(){
const cathcEventMiddleware = store => next => action => {
const eventType = 'eventType';
const eventListener = event => {
dispatch({
type: 'BROWSER_EVENT_FIRED',
eventType: eventType,
event
});
@Zapix
Zapix / redux-saga.js
Last active December 21, 2017 08:00
compare thunk vs saga
function* makeRequest() {
const response = yield call(
fetch,
'/url',
);
if (response status === 200) {
yield put({ type: 'SUCCESS' });
} else {
yield put({ type: 'FAILED' });
const step = 3;
const posts = new Array(100)
.fill('p')
.map((item, idx) => `${item}${idx + 1}`)
.map((item, idx) => ((idx + 1) % step) === 0 ? [item, null] : [item])
.reduce((acc, item) => [...acc, ...item], []);
console.log(posts);
@Zapix
Zapix / promo.py
Created September 11, 2016 15:34
Wok promo from farfor
import requests
response = requests.get('http://ufa.farfor.ru')
csrftoken = response.cookies['csrftoken']
while True:
response = requests.post(
'http://ufa.farfor.ru/api/marketing/slotmachine/',
headers={
'host': 'ufa.farfor.ru',
import { expect } from 'chai';
import nock from 'nock';
import configureStore from 'redux-mock-store';
import thunk from 'redux-thunk';
import { login, signUp, alertMessage, loadMe } from './application';
import constants from '../constants/application';
const middlewares = [thunk];
const mockStore = configureStore(middlewares);
import constants from '../constants/application';
export function showDialog(dialogName) {
return { type: constants.SHOW_DIALOG, payload: { dialogName } };
}
export function hideDialog() {
return { type: constants.HIDE_DIALOG };
}
@Zapix
Zapix / es7.jsx
Created June 18, 2016 06:46
func bindings react
class SomeComponent extends React.Component {
static propTypes = {
action: PropTypes.func,
}
handleSubmit() {
const { action } = this.props;
action();
}