Skip to content

Instantly share code, notes, and snippets.

View fxdave's full-sized avatar
🏠
Working from home

David Judge fxdave

🏠
Working from home
View GitHub Profile
@fxdave
fxdave / mocha_example.js
Created November 27, 2019 23:15
example code of mocha testing framework
describe("Testing something.", () => {
describe("Testing something", () => {
let val;
before(async () => {
val = await something();
});
it("shouldn't be null", () => {
assert(something !== null);
})
@fxdave
fxdave / Example.ts
Last active October 4, 2019 21:24
When you want to utilize a rust like Result structure, because it helps you to organize the code better.
function calc(a: number): Result<string, string> {
if (a !== 0) {
return Some("thing")
} else {
return Err("a cannot be zero")
}
}
let result = calc(0)
if(result.error) {
@fxdave
fxdave / dockertut.md
Created November 28, 2018 11:30
I got "No route to host" "Bad gateway" errors from the containers. This fixed my issue.

Delete all your rules and reset iptables.
My /etc/iptables/iptables.conf :

*filter
:INPUT DROP [0:0]
:FORWARD DROP [0:0]
:OUTPUT ACCEPT [0:0]
-A INPUT -p icmp -j ACCEPT 
-A INPUT -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT 
@fxdave
fxdave / first.md
Last active December 3, 2018 22:20
Kód normalizálás PHP

Kód normalizálás 1.

Nagyon sok dolog hiányzik belőle, szigorúan csak 1 principal-re vonatkoztattam! Ezek nem bevett szokások! A bevett szokás az hogy felrakunk egy framework-öt.

Kezdésként vegyünk egy oldalt, ahol minden kívánt funkciót, az elérési úton lévő php fájlban implementáltak, pl:

  • register.php
  • login.php
  • posts.php

Más fájlok nincsenek egyenlőre.

@fxdave
fxdave / Vector.js
Last active September 27, 2018 12:39
Simple 2D Vector class
/**
* @author Dávid Biró <dbiro97@gmail.com>
* @module Math
* @license MIT
*/
export default class Vector {
/**
*
* @param {number} x
@fxdave
fxdave / install_optionals.py
Last active August 27, 2018 14:41
This script installs all optional dependecies of the already installed packages (Arch linux, pacman, python 3.7.0)
import subprocess
import re
import math
regex = r".*Optional Deps\s*:(.*)\|\|\|Required By"
def getOptDepsFor(lib):
out = subprocess.run(["pacman","-Qi",lib], capture_output=True)
out = out.stdout.decode("utf-8").replace("\n","|||").replace("\r","")
match = re.match(regex, out)
if match: