Skip to content

Instantly share code, notes, and snippets.

View Yuribenjamin's full-sized avatar
🐉

Ibrahim Ragab Yuribenjamin

🐉
View GitHub Profile
const date = new Date(Date.now());
const dateTimeFormat = new Intl.DateTimeFormat('ar-sa', {
dateStyle: 'full',
timeStyle: 'full',
calendar: 'islamic-umalqura',
numberingSystem: 'arab',
timeZone: 'Asia/Riyadh',
hour12: true,
}).format(date);
// TODO: make `pages` optional and measure the div when unspecified, this will
// allow more normal document flow and make it easier to do both mobile and
// desktop.
import {
createContext,
useCallback,
useContext,
useEffect,
useMemo,
useRef,
import type { LoaderFunction, ActionFunction } from "remix";
import { useLoaderData, useFetcher } from "remix";
import invariant from "tiny-invariant";
import cuid from "cuid";
import React from "react";
import type { Task, User } from "@prisma/client";
import { requireAuthSession } from "~/util/magic-auth";
import { ensureUserAccount } from "~/util/account";
import { placeCaretAtEnd } from "~/components/range";
import { getBacklog } from "~/models/backlog";
function downloadFile(data, name='myData.tx') {
const blob = new Blob([data], {type: 'octet-stream'});
const href = URL.createObjectURL(blob);
const a = Object.assign(document.createElement('a'), {
href,
download: name,
});
document.body.appendChild(a);
////////////////////////////////////////////////////////////////////////////////
// Create a directory called "pages" next to
// this file, put markdown files in there, and
// then run:
//
// ```
// $ node build.mjs
// ```
//
// Then deploy the "build" directory somewhere.
@Yuribenjamin
Yuribenjamin / add-discord-role.js
Created July 30, 2020 12:14 — forked from kentcdodds/add-discord-role.js
An example of how you can add a role to a user with discord.js
const Discord = require('discord.js')
// your bot token
const token = 'NzM4MDk2NjA4NDQwNDgzODcw.XyG8CA.RbwIBFnAbrRDYOlTdLYgG_T4CMk'
const discordUsername = 'example#1234'
const roleToAdd = 'Cool Person'
const guildName = 'Your Guild Name'
function deferred() {
let resolve, reject
@Yuribenjamin
Yuribenjamin / Animate.js
Created March 1, 2020 11:48
Sytled Components => Animatation
import React from 'react';
import styled, { keyframes } from 'styled-components';
const move = keyframes`
from {
transform: translateX(0) rotate(0);
}
to {
transform: translateX(100%) rotate(45deg);
}
@Yuribenjamin
Yuribenjamin / StyleProps.js
Created March 1, 2020 11:44
Styled Compnent => Adjust Style based on props
import React from 'react';
import styled from 'styled-components';
const people = ['ibrahim', 'mohmaed', 'malak', 'moatz'];
const Person = styled.li`
font-family: Arial, Helvetica, sans-serif;
color: gray;
text-align: center;
${props =>
@Yuribenjamin
Yuribenjamin / StyleComponent.js
Last active March 1, 2020 11:36
Styled Components => Style Component ; material ui
import React from 'react';
import styled from 'styled-components';
import Button from '@material-ui/core/Button';
const Btn = styled(Button)`
padding: 8px 12px;
width: 30%;
height: 50px;
`;
const StyleComponent = () => {
@Yuribenjamin
Yuribenjamin / GlobalStyle.js
Last active March 1, 2020 11:22
Styled Components => global style
import React from 'react';
import { createGlobalStyle } from 'styled-components';
const Global = createGlobalStyle`
body {
margin: 0;
color: white;
background: #15202B;
text-align: center;
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',