Skip to content

Instantly share code, notes, and snippets.

@sevas
sevas / symlink.py
Created August 30, 2016 12:40
cross platform utility to make symlinks, useful to call from build events in cmake build scripts
@sevas
sevas / petype.py
Created August 28, 2016 16:13
Detect whether a Windows exe or dll is a 32 or 64bit executable.
"""Detect whether a Windows exe or dll is a 32 or 64bit executable.
Port of the perl script given by Paul Dixon on a Stack Overflow answer [1]_
.. [1] http://stackoverflow.com/a/495305/40056
"""
import sys
import os
from struct import unpack
@sevas
sevas / conda.fish
Last active October 27, 2015 11:14
modified conda.fish, based on https://gist.github.com/jiffyclub/9679788
function condalist -d 'List conda environments.'
for dir in (ls $HOME/anaconda/envs)
echo $dir
end
end
function condactivate -d 'Activate a conda environment' -a cenv
if test -z $cenv
echo 'Usage: condactivate <env name>'
return 1
https://www.quora.com/Object-Oriented-Programming/Was-object-oriented-programming-a-failure/answer/Michael-O-Church
No, not a failure. It's the worst kind of success.
Alexander Stepanov's complaint is blistering and accurate. If you read Types and Programming Languages, you get a sense for just how much complexity objects add to your world. OOP, as commonly envisioned, doesn't play well with static or dynamic typing.
Is OOP a failure? Well, what is it? I've heard OOP given about 12 definitions, all credible in some core way, but many conflicting. Like "Scrum", it's too all over the place to justify a closed-form, final opinion. It's either highly beneficial or loathsome depending on which interpretation one uses. There's good OOP and bad OOP. This should be no surprise: in the anti-intellectual world of mainstream business software, it's mostly bad OOP. (For "Scrum", there's the same sad story.)
Separation of implementation and interface is a clear win. That's not limited to OO languages, of course. Ha
import numpy as np
a = np.arange(0., 1.0, .1)
b = np.arange(0., 1.0, .1)
# modify 3 values to have differences
b[5:8] *= 1.1
@sevas
sevas / cl.exe
Last active January 2, 2016 00:39
C/C++ COMPILER OPTIONS
-OPTIMIZATION-
/O1 minimize space /O2 maximize speed
/Ob<n> inline expansion (default n=0) /Od disable optimizations (default)
/Og enable global optimization /Oi[-] enable intrinsic functions
/Os favor code space /Ot favor code speed
/Ox maximum optimizations /Oy[-] enable frame pointer omission
@sevas
sevas / setup.cfg
Last active December 30, 2015 13:59
configuration file for nose tests
# a test file:///Users/sevas/PycharmProjects/gulbis/doc/build/html/test_attributes.html file:///Users/sevas/PycharmProjects/gulbis/doc/build/html/test_attributes.html file:///Users/sevas/PycharmProjects/gulbis/doc/build/html/test_attributes.html
[nosetests]
verbosity=3
with-doctest=1
doctest-tests=1
@sevas
sevas / good_copytree.py
Created December 4, 2013 10:44
a non-retarded shutil.copytree (from http://stackoverflow.com/a/13814557/40056)
def copytree(src, dst, symlinks=False, ignore=None):
if not os.path.exists(dst):
os.makedirs(dst)
for item in os.listdir(src):
s = os.path.join(src, item)
d = os.path.join(dst, item)
if os.path.isdir(s):
copytree(s, d, symlinks, ignore)
else:
if not os.path.exists(d) or os.stat(src).st_mtime - os.stat(dst).st_mtime > 1:
{
"color_scheme": "Packages/Color Scheme - Default/Solarized (Dark).tmTheme",
"font_face": "Source Code Pro",
"font_size": 11.0,
"highlight_modified_tabs": true,
"theme": "Soda Dark.sublime-theme",
"trim_trailing_white_space_on_save": true,
"word_separators": "./\\()\"'-:,.;<>~!@#%^&*|+=[]{}`~?",
"tab_size": 4,
"scroll_past_end": true,
@sevas
sevas / rudolf.py
Created January 27, 2013 20:39
patched rudolf.py (color output for nose) to handle both py2.6 & py2.7's unittest interface.
"""Color output plugin for the nose testing framework.
Use ``nosetests --with-color`` (no "u"!) to turn it on.
http://en.wikipedia.org/wiki/Rudolph_the_Red-Nosed_Reindeer
"Rudolph the Red-Nosed Reindeer" is a popular Christmas story about Santa
Claus' ninth and lead reindeer who possesses an unusually red colored nose that
gives off its own light that is powerful enough to illuminate the team's path
through inclement weather.