Skip to content

Instantly share code, notes, and snippets.

const DB_VERSION = 1; // Use a long long for this value (don't use a float)
const DB_STORE_NAME = 'customer';
const DB_NAME = 'default';
class Database {
constructor(name = 'default', version = 1) {
this.name = name;
this.version = version;
}
@corburn
corburn / database_defined_summary.blade.php
Last active April 27, 2016 15:44
This script was created to visually answer the question which tables/fields in a database are actually being used. It uses Laravel and Canvas.js to create a webpage full of bar charts for each table, in ascending order by number of records in the table, showing all the fields present in the table and how many records have a non-null value in the…
<!DOCTYPE HTML>
<html>
<head>
<script type="text/javascript">
window.onload = function () {
@foreach($tables as $table => $columns)
var chart = new CanvasJS.Chart("{{$table}}",
{
theme: "theme3",
class StockTicker extends HTMLElement {
  createdCallback() {
    this.createShadowRoor().innerHTML = `
      <style> :host { display: block; } </style>
      <div id="quotes"></div>`;
  }
  
  updateQuotes() {
    let url = `https://api.finance.com?q=${this.symbols}`;
@corburn
corburn / Makefile
Last active April 27, 2016 15:29
Install Ansible
.PHONY: ansible
ansible:
command -v ansible || make ${HOME}/workspace/src/github.com/ansible/ansible/build
.PHONY: ansible-build-dependencies
ansible-build-dependencies: enable-epel
yum update \
&& yum -y groupinstall "Development tools" \
&& yum -y install python-{pip,setuptools,devel}
@corburn
corburn / UsingServiceWorkers.md
Last active April 27, 2016 15:28
Service Worker notes
  • HTTPS Required - Service Workers are restricted to running across HTTPS for security reasons.
  • Same Origin Required - Service workers must be from the same domain as for the page/app they are registered.
  • Beware Global Variables - A single service worker can control many pages. Each time a page within your scope is loaded, the service worker is installed against that page and operates on it. Bear in mind therefore that you need to be careful with global variables in the service worker script: each page doesn’t get its own unique worker.

Service worker functions like a proxy server, allowing you to modify requests and responses, replace them with items from its own cache, and more.

Events

@corburn
corburn / CSP.md
Last active September 20, 2023 12:55 — forked from xrstf/letsencrypt.md
Nginx server notes

The following is from scotthelme.co.uk

Content Security Policy

with Content Security Policy (CSP) enabled(and a browser that supports it(http://caniuse.com/#feat=contentsecuritypolicy), you can tell the browser that it can only download content from the domains you explicitly allow http://www.html5rocks.com/en/tutorials/security/content-security-policy/ https://www.owasp.org/index.php/Content_Security_Policy I need to change our application code so we can increase security by disabling 'unsafe-inline' 'unsafe-eval'

{
"preset": "google",
"jsDoc": {
"checkAnnotations": "jsdoc3",
"checkParamExistence": true,
"checkParamNames": true,
"requireParamTypes": true,
"checkRedundantParams": true,
"checkReturnTypes": true,
"checkRedundantReturns": true,
-- http://www.thedotpost.com/2015/11/francesc-campoy-flores-functional-go
-- https://youtu.be/ouyHp2nJl0I?t=85
quicksort [] = []
quicksort (x:xs) =
let smaller = quicksort [a | a <- xs, a <= x]
bigger = quicksort [a | a <- xs, a > x]
in smaller ++ [x] ++ bigger
@corburn
corburn / Makefile
Created November 25, 2015 21:23
SC15 Student Cluster Competition
# find ./ -type f -exec ldd {} \; 2>/dev/null | less
# LOCAL is the path prefix where the programs will be installed
# The environment variable will supersede the default value
#LOCAL ?= ${HOME}/local
SRC = ${CURDIR}
BIN = ${LOCAL}/bin
ifndef LOCAL
$(error LOCAL is not set)
endif
@corburn
corburn / .bashrc
Last active February 9, 2021 16:07
Bash functions
# https://danielmiessler.com/blog/the-one-line-cli-bandwidth-test/
alias bt="wget http://cachefly.cachefly.net/100mb.test -O /dev/null"
# Watch nginx logs
alias access='tail -f /var/log/nginx/access.log'
alias error='tail -f /var/log/nginx/error.log'
# column is used here to display a Tab Separated Values file with vertically aligned columns
# less is used so the arrow keys can be used to scroll up/down left/right
tsv() {