Skip to content

Instantly share code, notes, and snippets.

View tmandry's full-sized avatar

Tyler Mandry tmandry

View GitHub Profile
@tmandry
tmandry / configure.diff
Created April 22, 2013 04:31
Getting the octave-forge java package (v1.2.9) to install on OS X Lion. See below for instructions and more information.
--- /tmp/java/src/configure 2012-07-25 11:34:49.000000000 -0500
+++ configure 2013-04-21 22:56:40.000000000 -0500
@@ -1,4 +1,4 @@
-#! /bin/sh
+#! /bin/bash
# Guess values for system-dependent variables and create Makefiles.
# Generated by GNU Autoconf 2.65.
#
@@ -3252,9 +3252,10 @@
java_version=`$JAVA -version 2>&1 | sed -n -e 's/^java version[^0-9"]*"\([^"]*\)"/\1/p'`
@tmandry
tmandry / bfs.pro
Last active April 12, 2020 20:01
Prolog Breadth First Search
% Breadth-first search with a list of possible destinations (picks the closest first.)
bfs(Dests, [[Target,Path,Cost]|_], Target, Path, Cost):- member(Target, Dests).
bfs(Dests, [[N,P,C]|Queue], Target, Path, Cost):-
setof([Child,Pp,Cp], child(N, P, C, Child, Pp, Cp), Children),
append(Queue, Children, NextQueue),
bfs(Dests, NextQueue, Target, Path, Cost).
child(N0, P0, C0, N, P, C):-
arc(N0, N, Len),
append(P0, [N], P),
C is C0 + Len.
@tmandry
tmandry / .phoenix.js
Created May 18, 2014 23:48
i3-like Phoenix configuration: focusing, fullscreen, marks
// Move windows between monitors, taken from jakemcc's config
function moveToScreen(win, screen) {
if (!screen) {
return;
}
var frame = win.frame();
var oldScreenRect = win.screen().frameWithoutDockOrMenu();
var newScreenRect = screen.frameWithoutDockOrMenu();
@tmandry
tmandry / windowTracker.lua
Created December 21, 2014 08:30
Track all window open, close, move, and resize events using Hammerspoon
local events = hs.uielement.watcher
watchers = {}
function init()
appsWatcher = hs.application.watcher.new(handleGlobalAppEvent)
appsWatcher:start()
-- Watch any apps that already exist
local apps = hs.application.runningApplications()
@tmandry
tmandry / windowtracker.lua
Created May 27, 2015 17:07
windowtracker
--- === windowtracker ===
--- Track all windows on the screen.
---
--- You can watch for the following events:
--- * windowtracker.windowCreated: A window was created.
--- * windowtracker.windowDestroyed: A window was destroyed.
--- * windowtracker.mainWindowChanged: The main window was changed. This is usually the same as the
--- focused window, except for helper dialog boxes like file open windows and the like, which are
--- not reported by this event.
--- * windowtracker.windowMoved: A window was moved.
@tmandry
tmandry / msbuild.bzl
Created November 15, 2017 04:46
vcxproj generation from bazel aspect
def _expand_items(items):
return '\n'.join(items)
def _msb_project(*items):
return ("""<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
@tmandry
tmandry / errors.txt
Created April 7, 2018 20:06
rustc type inference error
Running `rustc --crate-name core src/lib.rs --crate-type lib --emit=dep-info,link -C debuginfo=2 -C metadata=dc98e8200778de86 -C extra-filename=-dc98e8200778de86 --out-dir /Users/tyler/code/rust/rust-core-template/target/debug/deps -C incremental=/Users/tyler/code/rust/rust-core-template/target/debug/incremental -L dependency=/Users/tyler/code/rust/rust-core-template/target/debug/deps`
error[E0282]: type annotations needed
--> src/iterator.rs:25:16
|
25 | val == LoopState::Continue(())
| ^^^^^^^^^^^^^^^^^^^ cannot infer type for `B`
error: aborting due to previous error
For more information about this error, try `rustc --explain E0282`.
@tmandry
tmandry / iterator.rs
Created April 8, 2018 00:27
rustc type inference error 2
#[lang = "sized"]
#[fundamental]
pub trait Sized {
}
pub trait Clone : Sized {
fn clone(&self) -> Self;
}
#[lang = "copy"]
@tmandry
tmandry / watch_spaces.swift
Last active March 29, 2022 21:22
Getting Spaces and their order for each display
var observer: Observer!
func stuff() {
guard let database = UserDefaults.init(suiteName: "com.apple.spaces") else {
fatalError("cannot read spaces data")
}
print(String(describing: database.object(forKey: "SpacesDisplayConfiguration")))
observer = Observer(object: database)
}
class Observer: NSObject {
@tmandry
tmandry / make_border.swift
Created November 1, 2018 23:01
Creating window borders for a WM
var win: NSWindow!
func makeWindow() {
let rect = NSRect(x: 1000, y: 1000, width: 400, height: 300)
win = NSWindow(contentRect: rect, styleMask: .borderless, backing: .buffered, defer: false)
win.center()
win.level = .floating
win.hasShadow = false
win.backgroundColor = NSColor.clear
win.animationBehavior = .none
win.ignoresMouseEvents = true