Skip to content

Instantly share code, notes, and snippets.

Avatar

Collin Donahue-Oponski colllin

View GitHub Profile
@colllin
colllin / gist:adf4626cc3e38391e5f7
Last active Aug 29, 2015
Meteor Shell -- collection.deny does not validate server writes
View gist:adf4626cc3e38391e5f7
> 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 Aug 29, 2015
Reactive Leaflet Wrapper for Meteor (Readme-driven development)
View README.md

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()

View backbone.autorun.js
(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;
View hello.js
// lskjdflskhjf
@colllin
colllin / prime.rb
Created Oct 31, 2012
ruby prime number generator
View prime.rb
#!/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 Nov 9, 2012
Google Map Marker Example
View whatever.html
<!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"
View gist:4084171
$(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 Nov 2, 2015
React Component for Filepicker.io pickAndStore dialog
View FilepickerPickAndStoreDialog.js
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 Apr 3, 2013
Exception stack traces from a bad outage around mongo connection failures.
View trace.md

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'
View contact-form.php
<?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;