Skip to content

Instantly share code, notes, and snippets.

View byteshiva's full-sized avatar
🎯
Focusing

Siva byteshiva

🎯
Focusing
View GitHub Profile
@byteshiva
byteshiva / umap_sparse.py
Created August 23, 2018 13:48 — forked from johnhw/umap_sparse.py
1 million prime UMAP layout
### JHW 2018
import numpy as np
import umap
# This code from the excellent module at:
# https://stackoverflow.com/questions/4643647/fast-prime-factorization-module
import random
@byteshiva
byteshiva / README.md
Created August 21, 2018 20:01 — forked from axic/README.md
WebAssembly kickstart guide

WebAssembly kickstart guide

Rolling your own compiler

One of the premises of WebAssembly is to support compiling multiple languages to WebAssembly.

C/C++

Building

@byteshiva
byteshiva / install-firefox-nightly.md
Created July 15, 2018 02:52 — forked from brenopolanski/install-firefox-nightly.md
Install Firefox Nightly in Ubuntu via PPA

via: http://www.webupd8.org/2011/05/install-firefox-nightly-from-ubuntu-ppa.html

Add the Mozilla Daily PPA (available for Ubuntu 11.04, 10.10 and 10.04) and install Firefox Nightly using the commands below:

$ [sudo] add-apt-repository ppa:ubuntu-mozilla-daily/ppa
$ [sudo] apt-get update
$ [sudo] apt-get install firefox-trunk

Since this is a daily builds PPA, it's nowhere near stable so use it at your own risk!

@byteshiva
byteshiva / index.html
Created July 12, 2018 19:36 — forked from jeffposnick/index.html
Exploration of how a service worker's fetch handler affects the DevTools Network panel
<html>
<head>
<title>DevTools Test</title>
</head>
<body>
<script>
if ('serviceWorker' in navigator) {
navigator.serviceWorker.register('sw.js');
// Wait until the SW has taken control of the page before inserting the <script> elements.
// That way we can be sure the SW's fetch handler will intercept them.
@byteshiva
byteshiva / gist:68c04da8d6ec1dab190b353958840438
Created July 8, 2018 17:54 — forked from gerryster/gist:18b67d6209c72a9739c0
firebase.json with support for HTML5 routing and cache busting (as long as the compiled html file also supports cache busting).
{
"firebase": "my-awesome-app",
"rewrites": [ {
"source": "**",
"destination": "/index.html"
} ],
"headers": [ {
"source" : "**/*.html",
"headers" : [ {
"key" : "Cache-Control",
@byteshiva
byteshiva / destructuring.js
Created June 30, 2018 10:40 — forked from mikaelbr/destructuring.js
Several demos and usages for ES6 destructuring. Runnable demos and slides about the same topic: http://git.mikaelb.net/presentations/bartjs/destructuring
// === Arrays
var [a, b] = [1, 2];
console.log(a, b);
//=> 1 2
// Use from functions, only select from pattern
var foo = () => [1, 2, 3];
// Good
exports.sendEmail = functions.auth.user().onCreate(event => {
const mailgun = require('mailgun-js');
// ...
});
// Not As Awesome
const mailgun = require('mailgun-js');
exports.sendEmail = functions.auth.user().onCreate(event => {
// Client-side code, in my case a web browser
firebase.auth().onAuthStateChanged(function (user) {
this.user = user; // Set my local copy of the 'user' object
if (user) {
this.displayName = user.displayName;
this.photoURL = user.photoURL;
var userRef = firebase.database().ref('queues/login').child(user.uid);
userRef.remove()
.then(function () {
const function = require('firebase-functions');
functions.database.ref('queues/login/{uid}').onWrite(event => {
const config = functions.config();
// functions.config() returns your environment variables.
// In this case I have an array of my admin users' email addresses in accessControlLists.adminUsers
// It looks like ['chris@chrisesplin.com', 'some-other-admin@chrisesplin.com']
const adminUsersString = config.['access-control-lists']['admin-users'];
const adminUsers = adminUsersString.split(',');
const user = event.data.val();
@byteshiva
byteshiva / gh-pages-deploy.md
Created June 11, 2018 16:49 — forked from cobyism/gh-pages-deploy.md
Deploy to `gh-pages` from a `dist` folder on the master branch. Useful for use with [yeoman](http://yeoman.io).

Deploying a subfolder to GitHub Pages

Sometimes you want to have a subdirectory on the master branch be the root directory of a repository’s gh-pages branch. This is useful for things like sites developed with Yeoman, or if you have a Jekyll site contained in the master branch alongside the rest of your code.

For the sake of this example, let’s pretend the subfolder containing your site is named dist.

Step 1

Remove the dist directory from the project’s .gitignore file (it’s ignored by default by Yeoman).