Skip to content

Instantly share code, notes, and snippets.

@Ebrahim-Ramadan
Ebrahim-Ramadan / index.js
Created July 5, 2023 02:18
A human-readable representation of a timestamp starting from the current time-Reactjs
import React, { Component } from 'react';
import { render } from 'react-dom';
import TimeAgo from 'react-timeago';
class App extends Component {
render() {
return (
<div>
<TimeAgo date={Date.now()} formatter={(value, unit, suffix) => {
switch (unit) {
@Ebrahim-Ramadan
Ebrahim-Ramadan / Image-crop-component.css
Last active July 5, 2023 02:24
pfp crop&update - Reactjs
body {
margin: 0;
padding: 0;
}
.crop-image {
position: absolute;
background-color: rgba(71, 71, 71, 0.901);
top: 0;
right: 0;
@Ebrahim-Ramadan
Ebrahim-Ramadan / grade-util.cpp
Created July 6, 2023 01:53
segmentation memory-management
#include "grade_util.hpp"
#include "mem.hpp"
Segment* mk_segments(RawSegment* segs, int size) {
if (size == 0)
return nullptr;
Segment** head = new Segment*;
Segment** next_seg = head;
Segment* last_seg = nullptr;
@Ebrahim-Ramadan
Ebrahim-Ramadan / transfer-method.mat
Last active July 18, 2023 15:01
The Transfer Matrix Method
% This code is to perform the transfer matrix method
% T{1},T{2},T{3}, have been already calculated. they are
% obviously 2 by-2 matrices. Now we want to obtain vector D{i} for each transfer matrix coefficients above.
T{1} = [0.9982 - 0.0616i, -0.0119 + 0.0121i;
-0.0119 - 0.0121i, 0.9982 + 0.0616i];
T{2} = [0.9831 - 0.1845i, -0.0157 - 0.0149i;
-0.0157 + 0.0149i, 0.9831 + 0.1845i];
@Ebrahim-Ramadan
Ebrahim-Ramadan / MainFunc.tsx
Created August 20, 2023 16:20
Images to PDF Next App with jspdf
import React, { ChangeEventHandler } from "react";
import Image from 'next/image'
import * as Helpers from "./helpers";
import { CustomImage } from "./custom-image";
import './style.css'
export function MainFunc() {
const [uploadedImages, setUploadedImages] = React.useState<CustomImage[]>([]);
const handleImageUpload = React.useCallback<
ChangeEventHandler<HTMLInputElement>
@Ebrahim-Ramadan
Ebrahim-Ramadan / TerminalloadingAnimation.jsx
Created September 14, 2023 17:31
Terminal-like loading Animation
// TerminalloadingAnimation.js
import React, { useState, useEffect } from 'react';
const TerminalloadingAnimation = () => {
const [loadingAnimation, setLoadingAnimation] = useState('|');
useEffect(() => {
const animationCharacters = ['|', '/', '-'];
const updateLoadingAnimation = () => {
```
'use client'
import EditProfile from "@/components/pages/profile/edit/edit";
import { useState, useEffect } from "react";
import secureLocalStorage from "react-secure-storage";
import Reload from '@/components/layout/Reload';
import { ProfileInfoFetching} from "@/services/auth";
import Notfound from "@/app/not-found";
export default function Home() {
@Ebrahim-Ramadan
Ebrahim-Ramadan / index.js
Created October 9, 2023 09:16
send 20 emails in one command - nodejs
const nodemailer = require('nodemailer');
const fs = require('fs');
// Create a transporter using Gmail SMTP
const transporter = nodemailer.createTransport({
service: 'Gmail',
auth: {
user: '[email protected]', // Your Gmail address
pass: 'your Application-specific password here', // Your Application-specific password
},
@Ebrahim-Ramadan
Ebrahim-Ramadan / script.js
Created December 11, 2023 02:00
matlap script to solve first-order ODEs
function solveFirstOrderODE()
function dydx = myODE(x, y)
dydx = -2 * x * y; %lets say dy/dx​=−2xy
end
% Define the range of x values
xspan = [0 5]; % Define the start and end values of x
% Define the initial condition y(x0) = y0
@Ebrahim-Ramadan
Ebrahim-Ramadan / ass.py
Last active December 21, 2023 07:32
paper-citation-project
import time
from collections import defaultdict
# readign nodes data from nodes.csv
def read_nodes(file):
with open(file, 'r', encoding='utf-8') as f:
lines = f.readlines()[1:] # Skip header
nodes = {}