Skip to content

Instantly share code, notes, and snippets.

//
// XPathQuery.m
//
// Created by Matt Gallagher on 4/08/08.
// Modified by Matt Bauman on 12/01/09 to ignore attributes and simplify the
// created data structure (depends upon the NSDictionary Category method
// - (void)addObject:forKey: below).
// Copyright 2008 Matt Gallagher. All rights reserved.
//
// Permission is given to use this source code file, free of charge, in any
@mbauman
mbauman / gist:770529
Created January 8, 2011 03:55
Reduce the zoom increment in WebKit
Index: WebKit/mac/WebView/WebView.mm
===================================================================
--- WebKit/mac/WebView/WebView.mm (revision 75189)
+++ WebKit/mac/WebView/WebView.mm (working copy)
@@ -3458,7 +3458,7 @@
#define MinimumZoomMultiplier 0.5f
#define MaximumZoomMultiplier 3.0f
-#define ZoomMultiplierRatio 1.2f
+#define ZoomMultiplierRatio 1.06265857f
@mbauman
mbauman / mac-bash-completion.patch
Created February 23, 2011 02:50
A patch to bash-completion version 1.3 (http://bash-completion.alioth.debian.org/). Adds completions for Mac OS X specific utilities: defaults, launchctl, open, and xcodebuild. Additionally, it properly enables killall.
diff -Naur bash-completion-1.3/completions/Makefile.am bash-completion-1.3-mac/completions/Makefile.am
--- bash-completion-1.3/completions/Makefile.am 2011-01-21 04:36:11.000000000 -0500
+++ bash-completion-1.3-mac/completions/Makefile.am 2011-02-22 22:02:25.000000000 -0500
@@ -33,6 +33,7 @@
cvs \
cvsps \
dd \
+ defaults \
dhclient \
dict \
diff --git a/src/unexmacosx.c b/src/unexmacosx.c
index df4c0da..d6f170c 100644
--- a/src/unexmacosx.c
+++ b/src/unexmacosx.c
@@ -822,6 +822,7 @@ copy_data_segment (struct load_command *lc)
}
else if (strncmp (sectp->sectname, "__la_symbol_ptr", 16) == 0
|| strncmp (sectp->sectname, "__nl_symbol_ptr", 16) == 0
+ || strncmp (sectp->sectname, "__got", 16) == 0
|| strncmp (sectp->sectname, "__la_sym_ptr2", 16) == 0
function postKeyEvent
import java.awt.event.KeyEvent
import java.util.Calendar
import java.lang.reflect.*
cmdwin = handle(com.mathworks.mde.desk.MLDesktop.getInstance.getClient('Command Window').getComponent(0).getComponent(0).getComponent(0),'CallbackProperties');
cal = Calendar.getInstance();
tnow = cal.getTime().getTime();
@mbauman
mbauman / argPrecedence.m
Created October 8, 2013 17:49
Simple Matlab utility to test and return the relative precedence of the given arguments. Inspired by Matt J's answer to the Matlab Answers question "How can I determine if one class is superior or inferior to another?" (http://www.mathworks.com/matlabcentral/answers/89208)
function [priority,classes] = argPrecedence(varargin)
% argPrecedence Return the relative class priority of the arguments
%
% Returns an array the same size as the argument list with each argument's
% relative priority level, with 1 as the highest.
%
% Optionally returns a second output of class names, with the unique classes
% of the argument list arranged in priority order.
%
% Note that the priority is dependent both on argument position and class.
@mbauman
mbauman / MatlabClasses.ipynb
Last active April 23, 2023 14:33
Documenting how to parse Matlab's opaque class structure for MAT files with Julia.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
julia> showall({"key$(i)" => randn(i,i) for i = 1:10})
Dict{Any,Any} with 10 entries:
"key6" => [0.7995137897612783 0.30301616050643354 -1.8242713165721007 -0.12085866079321517 -0.40016169770670645 -0.5231178478762234
1.328503819968753 0.452169193705579 0.11451815072694968 0.0018399482002831712 -1.846160890880193 0.4004558749903179
-1.7262858694496896 1.0163474789812468 0.7067600121148212 -0.4325724176628864 1.4279773418198034 0.6912539911447593
-1.4639758553884066 0.0962424010955328 1.0407232303631846 0.2340051334746554 0.46459256657155956 2.078259553003987
0.3073885311320213 0.8293793724443539 0.173905175998053 1.0541936463592403 1.6442529959343 -0.48446355061672663
-0.28691097504615776 0.23344891866376682 -0.6616365768644663 -0.49540419054307655 0.6288523988607045 -0.609976438451507]
"key9" => [-0.5551848781968902 -1.212184407152184 -0.028042351757473567 0.5194117970945017 -0.6460925612400668 0.4332683925961238 1.7095535835793614 -0.6682514118077872 1.6739508392869977
-1.4666570108790773 0.103742
julia> {"key$(i)" => randn(i,i) for i = 1:10}
{"key8"=>8x8 Array{Float64,2}:
-2.12749 -0.752214 0.492932 … -1.15896 -0.469876 -0.473766
0.591607 0.781237 -0.882523 -1.04401 -0.847492 1.46561
0.261209 1.07582 1.38244 2.45793 -1.72707 1.86853
1.77907 1.49788 -1.9545 -0.0986327 -1.00464 0.265882
0.890266 0.151234 0.0375418 0.250334 -0.857636 0.593363
-0.0338993 -0.465015 0.342204 … 0.701575 -0.506198 -1.8893
-1.1662 0.318207 0.961944 0.514062 -0.301675 0.768447
-0.946939 0.823065 1.35655 -0.55687 -0.28025 -0.125624,"key6"=>6x6 Array{Float64,2}:
@mbauman
mbauman / .juliarc.jl
Last active August 29, 2015 14:03
juliarc
module RC
## Method sorting: https://github.com/JuliaLang/julia/pull/6119 (closed wontfix)
Base.isless(a::Method, b::Method) = isless(a.func.code.name, b.func.code.name)
## Simplify life when calling methodswith. I always do it wrong.
Base.methodswith(x, showparents::Bool=false) = methodswith(typeof(x), showparents)
if VERSION < v"0.3-"
ENV["JULIA_HISTORY"] = joinpath(homedir(), "~/.julia_history_v0.2")