Skip to content

Instantly share code, notes, and snippets.

View athlonUA's full-sized avatar
:octocat:
I may be slow to respond.

Alexander G. athlonUA

:octocat:
I may be slow to respond.
View GitHub Profile
const http = require('http'),
fs = require('fs');
http.createServer(function(request, response) {
const filePath = 'test.wav';
const stat = fs.statSync(filePath);
const fileSize = stat.size;
const range = request.headers.range;
if (range) {
(function() {
Element.prototype.eventListenerList = {};
Element.prototype._addEventListener = Element.prototype.addEventListener;
Element.prototype.addEventListener = function(type, listener) {
this._addEventListener(type, listener);
if (!this.eventListenerList[this.id]) {
this.eventListenerList[this.id] = {};
}
@athlonUA
athlonUA / hack.js
Last active November 12, 2018 15:51
Solution of the "Цвет настроения — красный" Game https://meduza.io/games/tsvet-nastroeniya-krasnyy-igra-meduzy
function f() {
const nodes = document
.getElementById('/embed/colors-game')
.contentWindow.document.getElementsByClassName('_3K3dipl65wOMpaMU-KVKf0');
const nodesByColor = {};
for (let i = 0; i < nodes.length; i++) {
const outerHTML = nodes[i].outerHTML;
const color = outerHTML.split('background-color: ')[1].split(';')[0];
if (typeof nodesByColor[color] === 'undefined') {
nodesByColor[color] = [];
@athlonUA
athlonUA / nginx_remove_double_slashes.md
Created August 2, 2018 12:08 — forked from JustThomas/nginx_remove_double_slashes.md
nginx: Remove double slashes from URLs

Put the following directives in your server block. nginx will then redirect URLs with double (or triple or multiple) slashes to the corresponding URL with a single slash.

merge_slashes off;
rewrite ^(.*?)//+(.*?)$ $1/$2 permanent;
(() => {
var windowWidth = window.innerWidth;
var windowHeight = window.innerHeight;
var userAgent = navigator.userAgent;
var location = window.location.href;
var info = `Window: ${windowWidth}x${windowHeight}
User Agent: ${userAgent}
Location: ${location}`;
@athlonUA
athlonUA / script.js
Last active April 29, 2019 08:34
Google reCAPTCHA V2. Change language in real time
// Enum for language codes
var languageListsGoogleCaptchaEnum = {
Arabic: 'ar',
Afrikaans: 'af',
Amharic: 'am',
Armenian: 'hy',
Azerbaijani: 'az',
Basque: 'eu',
Bengali: 'bn',
Bulgarian: 'bg',
@athlonUA
athlonUA / object-to-form-data.js
Created June 19, 2017 13:39 — forked from ghinda/object-to-form-data.js
JavaScript Object to FormData, with support for nested objects, arrays and File objects. Includes Angular.js usage.
// takes a {} object and returns a FormData object
var objectToFormData = function(obj, form, namespace) {
var fd = form || new FormData();
var formKey;
for(var property in obj) {
if(obj.hasOwnProperty(property)) {
if(namespace) {

Keybase proof

I hereby claim:

  • I am athlonUA on github.
  • I am athlon_ua (https://keybase.io/athlon_ua) on keybase.
  • I have a public key whose fingerprint is 6662 9731 9C35 AC92 2934 6DC5 8F9D C802 C6A0 D078

To claim this, I am signing this object:

@athlonUA
athlonUA / gist:3ba6fd27df86f70cbb3bc3b13711e05a
Created July 20, 2016 20:27
elasticsearch aggregation by first letters of search fields
$field - the name of field to aggregate
$firstChars - the first letters to search aggregations values by
$data = [
'query' => [
'bool' => [
'must' => [
'query_string' => [
'query' => $field . ':' . $firstChars . '*'
]