Vim

Break up text into individual sentences:

:%j|:%s/\. /.\r\r/g

Posted in Uncategorized | Leave a comment

Satan

Summon Satan

#!/usr/bin/python3
import turtle
from PIL import Image
turtle.bgcolor("green")
t=turtle.Turtle()
t.color("red","blue")
t.begin_fill()
for i in range(0,5):
t.forward(200)
t.right(144)
t.end_fill()
t.hideturtle()
canvas=turtle.getcanvas()
name="satan.ps"
canvas.postscript(file=name)
psimage=Image.open(name)
psimage.save("satan.png")

Posted in Uncategorized | Leave a comment

Vday

#!/usr/bin/python3
from matplotlib import pylab
import scipy
x = scipy.linspace(-2,2,1000)
y1 = scipy.sqrt(1-(abs(x)-1)**2)
y2 = -3*scipy.sqrt(1-(abs(x)/2)**0.5)
pylab.fill_between(x, y1, color='red')
pylab.fill_between(x, y2, color='red')
pylab.xlim([-2.5, 2.5])
pylab.text(0, -1.5, 'Klingons do\nNOT celebrate\nValentines\nDay', fontsize=24, fontweight='bold',
color='white', horizontalalignment='center')
pylab.savefig('heart.png')

Posted in Uncategorized | Leave a comment

Xcowsay

xcowsay –think

 

Posted in Uncategorized | Leave a comment

FTP

You can surf FTP (older than the World Wide Web) with Midnight Commander, built right in. Linux geeks feel like they’re in Willie Wonka’s chocolate factory.

Posted in Uncategorized | Leave a comment

Area

Plot the area under a curve

#!/usr/bin/python3
from matplotlib import pyplot as plt
import numpy as np
x=np.arange(1,31)
y=x*x
plt.fill_between(x,y,color='blue', alpha=0.5)
plt.show()

Posted in Uncategorized | Leave a comment

SinCos

Display trig functions with Python

#!/usr/bin/python3
import matplotlib.pyplot as plt
import numpy as np
x = np.linspace(-np.pi,np.pi,100)
y = np.sin(x)
z = np.cos(x)
fig = plt.figure()
ax = fig.add_subplot(1, 1, 1)
ax.spines['left'].set_position('center')
ax.spines['bottom'].set_position('center')
ax.spines['right'].set_color('none')
ax.spines['top'].set_color('none')
ax.xaxis.set_ticks_position('bottom')
ax.yaxis.set_ticks_position('left')
plt.plot(x,y, 'c', label='y=sin(x)')
plt.plot(x,z, 'm', label='y=cos(x)')
plt.legend(loc='upper left')
plt.show()

Posted in Uncategorized | Leave a comment

Scrape

Extract all the links from a web page:

#!/usr/bin/python3
import requests,sys
from bs4 import BeautifulSoup
url = sys.argv[1]
r = requests.get(url)
htmlContent = r.content
soup = BeautifulSoup(htmlContent, 'html.parser')

anchors = soup.find_all('a')
all_links = set()
for link in anchors:
if(link.get('href') != '#'):
linkText = url+str(link.get('href'))
all_links.add(link)
print(linkText)

Posted in Uncategorized | Leave a comment

Clipboard

Get data from clipboard

import pandas as pd
pd.read_clipboard()

Posted in Uncategorized | Leave a comment

Nvlc

Ncurses terminal-based VLC interface:

nvlc '06 - Blue Stone Feat. Sheyenne Rivers - Substitute For Love.mp3'

Posted in Uncategorized | Leave a comment