Skip to content

Instantly share code, notes, and snippets.

View dexit's full-sized avatar
🎯
Focusing

Rihards Mantejs dexit

🎯
Focusing
View GitHub Profile
@dexit
dexit / 1-outbound-call.php
Created June 12, 2025 10:16 — forked from jmadden/1-outbound-call.php
Twilio PHP Outbound Call and Gather Example
<?php
// Get the PHP helper library from https://twilio.com/docs/libraries/php
require_once '/path/to/vendor/autoload.php'; // Loads the library
use Twilio\Rest\Client;
// Your Account Sid and Auth Token from twilio.com/user/account
$sid = "YOU_ACCOUNT_SID";
$token = "YOUR_AUTH_TOKEN";
$client = new Client($sid, $token);
@dexit
dexit / call.php
Created June 12, 2025 10:15 — forked from jonmarkgo/call.php
Simple Phone Verification with Twilio, PHP, MySQL, and jQuery
<?php
require("Services/Twilio.php");
require("database.php");
// require POST request
if ($_SERVER['REQUEST_METHOD'] != "POST") die;
// generate "random" 6-digit verification code
$code = rand(100000, 999999);
@dexit
dexit / Twilio_Client.php
Created June 12, 2025 10:15 — forked from jeremeamia/Twilio_Client.php
The beginnings of a Guzzle-based, PHP Twilio client.
<?php
namespace Twilio;
use GuzzleHttp\Client as HttpClient;
use GuzzleHttp\Collection;
use GuzzleHttp\Command\Guzzle\GuzzleClient;
use GuzzleHttp\Command\Guzzle\Description;
use GuzzleHttp\Command\Model;
use GuzzleHttp\Subscriber\Retry\RetrySubscriber;
@dexit
dexit / twilio-WPSMS.php
Created June 12, 2025 10:13 — forked from pamjadz/twilio-WPSMS.php
Twilio Wordpress Send SMS API
function twilioSendSMS($params = [], $endpoint = 'Messages.json'){
$sid = 'SID HERE';
$token = 'TOKEN HERE';
$request = wp_remote_get("https://api.twilio.com/2010-04-01/Accounts/{$sid}/{$endpoint}", [
'headers' => [
'Authorization' => 'Basic ' . base64_encode($sid . ':' . $token),
'Content-Type' => 'application/x-www-form-urlencoded;charset=UTF-8',
],
'body' => $params
]);
@dexit
dexit / cors-anywhere.js
Created June 12, 2025 10:06 — forked from madebyosama/cors-anywhere.js
CORS Anywhere with Cloudflare Workers
// Configuration
const whitelistOrigins = [".*"]; // regexp for whitelisted origins
const blacklistUrls = []; // regexp for blacklisted urls
// Helper function to check if a URI or origin is whitelisted
function isListedInWhitelist(uri, listing) {
if (!uri) return true; // Allow null origins by default
return listing.some(pattern => new RegExp(pattern).test(uri));
}
@dexit
dexit / helloworld.js
Created June 12, 2025 10:05 — forked from FrancescoPassanti/helloworld.js
Cloudflare Workers - Hello world
/*
An event listener for the FetchEvent tells the script to listen for any request coming to your Worker.
The event handler is passed the event object, which includes event.request, a Request object
which is a representation of the HTTP request that triggered the FetchEvent.
*/
addEventListener("fetch", event => {
// The call to .respondWith() lets the Workers runtime intercept the request in order to send back a custom response.
event.respondWith(handleRequest(event.request))
})
@dexit
dexit / url-shortener.js
Created June 12, 2025 10:05 — forked from maple3142/url-shortener.js
url shortener for cf workers
addEventListener('fetch', (event) => {
event.respondWith(
handleRequest(event.request).catch(
(err) => new Response(err.stack, { status: 500 })
)
);
});
const ID_LEN = 6
const SEC_PER_DAY = 60 * 60 * 24
@dexit
dexit / twilio-validation.js
Created June 12, 2025 10:02 — forked from kylemclaren/twilio-validation.js
Twilio CF Worker request validation
addEventListener('fetch', event => {
event.respondWith(fetchAndApply(event.request))
});
/* WARNING:
Anything starting with REPLACEABLE_SECRET_VDB12_ shouldn't be renamed,
because they are used in deployment transformations.
Do not remove the comment below,
it is required to timestamp workers on upload.
Sent from npm.
@dexit
dexit / getPrismaClient.ts
Created June 12, 2025 10:02 — forked from mizchi/getPrismaClient.ts
Get prisma in cf workers
import { PrismaClient } from "@prisma/client";
import { PrismaPg as PrismaPgWorker } from "@prisma/adapter-pg-worker";
import { Pool } from "@prisma/pg-worker";
let _db: PrismaClient | null = null;
export async function getPrismaClient(env: Env): Promise<PrismaClient> {
if (_db) return _db;
if (import.meta.env.DEV) {
const { default: pg } = await import("pg");
// ==UserScript==
// @name Print element as PDF
// @namespace http://tampermonkey.net/
// @version 2025-06-12
// @description Adds a function to Window to print a html element as a PDF
// @author Noah Martinez
// @match *://*/*
// @icon https://www.google.com/s2/favicons?sz=64&domain=acrobat.adobe.com
// @grant none
// ==/UserScript==