Skip to content

Instantly share code, notes, and snippets.

View patrick99e99's full-sized avatar

Patrick Collins patrick99e99

  • collinator studios
  • Saratoga Springs, Utah
View GitHub Profile
#import "HTTPClient.h"
#import "KSDeferred.h"
@interface HTTPClient ()
@property (strong, nonatomic) NSURLSession *session;
@property (strong, nonatomic) NSOperationQueue *mainQueue;
@end
@implementation HTTPClient
class FooController < ApplicationController
respond_to :json
def show
resource = SomeModelWithErrors.new
respond_with resource, serializer: MySerializer
end
end
module LpcFrameParser
extend self
BITS = [4,1,6,5,5,4,4,4,4,4,3,3,3]
def hexify(data)
bit_pattern = data.map do |frame|
frame.map.each_with_index do |d, index|
bits = d.to_s(2)
while bits.length < BITS[index]
pad_with_zero(bits)
def converted
low_pass!(buffer, 4000)
new_number_of_samples = ((8000.0 / 44100.0) * number_of_samples).ceil
period = 1 / buffer.sample_rate.to_f
new_period = 1 / target_sample_rate.to_f
new_number_of_samples.times do |m|
sum = 0
number_of_samples.times do |n|
class Webpage < ActiveRecord::Base
belongs_to :dropdown
has_many :contents, :order => "parent_id, layout_order"
end
class Content < ActiveRecord::Base
belongs_to :element
belongs_to :webpage
end
module WebpagesHelper
def display_html_content(contents, mode = nil)
completed_elements, dropzone_id_list, sortable_list, output = [], [], [], []
contents.map do |c|
unless completed_elements.include?(c.id)
result = get_nested_elements(c, contents, completed_elements, dropzone_id_list, sortable_list, mode)
require 'polaroid.rb'
def shipping_label
@from_address = Setting.find_by_name("shipping_from_address").address
@to_address = Address.find(params[:file_name].split("_").last)
prawnto :prawn => {
:page_layout => :landscape,
:page_size => [79.2, 252.0],
:left_margin => 0,
:right_margin => 0,
:top_margin => 0,
acts_as_fleximage do
image_directory "/media/master_images"
use_creation_date_based_directories true
# image_storage_format :jpg # the plugin is handling this now
require_image true
missing_image_message 'is required'
invalid_image_message 'was not a readable image'
# default_image_path 'public/images/image_not_available.png'
default_image nil
def file_path
# -- I changed this line from: --
# "#{directory_path}/#{id}.#{self.class.image_storage_format}"
"#{directory_path}/#{id}.#{self.server_format}"
end
def pre_save
if @uploaded_image
# perform preprocessing
perform_preprocess_operation