Skip to content

Instantly share code, notes, and snippets.

View MTco's full-sized avatar
😞

Mathew Tyler MTco

😞
View GitHub Profile
@vanyakosmos
vanyakosmos / github-html-preview-monkey.js
Last active January 26, 2024 15:49
Script for Tampermonkey that adds 'view' to the actions menu beside 'row', 'blame' and 'history' buttons and allow you to preview rendered .html pages.
// ==UserScript==
// @name Github html preview
// @author https://github.com/vaniakosmos
// @version 1.0
// @description Shortcut for htmlpreview.github.io
// @match https://github.com/**/*.html
// @grant none
// @require http://code.jquery.com/jquery-3.2.1.min.js
// ==/UserScript==
@AmeliaBR
AmeliaBR / basic-marker.svg
Created July 5, 2017 01:08
Testing SVG files in GitHub Gists
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@glaszig
glaszig / mkp2pblocklist
Last active January 30, 2022 00:30
creates a blocklist for your p2p endeavors
#!/usr/bin/env sh
# DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
# Version 2, December 2004
#
# Copyright (C) 2020 glaszig <glaszig@gmail.com>
#
# Everyone is permitted to copy and distribute verbatim or modified
# copies of this license document, and changing it is allowed as long
# as the name is changed.
@natecox
natecox / brunch-config.js
Created February 21, 2017 18:07
Phoenix-Framework Brunch config for sw-precache
let glob = require('glob')
exports.config = {
// See http://brunch.io/#documentation for docs.
files: {
javascripts: {
joinTo: "js/app.js"
},
stylesheets: {
joinTo: "css/app.css",

The Angular Service Worker

What is a service worker?

A service worker is a special script which runs in the background in the browser and manages network requests to a given origin. It's originally installed by an app and stays resident on the user's machine/device. It's activated by the browser when a page from its origin is loaded, and has the option to respond to HTTP requests during the page loading, including the initial navigation request (for /index.html). This makes service workers very useful for true offline support in applications.

Additionally, service workers are the client-side endpoint for push notifications on the web.

Features

@jianwu
jianwu / static_server.js
Last active February 9, 2023 22:38 — forked from ryanflorence/static_server.js
Node.JS static file web server, also provides CORSProxy, Http/Https proxy function. Put it in your path to fire up servers in any directory, takes an optional port argument. If provide second https port argument, it will also start https. For https to work, need to put key and cert file in the folder.
#!/usr/bin/env node
const { argv } = require('process');
/**
Static http server implemented with NodeJS.
Features:
1. No external dependencies
@DrSpeedy
DrSpeedy / dLocker.sh
Last active June 19, 2023 17:28
Prototype linux directory locker
#!/bin/bash
# dLocker.sh by Brian Wilson
#
# Quick and dirty prototype for a directory locker
#
# Initialization Example:
# $ cd dLocker
# $ ls
# dLocker/ dLocker.sh
@TimvdLippe
TimvdLippe / gradle-sw-precache-wrapper.md
Created September 10, 2016 11:18
Small wrapper example to use sw-precache with Gradle

Writing a custom Gradle wrapper

Using sw-precache with Gradle is rather straightforward which allows you to for example generate a service-worker for the Javadoc of your Java application.

task generateJavadoc(type: Javadoc) {
  <...>
  // Specify your Javadoc options here
  <...>
  // After the javadoc is generated, also generate the service-worker
  doLast {
@stefanmaric
stefanmaric / copy-to-clipboard-bookmarklet.md
Created September 7, 2016 20:54
Create Bookmarklet (browser bookmark that executes Javsacript) to copy a given text to Clipboard

Copy-to-clipboard Bookmarklet

Create Bookmarklet (browser bookmark that executes Javsacript) to copy a given text to Clipboard.

This is the base javascript:

(function (text) {
  var node = document.createElement('textarea')
  var selection = document.getSelection()
@AdReVice
AdReVice / storagePolyfill.js
Created July 6, 2016 10:19 — forked from hasdavidc/storagePolyfill.js
A LocalStorage polyfill that also works in private browsing Safari (by doing window.localStorage.__proto__ = ourPolyfillObject) (where window.localStorage !== 'undefined', but has a quota of 0 and throws an error when you try to setItem)
//variant of https://gist.github.com/Contra/6368485
(function () {
var isStorageAvailable = function (storage) {
if (typeof storage == 'undefined') return false;
try { // hack for safari incognito
storage.setItem("storage", "");
storage.getItem("storage");
storage.removeItem("storage");