Skip to content

Instantly share code, notes, and snippets.

View leonkyr's full-sized avatar
🎯
Focus

Leo Kyrpychenko leonkyr

🎯
Focus
View GitHub Profile
# Windows AMIs don't have WinRM enabled by default -- this script will enable WinRM
# AND install 7-zip, curl and .NET 4 if its missing.
# Then use the EC2 tools to create a new AMI from the result, and you have a system
# that will execute user-data as a PowerShell script after the instance fires up!
# This has been tested on Windows 2008 SP2 64bits AMIs provided by Amazon
#
# Inject this as user-data of a Windows 2008 AMI, like this (edit the adminPassword to your needs):
#
# <powershell>
# Set-ExecutionPolicy Unrestricted
@leonkyr
leonkyr / CORS.Demo.Web.confg
Last active August 29, 2015 14:18
CORS Enabling for .Net Web Api
<system.webServer>
<handlers>
<remove name=”ExtensionlessUrlHandler-ISAPI-4.0_32bit” />
<remove name=”ExtensionlessUrlHandler-ISAPI-4.0_64bit” />
<remove name=”ExtensionlessUrlHandler-Integrated-4.0" />
<add name=”ExtensionlessUrlHandler-ISAPI-4.0_32bit” path=”*.” verb=”GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS” modules=”IsapiModule” scriptProcessor=”%windir%\Microsoft.NET\Framework\v4.0.30319\aspnet_isapi.dll” preCondition=”classicMode,runtimeVersionv4.0,bitness32" responseBufferLimit=”0" />
<add name=”ExtensionlessUrlHandler-ISAPI-4.0_64bit” path=”*.” verb=”GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS” modules=”IsapiModule” scriptProcessor=”%windir%\Microsoft.NET\Framework64\v4.0.30319\aspnet_isapi.dll” preCondition=”classicMode,runtimeVersionv4.0,bitness64" responseBufferLimit=”0" />
<add name=”ExtensionlessUrlHandler-Integrated-4.0" path=”*.” verb=”GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS” type=”System.Web.Handlers.TransferRequestHandler” preCondition=”integratedMode,runtimeVersionv4.0
@leonkyr
leonkyr / Cors.demo.controller.cs
Created April 10, 2015 21:06
CORS Demo Controller
using System;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;
using System.Web.Http.Cors;
namespace LeonKyr.Demo.Api.Controllers
{
[EnableCors("*", "*", "*")]
@leonkyr
leonkyr / CORS.Demo.WebApiConfig.cs
Last active August 29, 2015 14:18
CORS Demo WebApiConfig.cs
/// <summary>
/// Registers the specified configuration.
/// </summary>
/// <param name="config">The configuration.</param>
public static void Register(HttpConfiguration config)
{
// This should be before call of MapHttpAttributeRoutes()
config.EnableCors();
ConfigureDependencyResolver(config);
@leonkyr
leonkyr / Squid.conf
Created April 29, 2015 19:06
Squid.conf for SSL sniffing
#
# Recommended minimum configuration:
#
sslproxy_capath /etc/opt/csw/ssl/certs
#cache_effective_user root
# Example rule allowing access from your local networks.
# Adapt to list your (internal) IP networks from where browsing
# should be allowed
acl localnet src 10.0.0.0/8 # RFC1918 possible internal network
acl localnet src 172.16.0.0/12 # RFC1918 possible internal network
@leonkyr
leonkyr / Generate SSL cert for squid
Created April 29, 2015 19:08
Generate SSL for Squid
cd /usr/local/squid
sudo mkdir ssl_cert
sudo chown nobody:nobody
chmod 700 ssl_cert
cd ssl_cert
openssl req -new -newkey rsa:2048 -sha256 -days 365 -nodes -x509 -keyout myCA.pem -out myCA.pem
@leonkyr
leonkyr / Generate the certificate for client Browsers
Created April 29, 2015 19:10
Generate the certificate for client Browsers
cd /usr/local/squid/ssl_cert
openssl x509 -in myCA.pem -outform DER -out myCA.der
cp myCA.der ~/myCA.der
# sftp vagrant@test
# get ~/myCA.der
@leonkyr
leonkyr / Create SSL Cache folder and change permissions
Created April 29, 2015 19:11
Create SSL Cache folder and change permissions
sudo mkdir -p /usr/local/squid/var/lib/ssl_db
sudo /usr/local/squid/libexec/ssl_crtd -c -s /usr/local/var/lib/ssl_db
sudo chown nobody:nobody -R /usr/local/squid/var/lib/ssl_db
@leonkyr
leonkyr / Download source code for Squid
Created April 29, 2015 19:13
Download source code for Squid
cd ~
mkdir squid
cd squid
wget http://www.squid-cache.org/Versions/v3/3.5/squid-3.5.3.tar.gz
tar xvzf squid-3.5.3.tar.gz
@leonkyr
leonkyr / Prepare the environment to build Squid (Ubuntu)
Last active September 24, 2016 12:22
Prepare the environment to build Squid (Ubuntu)
sudo apt-get install build-essential
sudo apt-get install autoconf g++ python2.7-dev