Skip to content

Instantly share code, notes, and snippets.

Jefe Johnson jeffjohnson9046

Block or report user

Report or block jeffjohnson9046

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
jeffjohnson9046 / td-hover-test.html
Created May 7, 2014
TD Hover - Different Color for Each Column. Seems to work for all major browsers (IE8+)
View td-hover-test.html
<!DOCTYPE html>
<title>Table Hover CSS Test</title>
th {
font-weight: bold;
font-size: 16px;
text-align: center;
jeffjohnson9046 / devise.rb
Created May 13, 2014
Bypass LDAP Authentication in Rails When Using Devise
View devise.rb
# Add the Warden strategy contained in local_override.rb into the devise.rb file. The devise.rb should also be in the config/intializers directory.
Devise.setup do |config|
config.warden do |manager|
manager.default_strategies(:scope => :user).unshift :local_override
# Other devise configuration...
View jquery_jsonp.js
// This is something I ALWAYS forget about, so hopefully this Gist will serve as a reminder. Whenever you get the "Access-Control-Allow-Origin"
// error, that's because you're trying to make a cross-domain AJAX request, which is a big no-no in the world of the internet.
// So, after spending WAY more time than I care to admit trying to address this, I remembered that JSONP is the answer. Here's
// how to do it:
url: [/* whatever your URL is */],
/*type: 'GET',*/ // seems superfluous - .ajax uses GET by default.
dataType: 'jsonp',
/*crossDomain: true,*/ // seems to work fine without this.
data: { /* an object with whatever data you need to pass along in your JSONP request */ },
jeffjohnson9046 / gist:2c4e35a082bb0abf74db
Last active Aug 29, 2015
C# - sort a list by some arbitrary sort order (i.e. not a "typical" sort order).
View gist:2c4e35a082bb0abf74db
// You can paste this code into IDEone ( and run it. For some reason, I can never remember how to do this.
// Therefore, I've made this Gist. There's probably a million smarter ways to handle this situation, but this one seems to
// work just fine.
using System;
using System.Collections.Generic;
using System.Linq;
public class Test
public static void Main()
jeffjohnson9046 / valid_json.rb
Created Aug 24, 2014
A quick and dirty way to tell if the data received in a response can be parsed as JSON.
View valid_json.rb
def valid_json?(data)
return true
rescue JSON::ParserError
return false
jeffjohnson9046 / persistence.xml
Created Oct 5, 2014
An example of a Spring MVC persistence.xml file.
View persistence.xml
<persistence xmlns=""
<persistence-unit name="punit"></persistence-unit>
jeffjohnson9046 /
Created Nov 7, 2014
Sort a List of Files and Cat Them Together
# The command below will take a list of files in the current directory, sort them and cat them together into a single file.
# The files against which this command was initially used were all named using the following convention:
# V[some number]__[the name of the file].sql
cat `ls -1 *.sql | sort -k1.2n` > /tmp/migration.sql
jeffjohnson9046 / Preferences.sublime-settings
Created Jan 19, 2015
My preferences file for the Sublime Text editor.
View Preferences.sublime-settings
"caret_style": "phase",
"color_scheme": "Packages/Base16 Color Schemes/base16-default.dark.tmTheme",
"fade_fold_buttons": false,
"font_face": "Source Code Pro",
"font_size": 12.0,
"highlight_line": true,
jeffjohnson9046 / log4x-config.xml
Created Mar 13, 2015
Configure Log4net/Log4j/Log4php Loggers for Each Class
View log4x-config.xml
<!-- Configure a Daily File Appender.
-- The datePattern param specifies how the date should appear in the file name.
-- The root element sets the log level for every logger that is configured in this file.
-- To override the log level for an individual logger, add a level element to the desired logger and set it to whatever you want.
-- Each class has its own logger.
-- The name of the logger matches the class exactly.
-- In PHP, this means we can create a logger like this (in a class's constructor, for example):
-- $logger = Logger::getInstance( __CLASS__ );
<configuration xmlns="">
jeffjohnson9046 / gist:57a17a534c7d4829d0b5
Created Mar 24, 2015
Git: Squashing [x] commits into a single commit
View gist:57a17a534c7d4829d0b5
# Came from the second answer on here:
# but writing it out myself helps get it through the metal plate in my head.
# Assumes the following situation:
# You have a feature branch that you're developing against, e.g. feature/diaper-horse.
# You have a remote branch origin/feature/diaper-horse.
# feature/diaper-horse is set up to track origin/feature/diaper-horse
# Let's say you have 8 commits total (of your own) for the branch feature/diaper-horse.
# Reset to x - 1, where x is the number of commits you're ahead of the remote branch. Like so:
You can’t perform that action at this time.