Skip to content

Instantly share code, notes, and snippets.

View vicneanschi's full-sized avatar

Valeri Vicneanschi vicneanschi

  • Montreal, Canada
View GitHub Profile
@vicneanschi
vicneanschi / CreateCARoot.cmd
Created March 7, 2016 17:44
Makecert in windows
rem http://www.jayway.com/2014/09/03/creating-self-signed-certificates-with-makecert-exe-for-development/
makecert.exe ^
-n "CN=CARoot" ^
-r ^
-pe ^
-a sha512 ^
-len 4096 ^
-cy authority ^
-sv CARoot.pvk ^
@vicneanschi
vicneanschi / rotate-matrix.js
Created March 15, 2016 23:32
Rotate the matrix anti-clockwise
/*
https://www.hackerrank.com/challenges/matrix-rotation-algo
You are given a 2D matrix, a, of dimension MxN and a positive integer R.
You have to rotate the matrix R times and print the resultant matrix.
Rotation should be in anti-clockwise direction.
*/
process.stdin.resume();
process.stdin.setEncoding("ascii");
_input = "";
function processData(input) {
var lines = input.split('\n');
var tmp = lines[0].split(' ').map(x => parseInt(x));
var n = tmp[0];
var m = tmp[1];
var coins = lines[1].split(' ').map(x => parseInt(x)).slice(0, m);
// sorting coins to decrease number of calls
coins.sort();
//console.log(n, m, coins);
// https://www.hackerrank.com/challenges/maximise-sum
function processData(input) {
var lines = input.split('\n')
var line = 0;
var t = parseInt(lines[line++]);
for (var i = 0; i < t; i++){
var tmp = lines[line++].split(' ').map(x => parseInt(x));
var n = tmp[0], m = tmp[1];
var arr = lines[line++].split(' ').map(x => parseInt(x)).slice(0, n);
@vicneanschi
vicneanschi / Install.txt
Created May 26, 2016 21:01
docker toolbox chocolatey test
C:\Users\VALVI\projects\github\chocolatey-test-environment>vagrant provision
==> default: Running provisioner: shell...
default: Running: shell/PrepareWindows.ps1 as c:\tmp\vagrant-shell.ps1
==> default: IE Enhanced Security Configuration (ESC) has been disabled.
==> default:
==> default: IE first run welcome screen has been disabled.
==> default: Setting Windows Update service to Manual startup type.
==> default: Running provisioner: shell...
default: Running: shell/InstallNet4.ps1 as c:\tmp\vagrant-shell.ps1
==> default: Running provisioner: shell...
@vicneanschi
vicneanschi / ssl.conf
Created June 15, 2016 14:15
Apache ssl.conf for CAC user authentication
[root@localhost ~]# cat /etc/httpd/conf.d/ssl.conf
#
# This is the Apache server configuration file providing SSL support.
# It contains the configuration directives to instruct the server how to
# serve pages over an https connection. For detailing information about these
# directives see <URL:http://httpd.apache.org/docs/2.2/mod/mod_ssl.html>
#
# Do NOT simply read the instructions in here without understanding
# what they do. They're here only as hints or reminders. If you are unsure
# consult the online docs. You have been warned.
#!/bin/bash
#
# Retrieves DoD root certificates, converts them to PEM
# format, and concatenates them into one big PEM file.
#
# @author DMcG
if [-d rootCerts]; then
rm -rf rootCerts
fi
subject=/C=US/O=U.S. Government/OU=ECA/CN=ECA Root CA
issuer=/C=US/O=U.S. Government/OU=ECA/CN=ECA Root CA
-----BEGIN CERTIFICATE-----
MIICmDCCAgGgAwIBAgIBDjANBgkqhkiG9w0BAQUFADBLMQswCQYDVQQGEwJVUzEY
MBYGA1UEChMPVS5TLiBHb3Zlcm5tZW50MQwwCgYDVQQLEwNFQ0ExFDASBgNVBAMT
C0VDQSBSb290IENBMB4XDTA0MDYxNDEwMjAwOVoXDTQwMDYxNDEwMjAwOVowSzEL
MAkGA1UEBhMCVVMxGDAWBgNVBAoTD1UuUy4gR292ZXJubWVudDEMMAoGA1UECxMD
RUNBMRQwEgYDVQQDEwtFQ0EgUm9vdCBDQTCBnzANBgkqhkiG9w0BAQEFAAOBjQAw
gYkCgYEArkr2eXIS6oAKIpDkOlcQZdMGdncoygCEIU+ktqY3of5SVVXU7/it7kJ1
EUzR4ii2vthQtbww9aAnpQxcEmXZk8eEyiGEPy+cCQMllBY+efOtKgjbQNDZ3lB9
If you enable ssl in apache, you can verify a client certificate.
If so apache will create a environment variable for you with the name 'SSL_CLIENT_VERIFY' with values 'NONE, SUCCESS, GENEROUS or FAILED:reason'.
See https://httpd.apache.org/docs/2.0/mod/mod_ssl.html
NONE: client has no cert
SUCCESS = cert is valid
GENEROUS = says only that some kind of certificate was sent at all
FAILED:reason = auth with the cert failed
subject=/C=US/O=U.S. Government/OU=DoD/OU=PKI/CN=DOD CA-27
issuer=/C=US/O=U.S. Government/OU=DoD/OU=PKI/CN=DoD Root CA 2
-----BEGIN CERTIFICATE-----
MIIFTDCCBDSgAwIBAgICAbIwDQYJKoZIhvcNAQEFBQAwWzELMAkGA1UEBhMCVVMx
GDAWBgNVBAoTD1UuUy4gR292ZXJubWVudDEMMAoGA1UECxMDRG9EMQwwCgYDVQQL
EwNQS0kxFjAUBgNVBAMTDURvRCBSb290IENBIDIwHhcNMTEwOTA4MTU1MDI1WhcN
MTcwOTA4MTU1MDI1WjBXMQswCQYDVQQGEwJVUzEYMBYGA1UEChMPVS5TLiBHb3Zl
cm5tZW50MQwwCgYDVQQLEwNEb0QxDDAKBgNVBAsTA1BLSTESMBAGA1UEAxMJRE9E
IENBLTI3MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAloQI/Xq6tpSD
0J07GQvPBN+IKp64GljrhyIqYzp/OcNra+e8GqgRAvVhzQGkmHVzxheMiTxCx+KO