Skip to content

Instantly share code, notes, and snippets.

View jgsamudio's full-sized avatar

Jonathan Samudio jgsamudio

View GitHub Profile
// MARK: - Helper Functions
extension DangerDSL {
func filesWithAdditions(fileTypes: [FileType] = [.swift], excludedFiles: [File] = []) -> [String] {
return (git.modifiedFiles + git.createdFiles).filter {
guard let fileType = $0.fileType, !excludedFiles.contains($0) else { return false }
return fileTypes.contains(fileType)
}
}
// MARK: - 1 - Pull Request Description
let pullRequestBody = danger.github.pullRequest.body ?? ""
if !pullRequestBody.contains("📲 What") ||
!pullRequestBody.contains("👀 See") ||
!pullRequestBody.contains("🤔 Why") ||
!pullRequestBody.contains("🛠 How") {
warn("""
Pull request description is missing required information:
- 📲 What
// MARK: - 3 - SwiftLint
SwiftLint.lint(inline: true, strict: true, lintAllFiles: true)
// MARK: - 3 - Celebrate Milestones
let pullRequestMilestones = [2, 10, 100]
let currentPRNumber = danger.github.pullRequest.number
if pullRequestMilestones.contains(currentPRNumber) {
let githubHandle = danger.github.pullRequest.user.login
message("Congratulations \(githubHandle)! You've made the 100th Pull Request!")
}
// MARK: - 4 - Celebrate Milestones
var largePRLineCount = 500;
let additions: Int = danger.github.pullRequest.additions ?? 0
let deletions: Int = danger.github.pullRequest.deletions ?? 0
if ((additions + deletions) > largePRLineCount) {
warn("""
Number of pull request changes is larger than 500! Consider breaking out future changes into smaller pull requests.
""");
public struct GitHubPR : Decodable, Equatable {
public enum PullRequestState : String, Decodable {
case open
case closed
case merged
/// The GitHub metadata for your pull request.
public struct GitHub : Decodable {
public let issue: Danger.GitHubIssue
public let pullRequest: Danger.GitHubPR
public let commits: [Danger.GitHubCommit]
public let reviews: [Danger.GitHubReview]
//
// ViewController.swift
// CodeImage
//
// Created by Jonathan Samudio on 5/29/19.
// Copyright © 2019 Prolific Interactive. All rights reserved.
//
import Cocoa
//
// CanvasViewController.swift
// CodeDesign
//
// Created by Jonathan Samudio on 5/20/19.
// Copyright © 2019 JustBinary. All rights reserved.
//
import Foundation
import Cocoa
@jgsamudio
jgsamudio / CodeJamSolution.java
Last active May 17, 2019 21:07
CodeJam - "You Can Go Your Own Way" Solution
import java.util.*;
import java.io.*;
public class Solution {
public static void main(String[] args) {
Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
int t = in.nextInt();
for (int i = 1; i <= t; ++i) {
int gridSize = in.nextInt();