Skip to content

Instantly share code, notes, and snippets.

View cozzbie's full-sized avatar
👻

Timi Aiyemo cozzbie

👻
View GitHub Profile
@cozzbie
cozzbie / gist:a9831e48667c49edfdbdfd8725c78c22
Created March 4, 2017 17:02 — forked from segebee/gist:7dde9de8e70a207e6e19
Nigeria States and Local Government Areas JSON - codingsavvy.com
[{"state":{"name":"Abia State","id":1,"locals":[{"name":"Aba South","id":1},{"name":"Arochukwu","id":2},{"name":"Bende","id":3},{"name":"Ikwuano","id":4},{"name":"Isiala Ngwa North","id":5},{"name":"Isiala Ngwa South","id":6},{"name":"Isuikwuato","id":7},{"name":"Obi Ngwa","id":8},{"name":"Ohafia","id":9},{"name":"Osisioma","id":10},{"name":"Ugwunagbo","id":11},{"name":"Ukwa East","id":12},{"name":"Ukwa West","id":13},{"name":"Umuahia North","id":14},{"name":"Umuahia South","id":15},{"name":"Umu Nneochi","id":16}]}},{"state":{"name":"Adamawa State","id":2,"locals":[{"name":"Fufure","id":1},{"name":"Ganye","id":2},{"name":"Gayuk","id":3},{"name":"Gombi","id":4},{"name":"Grie","id":5},{"name":"Hong","id":6},{"name":"Jada","id":7},{"name":"Lamurde","id":8},{"name":"Madagali","id":9},{"name":"Maiha","id":10},{"name":"Mayo Belwa","id":11},{"name":"Michika","id":12},{"name":"Mubi North","id":13},{"name":"Mubi South","id":14},{"name":"Numan","id":15},{"name":"Shelleng","id":16},{"name":"Song","id":17},{"name":"Toung
@cozzbie
cozzbie / gist:e12fc5756197b83509d452857b3a21bb
Created March 4, 2017 17:02 — forked from segebee/gist:7dde9de8e70a207e6e19
Nigeria States and Local Government Areas JSON - codingsavvy.com
[{"state":{"name":"Abia State","id":1,"locals":[{"name":"Aba South","id":1},{"name":"Arochukwu","id":2},{"name":"Bende","id":3},{"name":"Ikwuano","id":4},{"name":"Isiala Ngwa North","id":5},{"name":"Isiala Ngwa South","id":6},{"name":"Isuikwuato","id":7},{"name":"Obi Ngwa","id":8},{"name":"Ohafia","id":9},{"name":"Osisioma","id":10},{"name":"Ugwunagbo","id":11},{"name":"Ukwa East","id":12},{"name":"Ukwa West","id":13},{"name":"Umuahia North","id":14},{"name":"Umuahia South","id":15},{"name":"Umu Nneochi","id":16}]}},{"state":{"name":"Adamawa State","id":2,"locals":[{"name":"Fufure","id":1},{"name":"Ganye","id":2},{"name":"Gayuk","id":3},{"name":"Gombi","id":4},{"name":"Grie","id":5},{"name":"Hong","id":6},{"name":"Jada","id":7},{"name":"Lamurde","id":8},{"name":"Madagali","id":9},{"name":"Maiha","id":10},{"name":"Mayo Belwa","id":11},{"name":"Michika","id":12},{"name":"Mubi North","id":13},{"name":"Mubi South","id":14},{"name":"Numan","id":15},{"name":"Shelleng","id":16},{"name":"Song","id":17},{"name":"Toung
@cozzbie
cozzbie / intercept.js
Last active January 4, 2018 16:04
AngularJS interceptor
import { Injectable, Injector } from '@angular/core';
import { HttpEvent, HttpInterceptor, HttpHandler, HttpRequest } from '@angular/common/http';
import { Observable } from 'rxjs/Rx';
import 'rxjs/add/observable/throw'
import 'rxjs/add/operator/catch';
@Injectable()
export class MyHttpInterceptor implements HttpInterceptor {
constructor() { }
@cozzbie
cozzbie / audio.js
Last active January 11, 2018 15:44
A WebRTC audio channel.
function streamSuccess(stream) {
window.AudioContext = window.AudioContext || window.webkitAudioContext;
var audioContext = new AudioContext();
// Create an AudioNode from the stream
var mediaStreamSource = audioContext.createMediaStreamSource(stream);
// Hear thyself!
mediaStreamSource.connect(audioContext.destination);
}
@cozzbie
cozzbie / media.js
Last active January 15, 2018 18:33
WebRTC MediaStream
var constraints = { video: 1, audio: 1 },
localvid = document.querySelector("#localvid"); // A HTML5 video element with an 'autoplay' property.
// Success call
function success(stream){
localvid.src = URL.createObjectURL(stream);
}
// Failure call
function failure(e){
var iceserver = {...},
alice = new RTCPeerConnection(iceserver);
alice.setRemoteDescription(new RTCSessionDescription(data)) // 'data' is the session sent from Bob.
alice.createOffer({ offerToRecieveAudio: 1, offerToReceiveVideo: 1 })
.then(function(description){
// Alice adds the description as her local description.
alice.setLocalDescription(new RTCSessionDescription(description));
// Alice then sends this description to Bob. This action is seen as the 'call'
});
// Create Bobs WebRTC Peer. (same as Alice)
// ...
//Set Alice's description as the remote
bob.setRemoteDescription(new RTCSessionDescription(data)) // 'data' is the session description from Alice
.then(function(){
//Create answer
bob.createAnswer({ offerToRecieveAudio: 1, offerToReceiveVideo: 1 })
.then(function(description){
// Bob saves his description locally
// Flag for enabling cache in production
var doCache = false;
var CACHE_NAME = 'pwa-app-cache';
// Delete old caches
self.addEventListener('activate', event => {
const currentCachelist = [CACHE_NAME];
event.waitUntil(
caches.keys()