Skip to content

Instantly share code, notes, and snippets.

View itsabdessalam's full-sized avatar
🤔
Thinking

Abdessalam Benharira itsabdessalam

🤔
Thinking
View GitHub Profile
import * as React from 'react';
const useIsFirstRender = (): boolean => {
const isFirst = React.useRef(true);
if (isFirst.current) {
isFirst.current = false;
return true;
} else {
@andyrichardson
andyrichardson / useSynchronousReducer.tsx
Last active November 25, 2020 16:08
A reducer hook which calls the provided reducer function synchronously and returns the updated state from the dispatch.
import { useState, useCallback, useRef } from 'react';
export const useSynchronousReducer = <S, A>(
reducer: (s: S, a: A) => S,
initialState: S
) => {
const stateRef = useRef(initialState);
const [state, setState] = useState<S>(stateRef.current);
const dispatch = useCallback<(a: A) => S>((action) => {
@mmazzarolo
mmazzarolo / ffmpeg_resize.sh
Created September 6, 2020 13:05
Resize videos keeping the aspect ratio (shows black bar padding where needed)
#!/bin/bash
input="input.mp4"
output="output.mp4"
color="black"
while getopts ":i:o:w:h:c:" opt; do
case $opt in
i) input="$OPTARG"
;;
import { IgApiClient } from 'instagram-private-api';
import * as dotenv from 'dotenv';
import {AccountFollowersFeedResponseUsersItem} from "instagram-private-api/dist/responses";
dotenv.config({ path: __dirname+'/.env' });
const username = process.env.IG_USERNAME as string;
const password = process.env.IG_PASSWORD as string;
const INTERVAL_BETWEEN_CHECKS = 15000; // in ms
<html>
<head>
<style>
.fade {
display: block;
background: red;
margin-bottom: 50px;
width: 100%;
height: 150px;
opacity: 0.2;
@florimondmanca
florimondmanca / example_httpcore.py
Last active August 4, 2020 06:34
Proof of concept for an `httpcore` Unix Domain Socket (UDS) transport, compatible with asyncio and trio. Also contains an anyio implementation example.
"""
Example using the transport directly.
"""
import json
from httpcore_uds import AsyncUDSTransport
async def main() -> None:
"""
@twanmulder
twanmulder / my-name.gif
Last active March 25, 2020 19:53
🍳Welcome! 🍳
my-name.gif
@pmdartus
pmdartus / polyfill.js
Created March 20, 2020 08:41
String.prototype.endsWith polyfill
if (!String.prototype.endsWith) {
Object.defineProperty(String.prototype, 'endsWith', {
value: function (searchString, position) {
var subjectString = this.toString();
if (position === undefined || position > subjectString.length) {
position = subjectString.length;
}
position -= searchString.length;
var lastIndex = subjectString.indexOf(searchString, position);
return lastIndex !== -1 && lastIndex === position;
@PierreThiollent
PierreThiollent / Readme.md
Last active March 26, 2024 19:14
iTerm2 and Oh-my-zsh config

Setup iTerm2 and oh-my-zsh

Enjoy ! 😄

Install iTerm 2

Download iTerm2 here.

@itsabdessalam
itsabdessalam / welcome.png
Last active March 25, 2020 12:16
👋Welcome to my GitHub Profile !
welcome.png