Skip to content

Instantly share code, notes, and snippets.

View mrilikecoding's full-sized avatar

Nathan G mrilikecoding

View GitHub Profile
var FadeTransitionRegion = Backbone.Marionette.Region.extend({
show: function(view){
this.ensureEl();
view.render();
this.close(function() {
if (this.currentView && this.currentView !== view) { return; }
this.currentView = view;
@mrilikecoding
mrilikecoding / gist:9916292
Created April 1, 2014 15:19
data binding for attribute actions
var actions = {
action1: function() {},
action2: function() {}
//....
};
$('body').on('click', '[data-action]', function() {
var action = $(this).data('action');
if (action in actions) {
actions[action].apply(this, arguments);
@mrilikecoding
mrilikecoding / gist:9520502
Last active March 10, 2019 19:19
RVM Workflow for creating a new Rails Project with Postgres, ready for Heroku
#Make sure heroku toolbelt and rvm are installed
#heroku toolbelt available to download on their site, rvm available via curl
\curl -sSL https://get.rvm.io | bash -s stable --ruby
rvm use "2.1.1"
rvm use --create 2.1.1@project
gem install rails
#if using postgres (good for heroku) pass argument to 'rails new'
rails new project --database=postgresql
@mrilikecoding
mrilikecoding / gist:9124720
Created February 20, 2014 22:35
Smooth scroll to anchor element
$(function() {
$('a[href*=#]:not([href=#])').click(function() {
if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname) {
var target = $(this.hash);
target = target.length ? target : $('[name=' + this.hash.slice(1) +']');
if (target.length) {
$('html,body').animate({
scrollTop: target.offset().top
}, 1000);
return false;
@mrilikecoding
mrilikecoding / jQueryURLParams.js
Created February 6, 2014 20:39
Get URL parameters using jQuery
$.urlParam = function(name){
var results = new RegExp('[\\?&]' + name + '=([^&#]*)').exec(window.location.href);
if (results==null){
return null;
}else{
return results[1] || 0;
}
}
@mrilikecoding
mrilikecoding / icon-fix
Created January 30, 2014 19:43
Sometimes you'll wind up with doubled icons when working on a big bootstrap project. This is a hot fix if you don't have time to track down the real issue.
[class^="icon-"], [class*=" icon-"]{
background:none;
}
@mrilikecoding
mrilikecoding / wp-config
Created January 30, 2014 19:39
Use this wp-config.php along with a wp-local-config.php to allow you to run the wordpress site locally with your own local db configuration. The code checks to see if wp-local-config.php exists. If it does, the site will use that. Otherwise, it will use your normal production configuration. You have to leave wp-local-config.php out of production…
<?php
if ( file_exists( dirname( __FILE__ ) . '/wp-local-config.php' ) ) {
include( dirname( __FILE__ ) . '/wp-local-config.php' );
define( 'WP_LOCAL_DEV', true );
} else {
/**
* The base configurations of the WordPress.
*
* This file has the following configurations: MySQL settings, Table Prefix,
@mrilikecoding
mrilikecoding / fade-text-to-right
Created January 30, 2014 19:34
converts any text into a single line with a fade out on the right side
@mixin text-overflow-fade($background-color: #fff, $text-width: 100%, $fade-size: 30%) {
   width: $text-width;
   overflow: hidden;
   white-space: nowrap;
   position: relative;
   &:after {
       content: '';
       position: absolute;