Skip to content

Instantly share code, notes, and snippets.

View rnagasam's full-sized avatar

Ramana Nagasamudram rnagasam

  • Stevens Institute of Technology
  • Hoboken, NJ
View GitHub Profile
@rnagasam
rnagasam / infix.py
Created June 16, 2018 02:24
Infix functions in Python
from functools import partial
class Infix(object):
def __init__(self, func):
self.func = func
def __or__(self, other):
return self.func(other)
def __ror__(self, other):
return Infix(partial(self.func, other))
def __call__(self, v1, v2):
@rnagasam
rnagasam / dynamic_add.py
Created June 16, 2018 02:32
Dynamically add methods to classes
from types import MethodType
class MyObj(object):
def __init__(self, val):
self.val = val
def new_method(self, value):
return self.val + value
obj = MyObj(3)
@rnagasam
rnagasam / forbidden.py
Created June 16, 2018 02:46
Forbidden Fruit is one crafty library
from forbiddenfruit import curse, reverse
# add method to int type
def words_of_wisdom(self):
return self * "blah "
curse(int, "words_of_wisdom", words_of_wisdom)
# add classmethod
def hello(self):
@rnagasam
rnagasam / i3.config
Created June 18, 2018 16:46
current i3 config
# This file has been auto-generated by i3-config-wizard(1).
# It will not be overwritten, so edit it as you like.
#
# Should you change your keyboard layout some time, delete
# this file and re-run i3-config-wizard(1).
#
# i3 config file (v4)
#
# Please see http://i3wm.org/docs/userguide.html for a complete reference!
@rnagasam
rnagasam / .vimrc
Created June 18, 2018 20:35
vimrc
set nocompatible
inoremap jk <esc>
set scrolloff=999
set wildmenu
set path+=**
set number
set expandtab
set autoindent
filetype plugin indent on
syntax enable
@rnagasam
rnagasam / .emacs
Created June 18, 2018 20:36
Emacs config
;;;; Emacs configuration file
;;;; Compile configuration file
(defun autocompile nil
"compile itself if ~/.emacs"
(interactive)
(require 'bytecomp)
(let ((dotemacs (file-truename user-init-file)))
(if (string= (buffer-file-name) (file-chase-links dotemacs))
(byte-compile-file dotemacs))))
# i3status configuration file.
# see "man i3status" for documentation.
# It is important that this file is edited as UTF-8.
# The following line should contain a sharp s:
# ß
# If the above line is not correctly displayed, fix your editor first!
general {
colors = true
@rnagasam
rnagasam / user.cfg
Created June 18, 2018 23:32
FreeCAD config
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<FCParameters>
<FCParamGroup Name="Root">
<FCParamGroup Name="BaseApp">
<FCParamGroup Name="LogLevels">
<FCInt Name="Default" Value="2"/>
</FCParamGroup>
<FCParamGroup Name="Preferences">
<FCParamGroup Name="General">
@rnagasam
rnagasam / freecad-find-angle.py
Created June 22, 2018 19:32
Find angle between faces
## Finding the angle between two faces of a part.
s1 = doc.Geometry.Shape.Faces[0]
s2 = doc.Geometry.Shape.Faces[1]
vns1 = s1.normalAt(0,0)
vns2 = s2.normalAt(0,0)
alpha = math.degrees(vns1.getAngle(vns2))
@rnagasam
rnagasam / streams.scm
Created July 28, 2018 17:09
Streams from SICP
; SICP 3.5 Streams
; constraints :-
; (stream-car (cons-stream x y)) = x
; (stream-cdr (cons-stream x y)) = y
(define the-empty-stream '())
(define stream-null? null?)