Skip to content

Instantly share code, notes, and snippets.

View dillonhafer's full-sized avatar
🍄
Nintendo Power

Dillon Hafer dillonhafer

🍄
Nintendo Power
View GitHub Profile
@dillonhafer
dillonhafer / block_comments_by_email.php
Created August 18, 2013 03:03
This simple script should be inserted into line 54 of wp-comments-post.php to block comments based on email addresses.
// Goes after this section below
$comment_author = ( isset($_POST['author']) ) ? trim(strip_tags($_POST['author'])) : null;
$comment_author_email = ( isset($_POST['email']) ) ? trim($_POST['email']) : null;
$comment_author_url = ( isset($_POST['url']) ) ? trim($_POST['url']) : null;
$comment_content = ( isset($_POST['comment']) ) ? trim($_POST['comment']) : null;
// WordPress Block Commenters by email
$black_list = array(
"guert84****@gmail.com",
"test@dillonhafer.com"
@dillonhafer
dillonhafer / xss.aspx
Created August 27, 2013 20:25
XSS protection in ASP.net
<!-- ASP.NET 3.5 and below -->
<%= Html.Encode(yourStuff) %>
<!-- ASP.NET 4 -->
<%: yourStuff %>
@dillonhafer
dillonhafer / subdomain_helper.rb
Created August 27, 2013 20:28
Simple subdomain testing with Capybara
# Support for Rspec / Capybara subdomain integration testing
# Make sure this file is required by spec_helper.rb
#
# Sample subdomain test:
# it "should test subdomain" do
# switch_to_subdomain("mysubdomain")
# visit root_path
# end
DEFAULT_HOST = "lvh.me"
@dillonhafer
dillonhafer / import-cert.sh
Created November 6, 2013 18:28
Ubuntu - Import Self-signed certs.
#!/bin/bash
#
# usage: import-cert.sh remote.host.name [port]
#
# Thanks to Peter van der Does (http://blog.avirtualhome.com/adding-ssl-certificates-to-google-chrome-linux-ubuntu/)
#
REMHOST=$1
REMPORT=${2:-443}
exec 6>&1
exec > $REMHOST
@dillonhafer
dillonhafer / list-users.sh
Created November 22, 2013 15:38
List all users in OSX
dscacheutil -q user | grep -A 3 -B 2 -e uid:\ 5'[0-9][0-9]'
@dillonhafer
dillonhafer / gist:8562746
Created January 22, 2014 17:09
Fix MS issues
Manage virtual directories.
You can remove the old project, or change its port using WebMatrix, which has an administration interface for IIS Express.
You can also do it by hand, by modifying the applicationhost.config file directly. The file is located in the %userprofile%\documents\IISexpress\config folder. You can find the project configuration under the <system.applicationHost>/<sites> element.
@dillonhafer
dillonhafer / Rakefile
Created March 18, 2014 21:32
A simple install script for zipping WordPress Plugins
task :default do
puts "\033[01;32m---->\033[00m\ Zipping \033[01;33m#{Dir.pwd}\033[00m\ into \033[01;33m#{Dir.pwd}.zip\033[00m\ "
%x{mkdir -p install}
%x{zip -r install/#{File.basename(Dir.getwd)}.zip . --exclude=*.git* --exclude=*install*}
puts " Done. 📦"
end
@dillonhafer
dillonhafer / read-more.js
Created June 6, 2014 15:18
Darling Duffy
document.addEventListener('DOMContentLoaded', function(){
function fadeIn(el) {
el.style.opacity = 0;
var last = +new Date();
var tick = function() {
el.style.opacity = +el.style.opacity + (new Date() - last) / 400;
last = +new Date();
if (+el.style.opacity < 1) {
@dillonhafer
dillonhafer / database.yml
Created June 17, 2014 14:14
Database with ENV vars
defaults: &defaults
adapter: postgresql
pool: 5
timeout: 5000
host: localhost
database: <%= ENV['RAILS_DATABASE'] %>
user: <%= ENV['RAILS_DATABASE_USER'] %>
password: <%= ENV['RAILS_DATABASE_PASSWD'] %>
development:
var Retina = Retina || {};
Retina = {
init: function() {
var images = document.querySelectorAll("img[data-1x]");
var attr = Retina.isRetina() ? "data-2x" : "data-1x";
Array.prototype.forEach.call(images, function(el, i) {
var src = el.getAttribute(attr);
el.setAttribute("src", src);