Skip to content

Instantly share code, notes, and snippets.

View MikeRogers0's full-sized avatar
🚂

Mike Rogers MikeRogers0

🚂
View GitHub Profile
@MikeRogers0
MikeRogers0 / my-php-site.conf
Created July 7, 2014 21:34
My NGINX conf for PHP sites
server {
listen 80;
server_name _;
root /vagrant/www;
index index.html index.htm index.php;
expires -1;
location / {
try_files $uri $uri/ /index.php?q=$uri&$args;
@MikeRogers0
MikeRogers0 / awful_contact_us_controller.rb
Last active August 29, 2015 14:04
An example of a terrible approach to a contact form.
class ContactUsController < ApplicationController
def index
end
def send_enquiry
if contact_form_valid?
ContactUsMailer.send_enquiry(contact_form_params).deliver
return redirect_to action: :thank_you
end
render :index
<html>
<head>
<title>Vogue</title>
<style type="text/css">
#social-logos {
overflow: hidden;
}
#social-logos a{
float: left;
@MikeRogers0
MikeRogers0 / seeds.rb
Created January 27, 2015 13:52
The methods I use with seedbank to easily add new seeds with a nice message.
class Seeds
def self.add model, attrs
object = model.find_or_initialize_by(attrs)
if object.new_record? && object.save
puts "#{object}"
end
end
end
@MikeRogers0
MikeRogers0 / Gemfile
Created March 16, 2015 18:05
Gem rake group example
ruby '2.2.1'
source 'https://rails-assets.org' do
gem 'rails-assets-bootstrap'
end
source 'https://rubygems.org' do
gem 'rails', '4.2'
# Database / Memcache / Solr
@MikeRogers0
MikeRogers0 / application.html.erb
Created May 24, 2015 18:36
Example of how yield works
<%= yeild :some_content %>
@MikeRogers0
MikeRogers0 / gist:1751763
Created February 6, 2012 12:02 — forked from westonruter/gist:311373
jQuery fallback implementation of HTML5 placeholder attribute
if(!jQuery('<input PLACEHOLDER="1" />')[0].placeholder){ //Uppercase attr for IE
jQuery(':input[placeholder]').each(function(){
var $this = $(this);
if(!$this.val()){
$this.val($this.attr('placeholder'));
$this.addClass('input-placeholder');
}
}).live('focus', function(e){
var $this = $(this);
if($this.hasClass('input-placeholder')){
@MikeRogers0
MikeRogers0 / input-validator.php
Created June 10, 2012 22:10
Basic PHP Security
<?php
// Input must be a number
if(is_numeric($input)){
echo 'Input is a number';
} else {
echo 'Input is not a number';
}
// Input can only contain numbers and letters.
if(preg_match('/([^A-z0-9])/', $input)){
@MikeRogers0
MikeRogers0 / conditional-comments.html
Created June 10, 2012 22:51
Conditional Comments
<!–[if IE]>
This will only show for Internet Explorer (IE)
<![endif]–>
<!–[if !IE]>
This will only show if the client is not using IE.
<!–[endif]>
<![if IE 6]–>
Only shows on IE6
<!–[endif]>
<![if lte IE 6]–>
@MikeRogers0
MikeRogers0 / allow-from-ip
Created June 10, 2012 21:57
Blocking users via .htaccess
order allow,deny
allow from [IP here]
deny from all