This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<? | |
// VIN API decoder for PHP 4.x+ | |
define('ELEMENT_CONTENT_ONLY', true); | |
define('ELEMENT_PRESERVE_TAGS', false); | |
function getXML($vin) { | |
$curl = curl_init(); | |
curl_setopt ($curl, CURLOPT_URL, 'http://vinapi.skizmo.com/vins/'. $vin.'.xml'); | |
curl_setopt ($curl, CURLOPT_HTTPHEADER, array('Content-Type: application/xml', 'X-VinApiKey: #YOURAPIKEYGOESHERE#')); //use your API key here |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.awt.image.BufferedImage; | |
import java.beans.Beans; | |
import java.io.FileOutputStream; | |
import java.io.IOException; | |
import java.util.Date; | |
import java.util.logging.FileHandler; | |
import java.util.logging.Logger; | |
import java.util.logging.SimpleFormatter; | |
import com.sun.image.codec.jpeg.JPEGCodec; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
require 'usb' # this is the ruby-usb gem, I'm also using libusb 1.0 and linux | |
require 'logger' | |
class MagTek | |
def initialize | |
@device = find_device | |
interface = @device.interfaces.first | |
@endpoint = interface.endpoints.first | |
@logger = Logger.new("/var/log/monitor_usb.log") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<hash> | |
<telescopic-steering-column>Std.</telescopic-steering-column> | |
<front-split-bench-seat>N/A</front-split-bench-seat> | |
<powertrain-warranty-distance>36,000 mile</powertrain-warranty-distance> | |
<leather-seat>Std.</leather-seat> | |
<load-bearing-exterior-rack>N/A</load-bearing-exterior-rack> | |
<front-spring-type>Coil</front-spring-type> | |
<steel-wheels>N/A</steel-wheels> | |
<maximum-gvwr>No data lbs</maximum-gvwr> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# app/views/home/update_artists.js.haml | |
$('#artists_select').html("<%= escape_javascript(options_for_select(@artists)) %>"); | |
$('#songs_select').html("<%= escape_javascript(options_for_select(@songs)) %>"); | |
# app/views/home/update_songs.js.haml | |
$('#songs_select').html("<%= escape_javascript(options_for_select(@songs)) %>"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# app/views/home/index.html.haml | |
<%= collection_select(nil, :genre_id, @genres, :id, :name, {:prompt => "Select a Genre"}, {:id => 'genres_select'}) %> | |
<br/> | |
<%= collection_select(nil, :artist_id, @artists, :id, :name, {:prompt => "Select an Artist"}, {:id => 'artists_select'}) %> | |
<br/> | |
<%= collection_select(nil, :song_id, @songs, :id, :title, {:prompt => "Select a Song"}, {:id => 'songs_select'}) %> | |
<script> | |
$(document).ready(function() { | |
$('#genres_select').change(function() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# app/views/home/index.html.haml | |
= collection_select(nil, :genre_id, @genres, :id, :name, {:prompt => "Select a Genre"}, {:id => 'genres_select'}) | |
%br | |
= collection_select(nil, :artist_id, @artists, :id, :name, {:prompt => "Select an Artist"}, {:id => 'artists_select'}) | |
%br | |
= collection_select(nil, :song_id, @songs, :id, :title, {:prompt => "Select a Song"}, {:id => 'songs_select'}) | |
:javascript | |
$(document).ready(function() { | |
$('#genres_select').change(function() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# config/routes.rb | |
DynamicSelectBoxes::Application.routes.draw do | |
get 'home/update_artists', :as => 'update_artists' | |
get 'home/update_songs', :as => 'update_songs' | |
root :to => "home#index" | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# app/models/artist.rb | |
class Artist < ActiveRecord::Base | |
belongs_to :genre | |
has_many :songs | |
attr_accessible :genre_id, :name, :genre | |
end | |
# app/models/genre.rb |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# app/controllers/home_controller.rb | |
class HomeController < ApplicationController | |
def index | |
@genres = Genre.all | |
@artists = Artist.all | |
@songs = Song.all | |
end | |
def update_artists | |
# updates artists and songs based on genre selected |
NewerOlder