Skip to content

Instantly share code, notes, and snippets.

View martinpi's full-sized avatar

Martin Pichlmair martinpi

View GitHub Profile
@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
@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 / 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 / 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 / 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 / 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 / IncrementBuildNumber.cs
Created September 25, 2020 13:45
Automatically increment the iOS build number in Unity conforming to Apple's guidelines before every build. Be sure to drop into a folder name "Editor". Worked in autumn 2020.
using UnityEngine;
using UnityEditor.Build;
using UnityEditor.Build.Reporting;
using UnityEditor;
public class IncrementBuildNumber : IPreprocessBuildWithReport {
public int callbackOrder { get { return 0; } } // Part of the IPreprocessBuildWithReport interface
public void OnPreprocessBuild(BuildReport report) {
if (report.summary.platform == BuildTarget.iOS) {
@martinpi
martinpi / readme.txt
Created September 7, 2021 10:54
Simple Block Pushing Game (PuzzleScript Script)
Play this game by pasting the script in http://www.puzzlescript.net/editor.html
@martinpi
martinpi / readme.txt
Created September 7, 2021 11:00
Lilifee (PuzzleScript Script)
Play this game by pasting the script in http://www.puzzlescript.net/editor.html
@martinpi
martinpi / clean.py
Created January 17, 2022 16:17
A cleaning script for Gutenberg texts. Cleans a whole folder full of text files. Pretty rough around the edges but seems to work.
from gutenberg_cleaner import *
import getopt
import sys
import os
from pathlib import Path
argumentList = sys.argv[1:]
options = "hi:o:s"
long_options = ["help", "input", "output", "strip"]