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 / 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 / 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 / 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 / 0_reuse_code.js
Last active August 29, 2015 14:22
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@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 / NamespacedXmlMediaTypeFormatter.cs
Created October 20, 2014 22:45
XML Media Type Formatter which handles namespaces
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http.Formatting;
using System.Net.Http.Headers;
using System.Text;
using System.Threading.Tasks;
using System.Web;
using System.Xml;
using System.Xml.Serialization;
@kcuzner
kcuzner / UniFile.cs
Last active August 29, 2015 14:07
UniFile decompilation showing the difference between Read and ReadRecords
using System;
using System.Threading;
namespace IBMU2.UODOTNET
{
public class UniFile : UniRoot
{
//... lots of stuff
/// <summary>
/// Reads the UniVerse record from this file. It uses the record ID established via
@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 {
namespace MyMvcApplication
{
class DbQueries : IDisposable
{
protected TimeShedulerEntities Context { get; private set; }
public DbQueries()
{
this.Context = new TimeShedulerEntities();
}