Skip to content

Instantly share code, notes, and snippets.

@adamthedeveloper
adamthedeveloper / asi_search_for_pens
Created March 30, 2017 18:01
These are the results returned when I searched for "pens"
{
"Results": [
{
"Id": 550518851,
"Name": "Tri-Band Ballpoint Pen",
"Description": "Tri-band ballpoint pen with silver trim and black rubber grip for writing comfort and control. These tri-band ballpoint pens include plunger action. These tri-band ballpoint pens are also available in a variety of new colors! Tri-band ballpoint pens are a great giveaway for any event or trade show. Ensure your clients remember you and write away the competition with these great ballpoint pens!",
"Number": "AZ898",
"ImageUrl": "media/22117985",
"VirtualSampleImages": [
{
@adamthedeveloper
adamthedeveloper / SalesReceiptAdd.xml
Created June 5, 2014 23:38
QB SalesReceiptAdd XML
<?xml version="1.0" encoding="utf-8"?>
<?qbxml version="13.0"?>
<QBXML>
<QBXMLMsgsRq onError="stopOnError">
<SalesReceiptAddRq>
<SalesReceiptAdd defMacro="MACROTYPE"> <!-- required -->
<CustomerRef> <!-- optional -->
<ListID >IDTYPE</ListID> <!-- optional -->
<FullName >STRTYPE</FullName> <!-- optional -->
</CustomerRef>
@adamthedeveloper
adamthedeveloper / TerminalGitBranchPrompt
Created November 20, 2013 23:59
Show your current branch in your terminal. Add this to the bottom of you .bash_profile
# Git branch in prompt.
parse_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'
}
export PS1="\u@\h \W\[\033[32m\]\$(parse_git_branch)\[\033[00m\] $ "
source ~/.profile
@adamthedeveloper
adamthedeveloper / gist:7538338
Created November 19, 2013 00:59
Increment / Decrement coffeescript
window.ChangeQuantity ||= {}
ChangeQuantity.load = ()->
$("input.change-quantity").click((evnt)->
evnt.preventDefault()
quantityField = $(this).parent().find('input.quantity')
currVal = parseInt(quantityField.val())
@adamthedeveloper
adamthedeveloper / binary_tree_insert.rb
Last active December 20, 2015 02:49
Rebuild a binary tree from an array.
class Node
attr_accessor :data, :left, :right
def initialize(*args)
@data,@left,@right = args
end
end
class Tree
attr_accessor :root
<?xml version="1.0" encoding="UTF-8"?>
<CORSConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
<CORSRule>
<AllowedOrigin>*</AllowedOrigin>
<AllowedMethod>GET</AllowedMethod>
<MaxAgeSeconds>3000</MaxAgeSeconds>
<AllowedHeader>*</AllowedHeader>
</CORSRule>
</CORSConfiguration>
# Monkey Patch ruby because of a bug introduced in ruby versions greater than 1.9.2
# For some reason the exit code is all wrong in later version of ruby and even though
# the issue was closed as sorted it's still broken in ruby version 1.9.3-p194.
# (see http://redmine.ruby-lang.org/issues/5218 for more information)
# Put this in spec_helper.rb or test_helper.rb so that it only affects specs and the CI server.
if defined?(RUBY_ENGINE) && RUBY_ENGINE == "ruby" && RUBY_VERSION >= "1.9"
module Kernel
alias :__at_exit :at_exit
def at_exit(&block)
__at_exit do

Routing in Ember

In Ember, the application's state manager handles routing. Let's take a look at a simple example:

App.stateManager = Ember.StateManager.create({
  start: Ember.State.extend({
    index: Ember.State.extend({
      route "/",