Skip to content

Instantly share code, notes, and snippets.

View nicinabox's full-sized avatar

Nic Haynes nicinabox

View GitHub Profile
<table width="600" align="center" cellpadding="10" style="table-layout: fixed;">
<tr>
<td>
<table align="left" cellspacing="0" cellpadding="0" border="0" style="table-layout: fixed;">
<tr>
<td width="144" class="sidebar" style="padding-left: 10px;">
<h2 style="color: #ffffff; font-size: 14px;">In This Issue:</h2>
<ul id="contents" style="line-height: 15px; list-style-type: none; margin: 0; padding: 10px 0 0;">
<tableofcontents>
<li style="margin-bottom: 10px; padding-bottom: 10px; border-bottom-width: 1px; border-bottom-color: #77929f; border-bottom-style: solid; color: #ffffff">
<% [:en, :ru, :de].each do |locale| %>
<li>
<%= link_to Refinery::I18n.built_in_locales[locale], {:locale => locale}, :class => "flag #{locale.to_s}", :id => "locale_#{locale.to_s}" %>
</li>
<% end %>
@nicinabox
nicinabox / controller.rb
Created March 6, 2012 17:53
Setting i18n translations in Refinery
# In a controller
# This is not necessary when using the view code below
::I18n.locale = params[:locale]
<h4>July<br /><span>21</span></h4>
<time>July 21, 7-9pm</time>
<h2>New Voices/new Vistas Muntu’s Summer Concert And Gala</h2>
<h3>Harris Theatre For Music And Dance Millennium Park</h3>
<p>At 40, Muntu continues to explore the future of African &amp; African American dance. This concert will feature groundbreaking new work by choreographer Jeffery Page who has worked with Beyonce and was a lead dancer in the Broadway production ‘Fela.’</p>
<p>Gala dinner and reception following the performance on the Rooftop Terrace.</p>
<a class="button" href="#">Buy Tickets</a>
@nicinabox
nicinabox / 1_README.md
Created March 21, 2012 19:46
Schedule nightly backups to Amazon S3 with Ruby and Whenever

Install gems

gem install whenever mysql2 pony ruby-s3cmd

Configure S3 & schedule.rb

Go ahead and create your backup bucket on S3 now. Configure whenvever to do your backups at a time when server load will be low (I picked 2:00 am).

Update mysql_backup.rb configuration

<%= @blog_posts.each do |post| %>
<%= post.published_at.strtime('%B %d, %Y') %>
<%= post.title %>
<% end %>
@nicinabox
nicinabox / application_helper.rb
Created April 10, 2012 00:14
Plot elements on a circle with Ruby
def angle_to_radians(angle)
Math::PI * (angle * -1.0 / 180)
end
def radians_to_cartesian(radian, radius, offset_x, offset_y)
{
:x => (offset_x + (radius * Math::sin(radian))).round,
:y => (offset_y + (radius * Math::cos(radian))).round
}
end
@nicinabox
nicinabox / 1_migration.md
Created April 23, 2012 16:14
Add a key image to Refinery

Create migrations

rails g migration add_key_image_to_refinery_page key_image_id:integer

rake db:migrate

Override Page model

rake refinery:override model=refinery/page

@nicinabox
nicinabox / style.scss
Last active October 3, 2015 15:58
Center UL
ul {
position: relative;
float: left;
left: 50%;
li {
position: relative;
float: left;
left: -50%;
}
}
@nicinabox
nicinabox / env.sh
Created May 1, 2012 18:27
Pack Chrome extensions from the command line
# $ crx `pwd`
function crx() {
~/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --pack-extension=$@ --pack-extension-key=$@/key.pem
}