Skip to content

Instantly share code, notes, and snippets.

View chadjemmett's full-sized avatar

Chad Jemmett chadjemmett

View GitHub Profile
@chadjemmett
chadjemmett / true false to yes no in views.
Created April 13, 2013 15:01
A method for rails where you can take a boolean and convert the true false to yes no.
def complete_yes_no
self.complete ? "Yes" : "No"
end
@chadjemmett
chadjemmett / vimrc
Created April 24, 2013 18:54
My simple vim settings.
" Configuration file for vim
set modelines=0 " CVE-2007-2438
" Normally we use vim-extensions. If you want true vi-compatibility
" remove change the following statements
set nocompatible " Use Vim defaults instead of 100% vi compatibility
set backspace=2 " more powerful backspacing
set ai " auto indenting
set smartindent " smart indents after something?
require 'unirest'
font_formats = ["otf", "ttf", "svg", "woff"]
font_formats.each do
|format, response|
response = Unirest::post("https://ofc.p.mashape.com/convert/",
{"X-Mashape-Authorization" => "***********************" },
{:file => File.new("Arial.ttf", "rb"),
:format => "#{format}", :callback => "http://aqueous-taiga-8219.herokuapp.com/target"}
)
@chadjemmett
chadjemmett / gist:5588849
Created May 16, 2013 01:52
errors from fontvert
Started POST "/target" for 90.229.215.223 at 2013-05-15 19:48:26 -0600
Processing by CheckInputsController#target as */*
Parameters: {"file"=>#<ActionDispatch::Http::UploadedFile:0x007f9ca98975e0 @original_filename="Skia-Regular.ttf", @content_type="application/octet-stream", @headers="Content-Disposition: form-data; name=\"file\"; filename=\"Skia-Regular.ttf\"\r\nContent-Type: application/octet-stream\r\n", @tempfile=#<File:/var/folders/g0/m3jlqvpd4cbc3khznvn5c_7m0000gn/T/RackMultipart20130515-5063-1uybosa>>, "originalFileName"=>"Skia.ttf"}
WARNING: Can't verify CSRF token authenticity
Completed 500 Internal Server Error in 1ms
TypeError (can't convert ActionDispatch::Http::UploadedFile into String):
app/controllers/check_inputs_controller.rb:18:in `initialize'
app/controllers/check_inputs_controller.rb:18:in `new'
app/controllers/check_inputs_controller.rb:18:in `target'
@chadjemmett
chadjemmett / gist:5588991
Created May 16, 2013 02:28
fontvert pathname contains null byte error
Started POST "/target" for 90.229.215.223 at 2013-05-15 20:27:45 -0600
Processing by CheckInputsController#target as */*
Parameters: {"file"=>#<ActionDispatch::Http::UploadedFile:0x007f9cab4c37a0 @original_filename="Skia-Regular.woff", @content_type="application/octet-stream", @headers="Content-Disposition: form-data; name=\"file\"; filename=\"Skia-Regular.woff\"\r\nContent-Type: application/octet-stream\r\n", @tempfile=#<File:/var/folders/g0/m3jlqvpd4cbc3khznvn5c_7m0000gn/T/RackMultipart20130515-5063-1k02gby>>, "originalFileName"=>"Skia.ttf"}
WARNING: Can't verify CSRF token authenticity
Completed 500 Internal Server Error in 1ms
ArgumentError (pathname contains null byte):
app/controllers/check_inputs_controller.rb:18:in `initialize'
app/controllers/check_inputs_controller.rb:18:in `new'
app/controllers/check_inputs_controller.rb:18:in `target'
@chadjemmett
chadjemmett / string_puzzle.rb
Created September 18, 2013 00:08
A string generator for a programming challenge.
array = []
random_number = rand(5) + 5
string = ""
walls_and_halls = ["W", "."]
(random_number * random_number + 1).times { string << walls_and_halls.sample }
string = string.chop!
@chadjemmett
chadjemmett / _error_messages.html.erb
Created October 20, 2013 01:35
Shared error messages for ruby on rails. Replace @user with relevant variable. Also change the css classes and such to match the app you use it on.
<% if @user.errors.any? %>
<div id="error_explanation" >
<div class="alert alert-error">
The form contains <%= pluralize(@user.errors.count, "error") %>.
</div>
<ul>
<% @user.errors.full_messages.each do |msg| %>
<li>* <%= msg %></li></br>
<% end %>
</ul>
@chadjemmett
chadjemmett / csv_to_db.rb
Created October 26, 2013 19:19
So this will get csv data into a rails database. I just did it from the console. But you could make it a rake task. the headers in the csv file have to match the model attributes attr_accessor variables.
require 'csv'
CSV.foreach(filename, :headers => true) do |row|
Pokemon.create!(row.to_hash)
end
@chadjemmett
chadjemmett / click.coffee
Created January 3, 2014 21:50
basic coffeescript file
$('h1').click ->
alert("You clicked this")
<!DOCTYPE html>
<html>
<head>
<script src="https://code.jquery.com/jquery-1.10.1.min.js"></script>
<script src="click.js"></script>
</head>
<body>
<h1>This should do something!!</h1>
</body>