Skip to content

Instantly share code, notes, and snippets.

View allensarkisyan's full-sized avatar

Allen Sarkisyan allensarkisyan

View GitHub Profile
@allensarkisyan
allensarkisyan / Web5Provider.js
Last active July 18, 2023 04:21
Web5 - React Context Provider
/**
* @name Web5Provider
* @author Allen Sarkisyan
* @description Web5 - React Context Provider
* @copyright 2023
* @license Open Source MIT License
*/
import { createContext, useContext, useRef, useState, useEffect } from 'react';
import { Web5 } from '@tbd54566975/web5';

Keybase proof

I hereby claim:

  • I am allensarkisyan on github.
  • I am allensarkisyan (https://keybase.io/allensarkisyan) on keybase.
  • I have a public key ASDyK13vFKf0SciHaOIUD9OuEaSD1Op_Jk6mekClIZ6A-Ao

To claim this, I am signing this object:

@allensarkisyan
allensarkisyan / delete_spotify_music.listens_actions.js
Created August 16, 2014 18:58
Delete all Spotify music.listens actions
FB.api('me/music.listens', function (response) {
function callback (rr) { console.log(rr); }
for (var i in response.data) {
if (response.data.hasOwnProperty(i)) {
console.log(response.data[i].id);
FB.api('/' + response.data[i].id, 'DELETE', callback);
}
}
console.log(response);
@allensarkisyan
allensarkisyan / parseQueryString.js
Last active December 19, 2015 01:09
Parses a query string or location.search into an Object.
/**
* @name - parseQueryString
* @author - Allen Sarkisyan
* @license - Open Source MIT License
*
* @description - Parses a query string into an Object.
* - Optionally can also parse location.search by invoking without an argument
*/
function parseQueryString(queryString) {
@allensarkisyan
allensarkisyan / gist:5518862
Last active December 17, 2015 00:09
Check for HTTP Live Streaming (HLS) playback compatibility
var hlsCompatible = (function() {
try {
if (/ip(?:hone|[a|o]d)/gi.test(navigator.userAgent)) { return true; }
return (document.createElement('video').canPlayType('application/x-mpegURL').length > 0);
} catch(e) {
return false;
}
}());
@allensarkisyan
allensarkisyan / RegExp_iOS_Device
Created May 4, 2013 07:21
Regular Expression Pattern for matching a iOS device (iPhone, iPad, iPod)
/ip(?:hone|[a|o]d)/gi
@allensarkisyan
allensarkisyan / SMPTE_TimeCode_RegularExpresson.js
Last active August 28, 2020 12:51
SMPTE Time Code RegExp Pattern for matching SMPTE time codes that have a frame rate of 23.98, 24, 25, 29.97, or 30.
/**
* @author Allen Sarkisyan
* @copyright 2013
* @license Open Source MIT License
*/
/**
* Assumes the frame rate is 23.98, 24, 25, 29.97 NDF, or 30
*
* This pattern basically matches the hours being less then 24, the minutes, and seconds
@allensarkisyan
allensarkisyan / gist:4158486
Created November 28, 2012 01:36
ISO8601 DateTime RegExp pattern
var dtPattern = /^(\d{4})(-)?(\d\d)(-)?(\d\d)(T)?(\d\d)(:)?(\d\d)(:)?(\d\d)(\.\d+)?(Z|([+-])(\d\d)(:)?(\d\d))/;
@allensarkisyan
allensarkisyan / gist:3805208
Created September 29, 2012 21:16
ISO 8601 timestamp for facebook open graph implementations, omitted seconds
// ISO 8601 Date Prototype - Usage example: (new Date).ISO8601();
Date.prototype.ISO8601 = function() {
function wrap(n) { return (n < 10 ? '0' + n : n) }
var dt = this;
return dt.getUTCFullYear() + '-' + wrap(dt.getUTCMonth() + 1) + '-' + wrap(dt.getUTCDate()) + 'T' + wrap(dt.getUTCHours()) + ':' + wrap(dt.getUTCMinutes());
};