Skip to content

Instantly share code, notes, and snippets.

View mrosata's full-sized avatar
🐣

Michael Rosata mrosata

🐣
  • Quincy, MA USA
View GitHub Profile
@mrosata
mrosata / animation-queue.js
Last active August 29, 2015 14:16
Animate multiple elements with different positions and timing using an object to manage each frame with a queue
/* Animation Queue Object using vanilla JavaScript
* by: Michael Rosata
* https://jsfiddle.net/mrosata/gb96gcme/2/
*/
function AnimeQ (int) {
this.intv = parseInt(int,10) || 10;
this.queue = [];
}
AnimeQ.prototype.addToQueue = function (item) {
item.animating = true;
@mrosata
mrosata / dynamic-cryptoJS.js
Created June 19, 2015 03:04
Easy way to dynamically load and use CryptoJS hash algorithms on client side. Choose to load and use SHA1, SHA256, SHA512 or md5 on the fly.
/**
* Setup Password Hashing Object
* This will hash the passwords on the client side so that:
* 1. We don't ask people to submit sensitive data over the wire
* 2. We don't have to store plaintext passwords in MySQL
*/
// I wrapped this is private scope because there's no reason to trust wild code.
var passwordHasher = (function(window, undefined) {
// These scripts are open-source up on https://code.google.com/p/crypto-js/#Hashers - (More on the website too!)
/**
* This was a refactor to a loop that was building events on a series of toggle switches.
* The nature of the events binding would break upon ajax page loading (if it overwrote bs-toggles).
* To make it dynamic I had to refactor original code (top) to the nice code (bottom) which is
* independant of toggle switches themselves. It listens on a anscestor container. An element which
* will never be overwritten by ajax. On some pages this would have to be <body> perhaps.
*/
// Original Code. Author unknown.
$('.switch-toggle').each(function(i,ob){
@mrosata
mrosata / view.mapper.partial.js
Created September 11, 2015 16:25
Template adapter for phonegap version of our web app (Fill the hole that .htaccess left behind).
/******
* @author: Steven Spielburg, j/k, it's me!
* @since: Long time away
* @galaxy: Far far away
*
* Usually our .htaccess would build a proper query string so that index.php can handle any request for us.
* Now we have no .htaccess except on the api server. So we must map our own templates. This pattern below
* will serve as almost middleware to AjaxHustleBunny. Normally AHB would make HTTP request and index.php
* would return the correct page, then AHB would fire enpoint event (`controller/action`, id) to all JS
* modules, but now instead AHB will call aroma.loadAssets() with params and aroma.loadAssets shall return
/**
* HistoryImplement for SPA
* -- I created an application that was both a SPA and also took advantage of the
* pushState API. When I ported the app to Cordova, the back button no longer
* worked since I had used custom ajax nav and handled url using pushState. I
* easily solved the problem and I'm sure it's similiar to how many others have
* solved it as well.
*/
function HistoryImplement (callback, max) {
// max history
@mrosata
mrosata / twitter-api-call.php
Created February 25, 2016 00:31
A Twitter API Call - Allows clientside to make 3 requests which each return the next query results
<?php
ini_set('display_errors', 1);
error_reporting(E_ALL);
require '../vendor/autoload.php';
define("OAUTH_ACCESS_TOKEN", "the oauth here ya know");
define("OAUTH_ACCESS_TOKEN_SECRET", "put the secret here");
define("CONSUMER_KEY", "key key key key key key");
@mrosata
mrosata / components.signup-form.js
Created June 22, 2016 13:28
Integration | Component | signup form
import Em from 'ember';
const birthdayRE = /\d{4}-\d{2}-\d{2}/;
export default Em.Component.extend({
classNames: ['col-md-12', 'section-post-comment'],
title: 'Sign-up',
/**
@mrosata
mrosata / controllers.application.js
Last active June 26, 2016 13:20
Disabled Button Example
import Ember from 'ember';
export default Ember.Controller.extend({
isDisabled: false,
pureBoolean: Em.computed('isDisabled', function() {
return !this.get('isDisabled');
}),
actions: {
makeDisabled() {
@mrosata
mrosata / content-for-group.js
Created July 29, 2016 19:52 — forked from mrozema/content-for-group.js
Ember 2.0 compatible select box
import Ember from "ember";
export default Ember.Helper.helper(function([content, group, contentGroupKey]) {
return content.filterBy(contentGroupKey, group);
});
@mrosata
mrosata / ember-getsetter.js
Last active August 20, 2016 12:33
Ember partial getter and setter. A functional style get(this, 'prop') and set(this, 'prop', val) that also supports partial arguments by returning functions when supplied less arguments then required on the first call.
/**
* Ember
* (more functional style) Getter and Setter
*
* setup option 1 (modular):
* const {get, set} = getSetterDecorator();
* setup option 2 (global):
* getSetterDecorator( window );
*/
import Ember from 'ember';