Skip to content

Instantly share code, notes, and snippets.

View periakteon's full-sized avatar

Masum Gökyüz periakteon

View GitHub Profile
@periakteon
periakteon / .cursorrules
Created December 4, 2024 08:38
Cursor Rule for Routing-Controllers
You are a senior TypeScript programmer with experience in the routing-controllers library (an OOP based library based on Express.js, similar to Nest.js) and a preference for clean programming and design patterns.
Generate code, corrections, and refactorings that comply with the basic principles and nomenclature.
## TypeScript General Guidelines
### Basic Principles
- Use English for all code and documentation.
- Always declare the type of each variable and function (parameters and return value).
@periakteon
periakteon / curiouscat-api-scrapper.js
Created October 6, 2024 21:40
Curiouscat API Scrapper
const axios = require("axios");
const fs = require("fs").promises;
const path = require("path");
const { open } = require("fs/promises");
function pgbr(prcnt, dn = "█", rm = "░", length = 100, hint = "") {
const d = Math.floor(prcnt * length);
const r = length - d;
process.stdout.write(
`\r${hint} |${dn.repeat(d)}${rm.repeat(r)}| ${Math.floor(prcnt * 100)}%`
@periakteon
periakteon / middleware.ts
Created December 15, 2023 00:01
Upstash & Clerk Rate Limiting
import { authMiddleware } from "@clerk/nextjs";
import { ratelimit } from "./utils/redis";
import { NextResponse } from "next/server";
export default authMiddleware({
async afterAuth(_auth, req, evt) {
const ip = req.ip ?? "127.0.0.1";
if (req.nextUrl.pathname === "/api/blocked") return NextResponse.next(req);
@periakteon
periakteon / multiple-conditional-operator-solution.js
Created March 22, 2023 14:48
FreeCodeCamp: Use Multiple Conditional (Ternary) Operators (Solution)
function checkSign(num) {
// eğer 0'dan büyükse, "positive" stringi döndür ( if )
return num > 0 ? "positive"
// eğer 0'dan küçükse, "negative" stringi döndür (else if)
: num < 0 ? "negative"
// kalan tüm durumlarda "zero" döndür ( else )
: "zero"
}
@periakteon
periakteon / multiple-conditional-operator-challenge.js
Created March 22, 2023 14:43
FreeCodeCamp: Use Multiple Conditional (Ternary) Operators (Challenge)
function checkSign(num) {
}
checkSign(10);
@periakteon
periakteon / multiple-conditional-operator-inproper-form.js
Created March 22, 2023 14:40
FreeCodeCamp: Use Multiple Conditional (Ternary) Operators (inproper ex)
// uygun girinti olmadan kullanmak kodun okunuşunu zorlaştırır,
// dolayısıyla aşağıdaki gibi yazmak yerine
// girintili bir şekilde, bir üstteki örnekte gibi yazmak en iyisidir
function findGreaterOrEqual(a, b) {
return (a === b) ? "a and b are equal" : (a > b) ? "a is greater" : "b is greater";
}
@periakteon
periakteon / multiple-conditional-operator-ex2.js
Created March 22, 2023 14:37
FreeCodeCamp: Use Multiple Conditional (Ternary) Operators (Ex2)
function findGreaterOrEqual(a, b) {
// if gibi düşünelim
// " a === b " true döndüğünde, "a and b are equal" döndürür
return (a === b) ? "a and b are equal"
// else if gibi düşünelim
// " a > b " true döndüğünde, "a is greater" döndürür
: (a > b) ? "a is greater"
@periakteon
periakteon / multiple-conditional-operator-ex1.js
Created March 22, 2023 14:34
FreeCodeCamp: Use Multiple Conditional (Ternary) Operators (Ex1)
function findGreaterOrEqual(a, b) {
if (a === b) {
return "a and b are equal";
}
else if (a > b) {
return "a is greater";
}
else {
return "b is greater";
}
@periakteon
periakteon / conditional-operator-solution.js
Created March 22, 2023 14:28
FreeCodeCamp: Use the Conditional (Ternary) Operator (Solution)
function checkEqual(a, b) {
// a == b ise, yani "a == b" true dönerse, "Equal" stringi döndür
// else, yani diğer durumlarda, "Not equal" stringi döndür
return a == b ? "Equal" : "Not Equal";
}
console.log(checkEqual(1, 2));
// Not Equal
@periakteon
periakteon / conditional-operator-challenge.js
Created March 22, 2023 14:26
FreeCodeCamp: Use the Conditional (Ternary) Operator (Challenge)
function checkEqual(a, b) {
}
checkEqual(1, 2);