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
~>curl -i -N -H "Connection: Upgrade" -H "Upgrade: websocket" -H "Host: api.example.com" -H "Origin: https://www.example.com" https://api.example.com/socket
HTTP/2 301
date: Tue, 26 Jun 2018 02:27:07 GMT
content-type: application/json
content-length: 4
location: https://localhost:9999/localhost
server: restify
access-control-allow-origin: https://www.example.com
vary: origin
access-control-expose-headers: api-version, content-length, content-md5, content-type, date, request-id, response-time
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|
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)
class FooController < ApplicationController
respond_to :json
def show
resource = SomeModelWithErrors.new
respond_with resource, serializer: MySerializer
end
end
#import "HTTPClient.h"
#import "KSDeferred.h"
@interface HTTPClient ()
@property (strong, nonatomic) NSURLSession *session;
@property (strong, nonatomic) NSOperationQueue *mainQueue;
@end
@implementation HTTPClient
@patrick99e99
patrick99e99 / i18n_matchers.rb
Last active February 6, 2020 16:25
I18n matchers for rspec 2
RSpec::Matchers.define :translate_to do |key, options|
match do |actual|
@expected = I18n.t(key, options)
@failure = nil
@failure ||= :bad_actual if actual.start_with?('translation missing:')
@failure ||= :bad_expected if @expected.start_with?('translation missing:')
@failure ||= :no_match if @expected != actual
@failure.nil?
end
describe OffersController do
def do_create
post :create, { :post_id => bb_request.id, :offer => new_offer.attributes }
end
shared_examples "an access controlled action" do |action_proc|
it "denies access if the post is not verified" do
expect(&action_proc).to raise_error(CanCan::AccessDenied)
end
end
## my routes file
resources :users do
get :redeem, :on => :member
end
I want to be able to do:
redeem_user_path(@user, @user.code)
module Bar
end
class Foo
include Bar
end
puts Foo:CONS => Error
module Bar
GEM
remote: http://rubygems.org/
specs:
POpen4 (0.1.4)
Platform (>= 0.4.0)
open4
Platform (0.4.0)
actionmailer (3.2.3)
actionpack (= 3.2.3)
mail (~> 2.4.4)