Skip to content

Instantly share code, notes, and snippets.

View getaclue00's full-sized avatar

Alex getaclue00

View GitHub Profile
@getaclue00
getaclue00 / NSImage+RoundedCorners.swift
Created August 8, 2018 05:00 — forked from jeanetienne/NSImage+RoundedCorners.swift
Drawing an NSImage with rounded corners in Swift
// This extension is a port of @venj's solution from 2011
// https://github.com/venj/Cocoa-blog-code/blob/master/Round%20Corner%20Image/Round%20Corner%20Image/NSImage%2BRoundCorner.m
extension NSImage {
func roundCorners(withRadius radius: CGFloat) -> NSImage {
let rect = NSRect(origin: NSPoint.zero, size: size)
if
let cgImage = self.cgImage,
let context = CGContext(data: nil,
@getaclue00
getaclue00 / rspec.md
Created July 27, 2018 21:58 — forked from supertopher/rspec.md
rspec best practices

Automated Testing.

Testing is helpful for ensuring that your code runs (driver code). This is to make sure that current features work, old features still work, and future work will be easily tested. By default, every Rails application has three environments: development, test, and production.

Rails offers three kinds of testing:

  • Unit tests: 
In the context of Rails, unit tests are meant primarily to cover the domain logic in your models, which include things like validations, calculations, search methods, and any other interesting functionality that your models implement.
  • Functional tests: These provide a way to verify that the actions for a single controller are working as expected, and allow you to do things such as post data to a specific action and verify the correct response is returned
  • Integration tests: Any given session with a Rails application will span across several models and controllers. Integration tests provide a way to test those kinds of interactions. Essentia
import Alamofire
func makeGetCallWithAlamofire() {
let todoEndpoint: String = "https://jsonplaceholder.typicode.com/todos/1"
Alamofire.request(todoEndpoint)
.responseJSON { response in
// check for errors
guard response.result.error == nil else {
// got an error in getting the data, need to handle it
print("error calling GET on /todos/1")
@getaclue00
getaclue00 / AutoIncrementBuilds.sh
Created June 23, 2018 17:26 — forked from rodydavis/AutoIncrementBuilds.sh
Auto Increment Build and Version Numbers
#Works with Xcode 9 (Confirmed)
#1. Go to "Edit Schemes"
#2. Go to "Build"
#3. Go to "Pre-Actions"
#4. Select YOUR app in "Provide Build Settings from:"
#5. Paste Below Script in Box
#6. Build Project
#Build Number ++
@getaclue00
getaclue00 / ngrok-installation.md
Created June 22, 2018 19:19 — forked from wosephjeber/ngrok-installation.md
Installing ngrok on Mac

#Installing ngrok on OSX

  1. Download ngrok
  2. Unzip it to your Applications directory
  3. Create a symlink (instructions below)

Creating a symlink to ngrok

Run the following two commands in Terminal to create the symlink.

# cd into your local bin directory
@getaclue00
getaclue00 / latency.txt
Created June 22, 2018 13:14 — forked from jboner/latency.txt
Latency Numbers Every Programmer Should Know
Latency Comparison Numbers (~2012)
----------------------------------
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 ns 3 us
Send 1K bytes over 1 Gbps network 10,000 ns 10 us
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD
@getaclue00
getaclue00 / .gitignore
Created May 24, 2018 19:23 — forked from adamgit/.gitignore
.gitignore file for Xcode4 / OS X Source projects
#########################
# .gitignore file for Xcode4 and Xcode5 Source projects
#
# Apple bugs, waiting for Apple to fix/respond:
#
# 15564624 - what does the xccheckout file in Xcode5 do? Where's the documentation?
#
# Version 2.6
# For latest version, see: http://stackoverflow.com/questions/49478/git-ignore-file-for-xcode-projects
#
@getaclue00
getaclue00 / Screenshot.swift
Created May 24, 2018 05:30 — forked from nitrag/Screenshot.swift
This will allow you to take a screenshot of a UIView, but more importantly only a section of that view
//
// Screenshot.swift
//
// 1) Take a picture of a UIView
// 2) Take a picture of a UIView's subframe. EG. Fullscreen UIView with a
// small square box in the middle, it will only save what's visible in the box frame
// but not the box itself
import Foundation
import UIKit
@getaclue00
getaclue00 / ScreenshotManager.swift
Created May 23, 2018 22:28 — forked from mminer/ScreenshotManager.swift
Saves screenshots in a Cocoa application (wrapper around screencapture).
import AppKit
struct ScreenshotManager {
/// Matches macOS' screenshot filename format.
private static let filenameFormatter: DateFormatter = {
let formatter = DateFormatter()
formatter.dateFormat = "'Screen Shot' yyyy-MM-dd 'at' HH.mm.ss"
return formatter
}()
@getaclue00
getaclue00 / HOWTODMG.md
Created May 17, 2018 18:05 — forked from jadeatucker/HOWTODMG.md
How to create a "DMG Installer" for Mac OS X

Creating a "DMG installer" for OS X

A DMG Installer is convenient way to provide end-users a simple way to install an application bundle. They are basically a folder with a shortcut to the Applications directory but they can be customized with icons, backgrounds, and layout properties. A DMG file (.dmg) is a Mac OS X Disk Image file and it is used to package files or folders providing compression, encryption, and read-only to the package.

##Creating the DMG file #Disk Utility