Skip to content

Instantly share code, notes, and snippets.

View rogovski's full-sized avatar

Michael Rogowski rogovski

  • Connecticut, USA
View GitHub Profile
# coding: utf-8
# In[1]:
get_ipython().magic('matplotlib inline')
import matplotlib.pyplot as plt
import numpy as np
@rogovski
rogovski / shell_snips.sh
Created April 3, 2017 20:48
shell snippets
# remove all files in the current directory with 'copy' in the name
ls | grep .*copy | xargs rm
# remove files - works with whitespace in filename
find -type f -name '*.sql' -mtime +15 -print0 | xargs -0 rm
# replace white space in file names with underscore
for f in *\ *; do mv "$f" "${f// /_}"; done
@rogovski
rogovski / freebsd_on_mbp.md
Created November 24, 2016 12:07 — forked from mpasternacki/freebsd_on_mbp.md
FreeBSD on a MacBook Pro

FreeBSD on a MacBook Pro

Since 2008 or 2009 I work on Apple hardware and OS: back then I grew tired of Linux desktop (which is going to be MASSIVE NEXT YEAR, at least since 2001), and switched to something that Just Works. Six years later, it less and less Just Works, started turning into spyware and nagware, and doesn't need much less maintenance than Linux desktop — at least for my work, which is system administration and software development, probably it is better for the mythical End User person. Work needed to get software I need running is not less obscure than work I'd need to do on Linux or othe Unix-like system. I am finding myself turning away from GUI programs that I used to appreciate, and most of the time I use OSX to just run a terminal, Firefox, and Emacs. GUI that used to be nice and unintrusive, got annoying. Either I came full circle in the last 15 years of my computer usage, or the OSX experience degraded in last 5 years. Again, this is from a sysadmin/developer ki

@rogovski
rogovski / promisify.js
Created July 21, 2016 14:33
promisify something
export default function f_promisified(x) {
return new Promise((resolve, reject) => {
f(x, (err, res) => {
if(err) {
reject(err.stack);
}
else {
resolve(res);
}
});
@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]
@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 / 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 / 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 / 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 / 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;