Skip to content

Instantly share code, notes, and snippets.

View mspanish's full-sized avatar

Stacey Reiman mspanish

View GitHub Profile
@mspanish
mspanish / data.json
Created February 19, 2018 00:37
some json
var data = {
"coinlist": {
"bitcoin_faucets": {
"faucet_name": "btc Faucet",
"minutes": "5",
"amount": "90",
"claim_link": "http://bitcoinsfaucets.com"
},
"eth_faucets": {
"faucet_name": "eth Faucet",
@mspanish
mspanish / gist:7192053
Created October 28, 2013 06:06
Dust.js partial helper, sets new context
"partial": function( chunk, context, bodies, params ){
var partial_context = {};
/* optional : context fo server processed partial related data*/
var p_context = context.get("partial");
if(p_context || params) {
// add to the partial context
}
return bodies.block( chunk, dust.makeBase(partial_context));
}
@mspanish
mspanish / new_gist_file
Created August 28, 2013 21:17
Fetch json and put into collection, Backbone From https://snipt.net/search/?q=backbone
Fetch a collection require an array:
{
'wrapper' : [
{
id:0,
name: 'Little Model 0'
},
{
id:1,
@mspanish
mspanish / new_gist_file
Created August 28, 2013 20:38
Very cool snippet; use jquery to get css value from any selector (wow!) From https://snipt.net/public/tag/javascript/
// © 2012-2013, [ Abstract Codify ] Abstractcodify.com All Rights Reserved. <div class='class' style="right: 10px;"> any more.. </div> a = parseInt($('.class').css('right')); // value "a" echo 10
@mspanish
mspanish / new_gist_file
Created August 21, 2013 01:34
From http://www.actualtech.com/mysql_ssh.php SSH Tunnel for MySQL on OS X
ssh -C -N user_name@www.myhost.com -L 3307:127.0.0.1:3306
@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()
};
jQuery(function() {
// Create our namespace and related organizers
window.DartsLeague = {};
DartsLeague.Models = {};
DartsLeague.Collections = {};
DartsLeague.Views = {};
DartsLeague.TourneysApp = new Backbone.Marionette.Application({});
/********************************************
@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!
@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">').
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'))
});
}