Skip to content

Instantly share code, notes, and snippets.

View jpravetz's full-sized avatar

Jim Pravetz jpravetz

  • Self!
  • Costa Rica
View GitHub Profile
@jpravetz
jpravetz / resource-list.js
Created May 9, 2018 01:39
Aurelia CLI Task to Generate Webpack-compatible index.js files under the src/resources folder
import gulp from 'gulp';
import project from '../aurelia.json';
import fs from 'fs';
import Path from 'path';
import util from 'util';
/**
* Task generates webpack compatible index.js files under the src/resources folder,
* recursively descending and including every file that is found.
* To exclude files in a particular folder, add their names to a .resourceignore file in that
@jpravetz
jpravetz / BusyPromise
Created January 8, 2018 20:44
Promise wrapper, can be used in Node or in browser with transpiling
export class BusyPromise {
/**
* Promise wrapper that calls pre and post methods. Can be used to auto increment and decrement a
* counter, for example, or to indicate when busy and unbusy.
* @param opts {Object}
* @param [opts.pre] {Function} Function to execute before calling function
* @param [opts.onResolve] {Function} Function to execute after function resolves
* @param [opts.onReject] {Function} Function to execute if function rejects
* @param fn {function} Same as function in new Promise(fn)
@jpravetz
jpravetz / product_generator.rb
Created December 2, 2011 21:24
Jekyll generator to read json data file and generate product and ingredient pages
#------------------------------------------------------------------------
# encoding: utf-8
# @(#)product_generator.rb 1.00 29-Nov-2011 16:38
#
# Copyright (c) 2011 Jim Pravetz. All Rights Reserved.
# Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
#
# Description: A generator that creates product, products and
# ingredients pages for jekyll sites. Uses a JSON data
# file as the database file from which to read and
@jpravetz
jpravetz / TestTransition.mxml
Created August 19, 2011 01:17
Flex 4.x Example showing dialog sliding down and compressing VDiv below
<?xml version="1.0" encoding="utf-8"?>
<s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
xmlns:yahoo="http://www.yahoo.com/astra/2006/mxml"
xmlns:local="*">
<fx:Declarations>
<s:Parallel id="showRect"
duration="400"
@jpravetz
jpravetz / TextLink.mxml
Created July 22, 2011 03:20
Example that show how automated clicking of a link in an HTML control does not work after running a timer
@jpravetz
jpravetz / JsonMapper.as
Created November 10, 2010 05:43
Converts a tree of JSON objects into a tree of typed ActionScript objects
/*************************************************************************
* Copyright 2010 Cayo Systems, Inc.
* Copying and distribution of this file, with or without modification,
* are permitted in any medium without royalty provided the copyright
* notice and this notice are preserved.
* Author: Jim Pravetz
* Date: 2010/11/11
* Language: ActionScript 3.0
**************************************************************************/