Skip to content

Instantly share code, notes, and snippets.

View gjones's full-sized avatar

Gareth Jones gjones

View GitHub Profile

Keybase proof

I hereby claim:

  • I am gjones on github.
  • I am garethjones (https://keybase.io/garethjones) on keybase.
  • I have a public key ASASrzHbPodmQplU1Yh2hst-pvEgAN6Q5b0duIBl58V1kgo

To claim this, I am signing this object:

@gjones
gjones / DeviceDetection.swift
Last active June 12, 2017 01:12
UIDevice extension to identify different type sizes of iPad. (Swift 3.x)
import UIKit
extension UIDevice {
public var isiPadPro12: Bool {
if UIDevice.current.userInterfaceIdiom == UIUserInterfaceIdiom.pad
&& (UIScreen.main.bounds.size.height == 1366 || UIScreen.main.bounds.size.width == 1366) {
return true
}
return false
@gjones
gjones / fetchResultsFromApi.swift
Created May 5, 2017 22:39
JSON API with Basic Auth in Swift 3
func fetchResultsFromApi() {
let username = "username"
let password = "password"
let url = NSURL(string: "http://localhost:3000/api/v1/results.json")
let request = NSMutableURLRequest(url: url! as URL)
let config = URLSessionConfiguration.default
let userPasswordString = "\(username):\(password)"
let userPasswordData = userPasswordString.data(using: String.Encoding.utf8)
@gjones
gjones / deploy.rb
Created January 14, 2017 22:50
Example of Capistrano Deploy Script
server "#{Rails.application.secrets.server_port}", port: 22, roles: [:web, :app, :db], primary: true
set :repo_url, "#{Rails.application.secrets.git_address}"
set :application, "#{Rails.application.secrets.application_name}"
set :user, "#{Rails.application.secrets.application_user}"
set :puma_threads, [4, 16]
set :puma_workers, 0
# Don't change these unless you know what you're doing
set :pty, true
@gjones
gjones / FizzBuzz.rb
Last active January 9, 2017 17:23
Attempt at FizzBuzz solution in Ruby
# Write a program that prints the numbers from 1 to 100.
# For multiples of three print "Fizz" instead of the number
# For multiples of five print "Buzz". For numbers which
# For multiples of both three and five print "FizzBuzz".
1.step(100,1) do |input|
if (input % 5) == 0 && (input % 3) == 0
puts 'FizzBuzz'
elsif (input % 5) == 0
puts 'Buzz'
@gjones
gjones / UnitTestExample.swift
Last active January 9, 2017 17:06
Simple Unit Test
// Project: ExampleTestApp
// ViewController.swift
func isNumberEven(num: Int) -> Bool {
if num %2 == 0 {
return true
} else {
return false
}
@gjones
gjones / Fizzbuzz.swift
Last active February 10, 2017 02:39
Simple solution to the Fizzbuzz question in Swift.
// Write a program that prints the numbers from 1 to 100.
// For multiples of three print "Fizz" instead of the number
// For multiples of five print "Buzz". For numbers which
// For multiples of both three and five print "FizzBuzz".
for number in 1...100 {
if (number % 15 == 0) {
println("FizzBuzz")
}
else if (number % 3 == 0) {