Skip to content

Instantly share code, notes, and snippets.

Adam Yanalunas adamyanalunas

Block or report user

Report or block adamyanalunas

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View app_store_license.rb
def app_store_license(bundle_id: nil, license: "", countries: nil)
# Make sure your Spacehip::Tunes.client is already logged in
app = Spaceship::Tunes::Application.find(bundle_id)
raise "Could not find an app with the bundle ID `#{bundle_id}`" unless app
app_id = app.apple_id
details = app.details
url = "https://appstoreconnect.apple.com/WebObjects/iTunesConnect.woa/ra/apps/#{app_id}/details"
@adamyanalunas
adamyanalunas / fastlane_connect_api_data_protection.rb
Created Nov 14, 2019
A template for creating a request to set an App ID’s data protection capability
View fastlane_connect_api_data_protection.rb
def set_data_protection(bundle_id: nil, level: nil)
puts "Setting data protection level to `#{level}` for `#{bundle_id}`"
token = Spaceship::ConnectAPI::Token.create()
client = Spaceship::ConnectAPI::Provisioning::Client.new(token: token)
# Bundle IDs have, themselves, a unique ID. We’ll have to look that up first before firing off this request.
bundle_info = Spaceship::ConnectAPI::BundleId.all(filter: {identifier: bundle_id}).first
bundle_id_id = bundle_info.id
View check_provisioning_profile_expiration.rb
now = DateTime.now.to_time
# You can test different times, like testing 300 days in the future with: now = (DateTime.now + 300).to_time
provisioning_profile = "~/Library/MobileDevice/Provisioning Profiles/11BBCC...AF21BD2.mobileprovision"
expiration_string = `/usr/libexec/PlistBuddy -c 'Print :ExpirationDate' /dev/stdin <<< $(security cms -D -i #{provisioning_profile})`.chomp
expiration_date = DateTime.strptime(expiration_string, '%a %b %d %H:%M:%S PST %Y').to_time
remaining_days = (expiration_date.to_i - now.to_i) / (3600 * 24)
if remaining_days < 1
# Delete ".red" if you aren’t using the Colorize gem
View feed_muncher.rb
#!/usr/bin/env ruby
#coding:utf-8
require "open-uri"
require "fileutils"
destination_path = ENV['RSS_DOWNLOAD_DESTINATION'] || File.expand_path('.')
feed_url = ENV['RSS_FEED']
feed_file = URI.parse(feed_url).open
feed_file.close
@adamyanalunas
adamyanalunas / private_nsobject_initializer.swift
Created Feb 14, 2019
Generic Swift initializer of NSObjects with private init
View private_nsobject_initializer.swift
fileprivate extension NSObject {
/**
Initializes private init() subclasses of NSObject. Pure Swift classes
(and especially structs) will not work here.
```
// Given a class “PrivateInitClass” where `init()` is private
let somePrivateInitClassInstance = (PrivateInitClass.forcedInit() as PrivateInitClass)
```
@adamyanalunas
adamyanalunas / KeyboardTableView.swift
Created Jan 11, 2019 — forked from douglashill/KeyboardTableView.swift
A UITableView that allows navigation and selection using a hardware keyboard.
View KeyboardTableView.swift
// Douglas Hill, December 2018
// Made for https://douglashill.co/reading-app/
import UIKit
/// A table view that allows navigation and selection using a hardware keyboard.
/// Only supports a single section.
class KeyboardTableView: UITableView {
// These properties may be set or overridden to provide discoverability titles for key commands.
var selectAboveDiscoverabilityTitle: String?
@adamyanalunas
adamyanalunas / strings.swift
Created Sep 28, 2017
Swift 4 array of string iteration differences
View strings.swift
// Normal array of strings
let array = ["This", "is", "string", "array"]
let characters = array.flatMap {
$0.characters
}
// This prints ["T", "h", "i", "s", "i", "s", "s", "t", "r", "i", "n", "g", "a", "r", "r", "a", "y"]
print(characters)
let words = array.flatMap {
@adamyanalunas
adamyanalunas / levenshtein.swift
Created May 9, 2016
Siwft 3 compatible Levenshtein distance
View levenshtein.swift
// Light syntax cleanup from https://gist.github.com/daehn/f17e8cdcf8d91b046f3c
private extension String {
subscript(index: Int) -> Character {
return self[startIndex.advancedBy(index)]
}
subscript(range: Range<Int>) -> String {
let start = startIndex.advancedBy(range.startIndex)
View PULL_REQUEST_TEMPLATE.md

Addresses issue: #

Preflight (optional)

  • List work to be done before PR can be reviewed
  • Keep this as brief as possible, this is not a place for storytelling
  • bundle install or bundle exec pod install
  • Reading some backstory
  • Set up credentials someuser@domain.com/password in the “foo” database
@adamyanalunas
adamyanalunas / post-install
Created Feb 5, 2015
A git post-install to update your pods, if needed
View post-install
#!/bin/bash
PREVIOUS_HEAD=$1
NEW_HEAD=$2
BRANCH_SWITCH=$3
if [[ $BRANCH_SWITCH == "1" && $PREVIOUS_HEAD != $NEW_HEAD ]]; then
# Kill the simulator.
SIM=`pgrep 'iPhone Simulator'`
You can’t perform that action at this time.