Skip to content

Instantly share code, notes, and snippets.

View keitin's full-sized avatar

Keita Matsushita keitin

View GitHub Profile
final class CurrentUser {
private init() {}
static let sharedInstance = CurrentUser()
var user: User?
}
import java.util.Scanner;
public class ARC004B {
public static void main(String[] args) {
ARC004BSolve solve = new ARC004BSolve();
solve.main();
}
}
class ARC004BSolve {
import Foundation
import APIKit
import Himotoki
struct SearchRepositoryRequest: GithubRequest {
typealias Response = RepositoryCollection
var method: HTTPMethod {
return .get
public func <| <T: Decodable>(e: Extractor, keyPath: KeyPath) throws -> T {
return try e.value(keyPath)
}
extension GithubRequest where Response: Decodable {
func response(from object: Any, urlResponse: HTTPURLResponse) throws -> Response {
return try decodeValue(object)
}
}
@keitin
keitin / .swift
Last active March 30, 2017 06:11
let request = RateLimitRequest()
Session.send(request) { result in
switch result {
case .success(let rateLimit):
print("limit: \(rateLimit.limit)")
print("remaining: \(rateLimit.remaining)")
case .failure(let error):
print("error: \(error)")
}
}
import Foundation
import APIKit
import Himotoki
struct RateLimitRequest: GithubRequest {
typealias Response = RateLimit
var method: HTTPMethod {
return .get
import Foundation
import APIKit
import Himotoki
protocol GithubRequest: Request { }
extension GithubRequest {
var baseURL: URL {
return URL(string: "https://api.github.com")!
}
@keitin
keitin / .java
Created February 28, 2017 11:27
public class Solution {
int[][] adj;
int[] indegrees;
boolean[] isConfirm;
public String alienOrder(String[] words) {
this.adj = new int[26][26];
this.indegrees = new int[26];
@keitin
keitin / .java
Created February 22, 2017 02:21
/**
* Definition for binary tree with next pointer.
* public class TreeLinkNode {
* int val;
* TreeLinkNode left, right, next;
* TreeLinkNode(int x) { val = x; }
* }
*/
public class Solution {
public void connect(TreeLinkNode root) {