Skip to content

Instantly share code, notes, and snippets.

View frankshearar's full-sized avatar
💭
(╬ ಠ益ಠ) THE WIND CRIED LAMENTATION BEFORE MERGING WITH THE GRAVE

Frank Shearar frankshearar

💭
(╬ ಠ益ಠ) THE WIND CRIED LAMENTATION BEFORE MERGING WITH THE GRAVE
View GitHub Profile
@frankshearar
frankshearar / class-level-deps.st
Created July 24, 2013 10:22
On what classes does some particular class depend?
| classDeps |
classDeps := [:cls |
(cls methodDict values gather: [:cm |
(((1 to: cm numLiterals) collect: [:i | cm literalAt: i])
select: [:lit | lit isVariableBinding and: [lit value isBehavior]])
collect: #value]) asSet difference: {cls}].
classDeps value: TextComposer
@frankshearar
frankshearar / dotify-package-deps.st
Last active December 18, 2015 12:19
Visualising package dependencies in Squeak
| allDeps toDigraph |
toDigraph := [:hash | | s |
s := WriteStream on: String new.
s nextPutAll: 'digraph {'; lf.
hash keysAndValuesDo: [:pkg :pkgDeps |
pkgDeps do: [:dep |
(pkg includesSubString: 'Test')
ifTrue: [s nextPutAll: ' "'; nextPutAll: pkg; nextPutAll: '" [color="gray"]'; lf].
s nextPutAll: ' "'; nextPutAll: pkg; nextPutAll: '" -> "'; nextPutAll: dep; nextPutAll: '"'.
(pkg includesSubString: 'Test') ifTrue: [s nextPutAll: ' [color="gray"]'].
@frankshearar
frankshearar / gist:1716687
Created February 1, 2012 11:41
4x4-1's pitiful strategy: place your ships in the lower half of the map
(ns battleships.demo)
;; This is an example of how to create a player to submit to the server.
;; The entire namespace is submitted to the server.
;; You submit the file using the submit function in the client namespace.
(defn- random-coord
"Generates a random valid coordinate."
[]
(let [rows ["A" "B" "C" "D" "E" "F" "G" "H" "I" "J"]
@frankshearar
frankshearar / gist:1632449
Created January 18, 2012 11:01
Bootstrapping LanguageBoxes from Squeak 4.3
"===== Set up Squeak's compiler correctly ====="
Scanner prefAllowUnderscoreSelectors: true.
Scanner allowUnderscoreAsAssignment: false.
"===== Things that Squeak needs from Pharo ====="
Installer cache
addPackage: 'Pharo-Compatibility-fbs.1';
addPackage: 'VB-Regex-AdrianLienhard.48';
install.
@frankshearar
frankshearar / fake-http-context.cs
Created February 21, 2011 21:28
A Moq-using fake HTTP context to test controllers.
public HttpContextBase FakeHttpContext() {
var context = new Mock<HttpContextBase>();
var files = new Mock<HttpFileCollectionBase>();
var request = new Mock<HttpRequestBase>();
var response = new Mock<HttpResponseBase>();
var session = new Mock<HttpSessionStateBase>();
var server = new Mock<HttpServerUtilityBase>();
var user = new Mock<IPrincipal>();
var identity = new Mock<IIdentity>();
request.Setup(req => req.ApplicationPath).Returns("~/");