Skip to content

Instantly share code, notes, and snippets.

View colllin's full-sized avatar

Collin Kindrom colllin

View GitHub Profile
/*!
* jQuery Form Plugin
* version: 2.52 (07-DEC-2010)
* @requires jQuery v1.3.2 or later
*
* Examples and documentation at: http://malsup.com/jquery/form/
* Dual licensed under the MIT and GPL licenses:
* http://www.opensource.org/licenses/mit-license.php
* http://www.gnu.org/licenses/gpl.html
*/
@colllin
colllin / events_controller.rb
Last active December 24, 2015 12:29
Rails - basic filtering & sorting
class EventsController < ApplicationController
def index
# start with default filtering (usually no filtering)
@events = Event.all
# custom (user-chosen) filtering
if params[:filters].present?
# you can check for all the different filter values you want to allow. first is future/current/past
@colllin
colllin / gist:8321227
Created January 8, 2014 17:56
Meteor.js Custom Publish Function example
Meteor.publish('user-stats', function() {
var initializing = true;
var userStats = [];
var aYearAgo = moment().utc().subtract({years: 1});
var aQuarterAgo = moment().utc().subtract({months: 3});
var aMonthAgo = moment().utc().subtract({months: 1});
var defaultAggregation = {
wins: 0,
@colllin
colllin / _affixWithinContainer.md
Last active November 29, 2020 17:13
ion-list sticky headers

What this does:

Within an <ion-scroll>, this directive creates sticky item headers that get bumped out of the way by the next item.

Demo: http://cl.ly/2u2X390s0H1a

Requirements:

  • Needs UnderscoreJS for its _.throttle utility.
  • Must be used within an or
@colllin
colllin / gist:adf4626cc3e38391e5f7
Last active August 29, 2015 14:12
Meteor Shell -- collection.deny does not validate server writes
> Polygons.deny({update: function() { return true; }});
> p=Polygons.findOne();
{ _id: '74iGubCqxB29ZF2tJ',
geom:
{ type: 'Polygon',
coordinates: [ [Object] ],
type2: 'Polygonal' },
tags: {} }
> Polygons.update({_id: p._id}, {$set: {'geom.type2': 'Polygonify'}})
1
(function() {
Backbone.Events.autorun = function(f, context) {
if (!this.__autorunHandles) this.__autorunHandles = [];
var backboneContext = this;
var handle = Tracker.autorun(function() {
Tracker.currentComputation.__backboneContext = backboneContext;
f();
});
this.__autorunHandles.push(handle);
return handle;
@colllin
colllin / README.md
Last active August 29, 2015 14:22
Reactive Leaflet Wrapper for Meteor (Readme-driven development)

This Meteor package wraps Leaflet in a reactive API.

The following methods have been added to the L.Map class:

isDragging()

returns true or false and is reactive.

getCenterState()

@colllin
colllin / FilepickerPickAndStoreDialog.js
Created November 2, 2015 17:28
React Component for Filepicker.io pickAndStore dialog
import React from 'react';
import $ from 'jquery';
// Accepts these props:
// `apiKey` - Your Filepicker.io API key.
// `onSuccess` - A callback that receives (blobs) upon pickAndStore success.
// `onError` - A callback that receives (error) upon pickAndStore error. Note that a user-initiated cancel triggers an error with {code: 101}.
// `onCancel` - A callback that is triggered when the user closes/cancels the dialog. If `onCancel` is passed, it will be called instead of onError in the event of a user-initiated cancel.
// `onProgress` - A callback that receives (progress) upon pickAndStore progress.
class FilepickerPickAndStoreDialog extends React.Component {
@colllin
colllin / gist:22bc2bb79a842116e18c73b0e6a2368f
Created August 3, 2016 18:36
Auth0 `Login` database action script NO-OP
function login (email, password, callback) {
// This script should authenticate a user against the credentials stored in
// your database.
// It is executed when a user attempts to log in or immediately after signing
// up (as a verification that the user was successfully signed up).
// The `password` parameter of this function is in plain text. It must be
// hashed/salted to match whatever is stored in your database. For example:
// if (bcrypt.compareSync(password, dbPasswordHash)) { ... }
//
// There are three ways this script can finish:
@colllin
colllin / gist:12d77e03b6b6f717d5d1fe15b75bf2d4
Created August 3, 2016 18:36
Auth0 `Get User` database action script NO-OP
function getByEmail (email, callback) {
// This script should retrieve a user profile from your existing database,
// without authenticating the user.
// It is used to check if a user exists before executing flows that do not
// require authentication (signup and password reset).
//
// There are three ways this script can finish:
// 1. A user was successfully found. The profile should be in the following
// format: https://auth0.com/docs/user-profile
// callback(null, profile);