Skip to content

Instantly share code, notes, and snippets.

class ImagemagickAT6 < Formula
desc "Tools and libraries to manipulate images in many formats"
homepage "https://legacy.imagemagick.org/"
url "https://imagemagick.org/archive/releases/ImageMagick-6.9.12.tar.xz"
sha256 "dea17ba878b1e70b8c5d670a980706c82d7592028018eaff2a826df5ad022167"
license "ImageMagick"
head "https://github.com/imagemagick/imagemagick6.git", branch: "main"
livecheck do
url "https://imagemagick.org/archive/"
Keep in mind that Algolia has ~30ms latency on each request since it's remote server and Elastic instance is located on my local machine.
So for 100 reuqests it would be ~3 seconds latency
Benchmark.bm do |bm|
bm.report("Single Query: ") {
OrderFamily.algolia_search("19b").count
}
bm.report("SQ Second Run: ") {
OrderFamily.algolia_search("19b").count
}
export function promiseMiddleware() {
function isPromise(value) {
return value && typeof value.then === 'function';
}
return next => action => {
if (!isPromise(action.promise)) {
return next(action);
}
Q:
###############################################
merchant model and controller have a lot of code that is not related to this task, but I have left it in so we are looking at the same things.
Most of the "problem" is in merchant.rb - see these methods:
- def self.api_vouchercodes(content,zoom)
- def self.new_merchant_factual(name, description, options = {})
- def self.new_merchant_8coupon(name,phone, description,type_id, address, lon, lat, city, state, postal_code)
- def self.new_merchant_drinkowl(options = {}) # name phone full_address lon lat city state postal_code country
- def self.new_merchant_groupon(name, phone, description, type, location, city, state_province_region, postal_code,country, third_party_code)
- def self.new_merchant_vouchercodes(name, phone, lat,lon, city, postal_code, third_party_code, address,vouchercodes_merchant_id, vouchercodes_place_id)
# LJ friends feed
# -*- encoding : utf-8 -*-
require 'spec_helper'
describe Livejournal::FriendsFeed do
describe "#all" do
let(:livejournal_user) { FactoryGirl.create(:livejournal_user) }
context "when invalid html" do
it "should return nil" do
@leafmind
leafmind / gist:3904653
Created October 17, 2012 09:23
Models samples with built-in integrations
# Mechanize based Altergeo integration
# -*- encoding : utf-8 -*-
class Altergeo::Places
PER_PAGE = 3
EXPANDED_DISTANCE = 10000
def self.find_by_query(altergeo_user, query = '', page = 1)
options = { :query => query, :limit => PER_PAGE, :offset => PER_PAGE * (page - 1) }
@leafmind
leafmind / gist:3847457
Created October 7, 2012 07:46
vcr usage
# -*- encoding : utf-8 -*-
require 'spec_helper'
describe Livejournal::User do
let(:user_params) { {:nickname => 'fatumka', :password => '59909046'} }
let(:user) { FactoryGirl.create(:user) }
describe "#authorize!" do
it "should successfully authorize user and create livejournal_user row" do
VCR.use_cassette('livejournal/login_success') do
@leafmind
leafmind / gist:3847453
Created October 7, 2012 07:44
unit level
# -*- encoding : utf-8 -*-
require 'spec_helper'
describe Subscription do
let!(:subscription){FactoryGirl.create(:subscription)}
describe "#subscribe" do
let!(:user) { FactoryGirl.create(:user) }
before do
stub_request(:get, /.*/).to_return(:status => 200, :headers => {
@leafmind
leafmind / gist:3416666
Created August 21, 2012 15:39
encoding
Sent mail to (0ms)
NoMethodError (undefined method `encoding' for #<Array:0xb7935b4>):
mail (2.4.4) lib/mail/fields/unstructured_field.rb:65:in `do_decode'
mail (2.4.4) lib/mail/fields/unstructured_field.rb:46:in `decoded'
mail (2.4.4) lib/mail/fields/unstructured_field.rb:50:in `default'
mail (2.4.4) lib/mail/field.rb:133:in `method_missing'
mail (2.4.4) lib/mail/message.rb:1107:in `default'
mail (2.4.4) lib/mail/message.rb:1081:in `to'
actionmailer (3.2.8) lib/action_mailer/base.rb:429:in `set_payload_for_mail'
@leafmind
leafmind / gist:3314717
Created August 10, 2012 14:42
Permalink
# -*- encoding : utf-8 -*-
class PostAddPermalink < ActiveRecord::Migration
def up
add_column :posts, :permalink, :string # limit 256 by default
#add composite index to ensure uniquiness of permalink-title pair
add_index :posts, [:permalink, :title], :unique => true
# id with SHA1 first 8 characters permalink
#def generate_permalink(id, title)
# "#{id}-#{Digest::SHA1.hexdigest(title).slice(0,8)}"