Skip to content

Instantly share code, notes, and snippets.

View thexande's full-sized avatar

Alexander Murphy thexande

  • Ibotta
  • Denver, CO, USA, Planet Earth
View GitHub Profile
@bkeating
bkeating / howto-filemerge-git-osx.md
Created March 11, 2010 21:36
HOWTO: Using FileMerge (opendiff) with Git on OSX

HOWTO: Using FileMerge (opendiff) with Git on OSX

FileMerge (opendiff) can really come in handy when you need to visually compare merging conflicts. Other times it's just a nice visual way to review your days work.

The following method works by creating a simple bash script (git-diff-cmd.sh) that sets us up with the proper command line arguments for Git to pass off files to FileMerge.

@Digitalchemy
Digitalchemy / CropImage.cs
Created February 6, 2011 06:21
iOS: Crop a UIImage to the specified Rect
// Crop a UIImage to the specified cropRect
public UIImage CropImage(UIImage image, RectangleF cropRect)
{
UIGraphics.BeginImageContextWithOptions(cropRect.Size, false, 0);
var context = UIGraphics.GetCurrentContext();
context.TranslateCTM(0.0f, image.Size.Height);
context.ScaleCTM(1.0f, -1.0f);
context.DrawImage(new RectangleF(0, 0, image.Size.Width, image.Size.Height), image.CGImage);
context.ClipToRect(cropRect);
@hjst
hjst / gist:1326755
Last active November 21, 2018 05:22
Format a javascript Date object as a 12h am/pm time string.
function format_time(date_obj) {
// formats a javascript Date object into a 12h AM/PM time string
var hour = date_obj.getHours();
var minute = date_obj.getMinutes();
var amPM = (hour > 11) ? "pm" : "am";
if(hour > 12) {
hour -= 12;
} else if(hour == 0) {
hour = "12";
}
@chrisdarroch
chrisdarroch / idea
Created October 17, 2013 03:40
Open a project in IntelliJ IDEA from your command line!
#!/bin/sh
# check for where the latest version of IDEA is installed
IDEA=`ls -1d /Applications/IntelliJ\ * | tail -n1`
wd=`pwd`
# were we given a directory?
if [ -d "$1" ]; then
# echo "checking for things in the working dir given"
wd=`ls -1d "$1" | head -n1`
@rob-murray
rob-murray / set_agv_ver.sh
Last active July 1, 2022 01:31
Use agvtool to set Xcode project build number
#!/bin/bash
#
# Use agvtool to set Xcode project build number and create git tag
# Note: requires Xcode project configured to use Apple Generic Versioning and git
#
# Usage: set_agv_ver.sh 123
#
# src: https://gist.github.com/rob-murray/8644974
#
@shaps80
shaps80 / dev-scripts.sh
Last active December 7, 2021 15:24
Open Xcode and AppCode projects from the command line. I recommend keeping this in a separate file and just importing the code into your bash_profile using: source ~/.dev-scripts.sh
#!/usr/bin/env bash
function openWorkspaceOrProjectWithApp()
{
if [[ -z "$1" || "$#" -ne 2 ]]; then
echo -e "Nothing found\n"
return
fi
IDEFileName=${2##*/}
@rubenroques
rubenroques / FuzzySearch.swift
Last active April 29, 2018 16:03
Fuzzy String Search in Swift
func fuzzySearch(var originalString: String, var stringToSearch: String, caseSensitive: Bool = false)->Bool {
if countElements(originalString)==0 || countElements(stringToSearch)==0 {
return false
}
if countElements(originalString) < countElements(stringToSearch) {
return false
}
@mbigatti
mbigatti / UIColor+RGB.swift
Last active February 14, 2021 07:22
UIColor extension that add a whole bunch of utility functions.
//
// UIColor+RGB.swift
// Copyright (c) 2014 Massimiliano Bigatti. All rights reserved.
//
import Foundation
import UIKit
/**
UIColor extension that add a whole bunch of utility functions like:
@nvkiet
nvkiet / [Swift] Switch-RootViewController
Last active June 21, 2023 12:35
Switch root view controller
func switchRootViewController(rootViewController: UIViewController, animated: Bool, completion: (() -> Void)?) {
if animated {
UIView.transitionWithView(window, duration: 0.5, options: .TransitionCrossDissolve, animations: {
let oldState: Bool = UIView.areAnimationsEnabled()
UIView.setAnimationsEnabled(false)
self.window!.rootViewController = rootViewController
UIView.setAnimationsEnabled(oldState)
}, completion: { (finished: Bool) -> () in
if completion {
completion!()
import Foundation
extension String
{
var length: Int {
get {
return countElements(self)
}
}