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 / flower-power.py
Last active October 7, 2023 11:08
Python Turtle Flower... Stack like recursion
#!/usr/bin/python
# Udacity exercise. Just posted the code here to help anyone who wanted to see the work behind my posted result.
__author__ = 'Michael Rosata mrosata1984@gmail.com'
__package__ = ''
from random import random
import turtle
class TurtleArtist(turtle.Turtle):
_origin = (0, 0)
@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
"""
Merge together .csv files. I'm creating this because I have 30 .csv files which need to be concatenated
together. This uses the headers from 1 file and then will concate w/o headers 1 through n such as :
"customer-data.csv", "customer-data (1).csv" ... "customer-data (n).csv"
"""
# Todo: make use of the csv module and check headers from each file to make sure data lines up.
# Todo: allow explicit filenames to be passed in as well as lists of files
import csv
class CSV_Monster:
@mrosata
mrosata / csv_monster.py
Last active February 24, 2017 19:26
Improved CSV File merger/File splitter that I created to help with large amounts of .csv work I've been doing.
"""Created by Michael Rosata
Python 2.7
Merge together .csv files. I'm creating this because I have 30 .csv files which need to be concatenated.
I also have many files which need to be split, so I've added splitting functionality to this as well.
"""
import csv
import sys
@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',
/**