Skip to content

Instantly share code, notes, and snippets.

View Isaac-Kleinman's full-sized avatar

Isaac Kleinman Isaac-Kleinman

View GitHub Profile
@Isaac-Kleinman
Isaac-Kleinman / ThinkOfTheChildren.cs
Last active February 29, 2016 18:53
Solution to Jane Street "Think of the Children" Puzzle : https://www.janestreet.com/puzzles/think-of-the-children/
using System;
using System.Collections.Generic;
using System.Linq;
namespace ThinkOfTheChildren
{
public class Program
{
public static void Main(string[] args)
{
@Isaac-Kleinman
Isaac-Kleinman / sicp_2-54.rkt
Created December 18, 2015 17:01
SICP - Solution to Exercise 2.54
(define (equal? a b)
(or (and
(not (pair? a))
(not (pair? b))
(eq? a b))
(and
(pair? a)
(pair? b)
(equal? (car a) (car b))
(equal? (cdr a) (cdr b)))))
@Isaac-Kleinman
Isaac-Kleinman / search-for-primes.rkt
Created September 17, 2015 21:04
SICP Exercise 1.22
(define (timed-prime-test n)
(newline)
(display n)
(let-values ([(result-list t real gc)
(time-apply prime? (list n))])
(cond ((car result-list)
(display " *** ")
(display real)))))
#lang racket
(define (square x) (* x x))
(define (sum-square x y)
(+ (square x) (square y)))
(define (min x y)
(if (< x y) x y))
using System;
using System.Text;
using System.ServiceModel.Channels;
using System.Xml;
using System.IO;
using System.Security.Cryptography;
using System.Resources;
using System.Security.Cryptography.X509Certificates;
namespace eMedNySOAPClient
using System.ServiceModel.Channels;
namespace eMedNySOAPClient
{
public class CustomTextMessageEncoderFactory : MessageEncoderFactory
{
private MessageEncoder encoder;
internal CustomTextMessageEncoderFactory(string contentType, MessageVersion msgVersion)
{
using System;
using System.ServiceModel.Channels;
using System.Xml;
namespace eMedNySOAPClient
{
public class CustomTextMessageBindingElement : MessageEncodingBindingElement
{
private MessageVersion msgVersion;
private string mediaType;
@Isaac-Kleinman
Isaac-Kleinman / firstDraftException.txt
Created May 5, 2014 22:02
Exception thrown when running firstDraftClient.cs
Unhandled Exception: System.ServiceModel.Security.SecurityNegotiationException: Could not establish
trust relationship for the SSL/TLS secure channel with authority 'service01.emedny.org:7602'.
---> System.Net.WebException: The underlying connection was closed: Could not establish trust relationship for the SSL/TLS secure channel. --->
@Isaac-Kleinman
Isaac-Kleinman / firstDraftClient.xml
Created May 5, 2014 22:00
Message Generated by firstDraftClient.cs
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" xmlns:u="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
<s:Header>
<o:Security s:mustUnderstand="1" xmlns:o="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
<o:BinarySecurityToken u:Id="uuid-604c12aa-1a76-4f40-b7e3-57857b596549-3" ValueType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-x509-token-profile-1.0#X509v3" EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary">
MIICL...(USER CERTIFICATE)...lmdGpDz8gbg646R5gzebF1waazrrVM=</o:BinarySecurityToken>
<e:EncryptedKey Id="_0" xmlns:e="http://www.w3.org/2001/04/xmlenc#">
<e:EncryptionMethod Algorithm="http://www.w3.org/2001/04/xmlenc#rsa-1_5"/>
<KeyInfo xmlns="http://www.w3.org/2000/09/xmldsig#">
<o:SecurityTokenReference>
<o:KeyIde
@Isaac-Kleinman
Isaac-Kleinman / firstDraftClient.cs
Created May 5, 2014 21:59
A first attempt at configuring the SOAP request programmatically
AsymmetricSecurityBindingElement sec;
sec = (AsymmetricSecurityBindingElement) SecurityBindingElement.CreateMutualCertificateBindingElement(
MessageSecurityVersion.WSSecurity10WSTrust13WSSecureConversation13WSSecurityPolicy12BasicSecurityProfile10);
sec.DefaultAlgorithmSuite = SecurityAlgorithmSuite.TripleDesRsa15;
sec.IncludeTimestamp = false;
sec.AllowSerializedSigningTokenOnReply = true;
sec.MessageProtectionOrder = MessageProtectionOrder.SignBeforeEncrypt;
sec.EndpointSupportingTokenParameters.Signed.Add( new UserNameSecurityTokenParameters( ));