Skip to content

Instantly share code, notes, and snippets.

View kevinthompson's full-sized avatar
🕹️

Kevin Thompson kevinthompson

🕹️
View GitHub Profile
@kevinthompson
kevinthompson / gist:695d2cea49435994e485
Created January 21, 2015 07:20
Monitor H1Z1 Servers
require 'open-uri'
require 'json'
##
# Add underscore method to string for simple JSON
# key manipulation.
class String
def underscore
self.gsub(/::/, '/').
@kevinthompson
kevinthompson / .htaccess
Created January 27, 2011 03:38
ExpressionEngine Rewrite Rules
<IfModule mod_rewrite.c>
# Enable Rewrite Engine
# ------------------------------
RewriteEngine On
RewriteBase /
# Redirect index.php Requests
# ------------------------------
RewriteCond %{THE_REQUEST} ^GET.*index\.php [NC]
// REQUIRED VARS. Defaults to a 950px wide, 24-column grid that has 30px wide units and 10px wide
// gutters. If you do the fluid grid, then this 950/24/30/10px size will become the maximum size.
$grid_type: fixed !default
$grid_columns: 24 !default
$grid_column_width: 30 !default
$grid_gutter_width: 10 !default
// GENERATED VARS. You can ignore these.
$grid_full_width: $grid_columns * $grid_column_width + $grid_columns * $grid_gutter_width - $grid_gutter_width
$grid_column_width_percent: ($grid_column_width / $grid_full_width * 100) * 1%
@kevinthompson
kevinthompson / index.html
Created July 16, 2011 00:27
Hiding JavaScript-Dependent Content
<!DOCTYPE html>
<html>
<head>
<title>Hiding JavaScript-Dependent Content</title>
<script type="text/javascript">
var html = document.getElementsByTagName('html')[0];
html.className = (html.className != '' ? html.className + ' ' : '') + 'js';
</script>
</head>
@kevinthompson
kevinthompson / clear_input.js
Created August 9, 2011 20:57
Clear Default Text Input Value on Focus
// Clear Default Text Input Value on Focus
$('input[type="text"]').each(function(){
var def = $(this).attr('placeholder') != '' && $(this).attr('placeholder') != undefined ? $(this).attr('placeholder') : $(this).attr('value');
$(this).val(def).attr('placeholder','');
$(this).focus(function(){
if($(this).val() == def){
$(this).removeClass('placeholder').val('');
}
}).blur(function(){
if($(this).val() == ''){
@kevinthompson
kevinthompson / external_links.js
Created August 9, 2011 20:59
Open External Links in New Tabs
@kevinthompson
kevinthompson / gist:2657054
Created May 11, 2012 02:02
Create iPhone Simulator Shortcut
sudo ln -s /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/Applications/iPhone\ Simulator.app /Applications/iOS\ Simulator.app
@kevinthompson
kevinthompson / Rakefile
Created July 20, 2012 05:34
Alternate config definition in RubyMotion Rakefile
# -*- coding: utf-8 -*-
$:.unshift("/Library/RubyMotion/lib")
require 'motion/project'
Motion::Project::App.setup do |app|
# Dependencies
app.files.unshift(*Dir['vendor/teacup/lib/**/*.rb'])
# Config – Use `rake config' to see complete project settings.
config = {
@kevinthompson
kevinthompson / model.js.coffee
Last active October 13, 2015 15:48
Supporting Rails Nested Resources in Batman.js
class App.Model extends Batman.Model
@persist App.Storage
@encodeAttributesFor: ->
@encodeAttributesForKeys ?= []
for key in arguments
if typeof key == 'string'
@encodeAttributesForKeys.splice(index,1) if (index = @encodeAttributesForKeys.indexOf(key)) > 0
@encodeAttributesForKeys.push key
@kevinthompson
kevinthompson / border.sass
Created December 16, 2012 19:25
SASS Border Shorthand Mixin
// Border Shorthand
// -------------------------
=border($border: false, $border_horizontal: false, $border_bottom: false, $border_left: false)
$args: length($border)
// Reset Variables Based on Argument Count
@if $args > 1 and length(nth($border,1)) > 1 or nth($border,1) == none
@if $args == 4
$border_left: nth($border, 4)