Skip to content

Instantly share code, notes, and snippets.

Avatar
😀
chatting

Joey Guerra joeyguerra

😀
chatting
View GitHub Profile
View getbitcoin.js
Notification.requestPermission();
setInterval(async ()=>{
let data = await (await fetch("https://api.coindesk.com/v1/bpi/currentprice.json")).json();
document.body.innerHTML = `${data.time.updated}:%20${data.bpi.USD.rate}`;
if(Notification.permission == "granted") new Notification(`BitCoin Price: $${data.bpi.USD.rate}`);
},10000);
View Http2Example.mjs
import assert from "assert"
import http2 from "http2"
//using mocha
describe("Http2", ()=>{
it("Should make a get request to google with http2", done => {
const uri = "https://www.google.com"
const client = http2.connect(uri);
const req = client.request({
[http2.constants.HTTP2_HEADER_SCHEME]: "https",
[http2.constants.HTTP2_HEADER_METHOD]: http2.constants.HTTP2_METHOD_GET,
@joeyguerra
joeyguerra / ParseEnvFile.mjs
Created Sep 5, 2020
Parse a .env file key/value pairs
View ParseEnvFile.mjs
import assert from "assert"
describe("PropertyFile - externalize configuraiton with environment variables", ()=>{
it("Should parse an env file", async done => {
const env = `
CLIENT_ID="something"
CLIENT_SECRET="something"
# something id
ID=1
`
let config = {}
View sequential execution
const pipe = (...fns) => x => fns.reduce((y, f) => f(y), x)
View keybase.md

Keybase proof

I hereby claim:

  • I am joeyguerra on github.
  • I am joeyguerra (https://keybase.io/joeyguerra) on keybase.
  • I have a public key ASBDxkxeKV2rhI1xg9U9HoLNphwjWh_qk2Sj5V969ys6fAo

To claim this, I am signing this object:

@joeyguerra
joeyguerra / schema.js
Last active Jul 23, 2020
Schema.org microdata parser in Javascript for the client side.
View schema.js
(function(win){
/*
Copied from https://github.com/foolip/microdatajs/blob/master/jquery.microdata.json.js
without jQuery.
*/
var Schema = (function(doc){
function getTypes(node){
var type = node.getAttribute('itemtype');
if(!type) return [];
return type.split(' ');
@joeyguerra
joeyguerra / notificationcenter.js
Created Nov 25, 2013
Client side notification center. Publsih/Subscribe implementation in Javascript.
View notificationcenter.js
(function(module){
var observers = [];
module.exports.notificationcenter = {
publish: function(notification, publisher, info){
var ubounds = observers.length;
var i = 0;
for(i; i<ubounds; i++){
if(!observers[i]) continue;
if(observers[i].notification != notification) continue;
if(observers[i].publisher != null && observers[i].publisher != publisher) continue;