Skip to content

Instantly share code, notes, and snippets.

@Geal
Geal / set native window position.st
Created February 1, 2011 16:29
how to control the native window size and position
HostWindowProxy new
instVarNamed: #windowHandle put: 1;
windowPosition: 0 @ 0;
windowSize: 800 @ 600;
windowTitle: 'Screencast'
@Geal
Geal / dump content of method.st
Created February 2, 2011 10:31
Displays only the body of a method (without prototype and comments)
| scriptMethod sourceString sourceStringWithBracketsStripped |
scriptMethod := CLASS_HERE compiledMethodAt: #METHOD_HERE.
sourceString := scriptMethod methodNode body asString.
sourceStringWithBracketsStripped := sourceString copyFrom: 3 to: sourceString size - 2.
sourceStringWithBracketsStripped.
@Geal
Geal / get selected space in a workspace.st
Created February 3, 2011 16:36
Retrieve the text currently selected in a workspace
SHWorkspace allInstances first codeTextMorph textMorph selection asString
@Geal
Geal / reverse window title
Created February 4, 2011 09:28
Reverse all the window titles (except for PluggableSystemWindow)
SystemWindow allInstancesDo:[:win| win setLabel: (win labelString reverse)]
@Geal
Geal / repl.st
Created May 24, 2011 09:04
A simple command line REPL (run it with a headless image)
OSProcess thisOSProcess stdOut
nextPutAll: 'Welcome to the simple Smalltalk REPL';
nextPut: Character lf; nextPut: $>; flush.
[ |input|
[ input := OSProcess readFromStdIn.
input size > 0 ifTrue: [
OSProcess thisOSProcess stdOut
nextPutAll: ((Compiler evaluate: input) asString;
nextPut: Character lf; nextPut: $>; flush
]
@Geal
Geal / about.md
Created August 10, 2011 09:15 — forked from jasonrudolph/about.md
Programming Achievements: How to Level Up as a Developer
@Geal
Geal / gist:1393956
Created November 25, 2011 16:50
Macro displaying __FUNCTION__ and __LINE__ and concatenating its arguments
#define STR(x) #x
#define STR1(x) STR(x)
#define DEBUGME(a) OutputDebugStringA( "[DEBUG| " __FUNCTION__ ":" STR1(__LINE__) "] " a "\n")
@Geal
Geal / robot.js
Created December 6, 2012 13:46
géo
//FightCode can only understand your robot
//if its class is called Robot
var Robot = function(robot) {
};
Robot.prototype.onIdle = function(ev) {
var robot = ev.robot;
robot.ahead(100);
@Geal
Geal / gist:7894264
Created December 10, 2013 17:11
Rust file usage
use std::rt::io::File;
use std::rt::io::buffered::BufferedReader;
[...]
let s:~str = ~"file.txt";
let mut strings:~[~str] = ~[];
let path = PosixPath::new(s);
let mut rdr = BufferedReader::new(File::open(&path).unwrap());
@Geal
Geal / gist:8228049
Last active January 2, 2016 01:09
rough threat model for group chat
# Threat model
## Attacker categories
### Security adversary
Wants to read messages he is not supposed to.
able to control communication channels and read/modify packets
### Consensus adversary