Skip to content

Instantly share code, notes, and snippets.

View dchest's full-sized avatar
☮️

Dmitry Chestnykh dchest

☮️
View GitHub Profile
@dchest
dchest / main.go
Created April 26, 2011 08:59
Program that fetches URL, inlines images, css and js and saves the result in HTML file. It's not finished, some inlining doesn't work.
package main
import (
"fmt"
"http"
"flag"
"os"
"bytes"
"io"
"encoding/base64"
// Copyright 2010 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package main
import (
"crypto/aes"
"crypto/cipher"
"compress/gzip"
@dchest
dchest / meet.go
Created July 3, 2011 09:06
Example of meet-in-the-middle attack
// Written by Dmitry Chestnykh. Public domain.
package main
import (
"crypto/blowfish"
"fmt"
"time"
)
func encrypt(key uint8, src string) string {
@dchest
dchest / meet.c
Created July 3, 2011 18:10
Example of meet-in-the-middle attack (in C)
/* Written by Dmitry Chestnykh. Public domain. */
#include <err.h>
#include <stdint.h>
#include <stdio.h>
#include <string.h>
#include <time.h>
#include <openssl/blowfish.h>
#include <openssl/lhash.h>
/* Encryption and decryption */
@dchest
dchest / style.css
Created September 9, 2011 23:43
Stylebot CSS for new Google Groups
div.GOFTCUUBI3 {
min-height: 0;
}
div.GOFTCUUBJ3.GOFTCUUBGW {
padding: 5px;
height: 30px;
}
div.GOFTCUUBEE.GOFTCUUBCE.GOFTCUUBE4 {
@dchest
dchest / gist:1363656
Created November 14, 2011 10:08
rst-to-html (emacs)
(defun rst-to-html ()
"Convert current file from reStructuredText to HTML, outputting to file.html."
(interactive)
(when (not (stringp (buffer-file-name)))
(error "No file name"))
(message "Running...")
(shell-command
(concat "rst2html -d "
(shell-quote-argument (buffer-file-name))
@dchest
dchest / gist:1535291
Created December 29, 2011 18:00
N. Wirth - Good Ideas, Through the Looking Glass 2005 (extract)
5.5. Using wrong tools
Using the wrong tools is obviously an intrinsically bad idea. The trouble is
that often one discovers a tool’s inadequacy only after having invested a
substantial amount of effort to 24 build and understand it, and the tool thus
having become “valuable”. This happened to the author and his team when
implementing the first Pascal compiler in 1969.
The tools available for writing programs were an assembler, a Fortran and an
Algol compiler. The latter was so poorly implemented that we did not dare rely
@dchest
dchest / gist:3226624
Created August 1, 2012 12:54
Provisional format, subject to change.
MASTER CARD format:
1 byte | 1 byte | 2 bytes | 2 bytes | 32 bytes | 32 bytes | 16 bytes | 6 bytes | 8 bytes
=======|========|=========|=========|==========|***********************|=========|========
version| logN | r | p | salt | enc key | mac key | hash | MAC
-------|---------------------------------------|-----------------------|---------|--------
| blakrypt parameters |encrypted with nonce=0 |
enc key, mac key -- randomly generated keys for cards
(stored in Master card encrypted and authenticated with keys derived from password.)
@dchest
dchest / gist:3294120
Created August 8, 2012 10:35
Из Генри Форд - "Моя жизнь. Мои достижения" (http://lib.ru/MEMUARY/ZHZL/ford.txt)
Мы изучаем каждый чужой автомобиль,
который появляется на свет, чтобы открыть детали, которые могут быть
разработаны дальше или приспособлены к нашим автомобилям. Если кто-нибудь
работает лучше нас, мы, по крайней мере, хотим это знать и для этого
покупаем по экземпляру каждого, вновь выходящего автомобиля. Обыкновенно на
автомобиле некоторое время ездят и пробуют его, затем разбирают на части и
точно исследуют, чтобы установить, как и из чего сконструирована каждая
часть. Где-нибудь по соседству от Дирборна можно встретить образец каждого
автомобиля, который фабриковался когда-либо на свете. Время от времени,
когда мы опять покупаем новый автомобиль, об этом печатают в газетах и
@dchest
dchest / CRTransparentSearchFieldCell.h
Created August 15, 2012 19:46
CRTransparentSearchFieldCell -- transparent search field cell
#import <Cocoa/Cocoa.h>
@interface CRTransparentSearchFieldCell : NSSearchFieldCell
@end