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 / 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:
@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 / 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 / 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 / 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 / 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 / main.rs
Created December 29, 2019 16:09
example code for XCB in rust
extern crate xcb;
fn main() {
let (conn, screen_num) = xcb::Connection::connect(None).unwrap();
let screen = conn.get_setup().roots().nth(screen_num as usize).unwrap();
let foreground = conn.generate_id();
xcb::create_gc(
&conn,
@fxdave
fxdave / main.rs
Created April 13, 2020 16:37
Simple Rust File repository
use std::error::Error;
use std::fs::File;
use std::io::{BufRead, BufReader};
use std::path::Path;
mod seri {
pub trait Deserialize {
fn deserialize(atoms: Vec<String>) -> Option<Self>
where
Self: Sized;
@fxdave
fxdave / main.rs
Last active April 13, 2020 22:17
Bulky Cached Rust File Repository
mod seri {
pub trait Deserialize {
fn deserialize(atoms: Vec<String>) -> Option<Self>
where
Self: Sized;
}
}
mod db {
use super::seri::Deserialize;
@fxdave
fxdave / main.rs
Last active January 4, 2021 01:23
rust react style native gui toolkit concept
struct Styles {
padding: f64,
color: Color,
font_size: f64,
}
impl Styles {
fn with_padding(self, value: f64) -> Styles {
self.padding = value;
self