Skip to content

Instantly share code, notes, and snippets.

View rogovski's full-sized avatar

Michael Rogowski rogovski

  • Connecticut, USA
View GitHub Profile
@rogovski
rogovski / TreeTraversals
Created June 19, 2014 15:28
"Imperative" Tree Traversals in C# using stacks and queues
using System;
using System.Collections.Generic;
namespace TreeTraversals
{
public static class RT {
public static RoseTree<T> Node<T>(T value)
{
return new RoseTree<T>()
@rogovski
rogovski / gist:de49eec46923e3005ae3
Created March 18, 2015 12:31
convert utc epoch to local date with javascript
// http://stackoverflow.com/questions/4631928/convert-utc-epoch-to-local-date-with-javascript
var utcSeconds = 1234567890;
var d = new Date(0); // The 0 there is the key, which sets the date to the epoch
d.setUTCSeconds(utcSeconds);
@rogovski
rogovski / newton.py
Created April 9, 2015 21:52
Newtons Method
import sympy as s
from sympy.interactive.printing import init_printing
from sympy.matrices import Matrix
init_printing(use_unicode=False, wrap_line=False, no_global=True)
# In [1]: %load_ext autoreload
#
# In [2]: %autoreload 2
@rogovski
rogovski / hessian.py
Created April 20, 2015 23:04
second partial derivative test
import sympy as s
from sympy.interactive.printing import init_printing
from sympy.matrices import Matrix
init_printing(use_unicode=False, wrap_line=False, no_global=True)
# In [1]: %load_ext autoreload
#
# In [2]: %autoreload 2
@rogovski
rogovski / javascript error
Last active August 29, 2015 14:23
define a custom error in javascript
// from: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error
function MyError(message) {
this.name = 'MyError';
this.message = message || 'Default Message';
}
MyError.prototype = Object.create(Error.prototype);
MyError.prototype.constructor = MyError;
@rogovski
rogovski / colAgg.py
Last active August 29, 2015 14:25
aggregate accross columns in pandas
import pandas as pd
import numpy as np
# initial data frame
# looks like:
#
# >>> df
#
# A B C D
@rogovski
rogovski / image_re_size.cs
Created September 24, 2015 21:43
re-size an image in C#
// taken from http://stackoverflow.com/questions/1922040/resize-an-image-c-sharp
// user: Mark
/// <summary>
/// Resize the image to the specified width and height.
/// </summary>
/// <param name="image">The image to resize.</param>
/// <param name="width">The width to resize to.</param>
/// <param name="height">The height to resize to.</param>
/// <returns>The resized image.</returns>
@rogovski
rogovski / reactHandsontable.js
Created November 6, 2015 19:46
handsontable react js component
// https://github.com/thrashr888/mathr
/**
* @jsx React.DOM
*/
'use strict';
var React = require('react/react.js');
@rogovski
rogovski / disable.sh
Last active January 15, 2016 00:39
pi serial
# stop
sudo systemctl stop serial-getty@ttyAMA0.service
# disable
sudo systemctl disable serial-getty@ttyAMA0.service
# set baud
stty -F /dev/ttyAMA0 9600
@rogovski
rogovski / frameCli.py
Created March 13, 2016 19:59
rabbitmq - pyCommon
import pika
import sys
import pyCommon.data.serialize as serialize
import pyCommon.net.command as cmd
import pyCommon.net.event as evt
queueName = sys.argv[1]