iTerm2: inline images(Ruby)

Because Python is slower on my machine, I made a little script to use the proprietary escape code of iTerm2 for printing pictures inline.

Nothing fancy, just to exercice.

require "base64"

def printi(α)
    χtmp = nil
    File.open(α, 'rb') { |χf|
        χtmp = Base64.encode64(χf.read)
    }
    puts("\x1b]1337;File=name=#{Base64.encode64(α)};inline=1:" + χtmp + "\a\n")
end
Advertisements

IPython: Rename images with their SHA1 chekcsum

I got lazy, I don’t want to rename pictures anymore so I name them with their own sha1 checksum, so I made a really quick script to do that under IPython.

def grapimages():
"""return a list of all images in the current folder """
μ = list()
tmp = !ls | grep '[PpJjGg][NnPpIi][GgEeFf][Gg]\{0,1\}'

for ii in tmp:
if ii.lower().endswith('png') or ii.lower().endswith('jpg') or ii.lower().endswith('jpeg') or ii.lower().endswith('gif'): μ.append(ii)

return μ

def rensha():
"""rename images from the current folder with their own sha1 checksum""" χt = ''
iu = ''

for ii in grapimages():

with open(ii, 'rb', ) as φχer:
χt = sha1(φχer.read()).hexdigest()

if ii.lower().endswith('jpeg'): # + exception for jpegs iu = '{}.jpg'.format(χt)
else:
iu = '{}.{}'.format(χt, ii.split('.')[-1])

! mv $ii $iu
print('done.')

Yes I use IPython’s ability to use shell commands to populate python variables. But I told you it’s quick shit, or “life hack” like those pseudo geeks loves to call them. ;)

PyLab + tmux + iTerm2

Due to the fact that iTerm2 is crashing more and more often, I decided yesterday to put my python console inside a tmux window & at the same time launching pylab instead of a simple ipython console.

So in the iTerm2 conf we can launch a command to do that but it wasn’t working by containing the command inside single quotation marks. here’s the command:

/usr/local/bin/tmux -l new -s pylab "/usr/local/bin/ipython --pylab"

Continue reading

Orc Name Generator (again).

orc iconSo I’ve managed to have few hours to relax this weekend, so  I’ve played with ruby. I finally ended up with the will to remake the “Orc name generator” I’ve made few months ago, I’m happy to see my coding skills increases a little (everything’s less messy, I’ve get rid of my horrible C habit to make all my loops with “while” ah ah).

I’ve also discovered some really cool features of Ruby.

It’s a really stupid program that generates a random orc names with an Orcish clan name. This time Entirely in english.

Continue reading

Orc name generator (1)

Yesterday I’ve coded a simple script to generate random orc names with some sort of random alias or honor name (something like “Throgghor hund kid’chew”).

It’s a really small and useless thingy. I’ll share the code later.

 

Here’s some results (in french but I’ll make an english list of the words.)

------- Orc Name Generator -------
Agaudarth Eguar kass'clebz kosher
Sugarth frapp'bouteill'
Ehuoggung Krang Ahuoth bouff'droid hurlant
K'ogath Z'ath ecraz'tendon
Tuggath lance'armature
Emuumarth Uggoorth ronj'parebriz pourri
Z'adarth Ogaung chidu'plexus humide
Bgguk Amuor Ohaang ecraz'boyau
Odaudor Tok Krang grignoth'pneu
Gromak Odaung Ogoung krok'troll
Zadur Z'ath frapp'tibia

DNA Sample

