Skip to content

Instantly share code, notes, and snippets.

View khanzzirfan's full-sized avatar

Irfan Khan khanzzirfan

View GitHub Profile
@jord-goldberg
jord-goldberg / useVideoFrames.ts
Last active March 22, 2024 14:35
useVideoFrames react hook - a callback for every frame of a video element
import React, { useEffect, useRef, useState } from "react";
type VideoEventListenerMap = {
[EventName in keyof HTMLMediaElementEventMap]?: EventListener;
};
const useVideoFrames = (
frameCallback = (videoTime: number) => {}
): [HTMLVideoElement | null, React.RefCallback<HTMLVideoElement>] => {
const [video, setVideo] = useState<HTMLVideoElement | null>(null);
@kyo504
kyo504 / index.ios.js
Created April 12, 2017 16:38
Store base64 image with AsyncStorage
import React, { Component } from 'react';
import {
AppRegistry,
StyleSheet,
View,
ImageStore,
Image,
ImageEditor,
AsyncStorage,
Button,
@sandeepraju
sandeepraju / download-chromium.sh
Last active January 19, 2024 14:00
Download the latest bin of chromium for linux
#!/bin/bash
# source: http://askubuntu.com/a/64396/174460
CHROMIUM_ROOT="http://commondatastorage.googleapis.com/chromium-browser-snapshots/Linux_x64"
CHROMIUM_LATEST=`wget -q -O - "$CHROMIUM_ROOT/LAST_CHANGE"`
wget $CHROMIUM_ROOT/$CHROMIUM_LATEST/chrome-linux.zip
@konsumer
konsumer / easysql.js
Last active October 26, 2019 01:24
HTML5 Promise-based WebSQL query convenience-function
// https://github.com/Philzen/WebSQL-Polyfill
// https://github.com/jakearchibald/es6-promise
/**
* Usage:
* var db = new DB('demo', '1.0', 'Demo', 2 * 1024 * 1024);
* db.query('SELECT * FROM mytable')
* .then(function(res){
* console.log(res.rows);
* }, function(err){
var mediaJSON = { "categories" : [ { "name" : "Movies",
"videos" : [
{ "description" : "Big Buck Bunny tells the story of a giant rabbit with a heart bigger than himself. When one sunny day three rodents rudely harass him, something snaps... and the rabbit ain't no bunny anymore! In the typical cartoon tradition he prepares the nasty rodents a comical revenge.\n\nLicensed under the Creative Commons Attribution license\nhttp://www.bigbuckbunny.org",
"sources" : [ "http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4" ],
"subtitle" : "By Blender Foundation",
"thumb" : "images/BigBuckBunny.jpg",
"title" : "Big Buck Bunny"
},
{ "description" : "The first Blender Open Movie from 2006",
"sources" : [ "http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/ElephantsDream.mp4" ],
@nathansmith
nathansmith / scroll-offset.js
Last active November 27, 2023 04:51
Check if the user is scrolled to the bottom of the page.
window.onscroll = function() {
var d = document.documentElement;
var offset = d.scrollTop + window.innerHeight;
var height = d.offsetHeight;
console.log('offset = ' + offset);
console.log('height = ' + height);
if (offset >= height) {
console.log('At the bottom');
@hail2u
hail2u / bar.partial.mustache
Last active June 13, 2021 21:54
Load mustache partials from file.
Hey {{name}}! This is bar.
@shinyzhu
shinyzhu / GooglePoints.cs
Last active February 7, 2024 12:13
Encode/Decode Polyline Algorithm Format in C#
/// <summary>
/// See https://developers.google.com/maps/documentation/utilities/polylinealgorithm
/// </summary>
public static class GooglePoints
{
/// <summary>
/// Decode google style polyline coordinates.
/// </summary>
/// <param name="encodedPoints"></param>
/// <returns></returns>
@zhaoz
zhaoz / updatechromium.sh
Created February 21, 2012 23:13 — forked from benvanik/updatechromium.sh
Update Chromium on Linux to the latest version
#!/bin/bash
cd ~/Downloads/
if [ ! -x /usr/bin/curl ]; then
echo "Didn't find curl at /usr/bin/curl. Install with 'sudo apt-get install curl'."
exit 1
fi
echo -n "Determining latest build... "