Skip to content

Instantly share code, notes, and snippets.

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge"><script type="text/javascript">(window.NREUM||(NREUM={})).init={ajax:{deny_list:["bam.nr-data.net"]}};(window.NREUM||(NREUM={})).loader_config={licenseKey:"NRJS-41a5a2f008560c7bdc5",applicationID:"522948469"};;(()=>{var e,t,r={9071:(e,t,r)=>{"use strict";r.d(t,{I:()=>n});var n=0,i=navigator.userAgent.match(/Firefox[\/\s](\d+\.\d+)/);i&&(n=+i[1])},6562:(e,t,r)=>{"use strict";r.d(t,{P_:()=>p,Mt:()=>v,C5:()=>d,DL:()=>y,OP:()=>N,lF:()=>B,Yu:()=>A,Dg:()=>h,CX:()=>f,GE:()=>w,sU:()=>M});var n={};r.r(n),r.d(n,{agent:()=>x,match:()=>j,version:()=>O});var i=r(6797),o=r(909),a=r(8610);class s{constructor(e,t){try{if(!e||"object"!=typeof e)return(0,a.Z)("New setting a Configurable requires an object as input");if(!t||"object"!=typeof t)return(0,a.Z)("Setting a Configurable requires a model to set its initial properties");Object.assign(this,t),Object.entries(e).forEach((e=>{let[t,r]=e;const n=(0,o.q)(
@ahmedam55
ahmedam55 / App.js
Created March 7, 2021 21:04
Pokedex App
import { StatusBar } from 'expo-status-bar'
import React, { useCallback, useEffect, useState } from 'react'
import {
Image,
Pressable,
SafeAreaView,
StyleSheet,
Text,
useWindowDimensions,
View,
@ahmedam55
ahmedam55 / index.js
Last active February 12, 2020 00:30
import React, { Component } from "react";
import {
AppRegistry,
StyleSheet,
Text,
View,
FlatList,
AsyncStorage,
Button,
TextInput,
@ahmedam55
ahmedam55 / style.css
Last active July 7, 2019 14:08
Prevent scroll on IOS
.no-scroll {
overflow: hidden;
position: fixed;
}
@ahmedam55
ahmedam55 / index.html
Last active April 25, 2019 09:05
Service Worker: Serve from Cache, then revalidate the Cache After Specific Time
<html>
<head>
<link rel="stylesheet" href="/style.css">
</head>
<body>
PWA: Stale-while-revalidate: xx
<script src="/script.js"></script>
</body>
</html>
@ahmedam55
ahmedam55 / index.html
Last active April 25, 2019 06:47
Service Worker: Cache then Update Strategy
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Service Worker</title>
<link rel="stylesheet" href="/style.css">
</head>
<body>
@ahmedam55
ahmedam55 / script.sh
Created April 21, 2019 11:02
Convert Video to Gif
function gif {
ffmpeg -y -i $1 -vf fps=10,scale=${2:-1280}:-1:flags=lanczos,palettegen palette.png
ffmpeg -i $1 -i palette.png -filter_complex "fps=10,scale=${2:-1280}:-1:flags=lanczos[x];[x][1:v]paletteuse" output.gif
rm palette.png
}
@ahmedam55
ahmedam55 / googleImage.sh
Created November 27, 2018 10:05
Embedding or sharing an image or photo uploaded to Google Drive.
# Usage: googleImage https://drive.google.com/file/d/1ohKYjS7FxgkHCqdhP5gpYPMJN8xueqF2/view?usp=sharing
# Output: https://doc-0c-a4-docs.googleusercontent.com/docs/securesc/ha0ro937gcuc7l7deffksulhg5h7mbp1/50g94rphugajflevka9unjmgidqmudio/1543312800000/16295291601680688896/*/1ohKYjS7FxgkHCqdhP5gpYPMJN8xueqF2
function googleImage {
# Replace the parts around sharable link of google drive to extract the fileId
local fileId=$(echo 'https://drive.google.com/file/d/1ohKYjS7FxgkHCqdhP5gpYPMJN8xueqF2/view?usp=sharing' | sed 's/https:\/\/drive.google.com\/file\/d\///g' | sed 's/\/view\?usp=sharing//g')
# Prepend the exportable link
local url="https://docs.google.com/uc?id=$fileId"
# Get public generated url
local publicUrl=$(curl -Ls -o /dev/null -w %{url_effective} $url)
pipButtonElement.addEventListener('click', async function() {
pipButtonElement.disabled = true;
await videoElement.requestPictureInPicture();
pipButtonElement.disabled = false;
});
<video id="videoElement" src="https://example.com/file.mp4"></video>
<button id="pipButtonElement">Open Picture in Picture mode</button>