Skip to content

Instantly share code, notes, and snippets.

View reepush's full-sized avatar

Grisha Pushkov reepush

View GitHub Profile
const puppeteer = require('puppeteer')
const urls = [
'https://ticket.rzd.ru/searchresults/v/1/5a3244bc340c7441a0a556ca/5a323c29340c7441a0a556bb/2022-06-28?aim=social-media&trainNumber=759%D0%90',
'https://ticket.rzd.ru/searchresults/v/1/5a3244bc340c7441a0a556ca/5a323c29340c7441a0a556bb/2022-06-28?aim=social-media&trainNumber=761%D0%90',
]
const main = async () => {
const browser = await puppeteer.launch({ headless: false })
const page = await browser.newPage()
@reepush
reepush / readme.md
Last active February 12, 2018 10:24
local host to port mapping
brew install nginx
/etc/hosts

127.0.0.1 admin.local
@reepush
reepush / vue-loader.js
Last active January 17, 2018 17:33
Vue template loader
Vue.componentExternal = function(name, options) {
Vue.component(name, function(resolve) {
fetch(`components/${name}/${name}.html`)
.then(response => response.text())
.then(template => {
resolve(Object.assign(options, {
template: template
}))
})
})
@reepush
reepush / index.html
Created July 18, 2017 09:24
Login page
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<style>
.form-signin {
max-width: 330px;
margin: auto;
margin-top: 100px;
}
</style>
<div class="container">
@reepush
reepush / README.md
Last active December 13, 2015 17:14
Proxify assets with BrowserSync

Use BrowserSync as proxy with serving local files.

@reepush
reepush / links.md
Last active November 25, 2015 12:16
Firefox DevTools
@reepush
reepush / _description.md
Created August 16, 2015 18:46
ШРИ-2015 (задание 1)
@reepush
reepush / _description.md
Last active August 29, 2015 14:27
ШРИ-2015 (задание 3)
@reepush
reepush / _description.md
Last active August 29, 2015 14:27
ШРИ-2015 (задание 2)

Проблема заключается в том, что при вызове callback() переменная request всегда имеет значение /populations. Это происходит из-за асинхронного вызова функции callback().

Есть два способа решения проблемы:

  1. Использование bind (bind.js)
  2. Использование замыкания (closure.js)

В обоих случаях переменная request сохраняет значение, которое она имела на момент вызова функции getData().

В файле alternative.js сделан вывод популяции страны.

@reepush
reepush / server.js
Created July 20, 2015 13:24
CORS proxy
var express = require('express')
var request = require('request')
var app = express()
app.get('/', function(req, res) {
var src = req.query.src
res.header('Access-Control-Allow-Origin', '*')
if (!src) { res.send(''); return }