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 / problem.js
Last active June 26, 2019 08:44
Hitting hobbits for the first time
/** You need to add right body parts */
const asymHobbitBodyParts = [{name: "head", size: 3},
{name: "left-eye", size: 1},
{name: "left-ear", size: 1},
{name: "mouth", size: 1},
{name: "nose", size: 1},
{name: "neck", size: 2},
{name: "left-shoulder", size: 3},
{name: "left-upper-arm", size: 3},
{name: "chest", size: 10},
@3rdp
3rdp / history (preparing)
Last active November 23, 2018 08:32
Answering @ikngtty's question about `***` wildcard in fish shell
box@0536908972a6 ~> mkdir -p important/very-important/this.fish
box@0536908972a6 ~> mkdir -p usual/not-interested.fish
box@0536908972a6 ~> rm important/very-important/this.fish/ -R
box@0536908972a6 ~> touch important/very-important/this.fish
box@0536908972a6 ~> touch test.fish
box@0536908972a6 ~> rm -R usual/not-interested.fish
box@0536908972a6 ~> touch usual/not-interested.fish
box@0536908972a6 ~> vim
@3rdp
3rdp / pre-commit.sh
Last active June 6, 2019 06:52 — forked from gerad/pre-commit.sh
git pre-commit hook that checks for debugger / console.log
#!/bin/sh
#
# An example hook script to verify what is about to be committed.
# Called by git-commit with no arguments. The hook should
# exit with non-zero status after issuing an appropriate message if
# it wants to stop the commit.
#
# To enable this hook, make this file executable.
if git-rev-parse --verify HEAD 2>/dev/null
@3rdp
3rdp / sgdq-2019.txt
Created July 2, 2019 13:17
schedule from sgdq 2019; a neat list of games
Games Done Quick
Event Info
Community Info
About Us
Discord
VODS
HOTFIX
{
"name": "hooks-chat",
"version": "0.1.0",
"private": true,
"dependencies": {
"react": "^16.8.6",
"react-dom": "^16.8.6",
"react-scripts": "3.0.1",
"use-immer": "^0.3.3",
"use-socket.io-client": "^1.0.4"
@3rdp
3rdp / README.md
Created March 22, 2020 10:13
get dependencies of a package in a monorepo

Motivation

I have this awesome tool madge. I do

madge --extensions ts,tsx,js,jsx --json .

to get a nice view of local (read non-NPM) dependencies.

I have this awesome tool depcruise. I do

function timeSince(timeStamp) {
var now = new Date(),
secondsPast = (now.getTime() - timeStamp.getTime()) / 1000;
if(secondsPast < 60){
return [-parseInt(secondsPast), 'seconds']
}
if(secondsPast < 3600){
return [-parseInt(secondsPast/60), 'minutes']
}
if(secondsPast <= 86400){
@3rdp
3rdp / nocommit.sh
Last active April 16, 2021 15:22
no commit comment check in pre-commit hook
# NO COMMIT ;)
for FILE in `git diff --name-only --cached` ; do
if grep -q 'NO COMMIT' $FILE
then
echo $FILE ' contains NO COMMIT!'
exit 1
fi
done
exit
@3rdp
3rdp / gist:dca687639249025cb270bb82cb5b929d
Last active August 22, 2021 11:30
redbean 1.4 cache bug (seems to affect all html files except index.html)
going to update the file
D2021-08-22T03:52:47.871283:tool/net/redbean.c:1839:redbean-1:74710] indexing assets (inode 0xf79b5b)
cmd+r
D2021-08-22T03:53:06.587155:tool/net/redbean.c:5353:redbean-1:74731] 127.0.0.1:63870 LOOPBACK read 618 bytes
I--------------------000027:tool/net/redbean.c:4949:redbean-1:74731] RECEIVED 127.0.0.1:63870 LOOPBACK HTTP11 GET http://localhost:8080/hello.html "http://localhost:8080/" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:90.0) Gecko/20100101 Firefox/90.0"
D--------------------000006:tool/net/redbean.c:4984:redbean-1:74731] RoutePath("/localhost/hello.html")
D--------------------000003:tool/net/redbean.c:4984:redbean-1:74731] RoutePath("/www.localhost/hello.html")