Skip to content

Instantly share code, notes, and snippets.

abstract class Registry<H extends Handler>{
//абстрактный метод
void register(String s, H h);
//наш обобщенный код
void registerList(String s, List<H> hs){
for(H h: hs)
register(s,h);
}
}
@anton0xf
anton0xf / stdin.txt
Created July 4, 2012 08:18 — forked from anonymous/stdin.txt
stdin
sed -n 's/[^<>]*<[ \t\n]*set[ \t\n]\+value='\''\([^'\'']*\)'\''[ \t\n]\+name='\''\([^'\'']*\)'\''[ \t\n]*\/>[^<>]*/\n\$\$"\1","\2"\n/pg' test | sed -n 's/^\$\$\(.*\)$/\1/p;'
CL-USER> (defun filtered (hash &optional (filter-condition t))
(let ((res '()))
(maphash #'(lambda (k v)
(if (funcall filter-condition k v)
(push v res)))
hash)
res))
CL-USER> (defparameter *hash* (make-hash-table))
CL-USER> (dotimes (i 10) (setf (gethash i table) i))
CL-USER> (filtered *hash*
#!/bin/sh
if [ -z "$2" ]; then
echo "usage: git-cp-in-history FILE DIR"
exit 1
fi
FNAME="$1"
DNAME="$2"
git filter-branch --tree-filter \
'if [ ! -d "'"$DNAME"'" ]; then mkdir "'"$DNAME"'"; fi; '\
'if [ -f "'"$FNAME"'" -a ! -h "'"$FNAME"'" ]; then cp "'"$FNAME"'" "'"$DNAME"'"; fi' -- --all
(progn (load "/usr/share/emacs/site-lisp/slime-archimag/swank-loader.lisp" :verbose t) (funcall (read-from-string "swank:start-server") "/tmp/slime.2380" :coding-system "utf-8-unix"))
This is SBCL 1.0.55, an implementation of ANSI Common Lisp.
More information about SBCL is available at <http://www.sbcl.org/>.
SBCL is free software, provided as is, with absolutely no warranty.
It is mostly in the public domain; some portions are provided under
BSD-style licenses. See the CREDITS and COPYING files in the
distribution for more information.
STYLE-WARNING: redefining ASDF::LISP-VERSION-STRING in DEFUN
@anton0xf
anton0xf / TestList.java
Created June 19, 2012 18:09
Java Generics example.
import java.util.*;
class A{ public int i; }
class B extends A { public int j; }
public class TestList{
public static void main(String[] args){
A a = new A(); a.i = 1;
B b = new B(); b.i = 2; b.j = 3;
@anton0xf
anton0xf / gist:825659
Created February 14, 2011 09:29
emacs:rename-buffer-file
(defun rename-buffer-file (newname &optional ok-if-already-exists)
"rename visited file (buffer-file-name) to NEWNAME
and appropriately change buffer name (set-visited-file-name NEWNAME).
NEWNAME must be string.
Signals a `file-already-exists' error if a file NEWNAME already exists
unless optional third argument OK-IF-ALREADY-EXISTS is non-nil.
A number as third arg means request confirmation if NEWNAME already exists.
This is what happens in interactive use with M-x."
(interactive "FRename to: \np")