Skip to content

Instantly share code, notes, and snippets.

@vnisor
vnisor / Linear Regression
Created October 19, 2021 21:30 — forked from xxsang/Linear Regression
Linear Regression
1. Simple linear regression
1. Assumes the dependence of response Y on predictors X1,…Xp is linear
2. Simple is good
3. residual: e = yi-yi_hat
4. residual sum of squares = e1^2+…en^2
5. optimisation problem to minimise total RSS, has closed form solution
6. A measure of precision -> how close the estimator is close to 0 (no relationship)
1. Standard error of the slope
2. var(e)/spread around the mean of X
3. SE of the intercept
@vnisor
vnisor / hwcdirect.md
Created October 17, 2019 18:17 — forked from sneal/hwcdirect.md
How to run Cloud Foundry hwc.exe directly

How to run hwc.exe directly without CloudFoundry

When web applications are pushed to CloudFoundry they are pushed out to one or more Windows cells and run inside the Hostable Web Core (HWC). HWC is the same component that IIS uses underneath to do the heavy lifting of serving ASP.NET applications. In Cloud Foundry the HWC is bootstrapped by the command line hwc.exe which works much like IISExpress.

Setup

We're going to serve the PCF .NET Environment Viewer app locally using the hwc.exe. These steps will guide you through all the prereqs to get that app working.

  1. Install the following Windows features: Hostable Web Core, ASP.NET 4.6, Websockets.
  2. Download or build the hwc executable. Place the hwc.exe in c:\containerizer.
public class DisableMultipleQueuedItemsFilter : JobFilterAttribute, IClientFilter, IServerFilter
{
private static readonly TimeSpan LockTimeout = TimeSpan.FromSeconds(5);
private static readonly TimeSpan FingerprintTimeout = TimeSpan.FromHours(1);
public void OnCreating(CreatingContext filterContext)
{
if (!AddFingerprintIfNotExists(filterContext.Connection, filterContext.Job))
{
filterContext.Canceled = true;
@vnisor
vnisor / gist:42ebcc196ab2d8675df46adfc191242c
Created April 19, 2017 20:55 — forked from CharlTruter/gist:2110398
How to change bindings on a site in IIS using C#
void ChangeSiteBinding(string siteName, string oldBindingValue, string newBindingValue, string protocol)
{
using (ServerManager manager = new ServerManager())
{
// Find the site by name from IIS
Microsoft.Web.Administration.Site site = manager.Sites.Where(q => q.Name == siteName).FirstOrDefault();
if (site == null)
{
throw new Exception("The specified site name does not exist in IIS!");
}
@vnisor
vnisor / runner.js
Created March 31, 2017 17:34 — forked from phanan/runner.js
Record a webpage with PhantomJS and FFMpeg
// Run this from the commandline:
// phantomjs runner.js | ffmpeg -y -c:v png -f image2pipe -r 24 -t 10 -i - -c:v libx264 -pix_fmt yuv420p -movflags +faststart output.mp4
var page = require('webpage').create(),
address = 'http://s.codepen.io/phanan/fullembedgrid/YPLewm?type=embed&safe=true&_t=1424767252279',
duration = 3, // duration of the video, in seconds
framerate = 24, // number of frames per second. 24 is a good value.
counter = 0,
width = 500,
height = 500;

Intro

The plan is to create a pair of executables (ngrok and ngrokd) that are connected with a self-signed SSL cert. Since the client and server executables are paired, you won't be able to use any other ngrok to connect to this ngrokd, and vice versa.

DNS

Add two DNS records: one for the base domain and one for the wildcard domain. For example, if your base domain is domain.com, you'll need a record for that and for *.domain.com.

Different Operating Systems

@vnisor
vnisor / elasticsearch-nest-geoquery-example.cs
Created September 19, 2016 17:08 — forked from crunchie84/elasticsearch-nest-geoquery-example.cs
Easy example of indexing geo-based domain objects to ElasticSearch via #nest
using Nest;
using System;
using System.Globalization;
namespace elasticsearch_nest_geoindex_demo
{
public class Location
{
public string Name { get; set; }
@vnisor
vnisor / ngrok-selfhosting-setup.md
Created September 8, 2016 02:37 — forked from lyoshenka/ngrok-selfhosting-setup.md
How to setup Ngrok with a self-signed SSL cert

Intro

The plan is to create a pair of executables (ngrok and ngrokd) that are connected with a self-signed SSL cert. Since the client and server executables are paired, you won't be able to use any other ngrok to connect to this ngrokd, and vice versa.

DNS

Add two DNS records: one for the base domain and one for the wildcard domain. For example, if your base domain is domain.com, you'll need a record for that and for *.domain.com.

Different Operating Systems

@vnisor
vnisor / postgres_table_row_count.sql
Created April 18, 2016 23:51
Row counts for all tables in a postgres db.
SELECT schemaname,relname,n_live_tup
FROM pg_stat_user_tables
ORDER BY n_live_tup DESC;
@vnisor
vnisor / C# radix tree
Created April 1, 2016 22:27 — forked from paratechnical/C# radix tree
C# radix tree
public class Tree
{
/// <summary>
/// store the tree's root
/// </summary>
private Node _root;
/// <summary>
/// construct a new tree with it's root
/// </summary>