Skip to content

Instantly share code, notes, and snippets.

namespace MyMvcApplication
{
class DbQueries : IDisposable
{
protected TimeShedulerEntities Context { get; private set; }
public DbQueries()
{
this.Context = new TimeShedulerEntities();
}
@kcuzner
kcuzner / hostname.py
Created March 8, 2016 21:18
Getting a property based on the hostname
#!/usr/bin/env python2
# Demonstration for host to use the hostname to determine which property of the
# Field is "mine"
import socket
from geometry_msgs.msg import Pose2D
from bh_vision.msg import Field
hosts = {'BECKHAM': '1',
@kcuzner
kcuzner / register.php
Last active May 22, 2019 10:17
Registration page example
<?php
$emailvalid = null; //your email error
$passlength = null; //your password length error
$passmatch = null; //your password match error
$overallerror = null; //overall error ("Verification" below)
if ($_GET['submit'] == "true") {
try {
@kcuzner
kcuzner / kicad_octopart_bom
Created July 27, 2019 22:15
A Kicad BOM plugin which reads back pricing from digikey using the octopart API and generates a bill of materials table
#!/usr/bin/env python3
"""
Creates a BOM spreadsheet with updating pricing from Octopart using the custom
'Part No.' field on schematic components
"""
import sys, argparse, time, math, webbrowser, os
import json, urllib.parse, urllib.request
import xml.etree.ElementTree as ET
@kcuzner
kcuzner / archive.sh
Created October 31, 2012 20:36
Multi-process folder archiving
#!/bin/bash
# purpose: to compress my home folder
#output folder for the files
OUTPUTDIR="/media/My Book/HomeFolderBackup/"
#number of compressing process
NPROC=6
@kcuzner
kcuzner / Program.cs
Created December 29, 2014 17:30
ExpandoObject-esque DynamicObject ToString overriding
using System;
using System.Linq;
using System.Dynamic;
using System.Collections.Generic;
namespace Expando
{
public delegate string ToStringFunc();
class ToStringExpandoObject : DynamicObject
@kcuzner
kcuzner / ExpressionExtensions.cs
Created June 3, 2015 20:15
Extensions for concatenation of existing expressions using AndAlso and OrElse into a new expression
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;
namespace ETP
{
/// <summary>
@kcuzner
kcuzner / placement_helpers.py
Created February 12, 2023 17:03
Arranging components in a circle with kicad
#!/usr/bin/env python2
# Random placement helpers because I'm tired of using spreadsheets for doing this
#
# Kevin Cuzner
import math
from pcbnew import *
def place_circle(refdes, start_angle, center, radius, component_offset=0, hide_ref=True, lock=False):