Skip to content

Instantly share code, notes, and snippets.

View bheklilr's full-sized avatar

Aaron Stevens bheklilr

  • Arkansas
View GitHub Profile
import types
import typing
import ast
import inspect
class TypeViolationError(TypeError):
def __init__(self, variable_name, expected_type, actual_type):
super().__init__()
self.variable_name = variable_name
import types
import typing
import ast
import inspect
class TypeViolationError(TypeError):
def __init__(self, variable_name, expected_type, actual_type):
super().__init__()
self.variable_name = variable_name
import numpy as np
def matrix_sqrt(A):
'''Solve for B in A = B*B'''
# B can be decomposed into V * S * V.I where S is diagonal and V is a column
# matrix of the eigenvectors (provided it meets certain criteria, but that
# probably won't happen).
V = np.matrix(np.linalg.eig(A)[1]) # Returns eigenvalues and eigenvectors
VI = V.I
from collections import OrderedDict
class enummeta(type):
def __init__(cls, name, bases, classdict):
super(enummeta, cls).__init__(name, bases, classdict)
cls.__values__ = [v for v in classdict.values() if v not in (__name__, enummeta)]
def __iter__(cls):
return iter(cls.__values__)
from collections import OrderedDict, MutableMapping, ItemsView
class ordereddefaultdictwithkey(MutableMapping, ItemsView):
def __init__(self, factory_func):
self.__factory_func = factory_func
self.__dict = OrderedDict()
def __len__(self):
return len(self.__dict)
{-# LANGUAGE DeriveFunctor #-}
{-# LANGUAGE DeriveFoldable #-}
{-# LANGUAGE DeriveTraversable #-}
module Main where
import System.Directory
import System.FilePath
import System.Environment
import Data.List (intercalate, isPrefixOf)
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>comment</key>
<string>Failcoder - Theme</string>
<key>name</key>
<string>Failcoder "failcoder.com"</string>
<key>semanticClass</key>
<string>theme.failcoder</string>
<dict>
<key>name</key>
<string>CSV Commas</string>
<key>scope</key>
<string>punctuation.comma.csv</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#df9f2c</string>
</dict>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>fileTypes</key>
<array>
<string>csv</string>
</array>
<key>name</key>
<string>CSV</string>