Skip to content

Instantly share code, notes, and snippets.

View dchest's full-sized avatar
☮️

Dmitry Chestnykh dchest

☮️
View GitHub Profile
@dchest
dchest / asmcrypto-sha512.js
Created October 15, 2014 20:37
asmCrypto.js SHA512 - from https://github.com/vibornoff/asmcrypto.js built: grunt --with sha512
!function(a,b){"use strict";function c(){var a=Error.apply(this,arguments);this.message=a.message,this.stack=a.stack}function d(){var a=Error.apply(this,arguments);this.message=a.message,this.stack=a.stack}function e(){var a=Error.apply(this,arguments);this.message=a.message,this.stack=a.stack}function f(a){for(var b=a.length,c=new Uint8Array(b),d=0;b>d;d++){var e=a.charCodeAt(d);if(e>>>8)throw new Error("Wide characters are not allowed");c[d]=e}return c}function g(a){for(var b="",c=0;c<a.length;c++)b+=String.fromCharCode(a[c]);return b}function h(a){for(var b=(a.byteLength||a.length)/a.length,c="",d=0;d<a.length;d++){var e=a[d].toString(16);e.length<2*b&&(c+="00000000000000".substr(0,2*b-e.length)),c+=e}return c}function i(a){return btoa(g(a))}function j(a){return"string"==typeof a}function k(a){return a instanceof ArrayBuffer}function l(a){return a instanceof Uint8Array}function m(){return this.result=null,this.pos=0,this.len=0,this.asm.reset(),this}function n(a){if(null!==this.result)throw new c("state mus
@dchest
dchest / rc4.js
Last active August 29, 2015 14:08
function rc4(f,F,g,G){for(var U=256,b=[],c=a=0,d;U>a;a++)b[a]=a;for(a=0;U>a;a++)c=(c+b[a]+f[a%F])%U,d=b[a],b[a]=b[c],b[c]=d;for(var e=c=a=0;e<G;e++)a++,a%=U,c+=b[a],c%=U,d=b[a],b[a]=b[c],b[c]=d,g[e]=b[(b[a]+b[c])%U]}
// Usage:
//
var key = [75, 101, 121]; // input bytes: "Key"
var out = new Array(10); // place for keystream bytes
rc4(key, key.length, out, out.length); // out now contains keystream: [235, 159, 119, 129, 183, 52, 202, 114, 167, 25]

Keybase proof

I hereby claim:

  • I am dchest on github.
  • I am dchest (https://keybase.io/dchest) on keybase.
  • I have a public key whose fingerprint is F466 022B 936F 90F0 FCBB 50BA BE06 B1CD 3F41 D32D

To claim this, I am signing this object:

@dchest
dchest / main.swift
Created February 4, 2015 10:08
Swift HashDoS
import Foundation
func randomStringWithLength (len : Int) -> NSString {
// from http://stackoverflow.com/a/26845710/311196
let letters : NSString = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
var randomString : NSMutableString = NSMutableString(capacity: len)
for (var i=0; i < len; i++){
@dchest
dchest / autobuild
Created February 8, 2009 00:06
"Tag, build, zip, upload, etc" automation script
#!/usr/bin/env perl
use File::Temp qw/ tempdir /;
use File::Path qw/ rmtree /;
use File::Spec::Functions;
print "autobuild (C) 2009 Dmitry Chestnykh and friends (http://twitter.com/dchest/friends)\n\n";
if ($#ARGV < 3) {
usage();
@dchest
dchest / gist:77178
Created March 10, 2009 22:22
Apple's i386 implementation of strlen() from libc sources of Darwin. (for this thread http://news.ycombinator.com/item?id=510326)
/*
* Copyright (c) 2005 Apple Computer, Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
* The contents of this file constitute Original Code as defined in and
* are subject to the Apple Public Source License Version 1.1 (the
* "License"). You may not use this file except in compliance with the
* License. Please obtain a copy of the License at
* http://www.apple.com/publicsource and read it before using this file.
@dchest
dchest / log2icalendar.rb
Created April 14, 2009 02:24
Outputs git log in iCalendar (.ics) format
#!/usr/bin/env ruby
#
# Git log to iCalendar
#
# Written by Dmitry Chestnykh, 5 Aug 2008
# Public domain
#
# Usage:
#
# cd git-repo
@dchest
dchest / gist:97823
Created April 18, 2009 23:17
Detect clicked segment in NSSegmentedCell subclass
// -------------------- CRSegmentedCell.h ------------------------------
#import <Cocoa/Cocoa.h>
@interface CRSegmentedCell : NSSegmentedCell {
NSInteger highlightedSegment;
}
@property(assign) NSInteger highlightedSegment;
@end
@dchest
dchest / CRToolPopUpButton.h
Created April 27, 2009 00:24
NSPopUpButton sublass for use in toolbars (to get toolbar item with drop-down menu)
// Public domain code
#import <Cocoa/Cocoa.h>
@interface CRToolPopUpButton : NSPopUpButton {
NSControlSize controlSize;
IBOutlet NSToolbarItem *toolbarItem;
}
@property(assign) NSControlSize controlSize;
@dchest
dchest / gist:176995
Created August 28, 2009 14:02
MacRuby 0.5-trunk: rake install log
~/Projects/MacRuby-trunk $ sudo rake install --trace
(in /Users/dmitry/Projects/MacRuby-trunk)
** Invoke install (first_time)
** Invoke framework:install (first_time)
** Invoke framework:info_plist (first_time)
** Execute framework:info_plist
** Invoke framework:install_ext (first_time)
** Execute framework:install_ext
cd ext/ripper
/usr/bin/make top_srcdir=../.. ruby="../../miniruby -I../.. -I../../lib" extout=../../.ext hdrdir=../../include arch_hdrdir=../../include install