Skip to content

Instantly share code, notes, and snippets.

View huoxito's full-sized avatar
🏊‍♂️

Washington L Braga Jr huoxito

🏊‍♂️
View GitHub Profile
@huoxito
huoxito / 1.rb
Last active August 29, 2015 14:01
# This file is copied to spec/ when you run 'rails generate rspec:install'
ENV["RAILS_ENV"] ||= 'test'
require File.expand_path("../../config/environment", __FILE__)
require 'rspec/rails'
require 'rspec/autorun'
# Requires supporting ruby files with custom matchers and macros, etc,
# in spec/support/ and its subdirectories.
Dir[Rails.root.join("spec/support/**/*.rb")].each { |f| require f }
curl http://localhost:9292/api/variants.json -d "q[product_name_or_sku_cont]=baseball" -X GET -H "X-Spree-Token: 123" > /dev/null
def index
  @variants = scope.includes(:option_values, :product, :default_price, :images, { stock_items: :stock_location })
    .ransack(params[:q]).result.page(params[:page]).per(params[:per_page])

 render text: @variants.to_json
@huoxito
huoxito / sales_order.xml
Created February 18, 2014 21:19
NetSuite Sales Order
<soapenv:Body>
<getResponse xmlns="urn:messages_2013_2.platform.webservices.netsuite.com">
<readResponse>
<platformCore:status xmlns:platformCore="urn:core_2013_2.platform.webservices.netsuite.com" isSuccess="true"/>
<record xmlns:tranSales="urn:sales_2013_2.transactions.webservices.netsuite.com" internalId="9593" externalId="R375526411" xsi:type="tranSales:SalesOrder">
<tranSales:createdDate>2014-01-22T12:57:11.000-08:00</tranSales:createdDate>
<tranSales:customForm xmlns:platformCore="urn:core_2013_2.platform.webservices.netsuite.com" internalId="174">
<platformCore:name>Primary Sales Order Form</platformCore:name>
</tranSales:customForm>
<tranSales:entity xmlns:platformCore="urn:core_2013_2.platform.webservices.netsuite.com" internalId="2507">
Started GET "/api/products/awesome-pants" for 127.0.0.1 at 2014-02-03 11:55:19 -0300
ActiveRecord::SchemaMigration Load (0.9ms) SELECT "schema_migrations".* FROM "schema_migrations"
Spree::User Load (1.8ms) SELECT "spree_users".* FROM "spree_users" WHERE "spree_users"."id" = 1 ORDER BY "spree_users"."id" ASC LIMIT 1
 (12.0ms) SELECT COUNT(*) FROM "spree_roles" INNER JOIN "spree_roles_users" ON "spree_roles"."id" = "spree_roles_users"."role_id" WHERE "spree_roles_users"."user_id" = $1 AND "spree_roles"."name" = 'admin' [["user_id", 1]]
CACHE (0.0ms) SELECT COUNT(*) FROM "spree_roles" INNER JOIN "spree_roles_users" ON "spree_roles"."id" = "spree_roles_users"."role_id" WHERE "spree_roles_users"."user_id" = $1 AND "spree_roles"."name" = 'admin' [["user_id", 1]]
Spree::Product Load (8.9ms) SELECT "spree_products".* FROM "spree_products" WHERE ("spree_products".deleted_at IS NULL or "spree_products".deleted_at >= '
@huoxito
huoxito / gist:7804194
Created December 5, 2013 12:04
tmux.conf
# Our .tmux.conf file
# Setting the prefix from C-b to C-a
# START:prefix
set -g prefix C-a
# END:prefix
# Free the original Ctrl-b prefix keybinding
# START:unbind
unbind C-b
@huoxito
huoxito / make_orders.rake
Created November 22, 2013 17:21
To make 10 completed orders bundle exec rake make_order[10]
desc "Generate completed orders on a fresh Spree install. e.g. rake make_orders[10]"
task :make_orders, [:number] => :environment do |t, args|
address_attributes = {
firstname: "Spree",
lastname: "Commerce",
address1: "4600 East West Highway, Suite 800",
city: "Bethesda",
country_id: Spree::Country.find_by(iso: "US").id,
state_id: Spree::State.find_by(abbr: "MD").id,
zipcode: "20814",
Point* mypoint = &(Point){x: 5, y: 5}
mypoint->x=2;
(*mypoint).y=2;
unless File.exists?('Gemfile')
File.write('Gemfile', <<-GEMFILE)
source 'https://rubygems.org'
gem 'rails', '4.0.1.rc1'
gem 'pg'
GEMFILE
system 'bundle'
end
@huoxito
huoxito / jirafe_deferred.html.erb
Last active December 25, 2015 22:38
Jirafe basic frontend events
<script type="text/javascript">
/* Jirafe */
(function(){
var d=document,g=d.createElement('script'),s=d.getElementsByTagName('script')[0];
g.type='text/javascript';g.defer=g.async=true;g.src=d.location.protocol+'//sandbox-beacon.jirafe.net/jirafe_api.js';
s.parentNode.insertBefore(g,s);
})();
var jirafe_site_id = "";
var jirafe_org_id = "";
@huoxito
huoxito / params.json
Created October 5, 2013 21:47
curl --header "Content-type: application/json" --header "X-Spree-Token: 656612876c0a30dd41c86c81714f602a8f3e06cfb28dea37" http://localhost:9292/api/orders --data @./params.json
{
"order": {
"email":"[email protected]",
"shipments": [
{"number":"138848",
"cost":0.0,
"status":"ready",
"stock_location":"default",
"shipping_method":"UPS Ground (EUR)",