Skip to content

Instantly share code, notes, and snippets.

View bcnzer's full-sized avatar

Ben Chartrand bcnzer

View GitHub Profile
@bcnzer
bcnzer / project.json
Created May 1, 2017 06:58
project.json to add StackExchange.Redis for an Azure Function
{
"frameworks": {
"net46":{
"dependencies": {
"StackExchange.Redis": "1.2.1"
}
}
}
}
@bcnzer
bcnzer / run.csx
Created May 1, 2017 07:49
Sample Azure Function calling the Redis cache we configured
using System.Net;
using StackExchange.Redis;
public static async Task<HttpResponseMessage> Run(HttpRequestMessage req, TraceWriter log)
{
log.Info("C# HTTP trigger function processed a request.");
// **** REDIS CODE STARTS HERE
var connString = System.Configuration.ConfigurationManager.ConnectionStrings["mycats"].ConnectionString;
var redis = ConnectionMultiplexer.Connect(connString);
@bcnzer
bcnzer / timelapse.sh
Last active June 26, 2017 08:31
Create timelapse directory and start timelapse phototaking
mkdir timelapse
cd timelapse
raspistill -o picture%04d.jpeg -tl 10000 -t 7200000
@bcnzer
bcnzer / prereq.sh
Created June 30, 2017 10:36
Python 3.6.0 pre-requisites for Raspbian
sudo apt-get install build-essential checkinstall
sudo apt-get install libreadline-gplv2-dev libncursesw5-dev libssl-dev libsqlite3-dev tk-dev libgdbm-dev libc6-dev libbz2-dev
@bcnzer
bcnzer / downloadpython.sh
Last active April 20, 2020 06:45
Download python
cd /usr/src
wget https://www.python.org/ftp/python/3.6.0/Python-3.6.0.tgz
sudo tar xzf Python-3.6.0.tgz
@bcnzer
bcnzer / compilepython.sh
Last active June 30, 2017 10:48
Configure and compile Python
cd Python-3.6.0
sudo -s
bash configure
make altinstall
exit
@bcnzer
bcnzer / _Layout.cshtml
Last active July 1, 2017 10:38
Sample _Layout.cshtml with partial views and a section
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>@ViewData["Title"]</title>
<meta name="description" content="Sample code">
<meta name="author" content="Test code limited">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1.0, user-scalable=no, shrink-to-fit=no">
@bcnzer
bcnzer / _LayoutSnippet.cshtml
Last active July 1, 2017 11:08
Example of RenderSection in action
<div class="app-content-inner">
@RenderSection("MyContentHeader", required: true)
@RenderBody()
</div>
@bcnzer
bcnzer / DashboardSnippet.cshtml
Last active July 1, 2017 11:12
Snippet of the Dashboard cshtml with the 'content header' breadcrumb
@section MyContentHeader {
<div class="content-toolbar content-toolbar-left">
<h3 class="page-header">Dashboard</h3>
<ol class="content-breadcrumb breadcrumb breadcrumb-arrow">
<li><a href="#"><i class="icon-home mr-1"></i> Home</a></li>
<li><a href="#">Collections</a></li>
<li class="active">Item</li>
</ol>
</div>
}
@bcnzer
bcnzer / RegisterViewModel.cs
Last active November 25, 2019 06:04
Registration view model with a complex password requirement
public class RegisterViewModel
{
[Required]
[Display(Name = "First Name")]
[StringLength(100, ErrorMessage = "{0} must be at least {2} characters long.", MinimumLength = 2)]
public string FirstName { get; set; }
[Required]
[Display(Name = "Last Name")]
[StringLength(100, ErrorMessage = "{0} must be at least {2} characters long.", MinimumLength = 2)]