Skip to content

Instantly share code, notes, and snippets.

View carmichaelize's full-sized avatar

Scott Carmichael carmichaelize

View GitHub Profile
@carmichaelize
carmichaelize / angularfire-boot.js
Last active August 29, 2015 14:19
Boot Angular app after Firebase auth.
angular
.module('myApp')
.run(function(){
//The app is initialised.
});
//Get Firebase auth
var ref = new Firebase('https://<!--FIREBASEURL-->.com'),
auth = ref.getAuth();
@carmichaelize
carmichaelize / params-bind.js
Created April 16, 2015 15:42
Bind array values as function params.
if (_button){
_button.action = callback;
//Bind params
if(params) _button.action = _button.action.bind.apply(_button.action, [null].concat(params));
}
@carmichaelize
carmichaelize / scroll-load
Last active August 29, 2015 14:19
Know when you reached the bottom of the window
var scroll = function(){
if ($(window).scrollTop() + $(window).height() > $(document).height() - 50) {
//Do something
}
}
//Add/remove function from $(window)
$(window).on('scroll', scroll);
$(window).off('scroll', scroll);
@carmichaelize
carmichaelize / horizon.css
Last active August 29, 2015 14:19
Vertical Centering
.vdiv
{
display:table;
position:absolute;
width: 100%;
height:100%;
}
.vdiv > div
{
@carmichaelize
carmichaelize / gruntfile.js
Created February 28, 2015 09:40
Grunt Boilerplate
//$ npm install -g grunt-cli
//
//$ npm install grunt-contrib-concat --save-dev
//$ npm install grunt-contrib-uglify --save-dev
//$ npm install grunt-contrib-cssmin --save-dev
module.exports = function(grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
@carmichaelize
carmichaelize / gulpfile.js
Last active August 29, 2015 14:15
Gulp Boilerplate
//$ npm install --global gulp
//
//$ npm install
//$ npm install --save-dev gulp
//$ npm install --save-dev gulp-concat
//$ npm install --save-dev gulp-uglify
//$ npm install --save-dev gulp-cssmin
//$ npm install --save-dev gulp-ng-annotate
var gulp = require('gulp'),
@carmichaelize
carmichaelize / scroll-button.js
Last active August 29, 2015 14:07
jQuery Scroll Button
//Scroll Button
function windowScroll(event){
$('html, body').animate({scrollTop: event.data}, 1000);
return false;
}
//Scroll top top
$('#too-top').on('click', 0, windowScroll);
//Scroll to footer
@carmichaelize
carmichaelize / base64_encode_decode.js
Last active August 29, 2015 14:07
JavaScript Base64 Encode/Decode
//Encode
function encodeBase64( string ){
try{
if( typeof string == 'object'){
throw 'error';
}
return window.btoa(unescape(encodeURIComponent( string )));
} catch(e){
return false;
@carmichaelize
carmichaelize / wp_pagination.php
Last active August 29, 2015 14:04
Wordpress Query Pagination Function
<?php
function sc_pagination( $query ){
$string = "";
if( !$query ){
global $wp_query;
@carmichaelize
carmichaelize / map_ui.js
Created July 10, 2014 14:26
Google Maps API Framework
var ui = {
buildMarkers: function( data, first ){
var results = [];
$.each( data, function(i, marker){
var html = ui.buildHTML( marker.title, marker.address, marker.telephone );