Skip to content

Instantly share code, notes, and snippets.

View Adamkaram's full-sized avatar
🏠
Working from home

AhmedKaram Adamkaram

🏠
Working from home
View GitHub Profile
@pontusab
pontusab / proximity-prefetch.tsx
Created April 6, 2025 06:43
Next.js Proximity Prefetch (PPF)
"use client";
import { useRouter } from "next/navigation";
import type { ReactNode } from "react";
import { useCallback, useEffect, useState } from "react";
interface ProximityPrefetchProps {
children: ReactNode;
threshold?: number;
predictionInterval?: number;
@ElegantSoft
ElegantSoft / validate_enum.go
Created September 23, 2020 01:17
Use enum validation in golang with gin with custom error messages
// user model
type User struct {
gorm.Model
Name string `json:"name" binding:"required" gorm:"not null:true"`
Phone string `json:"phone" binding:"required"`
Email string `json:"email" binding:"required,email" gorm:"not null:true"`
Password string `json:"password" binding:"required,min=8" gorm:"not null:true"`
Gender string `json:"gender" binding:"Enum=male_female" gorm:"type:gender;not null:true;default:male"` // add binding Enum=male_female
}
@CodeMyUI
CodeMyUI / index.html
Created October 31, 2019 05:39
Link Hover Effects w/ mo.js
<div class="container">
<h1>Hover My Links</h1>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. <a href="">Voluptates</a> illum saepe, placeat ut <a href="">delectus</a> minima officiis. Inventore mollitia sapiente, aut est nesciunt perspiciatis, odio sunt ad <a href="">natus</a> labore, enim quod.</p>
</div>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>LuxonJS The Modern MomentJS</title>
<meta name="viewport" content="width=device-width">
<style>
#output{
font-size: 2rem;
}
@roachhd
roachhd / README.md
Last active April 22, 2025 07:38
Basics of BrainFuck

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

BrainFuck Programming Tutorial by: Katie

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

INTRODUCTION

@TheDistantSea
TheDistantSea / version_compare.js
Created December 18, 2013 12:19
Function to compare two version strings (e.g. "1.6.1" is smaller than "1.7"). Developed in order to answer http://stackoverflow.com/a/6832721/50079.
/**
* Compares two software version numbers (e.g. "1.7.1" or "1.2b").
*
* This function was born in http://stackoverflow.com/a/6832721.
*
* @param {string} v1 The first version to be compared.
* @param {string} v2 The second version to be compared.
* @param {object} [options] Optional flags that affect comparison behavior:
* <ul>
* <li>
@eristoddle
eristoddle / tampermonkey.jquery.js
Created January 3, 2013 04:06
How to get jQuery to work in Chrome Tampermonkey userscripts
// ==UserScript==
// @name Vortek Preload
// @namespace vortek
// @description Load variables
// @include http://localhost/vortek_php/*
// @version 1
// ==/UserScript==
// a function that loads jQuery and calls a callback function when jQuery has finished loading
function addJQuery(callback) {
var script = document.createElement("script");
@ElliotChong
ElliotChong / underscore.mixin.deepExtend.coffee
Last active November 28, 2020 23:55
Copy all of the properties in the source objects over to the destination object, and return the destination object. This method will recursively copy mutual properties which are also objects.
# Create a deep copy of an object. - CoffeeScript conversion of @cederberg's deepClone implementation https://github.com/documentcloud/underscore/pull/595
deepClone = (obj) ->
if !_.isObject(obj) or _.isFunction(obj) then return obj
if _.isDate obj then return new Date do obj.getTime
if _.isRegExp obj then return new RegExp obj.source, obj.toString().replace(/.*\//, "")
isArr = _.isArray obj or _.isArguments obj
func = (memo, value, key) ->
if isArr then memo.push deepClone value