Skip to content

Instantly share code, notes, and snippets.

View bergonom's full-sized avatar

Joel Berghoff bergonom

View GitHub Profile
@bergonom
bergonom / example.php
Created August 4, 2011 10:22
A simple Postmark PHP Class
<?php
require("postmark.php");
$postmark = new Postmark("your-api-key","from-email","optional-reply-to-address");
if($postmark->to("[email protected]")->cc('[email protected]')->bcc('[email protected]')->subject("Email Subject")->plain_message("This is a plain text message.")->send()){
echo "Message sent";
}
@bergonom
bergonom / custom_inputs.css
Created January 24, 2013 20:47
Update to CSS for creating custom checkboxes and radio buttons. This CSS will allow the input elements to show that they have focus when the user accesses tabs through form elements. See the original article here: http://www.inserthtml.com/2012/06/custom-form-radio-checkbox
/* Hide the checkbox offscreen */
.regular-checkbox {
display: inline;
left: -8000px;
position: fixed;
}
/* Highlight the custom checkbox's border when the checkbox has focus. */
.regular-checkbox:focus + label {
border: 1px solid #000;
@bergonom
bergonom / truncate_table.rb
Created March 15, 2013 22:43
Truncate a single table across multiple db types. I made this a private method in my application controller (app/controllers/application_controller.rb). Adapted from: https://gist.github.com/tvdeyen/3246525
def truncate_table table_name
config = Rails.configuration.database_configuration
connection = ActiveRecord::Base.connection
connection.disable_referential_integrity do
next if connection.select_value("SELECT count(*) FROM #{table_name}") == 0
case config[Rails.env]["adapter"]
when "mysql", "mysql2", "postgresql"
connection.execute("TRUNCATE #{table_name}")
when "sqlite", "sqlite3"
connection.execute("DELETE FROM #{table_name}")