Skip to content

Instantly share code, notes, and snippets.

@dnaismyth
dnaismyth / GameJDBCRepository.java
Created October 28, 2017 18:12
Adding our search for games by description method.
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.springframework.jdbc.core.RowMapper;
import org.springframework.stereotype.Repository;
import tutorial.springsetup.entity.Game;
@dnaismyth
dnaismyth / GameJDBCRepository.java
Created October 28, 2017 18:10
Adding our RowMapper and SQL query
import java.sql.ResultSet;
import java.sql.SQLException;
import org.springframework.jdbc.core.RowMapper;
import org.springframework.stereotype.Repository;
import tutorial.springsetup.entity.Game;
@Repository
@dnaismyth
dnaismyth / GameJDBCRepository.class
Created October 28, 2017 17:54
Basic skeleton of our Game JDBC Repository class
import org.springframework.stereotype.Repository;
@Repository
public class GameJDBCRepository extends BaseJDBCRepository {
}
@dnaismyth
dnaismyth / BaseJDBCRepository.java
Created October 28, 2017 17:48
Base JDBC parent class
import javax.sql.DataSource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment;
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;
@Repository
@Transactional
@dnaismyth
dnaismyth / CommentViewController.swift
Created October 28, 2017 02:07
Testing Comment POST request
import UIKit
class CommentViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
// Create a test comment
let comment = Comment()
comment.author = "Dayna"
@dnaismyth
dnaismyth / Constants.swift
Last active October 28, 2017 01:58
Hold our API constants and URL
import Foundation
struct Constants {
struct URL {
static let baseUrl = "http://localhost:8080/api"
static let searchGamesByTitle = baseUrl + "/games?title="
static let createGameComment = baseUrl + "/games/{gameId}/comments"
}
}
@dnaismyth
dnaismyth / Request.swift
Last active October 28, 2017 02:06
POST request
typealias PostCompletionHandler = (NSDictionary) -> ()
static func post(postUrl: String, body: [String: AnyObject], completionHandler: @escaping (PostCompletionHandler)){
let url = URL(string:postUrl)!
var request = URLRequest(url: url)
request.httpMethod = "POST"
request.addValue("application/json", forHTTPHeaderField: "Content-Type") // Set as JSON content-type
request.addValue("application/json", forHTTPHeaderField: "Accept")
@dnaismyth
dnaismyth / Comment.swift
Last active October 28, 2017 01:50
Comment for nintendo tutorial
import Foundation
class Comment {
var id: Int?
var game: Game?
var author: String?
var text: String?
var createdDate: String?
@dnaismyth
dnaismyth / ViewController.swift
Created October 22, 2017 17:33
DZNEmptyDataSet Example
import UIKit
import DZNEmptyDataSet
class ViewController: UIViewController, DZNEmptyDataSetSource, DZNEmptyDataSetDelegate {
@IBOutlet var tableView: UITableView!
let tungsten: UIColor = UIColor(red:0.20, green:0.20, blue:0.20, alpha:1.0)
override func viewDidLoad() {
@dnaismyth
dnaismyth / ViewController.swift
Created October 22, 2017 02:05
ViewController.swift file for Tutorial # 3
import UIKit
class ViewController: UIViewController, UITableViewDelegate, UITableViewDataSource {
var gameResults = [Game]()
@IBOutlet var tableView: UITableView!
override func viewDidLoad() {
super.viewDidLoad()
setupTableView()