Skip to content

Instantly share code, notes, and snippets.

View mspanish's full-sized avatar

Stacey Reiman mspanish

View GitHub Profile
@mspanish
mspanish / index.html
Created February 6, 2013 21:29
A CodePen by Stacey Reiman.
<div id="buttonbar"><img id="memoryToggle" onClick="memoryMode()" class="buttonBar" src="http://www.instaspanish.com/dev/memory.svg" height="75px" width="150px" /><img id="matchToggle" class="buttonBar" onClick="matchMode()" src="http://www.instaspanish.com/dev/match.svg" height="75px" width="150px" /></div>
@mspanish
mspanish / singly-mongoose.js
Last active December 15, 2015 23:39
Singly Passport Express Authentication with Mongoose/Mongodb Integration - this is my new passport.js file, along with my User model for Mongoose, and the 2 routes I use with this system.
// db.js (just the User model)
var UserSchema = new Schema({
// _id: String,
username: String,
name: String,
gravatar: String,
email: String,
provider: String,
services: String,
/**
* User: rupin_t
* Date: 6/27/13
* Time: 5:42 PM
*/
/**
* Custom the template loading.
* Each template is downloaded from the server and the cached.
* @param templateId
// Changes XML to JSON
function xmlToJson(xml) {
// Create the return object
var obj = {};
if (xml.nodeType == 1) { // element
// do attributes
if (xml.attributes.length > 0) {
obj["@attributes"] = {};
$.ajax({ url: "info.md", context: document.body, success: function(mdText){ //where text will be the text returned by the ajax call var converter = new Showdown.converter(); var htmlText = converter.makeHtml(mdText); $(".outputDiv").append(htmlText); //append this to a div with class outputDiv } });
var AmericasNextTopModel = Backbone.Models.extend({
initialize: function(){
this.set({
clefs: new ClefCollection(this.get('clefs')),
accidentals: new AccidentalCollection(this.get('accidentals')),
notes: new NoteCollection(this.get('notes')),
rests: new RestCollection(this.get('rests'))
});
}
@mspanish
mspanish / new_gist_file
Created August 16, 2013 21:37
From http://stackoverflow.com/questions/15675352/regex-convert-xml-to-json Working XML to JSON regex function in javascript
var regex = /(<\w+[^<]*?)\s+([\w-]+)="([^"]+)">/;
while(xml.match(regex)) xml = xml.replace(regex, '<$2>$3</$2>$1>'); // For attributes
xml = xml.replace(/\s/g, ' '). // Finds all the white space converts to single space
replace(/< *\?[^>]*?\? *>/g, ''). //Finds the XML header and removes it
replace(/< *!--[^>]*?-- *>/g, ''). //Finds and removes all comments
replace(/< *(\/?) *(\w[\w-]+\b):(\w[\w-]+\b)/g, '<$1$2_$3').
replace(/< *(\w[\w-]+\b)([^>]*?)\/ *>/g, '< $1$2>').
replace(/(\w[\w-]+\b):(\w[\w-]+\b) *= *"([^>]*?)"/g, '$1_$2="$3"').
replace(/< *(\w[\w-]+\b)((?: *\w[\w-]+ *= *" *[^"]*?")+ *)>( *[^< ]*?\b.*?)< *\/ *\1 *>/g, '< $1$2 value="$3">').
@mspanish
mspanish / index.html
Created August 18, 2013 01:32
A CodePen by Stacey Reiman. FORK of flip card, this was not my own creation. Here are the author's comments (url at bottom): Flip Card - My goal was to create re-useable card-like elements that flip on hover (or tap!) I've built markup for a flippable card that you can use to hold any content you want on the front or the back of the card. Simply…
<!--
Wrote a blog post about how it all works:
http://andymcfee.com/2012/08/24/css3-flip-cards/
-->
<div class="viewport">
<div class="flip-card">
<div class="card-front">
Front!
jQuery(function() {
// Create our namespace and related organizers
window.DartsLeague = {};
DartsLeague.Models = {};
DartsLeague.Collections = {};
DartsLeague.Views = {};
DartsLeague.TourneysApp = new Backbone.Marionette.Application({});
/********************************************
@mspanish
mspanish / new_gist_file
Created August 20, 2013 16:59
Loading multiple models from Ajax into Backbone collections - from StackOverflow http://stackoverflow.com/questions/9781102/backbone-multiple-collections-fetch-from-a-single-big-json-file
/*
Backbone is great for when your application fits the mold it provides. But don't be afraid to go around it when it makes sense for your application. It's a very small library. Making repetitive and duplicate GET requests just to fit backbone's mold is probably prohibitively inefficient. Check out jQuery.getJSON or your favorite basic AJAX library, paired with some basic metaprogramming as following:
*/
//Put your real collection constructors here. Just examples.
var collections = {
Languages: Backbone.Collection.extend(),
ProductTypes: Backbone.Collection.extend(),
Menus: Backbone.Collection.extend()
};