Skip to content

Instantly share code, notes, and snippets.

View mildfuzz's full-sized avatar

John Farrow mildfuzz

View GitHub Profile
@mildfuzz
mildfuzz / charts.js
Created April 30, 2013 11:18
JS Class for working with google charts
var Chart = function(){
var self = this;
self.setData = function(data){
self.data = google.visualization.arrayToDataTable(data);
};
self.bar = function(){
self.activeChart = new google.visualization.BarChart(self.el);
self.activeChart.draw(self.data, self.options);
};
self.column = function(){
@mildfuzz
mildfuzz / _mixins.scss
Created December 12, 2012 16:53
Mild Fuzz Mixins
@mixin lighter_link($color, $change:20%){
color: $color;
&:hover{
color: lighten($color, $change);
}
}
@mixin darker_link($color, $change:20%){
color: $color;
&:hover{
color: darken($color, $change);
@mildfuzz
mildfuzz / rails_remote_bindings.js
Created December 5, 2012 17:23
Simple AJAX bindings for Rails remote forms reference
$(document)
.on('ajax:loading', function() {alert("loading!"); console.log(['loading',arguments])})
.on('ajax:success', function(data, status, xhr) {alert("success!"); console.log(['success',arguments])})
.on('ajax:failure', function(xhr, status, error) {alert("failure!"); console.log(['failure',arguments])})
.on('ajax:complete', function() {alert("complete!"); console.log(['complete',arguments])});
@mildfuzz
mildfuzz / scopes.rb
Created November 30, 2012 09:56
Example Rails 3 Scopes for reference
scope :scope, where("column=value")
scope :scope_with_input, lambda { |value| where("column =?", value)}
scope :cope_with_join_and_input, lambda { |value| joins(:other_table).where("other_table.other_table_column =?", value)}
@mildfuzz
mildfuzz / admin-users.rb
Created November 21, 2012 09:15
User Admin
ActiveAdmin.register User do
filter :first_name
filter :last_name
filter :company_name
filter :email
form do |f|
f.inputs "Contact" do
f.input :first_name
@mildfuzz
mildfuzz / paperclip_help.rb
Created November 15, 2012 11:00
Paperclip File Size Help
has_attached_file :photo,
:styles => {
:tiny => "100x100", # fixed width and height
:thumb => "100>x100", # resize to a fixed width if original height if greather than specified
# dimension and fixed height
:small => "200x200>", # fixed width and resize to a fixed height if original height i greather than
# specified dimension
:medium => "200 "200x200<" # fixed width and resize to a fixed heigth if original height i less
# than specified dimension
}
@mildfuzz
mildfuzz / helperjs.scss
Created November 12, 2012 11:56
Mild Fuzz JS Helpers
//Requires Compass
.cover_slide{
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: rgba(0, 0, 0, 0.5);
z-index: 9999;
@mildfuzz
mildfuzz / mfBehaviours.js
Last active October 12, 2015 14:07
Behaviour Manager
/* Store for localised behaviours
*
* Requires jquery and Mild Fuzz's plugins.js (http://goo.gl/MVcH2)
* @mildfuzz
*
* Usage
*
* Create behaviour within case:
* case "BehaviourString":
* //some function
@mildfuzz
mildfuzz / plugins.js
Last active October 12, 2015 13:58
Mild Fuzz Plugins
/*
JS Extentions by Mild Fuzz
*/
(function(){
//Adds sum functionality to the Array object
Array.prototype.sum = function(){
String.prototype.recursiveReplace = function(a,b){
var newString = this;
while(newString.match(a) !== null){newString = newString.replace(a,b);}
return newString;
};