Skip to content

Instantly share code, notes, and snippets.

View mikofski's full-sized avatar
😎
Solving solar

Mark Mikofski mikofski

😎
Solving solar
View GitHub Profile
@mikofski
mikofski / excel_diff.py
Created July 15, 2014 20:31
diff of excel file in Git repository index and working copy
#! /usr/bin/env python
"""
diff of excel files
"""
from dulwich.repo import Repo # import Repo object from dulwich
import sys
import os
from openpyxl import load_workbook
@mikofski
mikofski / Django_view_utilities.py
Last active August 29, 2015 14:05
Django view utilities to add GET parameters to context and to use a Bootstrap navbar login template
from functools import wraps
from django.contrib.auth.views import login as auth_login
from django.contrib.auth.decorators import login_required
from django.http import HttpResponse, HttpResponseRedirect, QueryDict
from django.core.urlresolvers import reverse, resolve
from django.template.response import TemplateResponse
def add_GET_to_context(*keys):
"""
Check view's URL GET query string for keys and add values to context data
@mikofski
mikofski / gen_toc.html
Last active August 29, 2015 14:06
generate table of contents
<html>
<head>
<!-- either head or body -->
<style type="text/css">
.toc_item {
color: green;
}
</style>
<!-- css class -->
</head>
@mikofski
mikofski / rc2a1.m
Created November 25, 2014 20:27
convert MS Excel row-column reference to A1 reference
function [a1,aa] = rc2a1(row,col)
% RC2A1 convert row, column reference to A1 reference for excel
% A1 = RC2A1(ROW,COL) returns the equivalent reference as a string
% for the given row, ROW, and column, COL, numbers.
a1 = char(64+mod(col-1,26)+1);
xcol = ceil(col/26)-1;
if xcol>0
[~,aa] = rc2a1(row,xcol);
a1 = [aa,a1];
@mikofski
mikofski / gen_refs.js
Last active August 29, 2015 14:14
reference generator using counters
/* Build a references section that lists URLs of hyperlinks
* with specified class "ref". Put list in div element with
* specified id "references". Use CSS class called references
* that uses counters and ::before psuedo-element to add
* brackets around reference list numbers.
* links in body look like this:
* blah <a href="URL>reference</a><a class="ref"><a> */
document.body.onload = gen_refs("a", "references", "ref");
function gen_refs(tagname, refsname, classname) {
var alltags = document.getElementsByTagName(tagname);
@mikofski
mikofski / autovivication.json
Created July 17, 2015 06:00
autovivication
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
@mikofski
mikofski / output.md
Last active December 12, 2015 10:19
get rid of nan (or inf,-9999,0 or any flag) using circshift

Here's an example:

>> [data,shifts] = smooth_flag_wlast_nonflag(data_copy,NaN,true)

    0:     4    5  NaN    1    2    3  NaN  NaN  NaN    5    3  NaN  NaN    3
    1:     4    5    5    1    2    3    3  NaN  NaN    5    3    3  NaN    3
    2:     4    5    5    1    2    3    3    3  NaN    5    3    3    3    3
    3:     4    5    5    1    2    3    3    3    3    5    3    3    3    3
data =
@mikofski
mikofski / examples.m
Last active December 16, 2015 21:59
Spline2D - tools to fit 2D functions with piecewise continuous polynomials.
%% spline2D example
% Initialize a clean workspace.
% Save your work first!
clear all
close all
%% Set up test 2D polynomial.
[x,y] = meshgrid(-3:4,-3:4); % independent variables
% EG: Make a test 2D polynomial with coeffiecients 1, 2, 3, 4, 5, 6
% that is 2nd-order (quadratic) in x-direction, and 1st order (linear)
% in y-direction.
@mikofski
mikofski / cbox.py
Last active December 17, 2015 14:08
async Tk waitbox widget
"""
An example of a combobox that adds user entries using key binding to return
"""
from Tkinter import *
from ttk import *
def on_combobox_selected(event):
new_value = event.widget.get()
is_in_list = event.widget.current()
@mikofski
mikofski / blogger_codestyle.html
Last active December 18, 2015 18:19
CSS inline and block code classes for blogger
<!-- begin CSS styles -->
<head><style type="text/css">
.block-code{
background-color: pink;
border-style: solid none;
border-color: red white;
font-family: "Courier New", Courier, monospace;
}
.inline-code {