Skip to content

Instantly share code, notes, and snippets.

View devotox's full-sized avatar
💻
Innovating

Devonte devotox

💻
Innovating
View GitHub Profile
@devotox
devotox / s3-optimize-images.js
Last active January 21, 2021 00:09
Run Through S3 Images (JPEG) and optimize them using imagemin and reupload to same path - Automatically sets the cache control to a day and public
#!/usr/bin/node
const fs = require('fs');
const path = require('path');
const AWS = require('aws-sdk');
const Promise = require('bluebird');
const imagemin = require('imagemin');
const imageminJpegRecompress = require('imagemin-jpeg-recompress');
const config = {
@devotox
devotox / ember-sandbox-service.js
Last active October 18, 2022 07:46
Create A Javascript sandbox to execute custom code without giving access to things like window and outer contextThey still have a `this` object they can use across multiple executions to persist data
import Service from '@ember/service';
const has = () => true;
const { console, WeakMap, Proxy, Symbol } = window;
const get = (target, key) => key === Symbol.unscopables ? undefined : target[key];
export default Service.extend({
import Ember from 'ember';
import fetch from 'fetch';
const { FormData } = window;
import { debug } from '@ember/debug';
import Service, { inject } from '@ember/service';
{
"label": "Subform Top",
"sections": [
{
"label": "Subform Top",
"fields": [
{
"id": "121",
"type": "text",
"required": true,
@devotox
devotox / form2.json
Last active November 29, 2017 10:03
{
"id": "11223344",
"label": "D Form",
"description": "Forms so good ... Makes you wanna slap yo mama",
"hooks": [{
"type": "http",
"run": "click",
"pollTime": 5000,
"encrypted": true,
"element": "form",
@devotox
devotox / fa-icons.json
Created March 30, 2019 08:49
Font Awesome Icons
[
{
"value": "500px"
},
{
"value": "address-book"
},
{
"value": "address-book-o"
},
const def = {
'id': '11223344',
'label': 'D Form',
'description': 'Forms so good ... Makes you wanna slap yo mama',
'hooks': [{
'type': 'http',
'run': 'click',
'pollTime': 5000,
'encrypted': true,
'element': 'form',
@devotox
devotox / config | environment.js
Last active January 21, 2020 13:37
Zero cost web apps
'use strict';
module.exports = function(environment) {
let ENV = {
modulePrefix: 'zero-cost-web-app',
environment,
rootURL: '/',
locationType: 'auto',
EmberENV: {
FEATURES: {
@devotox
devotox / mirage-serializer-application.js
Last active December 27, 2019 18:05
Mirage JSON API Serializer (With Filtering, Sorting, Paging)
import sort from 'fast-sort';
import { JSONAPISerializer } from 'ember-cli-mirage';
const stringToBoolean = (str) =>
({ 'true': true, 'false': false }[str?.trim().toLowerCase()] || str);
export default class Application extends JSONAPISerializer {
// Can filter by any value on attributes
// Or an ID on a relationship that MUST be in the `includes`
filterResourceHash(resourceHash) {
@devotox
devotox / ember-orbit-data-store.js
Last active December 25, 2019 01:38
Ember Orbit Data Store (But Better)
import { Store } from 'ember-orbit';
export default class DataStore extends Store {
findRecords(type, { filter, sort, page, include, ...options } = {}) {
include && put(options, 'sources.remote.include', include);
return this.query((q) => {
let result = q.findRecords(type);
page && (result = result.page(page));