Skip to content

Instantly share code, notes, and snippets.

@pesterhazy
pesterhazy / building-sync-systems.md
Last active March 7, 2025 02:43
Building an offline realtime sync engine

So you want to write a sync system for a web app with offline and realtime support? Good luck. You might find the following resources useful.

Overview articles

@Raimo33
Raimo33 / speed_optimizations.md
Last active March 7, 2025 02:43
C Speed Optimizations

C Speed Optimization Checklist

This is a list of general-purpose optimizations for C programs, from the most impactful to the tiniest low-level micro-optimizations to squeeze out every last bit of performance. It is meant to be read top-down as a checklist, with each item being a potential optimization to consider. Everything is in order of speed gain.

Algorithm && Data Structures

Choose the best algorithm and data structure for the problem at hand by evaluating:

  1. time complexity
@adrian-enspired
adrian-enspired / php-first.md
Last active March 7, 2025 02:40
PHP _first_!

PHP First

Generally speaking, your PHP code can be sorted into two categories:

  • code which does work (processing input, controller logic, database access, error handling, etc.), and
  • code which produces output (echo, <?= $var ?>, plain <html>, etc.).

work goes FIRST. output goes LAST.


@adrian-enspired
adrian-enspired / PDO_mysql.connect.php
Last active March 7, 2025 02:39
how to make a new mysql connection with PDO.
<?php
$host = "db hostname";
$dbname = "db name";
$user = "db username";
$pass = "db password";
$charset = "UTF8MB4"; // if your db does not use CHARSET=UTF8MB4, you should probably be fixing that
$dsn = "mysql:host={$host};dbname={$dbname};charset={$charset}";
@adrian-enspired
adrian-enspired / PDO_MySQL.prepare.php
Last active March 7, 2025 02:39
how to make a simple prepared statement for MySQL with PDO
<?php
// let's make a query.
// only sql. NO DATA! put a named parameter where the data would normally go.
// parameters start with a ":", contain letters, numbers, and underscores only, and are not quoted.
const SQL_SELECT = 'SELECT foo, bar, baz FROM myTable WHERE quxx = :quxx';
// that's the parameter marker ---^
// prepare the statement.
$selectStmt = $pdo->prepare(SQL_SELECT);
@adrian-enspired
adrian-enspired / bad-config.md
Last active March 7, 2025 02:39
magic configs are bad, mmmkay?

Here's a very common pattern. People recommend it everywhere. Put your config into a separate file, and require it in your script. Awesome, right!?

Halfway. Yes, doing it is better than not. BUT now you have a bunch of invisible variables in your script! This makes for code that is hard to read and debug, and is fragile because code that directly affects your script is far away from it.

Imagine you got a warning like "undefined index 'foo' …" one day. It seems obvious now — the config file is messed up. But what if there were a ton of other stuff going on around this? What if this happens six months later (when you've completely forgotten about where $config comes from)? Even worse, what if a second config file gets included somewhere in the same scope and these invisible variables start colliding!?

BAD.config.php

<?php
$config["foo"] = "Hello, World!";
@adrian-enspired
adrian-enspired / array_extend_recursive.md
Last active March 7, 2025 02:39
array_merge|replace_recursive are frustrating.

say you have two arrays, $a1 and $a2, and you want to combine them.

<?php

$a1 = [
  'a' => 'foo',
  'b' => ['bar']
];
$a2 = [
  'a' => 'bar',
@maxkostinevich
maxkostinevich / herd-reverb-ssl.md
Created April 15, 2024 15:08 — forked from conradfuhrman/herd-reverb-ssl.md
Laravel Herd, SSL, and Reverb with Herd

The biggest issue with Herd Pro is that you cannot use Reverb out of the box with a site that has SSL enabled. Here is the workaround for it all to play nicely together.

First you will need to create two sites. The two I have here are as follows:

  • reverb-ssl - This is a new Laravel 11 project using Breeze for the ease of Inertia. This also follows the setup for Reverb line by line.
  • wss-reverb-ssl - This is an empty directory, we are going to use this only for editing a Nginx config and setting up a proxy to the reverb service.

Screenshot 2024-04-03 at 2 33 08 PM

Of note is that I'm using Herd Pro as well, so all additional services are being used directly though Herd Pro itself.

OK, so you have a filepath made from user input; something like

$path = __DIR__ . "/uploads/{$user_input_filename}"

#1: DO NOT DO THIS. Make up your own directory names. The user has no business picking path names on your server.

#2: Filesystem traversal is bad. If you mean for the given $user_input_filename to be inside the __DIR__ . "/uploads/ directory, take a moment to check.

@taihanseok
taihanseok / fake phonepe apk.md
Last active March 7, 2025 02:37
Fake PhonePe APK 90.5 Soun Box {Unlimited Cash} Free Download For Android 2025

Fake PhonePe MOD APK v1.6 (Premium Unlocked) 2025

image

What is Fake PhonePe MOD APK v1.6 (Premium Unlocked) 2025?

Fake PhonePe MOD APK v1.6 (Premium Unlocked) 2025 is a counterfeit version of the official PhonePe app. It claims to offer premium features, such as:

Unlimited transactions