Skip to content

Instantly share code, notes, and snippets.

View colllin's full-sized avatar

Collin Kindrom colllin

View GitHub Profile
@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
@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()

(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 / hello.js
Created May 26, 2011 00:42
public gist
// lskjdflskhjf
@colllin
colllin / prime.rb
Created October 31, 2012 20:45
ruby prime number generator
#!/bin/ruby
def calculatePrime
list = (2..7050000).to_a
print "2 "
list = list.select(&:odd?)
list.each_with_index.each do |n, i|
next if n == nil
print "#{n} "
while i < list.count do
@colllin
colllin / whatever.html
Created November 9, 2012 05:29
Google Map Marker Example
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
<style type="text/css">
html { height: 100% }
body { height: 100%; margin: 0; padding: 0 }
#map_canvas { height: 100% }
</style>
<script type="text/javascript"
@colllin
colllin / gist:4084171
Created November 16, 2012 04:48
Temp
$(document).scroll(function() {
var currentScrollTop = $(this).scrollTop();
if (currentScrollTop > prevScrollTop) {
//down
var lasthiddenbox = $('.fadeboxhidden:last');
var nextbox = (lasthiddenbox.length > 0) ? lasthiddenbox.next('.fadebox') : $('.fadebox:first');
while (nextbox.length) {
if (nextbox.offset().top < currentScrollTop) {
nextbox.css('opacity', (currentScrollTop - nextbox.offset().top) / nextbox.outerHeight());
}
@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 / trace.md
Created April 3, 2013 23:22
Exception stack traces from a bad outage around mongo connection failures.

At the beginning

PostsController# (Timeout::Error) "execution expired"

/app/vendor/bundle/ruby/1.9.1/gems/moped-1.3.2/lib/moped/sockets/connectable.rb:45:in `read'
/app/vendor/bundle/ruby/1.9.1/gems/moped-1.3.2/lib/moped/sockets/connectable.rb:45:in `block in read'
/app/vendor/bundle/ruby/1.9.1/gems/moped-1.3.2/lib/moped/sockets/connectable.rb:78:in `handle_socket_errors'
/app/vendor/bundle/ruby/1.9.1/gems/moped-1.3.2/lib/moped/sockets/connectable.rb:45:in `read'
/app/vendor/bundle/ruby/1.9.1/gems/moped-1.3.2/lib/moped/connection.rb:177:in `read_data'
/app/vendor/bundle/ruby/1.9.1/gems/moped-1.3.2/lib/moped/connection.rb:99:in `block in read'
<?php
// only run this code if they submitted the form (we can check if the submit button was pressed)
if (isset($_POST['contact-submit'])) {
$email = isset($_POST['email']) ? trim($_POST['email']) : '';
$name = isset($_POST['name']) ? trim($_POST['name']) : '';
$message = isset($_POST['message']) ? trim($_POST['message']) : '';
success = true;