Skip to content

Instantly share code, notes, and snippets.

Daniel Honig dhonig

Block or report user

Report or block dhonig

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 GraphQL Solidus scratch
query{
products{
id
images{
attachment {
url
}
}
optionTypes {
edges {
@dhonig
dhonig / merge_sort.js
Created Apr 18, 2017
Merge sort in Javascript
View merge_sort.js
class Mergesort{
constructor(numbers){
this.numbers=numbers;
}
merge(left, right){
var result=[];
console.log("Left:"+left);
console.log("Right"+right);
@dhonig
dhonig / Inversions.js
Created Apr 18, 2017
Count Integer Inversions by modifying merge sort
View Inversions.js
class Inversioncount{
constructor(numbers){
this.numbers=numbers;
this.count=0;
}
merge(left, right){
var result=[];
@dhonig
dhonig / find_inversions.js
Created Apr 17, 2017
Linear version of find all integer inversions
View find_inversions.js
function getInversionCount(arr){
var inv_count = 0;
var n=arr.length
for (var i = 0; i < n - 1; i++)
for (var j = i+1; j < n; j++)
if (arr[i] > arr[j])
inv_count++;
return inv_count;
}
@dhonig
dhonig / solution.ex
Created Jul 25, 2016
Progammiung in Elixir Exercise 4
View solution.ex
prefix= fn doputs -> fn(s) -> IO.puts "#{s}" end end
View gist:ced936f397345e061ee8
cap aborted!
SSHKit::Runner::ExecuteError: Exception while executing on host 52.88.81.221: scp: /tmp/cardfool/git-ssh.sh: Permission denied
/Users/Daniel/.rvm/gems/ruby-2.1.2/gems/net-scp-1.2.1/lib/net/scp.rb:398:in `await_response_state'
/Users/Daniel/.rvm/gems/ruby-2.1.2/gems/net-scp-1.2.1/lib/net/scp.rb:369:in `block (3 levels) in start_command'
/Users/Daniel/.rvm/gems/ruby-2.1.2/gems/net-ssh-2.9.1/lib/net/ssh/connection/channel.rb:311:in `call'
/Users/Daniel/.rvm/gems/ruby-2.1.2/gems/net-ssh-2.9.1/lib/net/ssh/connection/channel.rb:311:in `process'
/Users/Daniel/.rvm/gems/ruby-2.1.2/gems/net-ssh-2.9.1/lib/net/ssh/connection/session.rb:222:in `block in preprocess'
/Users/Daniel/.rvm/gems/ruby-2.1.2/gems/net-ssh-2.9.1/lib/net/ssh/connection/session.rb:222:in `each'
/Users/Daniel/.rvm/gems/ruby-2.1.2/gems/net-ssh-2.9.1/lib/net/ssh/connection/session.rb:222:in `preprocess'
/Users/Daniel/.rvm/gems/ruby-2.1.2/gems/net-ssh-2.9.1/lib/net/ssh/connection/session.rb:205:in `process'
View routes.rb
Rails.application.routes.draw do
# This line mounts Spree's routes at the root of your application.
# This means, any requests to URLs such as /products, will go to Spree::ProductsController.
# If you would like to change where this engine is mounted, simply change the :at option to something different.
#
# We ask that you don't use the :as option here, as Spree relies on it being the default of "spree"
mount Spree::Core::Engine, :at => '/'
Spree::Core::Engine.add_routes do
namespace :api do
View routes.rb
Rails.application.routes.draw do
# This line mounts Spree's routes at the root of your application.
# This means, any requests to URLs such as /products, will go to Spree::ProductsController.
# If you would like to change where this engine is mounted, simply change the :at option to something different.
#
# We ask that you don't use the :as option here, as Spree relies on it being the default of "spree"
mount Spree::Core::Engine, :at => '/'
Spree::Core::Engine.add_routes do
namespace :api do
View shipment_decorator.rb
Spree::Shipment.class_eval do
audited associated_with: :order
has_associated_audits
def transfer_to_shipment(variant, quantity, shipment_to_transfer_to)
quantity_already_shipment_to_transfer_to = shipment_to_transfer_to.manifest.find{|mi| mi.line_item.variant == variant}.try(:quantity) || 0
if (quantity <= 0 || self == shipment_to_transfer_to)
View shipment_decorator_spec.rb
describe 'Transfers between shipments' do
let(:user) { stub_model(Spree::User, :email => "spree@example.com") }
#populated with order,email bill_address and ship_address,
let(:order) { FactoryGirl.create(:order_with_line_items) }
let(:a_variant){FactoryGirl.create(:variant)}
it 'should It should transfer items between shipments without adding line items' do
stock_location=order.shipments.first.stock_location
variant=stock_location.stock_items.first.variant
You can’t perform that action at this time.