Skip to content

Instantly share code, notes, and snippets.

Amiel Martin amiel

Block or report user

Report or block amiel

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View item_gateway.rb
module Navision
class ItemGateway
def initialize(options = {})
@client = options.fetch(:client) { Navision.item_client } # item_client => Savon.client(...)
end
def get_product_by_number(number)
get_result client.call :read, message: { 'No' => number }
end
@amiel
amiel / ignorable_errors.rb
Last active Aug 29, 2015
Ignoring stupid errors
View ignorable_errors.rb
SMRT_ERRORS = [ServiceClaimsIsATeapot]
def ignore_stupid_errors(error_block = ->(*){})
yield
rescue *SMRT_ERRORS => e
error_block.call e
end
@amiel
amiel / api_client.rb
Created Feb 21, 2014
Ignoring API errors
View api_client.rb
class APIClient
def get_teapots
ignore_errors do
make_request :teapots
end
end
def get_coffeepots
ignore_errors do
make_request :coffeepots
@amiel
amiel / my_custom_date_presenter.rb
Last active Aug 29, 2015
HTMLCalendar date presenter example
View my_custom_date_presenter.rb
class MyCustomDatePresenter < HTMLCalendar::DatePresenter
# Available methods: `date` and `template`
# The only required method
def html_classes
if monday?
['a-case-of-the-mundays']
else
[]
end
@amiel
amiel / helper.rb
Created Mar 5, 2014
classes helper
View helper.rb
def link_to_post(post)
html_class = ["post"]
html_class << "active" if post.active?
link_to(post.title, post, class: html_class)
end
@amiel
amiel / custom-predicate.rb
Created Mar 11, 2014
custom predicate in rspec
View custom-predicate.rb
class MyFoo
def awesome?
true
end
end
describe MyFoo do
let(:my_foo) { MyFoo.new }
it 'is awesome' do
@amiel
amiel / gist:9625148
Last active Aug 29, 2015
jenkins ghprb
View gist:9625148
if [ -z "$ghprbSourceBranch" ];then
# special case non GHPRB build
git fetch origin '+refs/heads/*:refs/remotes/origin/*'
git reset --hard "$sha1"
fi
View digicolor.rb
#!/usr/bin/env ruby -rubygems
# :P
# exit
require 'digiusb/digiblink'
# TODO:
COLORS = {
'success' => 'green',
@amiel
amiel / IDEAS.md
Created May 13, 2014
nested urls ideas
View IDEAS.md
@amiel
amiel / example.js
Created May 14, 2014
Example gist cursor misalignment.
View example.js
Object.create({ braces: { make: { it: { slightly: { worse: { each: { time: {} } } } } } } });
return { cursor: "is basically one character off here" };
You can’t perform that action at this time.