AACAACGAAGTTGATGCTACGCAAACGCAACAAGAATTAACTTTTGCAGGCATGAATGCTGGTGATGTGTTTGGGGCAGTGATCGACCGGACATTAGGACCTATGTCTTAGCACGGCATAGTCTGATAGTCTTGTCCAAAAGCATTGCTCCGAGCGGATCAAATGTATAATAGACCATGTCTCCCGAATTCTTCGGCGCCGCCACGCCGACTTGACCACATGTTTCCATGCCTTCCCGGTGTGGGTTTTATTGGGCTTGGCTTCGAGAGATCAGTGCGCAGATAGCCCATTGTGTCGCCACCCCTATAGAAAAAAGCGTGCGAAATGGATTCAATTCGTTTAATAAGCGCTAATAAGGTGGGAGGTGTCCTACTACTGTGTGGTGGAACTTTCTCTGTTTCGAGCAAAGTGCCACTTCAAATTCGAAAATTCCTTGTTTCGCTAGATCCTCCGAGAAGAAGACTTCGTACATGTTATGCAGGCAGTCTGCTACCTCGCAGGACCAACTTTACCCCACGTTAGTCTGGCAGAGTCTTGCGCAGGCATCCGAAGTTTGCGACAAATCTGTACAATGGTGTAAAAGTTCCCTCGACGTTGGGGTTTGCCGTAGTATCTGTCTGGGGAAGTGACCTAACGCTCCGCGCGCTCGTACCGCCAAAACCTGCCAGACTGGCTCTTGCGGGTCTACTAGCCCTGGTATAACTCCAAAGGGCACGACTTGCATTTGCGGATGGGATGATAGCCTGTTTTGCATCTGTCCCCAATGAGAACATGGGACCAATCCGGACCCGTTGTGATCATGAGCGACACCACTCTCGATTGGGACCAAGATACGCTGTTAAACTCACTCATTGCATGATACGCGAGCTCCTGCACGAGGCGCCAGCTCCGCGCGACCGAGTTAATGGAAACTCGTATTCCCGTGCAAGGAACACCTTTTTACGCTGCTCGAGCTCGTCACCAGCCTCATAATCGACAGACAAACTCTTGTATATCCGGGCGGAAACCCTCGTCGCATATCAACATGCCATTGCTGGATTTACTCAAGTACCACGAAAGGACCGTACCCAAACCTGCTACAGGATACAATGAATGTTTAAAACCGATTAAAAGGACGCCGATGCGCAGACGACTCTACTACTATGAAAGGTGCCTAGAGTCATGACGAGCATAAGGAGTGAGCGTAGGAACCAAAACGATTAGTAAGCTCTTTACGCTACTCTAGTATCCTACCTGGCTCGGACTGAACACCGACATCTAGGAAAAGGCCTATTCGCCGTGAAAACAAGTACGCCGCTAGATGTGAGACATTATTCATCGTCTCGATTTTGTGATAACAGCTCGGCTGAACTCAAACTTAGCAAGTCGACACCGTTTGGTGTTATTAATTCCCCGTATCAAGCCACCTTTGGGCGCCGGACTCGATCAGTATCCACGCAGAGAGAGACAGCCCGACGCCAACTCGAGCCGTGCTACCAGCGTGTCGATACAAGTGCTAGCTCTAATCCATGGGAGTTGTTATTGGCTGGCTCGGCGCGTCCCATGGGCACAAATTTCGCTAAAGGCCTTACAGCTATCCTTCATATGCCTACTAACCCCACGATTTTGCACACCTGAGTGCATCATGGATGGCTCAGCGTCATTCTCGCAAGATTCTGTTCCCTATTTAGGCGGATCCCGGCAGCATAGGTTACGAAGTAAGCGAGCCTTTCATACTTCCGCCGGTGGCGGCATTACCCCAAGATGGTGTAAACGGCAAGGGAGGTGTATAATTCTCTGTGGTTACCCGGTAATTGTCGTCGAACCTTACGGAGCATTCCCAGCACATGGGTAGAGTTCTCTGCCTCCGGGTGACGCCCATATTGTCGTGCAGTCTTGACATCGTGCCTGCGGACCATTTCATTAATTGTAGGCAGTCTGAAAGAGTACGTGTGGTGCGAAGGTATCTAAGAAGTAAGCCCAAATGTCTCGTTAGTTTTATCATTTAAGCCTCCTATGGGTAGGAAGAACATGATCATCGATCCAAGAGAGCAATACCACGAAACTGC

WIP : Futurama, Alien Language 2

This last few weeks I’ve watched some audio commentaries of futurama. Probably less informative than the lecture about maths in the show but still very interesting and funny.

Anyway, I’m interested about the alien alphabets and language since the start of the show, and I’ve decided to make a small software to encode (and in future : decode ) the alien language… By language I mean the second alien writing they made in the show which involves a encoding of all characters after the first one.

Saddly I forgot everything about PIL so I’ve used imagemagick… and I’ll probably make a gui.. but I don’t have much time, that’s why it’s still usable only by command line… which is not a problem.

I’ve also made the second alphabet (a monospaced one for sure ;) ) in SVG using inkscape.

Enough talking!

Aa2-table_smallCbcrYt