Skip to content

Instantly share code, notes, and snippets.

View mgadda's full-sized avatar

Matt Gadda mgadda

View GitHub Profile
@mgadda
mgadda / arpack_patch
Created November 21, 2010 03:38
ARPACK Patch in the form of a diff
diff --git a/EXAMPLES/BAND/cnband.f b/EXAMPLES/BAND/cnband.f
index ccecda5..7112fef 100644
--- a/EXAMPLES/BAND/cnband.f
+++ b/EXAMPLES/BAND/cnband.f
@@ -42,7 +42,7 @@ c
c \Usage
c call cnband
c ( RVEC, HOWMNY, SELECT, D , Z, LDZ, SIGMA, WORKEV, N, AB,
-c MB, LDA, FAC, KL, LU, WHICH, BMAT, NEV, TOL, RESID, NCV,
+c MB, LDA, FAC, KL, KU, WHICH, BMAT, NEV, TOL, RESID, NCV,
@mgadda
mgadda / clean_catch.sh
Created March 9, 2011 18:05
Run rake test on a clean working copy of your git-based rails project
#!/bin/bash
# If you're like me and don't always have a squeeky clean working copy, then
# it can be difficult to know for sure if your rails project's "rake test" is
# really returning the same results that your coworkers would see.
# This script clones a copy of whatever local git repository you're currently
# "in" (as reported by pwd), and runs the tests on the clean copy.
# Expect near silence if all goes well.
@mgadda
mgadda / pretty_format_json.rb
Created May 6, 2011 17:04
Pretty formatting for JSON within Rails 3 apps
#!/usr/bin/env ruby
=begin
Copyright (C) 2011 by Matt Gadda
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>bundleUUID</key>
<string>B7BC3FFD-6E4B-11D9-91AF-000D93589AF6</string>
<key>content</key>
<string>Bacon ipsum dolor sit amet biltong pork loin ball tip swine ground round sausage hamburger beef. Pastrami short ribs ribeye sirloin. T-bone tenderloin rump chuck pork pork chop, ham pork loin jerky tri-tip shank sausage jowl. Chuck jerky meatball pig venison. Meatloaf salami ham flank, hamburger tenderloin jerky beef pork sausage. Tenderloin swine ribeye, bresaola sausage biltong strip steak ham hock pork belly fatback beef shoulder. Flank venison ball tip, pastrami short loin meatball sirloin pork.</string>
<key>name</key>
<string>Bacon ipsum</string>
@mgadda
mgadda / Convert to HTML List.tmCommand
Created October 11, 2011 19:28
Convert plain text lists to HTML Lists
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>beforeRunningCommand</key>
<string>nop</string>
<key>bundleUUID</key>
<string>79DE1A1A-DCD0-4E2F-B20B-8FEFE97A7270</string>
<key>command</key>
<string>#!/usr/bin/env ruby
@mgadda
mgadda / .flowconfig
Created June 30, 2016 14:16
Why does line 16 of index.js produce a Flow error?
[ignore]
[include]
[libs]
[options]
@mgadda
mgadda / domEventHandlers.elm
Last active December 5, 2016 01:34
Conditional event handlers for key presses
module Util exposing (..)
import Html.Events exposing (on, keyCode)
import Html exposing (Attribute)
import Json.Decode as Json
import Dict exposing (Dict)
{-| Conditionally emit msg defined by `tagger` if the
key pressed was the enter key. Cannot be used with onEscape.
@mgadda
mgadda / IO.swift
Last active December 17, 2016 04:50
typealias RealWorld = Int
typealias IO<T> = (RealWorld) -> (T, RealWorld)
func putStrLn(_ str: String) -> IO<()> {
return { (world) in
print(str)
return ((), world + 1)
}
}
@mgadda
mgadda / output.log
Last active January 2, 2017 22:20
A simple but likely not fully distilled code snippet which produces swiftc segfault
> swiftc main.swift
0 swift 0x00000001094d13ad PrintStackTraceSignalHandler(void*) + 45
1 swift 0x00000001094d0b56 SignalHandler(int) + 790
2 libsystem_platform.dylib 0x00007fffa03fcbba _sigtramp + 26
3 libsystem_platform.dylib 0x00007fdef523a8a8 _sigtramp + 1424219400
4 swift 0x00000001066b979c swift::ASTVisitor<(anonymous namespace)::SILGenApply, void, void, void, void, void, void>::visit(swift::Expr*) + 4492
5 swift 0x00000001066be19e (anonymous namespace)::SILGenApply::visitApplyExpr(swift::ApplyExpr*) + 5166
6 swift 0x00000001066ac5f1 prepareApplyExpr(swift::Lowering::SILGenFunction&, swift::Expr*) + 273
7 swift 0x00000001066fd8b7 swift::ASTVisitor<(anonymous namespace)::RValueEmitter, swift::Lowering::RValue, void, void, void, void, void, swift::Lowering::SGFContext>::visit(swift::Expr*, swift::Lowering::SGFContext) + 103
8 swift 0x000000010675dfaa swift::Lowerin
@mgadda
mgadda / write_to_immutable_array.swift
Created January 11, 2017 19:35
How to write to an immutable array
let immutable = Array<Int32>(repeating: 0, count: 4) // => [0, 0, 0, 0]
let ptr = UnsafeMutablePointer<Int32>(mutating: immutable)
let mutableBuffer = UnsafeMutableBufferPointer(start: ptr, count: immutable.count * MemoryLayout<Int32>.size)
let data: Data = Data(bytes: [
0, 0, 0, 0,
1, 0, 0, 0,
2, 0, 0, 0,
3, 0, 0, 0])
data.copyBytes(to: mutableBuffer)
immutable // => [0, 1, 2, 3]