Skip to content

Instantly share code, notes, and snippets.

@p0358
p0358 / Aaaaa.js
Last active December 17, 2019 23:28
Aaaaaaa aa aaaa aa aaaa aaaa "A" aaa "a" aaaaaaa ("A language", aaaaaaaa aAaaaa aaaa)
(function(){
// Aaa aaaaaa:
// Get all text nodes in a given container
// Source: http://stackoverflow.com/a/4399718/560114
function getTextNodesIn(node, includeWhitespaceNodes) {
var textNodes = [], nonWhitespaceMatcher = /\S/;
function getTextNodes(node) {
if (node.nodeType == 3) {

Demo

What demos are?

A file type (with the .dem extension) containing recorded events that can be edited and played back in-game. Demos can be edited to change camera angles, speed up, slow down, play music, and other functions. (from Valve wiki)

Benefits

  • You have your every game archived once enabled. Something nice happened to game? You can always get back to it!
  • It takes way less size than a video and about no system resources compared to its recording.
@p0358
p0358 / any_bool_case_in_any_switch.php
Created January 4, 2018 02:17
PHP any bool case in any switch
<?php
// PHP any bool case in any switch
// useful if you want to do also some other switch case
// being exceptional result of some separate check/comparsion
//$t = 'text!';
$t = '';
$b = true; // any bool check you want in the switch, it can be inlined in the case statement too
@p0358
p0358 / polish_numbers_within_roman_numbers.php
Created April 21, 2018 15:26
Check which of the roman numbers are valid Polish words
<?php
// https://sjp.pl/slownik/growy/
// Firstly, put into separate file only those words that contain only letters making up roman numbers
$handle = fopen("slowa.txt", "r");
$handle_write = fopen("jakby_rzymskie.txt", "w");
if ($handle) {
while (($line = fgets($handle)) !== false) {
@p0358
p0358 / messenger_thread_info.php
Last active October 23, 2018 23:24
Very simple stats about Messenger conversation based on JSON data export from Facebook
<?php
// https://github.com/p0358
// Example output: https://imgur.com/UzAIAMH
function intformat($number) { return number_format($number, 0, '.', ' '); }
if (sizeof($argv) == 1) {
echo <<<'USAGE'
@p0358
p0358 / atlas_extract.php
Created June 9, 2019 21:01
Flappy Bird's atlas.png/txt simple extractor. — Extracts assets from atlas.png into separate files based on assets definitions from atlas.txt
<?php
$atlas_file = file_get_contents('atlas.txt');
// Hardcoded source image size
$x = 1024;
$y = 1024;
@mkdir('out');
@p0358
p0358 / videoplayer.html
Created November 15, 2020 22:36
Simple video player which allows you to play videos being fed with a direct link to them, with native controls, on the entire page. Good for use with Metastream, where it will nicely cooperate with it, unlike many source pages which have interferencing scripts.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="referrer" content="no-referrer">
<meta property="og:title" content="Video Player" />
<meta property="og:description" content="Simple video player which allows you to play videos being fed with a direct link to them, with native controls, on the entire page. Good for use with Metastream, where it will nicely cooperate with it, unlike many source pages which have interferencing scripts." />
<meta property="og:type" content="video.other" />
<title>Video</title>
@p0358
p0358 / dedi_delete_tfo.txt
Last active December 28, 2021 20:01
Unneeded PKG files that can be removed from TFO's dedicated server: cd Data && cat dedi_delete_tfo.txt | xargs rm
001fc10884c618169cc7f9f9e48430e0.pkg
00223b2d63d2e0b8a5299929bf39610d.pkg
00523282ff2175e5e85dc10dd6c72cba.pkg
006b811f482bff8bd5a5ed9ed74503f1.pkg
00b033bf120ff26a98f182d7410e549f.pkg
00e6b68c3f01c4e96777303e1bfe5b46.pkg
011ed3bbe8285eba7cf37362e9e9d3e4.pkg
0192bc64e82ec56c59bd8a01969411c8.pkg
01a0fac9769bd17f39731934a3ca8730.pkg
02086328c3647de3a44e5e24df6189be.pkg

Running Titanfall 2 (+Northstar) / Titanfall 1 in Sandboxie for increased security

In the light of recent events regarding an unclear exploit existing between Titanfall/Origin, and since neither Source Engine itself or Respawn/EA are known for their good security track records, I decided it will be a good idea to write a tutorial on how to run the game and Origin in a sandboxed environment, when even if the worst came to the worst, your system and data would still be secure and you could sleep calmly. Even though we try to fix any security vulnerabilities in Titanfall/Titanfall 2 as soon as they're uncovered, nobody can ever guarantee guarantee the game is 100% secure (just like with virtually any software honestly), and running things sandboxed will let you combat any dangers and prevent any damage ahead of time, before any danger is even known.

If you're slightly paranoid about possible security issues and want to sleep calmly while enjoying Titanfalls, you came to the right place. On the other hand, if

@p0358
p0358 / rectangle_hole_reverse.cpp
Created January 11, 2023 00:00
Given rectangular area with holes inside, constructs vector of reversed rectangles (ones that are outside of holes and cover the entirety of the remaining area). This algorithm can be used to for example draw some background around windows on the screen, without drawing over the windows.
#include <iostream>
#include <vector>
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
class Rectangle {