Skip to content

Instantly share code, notes, and snippets.

@devotdev
devotdev / webserver_caching.conf
Created June 18, 2024 12:27
Benefits of caching - Webserver caching configuration
server {
listen 3000;
proxy_cache my_cache;
location / {
proxy_set_header Host $host;
proxy_pass http://my-backend-service/;
proxy_cache_key $scheme://$host$uri$is_args$query_string;
proxy_cache_valid 200 10m;
}
@devotdev
devotdev / account.html
Last active August 2, 2024 07:56
GET Account by ID - net positive status
HTTP/1.1 200 OK
<html>
<body>
<div>Account number: 12345</div>
<div>Balance: $100.00 USD</div>
<div>Links:
<a href="/accounts/12345/deposits">deposits</a>
<a href="/accounts/12345/withdrawals">withdrawals</a>
<a href="/accounts/12345/transfers">transfers</a>
</div>
@devotdev
devotdev / account.html
Created August 2, 2024 07:58
GET Account by ID - net negative status
HTTP/1.1 200 OK
<html>
<body>
<div>Account number: 12345</div>
<div>Balance: -$50.00 USD</div>
<div>Links:
<a href="/accounts/12345/deposits">deposits</a>
</div>
<body>
@devotdev
devotdev / account.json
Created August 2, 2024 07:59
GET Account by ID - net negative status JSON
{
"account": {
"account_number": 12345,
"balance": {
"currency": "usd",
"value": -50.00
},
"status": "overdrawn"
}
}
@devotdev
devotdev / employee.gql
Created August 2, 2024 08:00
GET Employee by ID - safe values GraphQL
{
employee(id: 1234567) {
id,
name
}
}
@devotdev
devotdev / employee.gql
Created August 2, 2024 08:01
GET Employee by ID - vulnerable values GraphQL
{
employee(id: 3500401) {
id,
name,
salary
}
}
@devotdev
devotdev / account.curl
Created August 2, 2024 08:09
GET Account by ID - Curl Request
GET /accounts/12345 HTTP/1.1
Host: bank.example.com
{
"compilerOptions": {
"target": "ES5",
"experimentalDecorators": true
}
}
class Monster {
health: number;
constructor(health: number) {
this.health = health;
}
takeDamage(damage: number): number {
console.log(`Monster health: ${this.health} and damage: ${damage}`);
this.health -= damage;
@devotdev
devotdev / log.ts
Last active August 29, 2024 13:30
function log(target: any, methodName: string, descriptor: PropertyDescriptor) {
const originalMethod = descriptor.value;
descriptor.value = function (...args: any[]) {
console.log(Method ${methodName} called with arguments: ${JSON.stringify(args)});
console.log(`State before method ${methodName}: ${JSON.stringify(this)}`);
const result = originalMethod.apply(this, args);
console.log(Method ${methodName} returned: ${JSON.stringify(result)});
return result;