Skip to content

Instantly share code, notes, and snippets.

View 3rdp's full-sized avatar

Alex Davydenko 3rdp

  • Ukraine
View GitHub Profile
@3rdp
3rdp / Complaining.txt
Last active October 2, 2018 11:05
Embed: Error in console from 'embed.js' file
I work on a project for a blog web-site and I'm trying to resolve the issue I constantly get on an article page.
On an article page, we have a subscribe form. When user posts a request to subscribe to our blog, the error from Disqus embed file pops up in user's browser console: "TypeError: c is null" in Firefox, or "TypeError: Cannot read property 'sender' of null" in Chrome.
I tried to debug the issue and I stumbled upon a global (window.addEv...) 'message' event handler which parses 'data' property of its first parameter as JSON. But! This 'data' parsing is via JSON.parse and JSON.parse(null) throws no error and just returns null, meaning that though Disqus developers embedded the parsing procedure in try-catch statement, the code execution continues until on the next line you try to access property 'sender' of a null.
Can you please resolve the issue?
@3rdp
3rdp / vscode.json
Created June 14, 2018 12:20
My VSCode settings
{
"git.confirmSync": false,
"editor.tabSize": 2,
"window.zoomLevel": -1,
"editor.renderControlCharacters": false,
"explorer.confirmDragAndDrop": false,
"eslint.validate": [
"javascript",
"javascriptreact",
{
@3rdp
3rdp / .hyper.js
Last active April 4, 2018 09:34
Git Bash + Hyper
module.exports = {
shell: 'C:\\Program Files\\Git\\usr\\bin\\bash.exe',
shellArgs: ['-l', '-i'],
env: {TERM: 'cygwin'},
/** hypercwd plugin breaks */
}
@3rdp
3rdp / index.js
Created March 19, 2018 17:35
Scale SVG path; output scaled path to file.
const pathast = require('path-ast')
const fs = require('fs')
const pathStr = 'M0.8572927713394165,-1.4711437225341797C0.8572927713394165,-1.4369948508298824,0.8682440455349504,-1.4005078563677493,0.8709338903427124,-1.366212010383606C0.8776826492648646,-1.2801645194985007,0.8804045332926923,-1.1940720868133363,0.8877229690551758,-1.1080797910690308C0.8915414388864679,-1.0632124180838844,0.8846852909889699,-1.0176606977598863,0.8898215889930725,-0.9727177619934082C0.8963484015589094,-0.9156077349521522,0.8963460263068671,-0.8637286793616796,0.8887723088264465,-0.8069254755973816C0.88760593190895,-0.7981775990253006,0.8941220903616892,-0.7752338143373014,0.8887723088264465,-0.7681007385253906C0.8770788784447072,-0.7525094242138122,0.8493030484211967,-0.7501287302461596,0.8321091532707214,-0.7481637001037598C0.7888428424721896,-0.7432189447632457,0.7389142063430592,-0.7438954126416102,0.6956977844238281,-0.7481637001037598C0.6102252345500444,-0.7566054312046374,0.5268991562099881,-0.7773976475199617,0.445960134
@3rdp
3rdp / TrackerPDO.php
Created March 8, 2018 13:09
Simple logger for PHP
<?php
class TrackerPDO {
private static $_instance = null;
private static $request_log = array();
private function __construct() {
}
protected function __clone() {
@3rdp
3rdp / countOfSymbol.js
Last active November 27, 2017 21:36 — forked from anonymous/countOfSymbol.js
Test quest javascript / Save The Day
/*
* Finished: 30 min
*/
function countOfSymbol(arr) {
let filter2 = (v) => v == '2'
return arr.map((v) => v.toString().split(''))
.reduce((prev, curr) => prev.filter(filter2).length >= curr.filter(filter2).length ? prev : curr, [])
.join('') || null
}
#!/bin/bash
ALARM='today 22:45'
SOUND='/home/sasha/Музика/'
sudo rtcwake -d rtc0 -m mem -t $(date +%s -d "$ALARM") -v && vlc -L $SOUND
@3rdp
3rdp / stuff.sh
Last active May 12, 2017 05:26
useful stuff
# play white noise right in the terminal https://askubuntu.com/a/789472/352074
play -n synth brownnoise synth pinknoise
play -n synth whitenoise
@3rdp
3rdp / regex_autoselect_google_keep.js
Last active May 10, 2017 19:37
an attempt to auto select multiple notes in google keep. with jquery 1.10.1
var regx = /\d+\D\d+\D\d+/; // to find headers like "20/04/2017"
var notes_clstr = ".IZ65Hb-n0tgWb.IZ65Hb-WsjYwc-nUpftc";
var header_clstr = ".IZ65Hb-YPqjbf.r4nke-YPqjbf";
var button_select_clstr = ".Q0hgme-LgbsSe.Q0hgme-Bz112c-LgbsSe.IZ65Hb-NGme3c.VIpgJd-LgbsSe";
var button_not_clstr = ".LwH6nd";
$(notes_clstr).each(function() {
// 1. check an header
var header_text = $(this).find(header_clstr).not(button_not_clstr).text();
if (!regx.test(header_text)) return;
console.log(header_text);
@3rdp
3rdp / helloworld.pl
Last active June 17, 2016 22:18
балуюсь с perl
use strict;
use warnings;
# print "Hello world. " x 80; # умножение
# print "\n\nHello world!";
# print "Hello" ge "wor";
# my $var = 'A string'; # объявляем скаляр
# print $var;