Skip to content

Instantly share code, notes, and snippets.

View omar2205's full-sized avatar
🍕

omar2205

🍕
View GitHub Profile
@omar2205
omar2205 / README.md
Created July 2, 2024 12:52
draw image on canvas
function drawImageFromUrl(url, canvasId, x = 0, y = 0) {
    const canvas = document.getElementById(canvasId)
    const ctx = canvas.getContext('2d')
    const img = new Image()
    
    img.onload = function() {
        ctx.drawImage(img, x, y)
 }
@omar2205
omar2205 / loading.js
Created February 6, 2024 19:42
loading button jquery plugin
;(function ($) {
$.fn.button = function (action) {
const $btn = $(this)
let alt_text = 'Loading'
if (action === 'loading') {
let original_icon = false
$btn.attr('data-oringinal-text', $btn.text())
if ($btn.has('i').length) original_icon = $btn.find('i').attr('class')
$btn.attr('data-oringinal-icon', original_icon)
@omar2205
omar2205 / main.go
Created November 15, 2023 10:07
Check HTTPs with Golang
package main
import (
"fmt"
"net/http"
)
var urls = []string{
"https://expired.badssl.com/",
"https://oskr.nl",
@omar2205
omar2205 / hey_bash
Created November 15, 2023 07:44
hey_bash ask AI for commands from the terminal
#!/usr/bin/python3
import sys
from openai import OpenAI
client = OpenAI()
user_input = ' '.join(sys.argv[1:])
shell = 'BASH'
@omar2205
omar2205 / style.css
Created August 1, 2023 17:19
egy.finance simple improvement
html, body {
margin: 0;
padding: 0;
height: 100vh;
}
body {
background: #121212;
color: #f4f4f4;
display: flex;
@omar2205
omar2205 / main.ts
Last active March 22, 2023 20:55
More than one cookie
import fast, { type Context } from 'https://deno.land/x/fast@3.8.0/mod.ts'
import {
verifySignedCookie,
} from 'https://deno.land/x/squishy_cookies@v1.0.0/mod.ts'
const COOKIE_SECRET = 'super_secret'
const app = fast()
/*
@omar2205
omar2205 / formatNumbers.ts
Created March 17, 2023 21:12
Format number
export function formatNumber(num: number): string {
if (num < 1000) return num.toString()
// If the number is between 1000 and 999999, divide it by 1000 and append K
else if (num >= 1000 && num <= 999999) {
return (num / 1000).toFixed(1) + "K"
}
// If the number is greater than or equal to 1000000, divide it by 1000000 and append mil
else {
return (num / 1000000).toFixed(1) + "M"
@omar2205
omar2205 / main.ts
Created February 15, 2023 07:39
Parse FormData with Zod
// Using Deno :P
import { z } from 'npm:zod'
const User = z.object({
username: z.string(),
email: z.string().email()
})
function getMissingFields(error: z.ZodError): string[] {
const missingFields: string[] = []
@omar2205
omar2205 / convert.ts
Created January 28, 2023 01:28
Convert text to 𝕺𝖑𝖉𝖊 𝕰𝖓𝖌𝖑𝖎𝖘𝖍
function toOldeEnglish(text: string, is_bold = false) {
const regularUpper = {
A: "𝔄",
B: "𝔅",
C: "ℭ",
D: "𝔇",
E: "𝔈",
F: "𝔉",
G: "𝔊",
H: "ℌ",
@omar2205
omar2205 / app.html
Last active February 3, 2023 15:10
i18n svelte type-safe
<html theme="%theme%" lang="%lang%" dir="%dir%">