Skip to content

Instantly share code, notes, and snippets.

View jlott1's full-sized avatar

Jonathan Lott jlott1

View GitHub Profile
@alex-cellcity
alex-cellcity / Version.m
Created May 30, 2011 04:55
Runtime iOS Version Checking
/*
* System Versioning Preprocessor Macros
*/
#define SYSTEM_VERSION_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedSame)
#define SYSTEM_VERSION_GREATER_THAN(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedDescending)
#define SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedAscending)
#define SYSTEM_VERSION_LESS_THAN(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedAscending)
#define SYSTEM_VERSION_LESS_THAN_OR_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedDescending)
@praeclarum
praeclarum / DrawingScrollView.cs
Created June 24, 2011 00:37
A UIScrollView that draws sharp dynamic graphics at any zoom scale
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using MonoTouch.CoreAnimation;
using MonoTouch.CoreGraphics;
using MonoTouch.UIKit;
namespace ScrollViewExperiments
{
@akisute
akisute / gist:1141953
Created August 12, 2011 12:41
Create an animated gif file from images in iOS
#import <UIKit/UIKit.h>
#import <ImageIO/ImageIO.h>
#import <MobileCoreServices/MobileCoreServices.h>
- (void)exportAnimatedGif
{
UIImage *shacho = [UIImage imageNamed:@"shacho.png"];
UIImage *bucho = [UIImage imageNamed:@"bucho.jpeg"];
NSString *path = [[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject] stringByAppendingPathComponent:@"animated.gif"];
@nfreear
nfreear / orbiter-micro-chat.html
Created June 16, 2012 07:14
Union Platform / OrbiterMicro / NDF, 28 May 2012 / http://www.unionplatform.com/?page_id=1587
<!doctype html><html lang="en"><meta charset=utf-8 /><title>*OUnion client demo</title>
<!--
Union Chat for Javascript - improved..
Copyright N.D.Freear, 28 May 2012
* Accessibility improvements
* URL auto-linking
* Colour
http://unionplatform.com/samples/orbitermicro/UnionChatPart1/chat.html
-->
@mayoff
mayoff / Arrow.swift
Last active May 13, 2022 07:30
UIBezierPath category to create an arrow (now with a Swift version!)
// Swift 2.2 syntax / API
import UIKit
extension UIBezierPath {
class func arrow(from start: CGPoint, to end: CGPoint, tailWidth: CGFloat, headWidth: CGFloat, headLength: CGFloat) -> Self {
let length = hypot(end.x - start.x, end.y - start.y)
let tailLength = length - headLength
@mayoff
mayoff / ArrowLayer.h
Created November 27, 2012 06:44
A CALayer subclass that draws a very simple arrow
#import <QuartzCore/QuartzCore.h>
@interface ArrowLayer : CALayer
@property (nonatomic) CGFloat thickness;
@property (nonatomic) CGFloat startRadians;
@property (nonatomic) CGFloat lengthRadians;
@property (nonatomic) CGFloat headLengthRadians;
@property (nonatomic, strong) UIColor *fillColor;
@dblandin
dblandin / activate_tab.applescript
Last active September 29, 2023 16:26
AppleScript to grab a list of tab titles from Google Chrome.
# Activate tab
# $ osascript activate_tab.applescript 1, 2
on run argv
set window_index to item 1 in argv
set target_index to item 2 in argv
tell application "Google Chrome" to set active tab index of first window to target_index
tell application "Google Chrome" to activate
end run
@vitorgalvao
vitorgalvao / Get Title and URL.applescript
Last active May 6, 2024 04:49
AppleScript and JavaScript for Automation to get frontmost tab’s url and title of various browsers.
-- AppleScript --
-- This example is meant as a simple starting point to show how to get the information in the simplest available way.
-- Keep in mind that when asking for a `return` after another, only the first one will be output.
-- This method is as good as its JXA counterpart.
-- Webkit variants include "Safari", "Webkit", "Orion".
-- Specific editions are valid, including "Safari Technology Preview".
-- "Safari" Example:
tell application "Safari" to return name of front document
@Shilo
Shilo / XDGLScrollView.h
Last active December 22, 2015 12:39
A UIScrollView subclass that will allow a specified GLKViewController to continue rendering, while scrolling.
//
// XDGLScrollView.h
// A scroll view that will allow a specified GLKViewController to continue rendering, while scrolling.
//
// Created by Shilo White on 9/7/13.
// Copyright (c) 2013 XIDA Design & Technik. All rights reserved.
//
#import <UIKit/UIKit.h>
@class GLKViewController;
@suruja
suruja / gist:10241312
Created April 9, 2014 08:27
Mongo dump and restore on Heroku
require 'uri'
namespace :mongo do
desc "Dump the production database and restore to development and staging databases."
task :dump_and_restore => :environment do
dev = URI.parse(ENV["MONGO_URI"])
prod = URI.parse(`heroku config:get MONGO_URI --remote production`)
prod_username, prod_password = prod.userinfo.split(':')