We can already use --graph and --decorate to get a pretty, colored commit tree, but we can create a function for less typing, more flexibility and more info:
The standard approach for this would be something like this:
struct Theme { enum Color { case title case subtitle // [...] var color: UIColor { switch self { case .title: return UIColor.red case .subtitle: return UIColor.blue ... } } } enum Font { }}
And using it throughout the app would look like this:
I don't know why, but I've always seemed to be looking for the "perfect" Markdown editor - although I used a lot of reallygreatones, none really clicked with me.
Come in, LightPaper. Easy file access via the sidebar, multi-tabs, script assets, Jekyll Rendering, Math Rendering, MultiMarkdown or GitHub Flavored Markdown, a preference tab where you write CSS for extra customization on top of the usual CSS-based themes, and much more.
It all started with this post by Joe for updating a plug-in from the terminal, which lead to this script for automating the process of updating all plug-ins.
Even though I could have created an Alfred workflow to easily run the script with a single command, I always wanted to start working on Mac apps, so this was a good opportunity to get my feet wet.
First, we need to ask for the user's permission to access the folder, but for that, we need an NSSavePanel:
let op = NSSavePanel()op.message = "Descriptive message here"op.canCreateDirectories = falseop.canChooseDirectories = falseop.showsHiddenFiles = falseop.prompt = "Allow"op.title = "Allow access"op.isExtensionHidden = trueop.directoryURL = URL(string: "/path/to/folder")// Depending on your purpose, you might need these to trueop.allowsMultipleSelection = falseop.canChooseFiles = false
Say you have a Mac app and you want to run a script, either to perform some action, or to return something, here's one way to do it.
First, we create an NSTask, set the launch path of the handler, in our case ruby (we will use the default one, to be sure it exists), and the required parameters, if required:
Been slacking lately, but I hope I can make it up with this one. Let's say you need to display a price, and the currency, but the currency code should have a different font. You could have two labels, but that just complicates code and brings unwanted overhead, so let's use the same label.
This week, Christmas arrived early for developers. Swift is now open source, it has a package manager, there is a dedicated evolution / roadmap repo for it (the changes for 3.0 look really nice) and Apple already accepted a lot of pull requests.
Can't wait to see what will happen with Swift in the next year or so, but I do know its future looks bright and it looks like others feel the same, even more so than me.
I recently saw Joe's post about updating Xcode plug-ins, but since I'm really lazy, updating them one by one didn't suffice, so here's my take on it. In case you want to skip straight to the desert, here's the gist.
First, we change our script's directory:
# You might need these.# require 'pathname'# require 'fileutils'