Skip to content

Instantly share code, notes, and snippets.

😎
Solving solar

Mark Mikofski mikofski

😎
Solving solar
Block or report user

Report or block mikofski

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@mikofski
mikofski / excel_diff.py
Created Jul 15, 2014
diff of excel file in Git repository index and working copy
View excel_diff.py
#! /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 Aug 29, 2015
Django view utilities to add GET parameters to context and to use a Bootstrap navbar login template
View Django_view_utilities.py
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 / memcached_service.py
Created Aug 26, 2014
memcached service for windows
View memcached_service.py
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Attribution: Hijacked from tracservice.py by Florent Xicluna <laxyf@yahoo.fr>
# http://trac-hacks.org/wiki/WindowsServiceScript
#
# To use this class, users must do the following:
# 1. Download and install the PyWin32all package
# (http://starship.python.net/crew/mhammond/win32/)
# 2. Edit the constants section with the proper information.
@mikofski
mikofski / gen_toc.html
Last active Aug 29, 2015
generate table of contents
View gen_toc.html
<html>
<head>
<!-- either head or body -->
<style type="text/css">
.toc_item {
color: green;
}
</style>
<!-- css class -->
</head>
@mikofski
mikofski / rc2a1.m
Created Nov 25, 2014
convert MS Excel row-column reference to A1 reference
View rc2a1.m
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 Aug 29, 2015
reference generator using counters
View gen_refs.js
/* 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);
View autovivication.json
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
@mikofski
mikofski / output.md
Last active Dec 12, 2015
get rid of nan (or inf,-9999,0 or any flag) using circshift
View output.md

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 Dec 16, 2015
Spline2D - tools to fit 2D functions with piecewise continuous polynomials.
View examples.m
%% 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 Dec 17, 2015
async Tk waitbox widget
View cbox.py
"""
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()
You can’t perform that action at this time.