This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
~>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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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| |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class FooController < ApplicationController | |
respond_to :json | |
def show | |
resource = SomeModelWithErrors.new | |
respond_with resource, serializer: MySerializer | |
end | |
end | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import "HTTPClient.h" | |
#import "KSDeferred.h" | |
@interface HTTPClient () | |
@property (strong, nonatomic) NSURLSession *session; | |
@property (strong, nonatomic) NSOperationQueue *mainQueue; | |
@end | |
@implementation HTTPClient |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## my routes file | |
resources :users do | |
get :redeem, :on => :member | |
end | |
I want to be able to do: | |
redeem_user_path(@user, @user.code) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Bar | |
end | |
class Foo | |
include Bar | |
end | |
puts Foo:CONS => Error | |
module Bar |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
NewerOlder