Skip to content

Instantly share code, notes, and snippets.

A PAINLESS GUIDE TO CRC ERROR DETECTION ALGORITHMS

"Everything you wanted to know about CRC algorithms, but were afraid to ask for fear that errors in your understanding might be detected."

Version : 3. Date : 19 August 1993. Author : Ross N. Williams. Net : ross@guest.adelaide.edu.au.

@ahri
ahri / csproj_xml.rb
Created September 15, 2016 07:46
Basic XML parser aimed at simple .csproj files
class Xml
def initialize()
@stack = []
@tag_start_trails = {}
@tag_end_trails = {}
end
def tag_start(trail, block)
@tag_start_trails[trail] = [] if @tag_start_trails[trail] == nil
@tag_start_trails[trail].push block
@ahri
ahri / user_event_monitor.js
Created February 24, 2015 16:32
JS User Event Monitor, to facilitate emulation of user interactions
function monitor(el, types, callback) {
var events = {
mouse: ["mousedown", "mouseup", "click", "dblclick", "mousemove", "mouseover", "mouseout", "mousewheel"],
key: ["keydown", "keyup", "keypress", "textInput"],
touch: ["touchstart", "touchmove", "touchend", "touchcancel"],
control: ["resize", "scroll", "zoom", "focus", "blur", "select", "change", "submit", "reset"],
misc: ["load", "unload", "abort", "error", "select", "change", "submit", "reset", "focus", "blur", "resize", "scroll", "search", "devicemotion", "deviceorientation"],
};
types.split(/\s/).forEach(function (type) {
'use strict';
var Q = require('q');
var p = Q.fcall(function () {
console.log("P init");
});
var a = Q.fcall(function () {
console.log("A init");
function foobar() {
return lazypipe()
.pipe(plugins.cached, 'codeAndTest')
.pipe(plugins.jshint)
.pipe(plugins.jshint.reporter, stylish)
.pipe(plugins.jshint.reporter, 'fail')
.pipe(plugins.remember, 'codeAndTest')
.pipe(plugins.ignore.include, '**/test/*.js')
.pipe(plugins.mocha, {reporter: 'spec', bail: true})
.pipe(plugins.remember, 'codeAndTest')
import System.Directory
example = ["foo.mkv", "bar.jpg", "baz.avi", "blah.mpg"]
endswith :: String -> String -> Bool
endswith [] _ = True
endswith _ [] = False
endswith search str =
last search == last str &&
endswith (init search) (init str)
return mock(
Foo.class,
withSettings()
.spiedInstance(new Foo())
.verboseLogging()
);
@ahri
ahri / express4.js
Created July 2, 2014 08:29
Why doesn't the middleware error handler get called?
var app = require('express')();
app.use(function (err, req, res, next) {
console.log("using my error middleware");
return next(err);
});
app.get('/', function (req, res, next) {
next(new Error("test"));
});
@ahri
ahri / jarsigner_verify
Created December 26, 2013 10:56
Output of: jarsigner -verify android/target/aligned.apk -keystore ~/.android/debug.keystore -verbose
s k 1438 Thu Dec 26 01:34:06 GMT 2013 META-INF/MANIFEST.MF
1559 Thu Dec 26 01:34:06 GMT 2013 META-INF/CERT.SF
1209 Thu Dec 26 01:34:06 GMT 2013 META-INF/CERT.RSA
smk 21743 Thu Dec 26 01:33:52 GMT 2013 com/badlogic/gdx/utils/arial-15.fnt
smk 21814 Thu Dec 26 01:33:52 GMT 2013 com/badlogic/gdx/utils/arial-15.png
smk 12853 Thu Dec 26 01:33:52 GMT 2013 com/badlogic/gdx.gwt.xml
smk 167 Thu Dec 26 01:33:52 GMT 2013 com/esotericsoftware/TableLayout.gwt.xml
smk 408 Thu Dec 26 01:33:52 GMT 2013 com/kaizen/mapdone/UiModule.dot
smk 61381 Thu Dec 26 01:34:06 GMT 2013 lib/armeabi/libandroidgl20.so
Manifest-Version: 1.0
Created-By: 1.7.0_25 (Oracle Corporation)
Name: res/drawable-xhdpi/ic_launcher.png
SHA1-Digest: UCzYT6RE8m1+z99KNVBkhnl38jY=
Name: res/drawable-hdpi/ic_launcher.png
SHA1-Digest: RQ09RDJf3yWYEKYOavo2ED4Yaz0=
Name: com/badlogic/gdx.gwt.xml