Skip to content

Instantly share code, notes, and snippets.

View krono's full-sized avatar

Tobias Pape krono

View GitHub Profile
from pypy.rlib.parsing.tree import Node as PyNode
from pypy.rlib.parsing.lexer import SourcePos
class Node(PyNode):
def __init__(self, source_position=None):
self.source_position = source_position or SourcePos(-1,-1,-1)
def __eq__(self, other): pass #...
[14:41:04]ζtobias@Claudio ± structs
~/dev/pypy/pycket % ./pycket-c binarytrees-generic-boolean.rkt 18
stretch tree of depth 19 check: 1
524288 trees of depth 4 check: 262144
131072 trees of depth 6 check: 65536
32768 trees of depth 8 check: 16384
8192 trees of depth 10 check: 4096
2048 trees of depth 12 check: 1024
512 trees of depth 14 check: 256
128 trees of depth 16 check: 64
--- binarytrees-generic.rkt 2015-10-28 11:06:42.000000000 +0100
+++ binarytrees-generic-boolean.rkt 2015-10-28 11:51:04.000000000 +0100
@@ -14,15 +14,15 @@
(define-syntax leaf? (make-rename-transformer #'*leaf?))
(define-syntax node (make-rename-transformer #'*node))
(define-syntax node? (make-rename-transformer #'*node?))
-(define-syntax-rule (leaf-val l) (*leaf-val l))
+(define-syntax-rule (leaf-val l) (if (*leaf-val l) 0 1))
(define-syntax-rule (node-left n) (*node-left n))
(define-syntax-rule (node-right n) (*node-right n))
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@krono
krono / fix-brew-outdated-gettext.sh
Created March 31, 2013 17:04
Gettext via brew was updated and the old one cleaned, yet, some libs still directly linked to the old gettext directly. This gist fixes this problems by reinstalling all affected packages.
#!/bin/bash
pushd /usr/local/lib
for package in $(
for i in *.dylib; do
if otool -L $i | grep -q gettext/0.18.1.1; then
# get pacakge out ouf library
echo $(basename $(dirname $(dirname $(dirname $(readlink $i)))));
fi;
@krono
krono / dotify-package-deps.st
Last active December 20, 2015 07:18 — forked from frankshearar/dotify-package-deps.st
Make a dot/graphviz-file from the package-dependencies in Squeak
| allDeps toDigraph |
"Avoid artifacts"
MCWorkingCopy flushObsoletePackageInfos.
PackageOrganizer default flushObsoletePackages: [:p |
p classes size = 0 and: [p methods size = 0]].
Smalltalk garbageCollect.
""
toDigraph := [:hash | | s |
s := WriteStream on: String new.
s nextPutAll: 'digraph {'; lf.
#include <stdio.h>
void foo(void) {
static int barf=10;
barf++;
}
int main()
{
printf("test: %d\n", (int)foo());
@krono
krono / ban-ssh.sh
Last active November 21, 2016 22:55
Ban everyone who tries SSH (inspiration: http://huschi.net/14_360_de-portscan-honeypot-mit-iptables.html )
#!/bin/sh
PORT=22
TIMEOUT=600
for IPTABLE in iptables ip6tables; do
case "${IPTABLE}" in
iptables) LOCALHOST="127.0.0.1";;
ip6tables) LOCALHOST="::1";;
esac
'From Squeak5.0 of 15 January 2016 [latest update: #15117] on 4 February 2016 at 1:52:02 pm'!
Object subclass: #RSqueak
instanceVariableNames: ''
classVariableNames: ''
poolDictionaries: ''
category: 'RSqueak'!
!AutoStart class methodsFor: 'initialization' stamp: 'tfel 2/4/2016 13:09'!
startUp: resuming
"The image is either being newly started (resuming is true), or it's just been snapshotted.
"-=-=-=-=-="
" This gets us Metacello "
"-=-=-=-=-="
Installer gemsource
project: 'metacello';
addPackage: 'ConfigurationOfMetacello';
install.
"Bootstrap Metacello Preview, using mcz files (#'previewBootstrap' symbolic version"