Skip to content

Instantly share code, notes, and snippets.

@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):
@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 / 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 / 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 / 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 / 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 / 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',
namespace MyMvcApplication
{
class DbQueries : IDisposable
{
protected TimeShedulerEntities Context { get; private set; }
public DbQueries()
{
this.Context = new TimeShedulerEntities();
}
@kcuzner
kcuzner / AwaitableBasicConsumer.cs
Last active December 27, 2015 01:09
Awaitable basic consumer
using System;
using System.Collections.Generic;
using System.Collections.Concurrent;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using System.Threading;
namespace Common
@kcuzner
kcuzner / puzzle.txt
Last active December 21, 2015 05:49
Quick program to find a string inside a grid of letters as if it were a standard word search where words can only go to the right or downward
DGOODDODGOODDO
ODOOGGGDODGOGG
OGOGDOODGOODDD
DGDOOOGGOOGDGO
OGDGOGDGOGGOGD
DDDGDDODOOGDOO
ODGOGGDOOGGOOD