Skip to content

Instantly share code, notes, and snippets.

View luckydonald's full-sized avatar
👀
294 people are currently looking at this profile

Luckydonald luckydonald

👀
294 people are currently looking at this profile
  • Some basement in Equestria.
View GitHub Profile
@luckydonald
luckydonald / function.cast.php
Created July 23, 2018 21:14 — forked from borzilleri/function.cast.php
PHP function to cast an object from one class to another.
<?php
/**
* Cast an object into a different class.
*
* Currently this only supports casting DOWN the inheritance chain,
* that is, an object may only be cast into a class if that class
* is a descendant of the object's current class.
*
* This is mostly to avoid potentially losing data by casting across
* incompatable classes.
def num(n):
string = ["", "", ""]
for d in str(int(n)):
for i, l in enumerate(digit(int(d)).split("\n")):
string[i] += l
# end for
# end for
return "\n".join(string)
# end def
@luckydonald
luckydonald / Pipboy Protocol.md
Last active December 13, 2018 01:41
Fallout 4 Protocol description

luckydonald/JavaPipBoyServer/PROTOCOL.md Now summarizes this and other findings, and is generally more maintainend.

C Structs

struct Entry {
  uint8_t type;
  uint32_t id;
  switch (type) {
    case 0:
      uint8_t boolean;
@luckydonald
luckydonald / gist:cfde4c8107da30390b17ddc35b964f4a
Created June 11, 2019 13:54 — forked from nerones/gist:6778719
An easy way to log session data and queries with Monolog and Hooks in codeigniter. Some of the code is taken from Profiler class in the core of CI. The hook must be post_controller or post_system
class LoggerHook
{
private $CI;
function __construct()
{
$this->CI =& get_instance();
}
public function log()
{
@luckydonald
luckydonald / python_like_exception.php
Last active March 23, 2020 21:20
python style exception trace for PHP
static function python_like_exception(
Throwable $e, bool $skip_seen = true, ?array $seen = null
): string {
if ($skip_seen && !$seen) {
$seen = array();
}
$prev = $e->getPrevious();
if ($prev) {
$result[] = self::python_like_exception($prev, $skip_seen, $seen);
$result[] = "\nDuring handling of the above exception, another exception occurred:\n";
extern crate hyper;
extern crate url;
static HOST: &'static str = "www.google.com";
macro_rules! ret_err(
($e:expr) => {{
match $e {
Ok(v) => v,
Err(e) => { println!("Line {}: {}", line!(), e); return; }
@luckydonald
luckydonald / cubietruck_wifi_bridge.md
Last active March 15, 2021 15:39
How I configure the Cubietruck to work as an WLAN bridge.

In this file I document the steps taken to get the onboard wifi chip of the Cubietruck (Cubieboard 3) up and running.

Add the wifi driver to the modules to load on startup.

sudo nano /etc/modules

Now add at the end of the file, if not already in the list:

bcmdhd
@luckydonald
luckydonald / Fallout 4 Save File Format.md
Created April 18, 2021 11:29 — forked from SirTony/Fallout 4 Save File Format.md
The binary format for Fallout 4 PC save files.

Fallout 4 Save File Format

The binary format for Fallout 4 PC save files. This document was created by reverse-engineering files from version 1.2.37.0 of the game.

Note: This document is incomplete!

Table of Contents

@luckydonald
luckydonald / tg-2021-10-12_16-57-25.md
Created October 12, 2021 14:57
tg-2021-10-12_16-57-25.md

Before:

NONE_TYPE = type(None)
union_params = type_hint.__args__   # this was __union_params__ in python3.5, but __args__ in 3.6+

assert union_params
is_optional = NONE_TYPE in union_params
if len(union_params) == (2 if is_optional else 1):
    # None is the first/second one, the actual type has to be the other.
 raise ValueError('MEhhhh')
@luckydonald
luckydonald / image_sizer.py
Last active January 18, 2022 19:21
A script to scale images to a monitor resulution and add the best fitting background color
"""
Makes border aware sizing of desktop wallpapers.
You need to install:
$ pip install Pillow easygui joblib
"""
import glob
import os