Skip to content

Instantly share code, notes, and snippets.

View alexdiliberto's full-sized avatar

Alex DiLiberto alexdiliberto

View GitHub Profile
@alexdiliberto
alexdiliberto / service_config.js
Created April 10, 2018 17:46
Ember config service
import Service from '@ember/service';
import { get } from '@ember/object';
import { equal } from '@ember/object/computed';
import config from '../config/environment';
export default Service.extend({
unknownProperty(path) {
return get(config, path);
},
@alexdiliberto
alexdiliberto / self-signed-cert-mamp-chrome.md
Created April 9, 2018 03:44
Self Signed Certs working with MAMP and Chrome 65+
  1. cd ~/.ssl

  2. Generate new .key and .crt file

# SEE: https://github.com/webpack/webpack-dev-server/issues/854#issuecomment-292445914

openssl req \
    -newkey rsa:2048 \
    -x509 \
@alexdiliberto
alexdiliberto / .eslintrc.js
Last active August 31, 2022 23:20
Integrate Prettier with Ember
/*
'plugin:prettier/recommended' does the following:
extends: ['prettier'],
plugins: ['prettier'],
rules: {
'prettier/prettier': 'error'
}
*/
module.exports = {
@alexdiliberto
alexdiliberto / components.ui-progress-bar.js
Created April 1, 2018 14:33
Ember Instagram Page Loader
import Ember from 'ember';
export default Ember.Component.extend({
});
@alexdiliberto
alexdiliberto / cloudflare-purge-all-files-post-receive.sh
Created March 16, 2018 02:25
CloudFlare "Purge All Files" githook after deploying to GitHub Pages (post-receive)
#!/bin/sh
#
# Purge the CloudFlare cache after pushing an update to a Github Repo branch
#
# To use, rename this file to "post-receive" and drop it into the `.git/hooks/` directory in your project's root.
# Change the $branch value based on the type of page you're deploying.
# EX: Use "master" for Organization Pages, and "gh-pages" for Project Pages.
#
# Find your CloudFlare API token here: https://www.cloudflare.com/a/profile

ServiceWorker for github pages

This is a ServiceWorker template to turn small github pages into offline ready app.

Why ?

Whenever I make small tools & toys, I create github repo and make a demo page using github pages (like this one).
Often these "apps" are just an index.html file with all the nessesary CSS and JavaScript in it (or maybe 2-3 html/css/js files). I wanted to cache these files so that I can access my tools offline as well.

Notes

Make sure your github pages have HTTPS enforced, you can check Settings > GitHub Pages > Enforce HTTPS of your repository.

@alexdiliberto
alexdiliberto / httpd-vhosts.conf
Last active March 12, 2018 22:52
Example vhosts.conf
// Re: busting the cache when using service worker
// The service worker JS name isn't fingerprinted, so if it has cache headers, it won't be updated and then none of your
// assets will be updated (because they're cached by the service worker for offline access). This is one technique for
// caching headers to ensure you're only caching fingerprinted assets
<VirtualHost *:8080>
ServerAdmin webmaster@dummy-host.example.com
DocumentRoot "/Users/martndemus/Projects/DockYard/smart-shopping-list/dist"
ServerName localhost
@alexdiliberto
alexdiliberto / assert-async.md
Created March 8, 2018 00:16
Stop an Ember integration test, mid-test to quickly inspect visually
assert.async();

This assert.asyncThrows custom assertion allows us to write tests against failing async code, usually as a result of a server error (4xx/5xx response).

test('If the index route errors, I see a message', async function(assert) {
  server.create('post');
  server.get('/posts/:id', { errors: ['The site is down'] }, 500); // force Mirage to error

  await assert.asyncThrows(() => {
    return visit('/posts/1');
 }, 'GET /posts/1 returned a 500');
@alexdiliberto
alexdiliberto / ember-concurrency-tips.md
Last active January 15, 2018 16:39
ember-concurrency Tips and Tricks

Using ember-concurrency to easily load data inside a component

import { task } from 'ember-concurrency';
import { readOnly } from '@ember/object/computed';

export default Component.extend({
  tags: readOnly('loadTags.lastSuccessful.value'),

 loadTags: task(function * () {