Skip to content

Instantly share code, notes, and snippets.

View martinpi's full-sized avatar

Martin Pichlmair martinpi

View GitHub Profile
@martinpi
martinpi / CorrectAspectRatio.cs
Created March 4, 2019 15:39
Use screen width instead of height as reference for scaling orthographic size of a Unity camera. Especially useful for supporting a wide range of mobile phones.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
/* Camera usually uses screen height as their reference for orthographic size.
This script makes it scale with width instead.
*/
public class CorrectAspectRatio : MonoBehaviour {
@martinpi
martinpi / AutocompleteView.swift
Created November 5, 2018 13:41
An autocomplete popup for text entry. Ported to Swift from this example: https://github.com/danjonweb/NCRAutocompleteTextView
//
// AutocompleteView.swift
//
// Originally created by Daniel Weber on 9/28/14.
// Copyright (c) 2014 Null Creature. All rights reserved.
// Ported to Swift by Martin Pichlmair 2018
//
import Cocoa
@martinpi
martinpi / SyntaxHighlighter.swift
Created October 13, 2018 14:27
A simple Swift 4.0 class for syntax highlighting in an NSTextView
//
// SyntaxHighlighter.swift
// CardsCardsCards
//
// Created by Martin Pichlmair on 12/10/2018.
//
// Based on https://raw.githubusercontent.com/kuyawa/Macaw/master/Macaw/Macaw.swift
import Cocoa
@martinpi
martinpi / sync-git.sh
Created September 17, 2018 10:00
Update all my copies of Unitilities to the most recent commit
#!/bin/bash
find /Users/pi/Projects -name "Unitilities" -exec sh -c '
for file do
echo "\033[0;32m[ Updating $file ]\033[0m"
cd "$file"
git pull
done
' sh {} +
@martinpi
martinpi / init.sh
Created September 10, 2018 11:24
A little script I use to init git repositories (including those hosted on GitHub and BitBucket). You have to register a push-enabled public key first and it expects a .gitignore and some utility libraries in the same folder.
# usage
# init.sh <repository> <folder>
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )"
if [ -d $2/Assets ]; then
echo "Setting up git repository $1"
else
echo "An init script for git hosted Unity projects"
echo "Usage: init.sh <repository> <folder>"
@martinpi
martinpi / gist:c84d5530dafb73b5a9815768f5f9a160
Created August 25, 2017 09:48
Import a folder of text files into Evernote (OSX/AppleScript)
tell application "Finder"
set fl to files of folder POSIX file "/Users/pi/Desktop/VoodoopadExport" as alias list
end tell
repeat with f in fl
set theText to (do shell script "cat " & quoted form of (POSIX path of f))
set theName to (do shell script "basename " & quoted form of (POSIX path of f))
tell application "Evernote"
create note with text theText title theName notebook "private" tags "VoodooPad"
end tell
end repeat