Skip to content

Instantly share code, notes, and snippets.

View mib32's full-sized avatar

Antoni Mur mib32

View GitHub Profile
@mib32
mib32 / views.js
Created January 22, 2021 14:12
How to fetch message views using TaaS
async function taasRequest(data) {
data.api_key = "xxxxxx:xxxxxxxx";
let res = await fetch('https://api.t-a-a-s.ru',
method: 'POST',
body: JSON.generate(data)
)
res = await res.json();
return res;
}

Кодовое название “Хранилище” - сервис хранения данных в своем Телеграме. Как Яндекс.Диск и прочее, только файлы хранятся у вас в “Избранных сообщениях” - мы используем Телеграм как облачное хранилище.

Что нужно сделать? Дизайн Бэкенд Фронтенд

Уже есть каркас приложения на Ruby on Rails и React JS - с аутентификацией через Телеграм. Можно сделать с нуля на чем-то покруче, почему бы и нет. Желательно чтобы могло крутится на бесплатном тире Хероку - хотя согласен что это спорная идея.

Для связи с Телеграмом будем использовать https://www.t-a-a-s.ru

We use the Flux pattern, meaning triggering actions and reacting to state changes is done in a certain way. Calling the API and using a promise in the component isn't Flux. Your code here I'm sure works, however in a web app like ours we can quickly run into problems if we don't follow this Flux pattern.
For example, it's common that multiple different actions happen at once. Separate components may also be interested in the the result of an action and want to react to a state change. One or more actions may error.
In the jQuery/promises world web apps like ours quickly ended up in callback hell with messy chains of API calls and updates/errors. Functions got really large too. Flux is an architecture that helps us avoid that as long as we stick to some rules like:
components render store state and call actions (nothing else)
actions make API calls and update the store with the result (state)
components listen to the store and react to state changes
This lets us keep components, actions and stores small and
@mib32
mib32 / compressor_test
Created November 29, 2017 21:48
Performance comparison of JS and CSS compressors
#!/usr/bin/env ruby
require 'sprockets'
require 'uglifier'
require 'closure-compiler'
require "yui/compressor"
require 'sass-rails'
require 'httparty'
@mib32
mib32 / function_1.rb
Created June 3, 2016 17:03
function of double array calculation
stats_source.clicks_statistic_by(start_date..end_date, :device).tap {|arr| arr.map{|row| row[:max] = arr.max{|a, b| a[:clicks_amount] <=> b[:clicks_amount]}[:clicks_amount]}}.map{|row| row[:clicks_percentage] = 100 * row[:clicks_amount] / row[:max]; row}.each do |row|
print row
end
#= require jquery
#= require bootstrap
#= require ./application-view
@Modal = ApplicationView
getStores: ->
ModalStore
getPropsFromStores: ->
paths = Dir[Rails.root.join("config/routes/**/*.rb")]
updater = ActiveSupport::FileUpdateChecker.new(paths) { Rails.application.routes_reloader.reload!; Rails.logger.debug('shita') }
Rails.application.configure do
config.to_prepare do
puts 'updated status: ' + updater.updated?.to_s
Rails.logger.debug('shita')
updater.execute_if_updated
end
end
@mib32
mib32 / file.txt
Created September 7, 2015 11:09
javascript_include_tag profiling
Measure Mode: wall_time
Thread ID: 70308086497800
Fiber ID: 2341215640
Total: 4.077675
Sort by: self_time
%self total self wait child calls name
6.24 0.255 0.255 0.000 0.000 89 IO#read
3.70 0.151 0.151 0.000 0.000 21928 String#gsub
require 'digest/md5'
string = 'MerchantId=5000&OrderId=214545&Amount=500.00&Currency=RUB&PayRequsites={
"PayRequsites" : {
"ReceiverName" : "УФК по МО (УГИБДД ГУ МВД России по Московской области)",
"ReceiverInn" : "7702300872",
"ReceiverKpp" : "770201001",
"Bic" : "044583001",
"BankName" : "Отделение №1 МГТУ Банка России г.Москва 705",
"Account" : "40101810600000010102",
"CorrAccount" : "40101810600000010102",
@mib32
mib32 / .rb
Last active August 29, 2015 14:26
30.07.2015
OK.[{"Сид"=>{:tariff=>"5496", :type=>"Сид"}}, {"Купе"=>{:tariff=>"2616", :type=>"Купе"}}, {"Люкс"=>{:tariff=>"5735", :type=>"Люкс"}}, {"Мягкий"=>{:tariff=>"16617", :type=>"Мягкий"}}]
31.07.2015
RID.RID.OK.[{"Купе"=>{:tariff=>"1546", :type=>"Купе"}}, {"Люкс"=>{:tariff=>"4880", :type=>"Люкс"}}, {"Плац"=>{:tariff=>"1387", :type=>"Плац"}}, {"Сид"=>{:tariff=>"13037", :type=>"Сид"}}, {"Мягкий"=>{:tariff=>"17694", :type=>"Мягкий"}}]
01.08.2015
RID.RID.RID.RID.OK.[{"Люкс"=>{:tariff=>"3990", :type=>"Люкс"}}, {"Купе"=>{:tariff=>"2032", :type=>"Купе"}}, {"Плац"=>{:tariff=>"1387", :type=>"Плац"}}, {"Сид"=>{:tariff=>"3225", :type=>"Сид"}}, {"Мягкий"=>{:tariff=>"13964", :type=>"Мягкий"}}]
02.08.2015
RID.RID.RID.OK.[{"Купе"=>{:tariff=>"2089", :type=>"Купе"}}, {"Люкс"=>{:tariff=>"4869", :type=>"Люкс"}}, {"Плац"=>{:tariff=>"1387", :type=>"Плац"}}, {"Сид"=>{:tariff=>"3870", :type=>"Сид"}}, {"Мягкий"=>{:tariff=>"14895", :type=>"Мягкий"}}]