Skip to content

Instantly share code, notes, and snippets.

👨‍🔬
Researching 'em microbes...

Christian Diener cdiener

👨‍🔬
Researching 'em microbes...
Block or report user

Report or block cdiener

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@cdiener
cdiener / overload.R
Last active Aug 23, 2019
R operator overloading
View overload.R
a = "bla"
b = "so on"
class(a) = append("my_class", class(a))
'+.my_class' = function(x,y) paste(x,y,sep=" and ")
print(a+b)
@cdiener
cdiener / topics.md
Last active Aug 29, 2015
Learning Topics
View topics.md

Learning List

Next topics to learn:

  • webservers
  • node.js
  • Django or Pyramid [maybe Jinja2+Tornado a better option for smaller projects]
  • Plone plugins [too complex, substituded by FormGen]
  • D3
  • Python testing frameworks
@cdiener
cdiener / asciinator.py
Created Apr 13, 2014
asciinator.py now with documentation
View asciinator.py
# This line imports the modules we will need. The first is the sys module used
# to read the command line arguments. Second the Python Imaging Library to read
# the image and third numpy, a linear algebra/vector/matrix module.
import sys; from PIL import Image; import numpy as np
# This is a list of characters from low to high "blackness" in order to map the
# intensities of the image to ascii characters
chars = np.asarray(list(' .,:;irsXA253hMHGS#9B&@'))
# Check whether all necessary command line arguments were given, if not exit and show a
@cdiener
cdiener / asciinator.py
Last active Aug 14, 2019
Convert image to ascii art
View asciinator.py
import sys; from PIL import Image; import numpy as np
chars = np.asarray(list(' .,:;irsXA253hMHGS#9B&@'))
if len(sys.argv) != 4: print( 'Usage: ./asciinator.py image scale factor' ); sys.exit()
f, SC, GCF, WCF = sys.argv[1], float(sys.argv[2]), float(sys.argv[3]), 7/4
img = Image.open(f)
S = ( round(img.size[0]*SC*WCF), round(img.size[1]*SC) )
img = np.sum( np.asarray( img.resize(S) ), axis=2)
You can’t perform that action at this time.