Skip to content

Instantly share code, notes, and snippets.


Marc Gayle marcamillion

View GitHub Profile
View another-html.html
<pre class="highlight ruby">
<p>def convert_relation(invited_gender, relation)<br>
case invited_gender<br>
when &quot;male&quot;<br>
case relation<br>
when &quot;daughter&quot;, &quot;son&quot; then &quot;dad&quot;<br>
when &quot;mom&quot;, &quot;dad&quot; then &quot;son&quot;<br>
when &quot;grandfather&quot;, &quot;grandmother&quot; then &quot;grandson&quot;<br>
when &quot;sister&quot;, &quot;brother&quot; then &quot;brother&quot;<br>
when &quot;wife&quot; then &quot;husband&quot;<br>
marcamillion / finding-deleted-associated-records-by-inverse-using-where-not.rb
Last active Dec 23, 2015
Easily Find Polymorphically Associated Records whose destroy callbacks were not called
View finding-deleted-associated-records-by-inverse-using-where-not.rb
# The main issue here is, if you do a bunch of delete calls on a model that has associations there will be some other records that
# still exist and point to legit looking values that don't work, because even though the foreign_key exists in the table,
# the record it is pointing to does not.
# For e.g. A User and an Event
# == Schema Information
# Table name: users
View create_videos.rb
class CreateVideos < ActiveRecord::Migration
def change
create_table :videos do |t|
t.string :video
t.text :meta_info
marcamillion / index.css
Created Sep 17, 2014
Word & Character Counter in JS - as originally seen:
View index.css
#border {
border: 1px solid red;
height: 200px;
width: 100%;
textarea {
height: 100%;
width: 100%;
border: 0px;
View gh-error.txt
The page build failed with the following error:
The submodule `octopress` was not properly initialized with a `.gitmodules` file.
For information on troubleshooting Jekyll see:
View ruby_warrior_level_4.rb
class Player
def play_turn(warrior)
if warrior.feel.empty? && !taking_damage?(warrior) && < 20!
elsif warrior.feel.empty?
@health =
View ruby_warrior_lvl_5.rb
class Player
def play_turn(warrior)
if @health.nil?
@health =
if warrior.feel.empty? && !taking_damage?(warrior) && < 20!
elsif warrior.feel.captive?
View Contract Killer

Contract Killer 3

Revised date: 07/11/2012

Between us [company name] and you [customer name]


We’ll always do our best to fulfil your needs and meet your expectations, but it’s important to have things written down so that we both know what’s what, who should do what and when, and what will happen if something goes wrong. In this contract you won’t find any complicated legal terms or long passages of unreadable text. We’ve no desire to trick you into signing something that you might later regret. What we do want is what’s best for both parties, now and in the future.

marcamillion / posterous_import.rb
Last active Dec 16, 2015 — forked from nitrogenlogic/
Added support for posts that were archived by Posterous - i.e. moved the images into subfolders belonging to dates & times that don't correspond (obviously) to the publish date of the post itself.
View posterous_import.rb
#!/usr/bin/env ruby
# This quick and dirty script imports posts and images exported by the
# Posterous backup feature into Octopress. Requires the escape_utils and
# nokogiri gems. Doesn't import comments.
# Videos and images are copied into a post-specific image directory used
# by my customized Octopress setup. Encoded videos are downloaded from
# Posterous. Images will probably need to be compressed/optimized afterward.
# Links to other posts in the same import will try to be converted. You will