Skip to content

Instantly share code, notes, and snippets.

View dlwhitehurst's full-sized avatar

David L. Whitehurst dlwhitehurst

View GitHub Profile
/**
* Copyright (c) CI Wise Inc. All rights reserved. http://www.ciwise.com
* The software in this package is published under the terms of the Apache
* version 2.0 license, a copy of which has been included with this distribution
* in the LICENSE.txt file.
*
*/
package com.ciwise.accounting.util;
/**
* Copyright (c) CI Wise Inc. All rights reserved. http://www.ciwise.com
* The software in this package is published under the terms of the Apache
* version 2.0 license, a copy of which has been included with this distribution
* in the LICENSE.txt file.
*
*/
package com.ciwise.accounting.util;
@dlwhitehurst
dlwhitehurst / DatabaseConfiguration.java
Created March 2, 2017 06:41
Modifications to DatabaseConfiguration
package com.ciwise.accounting.config;
import java.util.Arrays;
import javax.inject.Inject;
import javax.sql.DataSource;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
@dlwhitehurst
dlwhitehurst / CustomAggregator
Created July 22, 2016 20:55
This custom agreggator for Scatter-Gather was the only solution I've found to aggregating multiple collections with the same root tag
package org.hoeggsoftware;
import org.mule.api.MuleEvent;
import org.mule.api.MuleException;
import org.mule.api.context.MuleContextAware;
import org.mule.api.routing.AggregationContext;
import org.mule.routing.AggregationStrategy;
import org.mule.api.MuleContext;
import org.mule.api.routing.RouterResultsHandler;
import org.mule.routing.DefaultRouterResultsHandler;
@dlwhitehurst
dlwhitehurst / app.xml
Created July 19, 2016 15:57
Dataweave is remembering old column data from query after table was altered adding new columns.
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns:metadata="http://www.mulesoft.org/schema/mule/metadata" xmlns:dw="http://www.mulesoft.org/schema/mule/ee/dw" xmlns:db="http://www.mulesoft.org/schema/mule/db" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation" xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:apikit="http://www.mulesoft.org/schema/mule/apikit" xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns:spring="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd
http://www.mulesoft.org/schema/mule/apikit http://www.mulesoft.org/schema/mule/apikit/current/mule-apikit.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
http://www.mulesoft.org/schema/mule/
@dlwhitehurst
dlwhitehurst / challenge4.rs
Created July 18, 2016 01:41
Unused variable ... conundrum
pub fn wc_single_char_xor_encrypted_line(hex_line_60: &str) -> usize {
let mut best: usize = 0;
for x in 0..255 {
let hexkey = format!("{:02x}",x);
let bigkey = iter::repeat(hexkey).take(30).collect::<String>();
let result = xor(hex_line_60,&bigkey);
let utf8_error = "UTF-8 Error".to_string();
let s = match String::from_utf8(result) {
Ok(v) => v,
@dlwhitehurst
dlwhitehurst / Long running stuff
Created July 15, 2016 05:45
Anyway to better format this in the code module?
#[test]
fn test_repeating_xor() {
use set1::challenge2::xor;
use rustc_serialize::hex::ToHex;
let plain_text_hex = "4275726e696e672027656d2c20696620796f752061696e277420717569636b20616e64206e696d626c650a4920676f206372617a79207768656e2049206865617220612063796d62616c";
let key = "4943454943454943454943454943454943454943454943454943454943454943454943454943454943454943454943454943454943454943454943454943454943454943454943454943";
let result = xor(plain_text_hex, key);
assert_eq!("0b3637272a2b2e63622c2e69692a23693a2a3c6324202d623d63343c2a26226324272765272a282b2f20430a652e2c652a3124333a653e2b2027630c692b20283165286326302e27282f",result.to_hex());
}
@dlwhitehurst
dlwhitehurst / Doesn't Work
Created July 14, 2016 01:09
Freakin' overkill
//! # Examples
//!
//! ```
//! extern crate rustc_serialize;
//! extern crate cryptowise;
//! use cryptowise::set1::challenge2::xor;
//! use rustc_serialize::hex::ToHex;
//! let a = "1c0111001f010100061a024b53535009181c";
//! let b = "686974207468652062756c6c277320657965";
//! let result = xor(a,b);
@dlwhitehurst
dlwhitehurst / Test Output
Created July 14, 2016 00:21
challenge2.rs test failure
guita@David-Asus MINGW64 /c/Development/Rust/projects/cryptowise (master)
$ cargo test
Running target\debug\cryptowise-637d5e98fd8788fc.exe
running 2 tests
test set1::challenge1::tests::it_works ... ok
test set1::challenge2::tests::it_works2 ... ok
test result: ok. 2 passed; 0 failed; 0 ignored; 0 measured
@dlwhitehurst
dlwhitehurst / main.rs
Created July 13, 2016 18:02
Look at line 16
extern crate rustc_serialize;
use rustc_serialize::hex::{FromHex,ToHex};
/*
This is the application main
*/
fn main() {
let a = "1c0111001f010100061a024b53535009181c";