Skip to content

Instantly share code, notes, and snippets.

View atakde's full-sized avatar
🎯
Focusing

Atakan Demircioğlu atakde

🎯
Focusing
View GitHub Profile
@atakde
atakde / proxy2.php
Created April 13, 2024 09:48
PHP Proxy pattern example
<?php
interface AnyInterface
{
public function anyMethod();
}
class AnyClass implements AnyInterface
{
public function anyMethod()
@atakde
atakde / proxy.php
Created April 13, 2024 09:35
Proxy Pattern Example in PHP
<?php
interface ImageInterface
{
public function display();
}
class Image implements ImageInterface
{
public function __construct(
@atakde
atakde / state-pattern.php
Created April 9, 2024 15:47
State pattern in PHP
<?php
// Interface for states
interface DeploymentState
{
public function handle(DeploymentManager $manager);
}
// Concrete state class
class PendingState implements DeploymentState
@atakde
atakde / qr-pdf.js
Created March 13, 2024 19:39
How to add QR code to PDF?
import fs from 'fs';
import fsPromises from 'fs/promises';
import { PDFDocument } from "pdf-lib";
import QRCode from "qrcode";
export const generateQR = async text => {
try {
const response = await QRCode.toDataURL(text);
return response;
} catch (err) {
@atakde
atakde / termwind.php
Created March 2, 2024 22:34
Termwind style example
<?php
require 'vendor/autoload.php';
use function Termwind\{render};
use function Termwind\{style};
style('my-btn')->apply('bg-blue', 'text-black');
render(<<<HTML
@atakde
atakde / termwind.php
Created March 2, 2024 22:28
Termwind php example
<?php
require 'vendor/autoload.php';
use function Termwind\{render};
use function Termwind\{ask};
$answer = ask(<<<HTML
<span class="mt-1 ml-2 mr-1 bg-green px-1 text-black">
What is your name?
@atakde
atakde / cli.php
Created March 2, 2024 22:23
Termwind example
<?php
require 'vendor/autoload.php';
use function Termwind\{render};
render(<<<'HTML'
<div>
<div class="px-4 text-red-800 bg-white uppercase">Termwind</div>
<em class="ml-2">
import { onRequest } from 'firebase-functions/v2/https';
import { google } from 'googleapis';
import admin from 'firebase-admin';
import { setGlobalOptions } from 'firebase-functions/v2';
setGlobalOptions({
maxInstances: 1
});
admin.initializeApp();
@atakde
atakde / deploy.yml
Created January 20, 2024 08:31
PHP FTP Github Action
on: push
name: 🚀 Deploy website on push
jobs:
web-deploy:
name: 🎉 Deploy
runs-on: ubuntu-latest
steps:
- name: 🚚 Get latest code
uses: actions/checkout@v3
import { onSchedule } from 'firebase-functions/v2/scheduler';
import { logger } from 'firebase-functions';
const sendEmailDummy = async (user) => {
logger.info(`Sending email to ${user.email}...`);
return new Promise((resolve, reject) => {
setTimeout(() => {
logger.info(`Email sent to ${user.email}!`);
resolve();
}, 1000);