Skip to content

Instantly share code, notes, and snippets.

@nmeri17
nmeri17 / Track - unfollower.js
Last active April 5, 2024 06:36
twitter unfollower
/**
* Steps to run
* 1) turn off images, to save data
* 2) paste https://code.jquery.com/jquery-3.7.1.min.js
* 3) wait for the first frame of following to appear before running below code
*/
var processedRows = 0, batchToProcess = 12/*00*/,
followingIndicator = ".r-z2wwpe.r-6koalj.r-1q142lx", // .css-175oi2r.r-1awozwy
@nmeri17
nmeri17 / psr to suphle equivalents.txt
Created April 18, 2023 01:09
Unable to use due to conflicts with other packages with conflicting dependencies
message based interfaces are implemented by GuzzleHttp\Psr7 that we already depend on. but the return types and the way
the values are derived are different
CacheManager: https://www.php-fig.org/psr/psr-16/
container: https://www.php-fig.org/psr/psr-11/
request stuff: https://www.php-fig.org/psr/psr-7/ (will be impossible if they're all one object)

Home

Let's not forget: this is still Suphle's first official release. The idea is that when it's augmented by a community no longer burdened by the issues it currently puts to rest, it'll serve as springboard for the next level of engineering web and CLI based software.

Module

Descriptor definition

This class allows us expose desired functionality to its module's consumers. In addition, it serves as both a platform for declaring module-wide dependencies, as well as the port through which other modules are inserted into ours.

@nmeri17
nmeri17 / Challenges of api dev.md
Created December 25, 2022 07:50
Appendix page for when documentation generator is available
  • Decoupled development
  • Documentation
  • Seamless integration

If you don't have the luxury of developing at your pace, you will greatly benefit from design first tools like API blueprint. It's important to not work under pressure of delivering endpoints to kick off API consumption. Aside from this, APIs should be rapidly prototyped. And the first step in doing so would be setting up the routes and returning dummy responses. That's the bare minimum promise of what is to come

If you don't care much about using an API design tool, it is assumed you have an alternative or intuitive means of arriving at a decent design your consumers will consent to. Should this be the case, after implementation, suphle solves the documentation problem by generating openAPI schemas from your routes and their associated responses

@nmeri17
nmeri17 / request-lifecycle.md
Created December 17, 2022 00:03
Don't know where else to place this

Request lifecycle

Though not compulsory, it's strongly recommended to compartmentalize your app into modules. Modules exist independently, which means they tend to contain their own routes and exist in a state where they can be deployed without knowledge of their sibling modules' internal details.

For every request received by your app, it's apportioned to its appropriate handler before being passed onto a module where applicable.

Suphle has 3 different kinds of request, which are in turn, subdivided into their subcategories:

@nmeri17
nmeri17 / NativeErrorHandlers.php
Created November 16, 2022 14:05
Class for converting native php notices/warnings to exceptions. Deleting cuz it eventually didn't get used. If I have to set and restore between calls, I might as well use a local variable to check for operation failure
<?php
namespace Suphle\Exception;
use ErrorException;
class NativeErrorHandlers {
/**
* After the failable operation that required this call, unset this catcher so it doesn't affect everyone else, using restore_error_handler
*/
@nmeri17
nmeri17 / qutee.php
Created October 31, 2022 02:42
qutee suphle adapter. removing it cuz i'm tired of limitations from github rate limiting me cuz of composer repos
<?php
namespace Suphle\Adapters\Queues;
use Suphle\Contracts\IO\EnvAccessor;
use Qutee\{Task, Queue, Worker, Persistor\Redis};
use Throwable;
class QuTee extends BaseQueueAdapter {
@nmeri17
nmeri17 / payloadStringifier.php
Created August 12, 2022 04:12
cut from moduleHttpTest but became redundant since payload receivers seem to all work with arrays directly. Was wrapping payload received in methods post, put and delete
private function payloadStringifier (array $payload, array $headers):string {
if (
array_key_exists($this->CONTENT_TYPE_KEY, $headers) &&
$headers[$this->CONTENT_TYPE_KEY] == $this->JSON_HEADER_VALUE
)
@nmeri17
nmeri17 / resque.php
Created July 13, 2022 14:31
Inadequate Queue adapters
<?php
namespace Tilwa\Adapters\Queues;
use Tilwa\Contracts\IO\EnvAccessor;
use Resque as ResqueLib;
class Resque extends BaseQueueAdapter {
private $envAccessor;
Htmx
Custom js language (in code), called hyperscript
You'd have to handle your own styling for transitions and effects
Duplicate implementation (on front and back end) for things like validation
Lots of examples for commonly encountered tasks
Unpoly
Has a place for writing js called compilers that is more or less like using jQuery, but with up.element instead of $()
Has examples in form of a demo site. You check which functionality suits what you're looking for and peek under the hood
No websocket support